Multishapes and their position

skumancer

30-03-2008 21:51:37

Hey guys,

I'm trying to create a table using a multishaped actor.

This is the code I'm using:

scene->createBody("table_rectangle.mesh",
new NxOgre::CompoundShape(new NxOgre::CubeShape(0.8, 0.2, 0.8, "mass: 0.5 Offset:0 2 0"),
new NxOgre::CubeShape(0.1, 1, 0.1, "mass: 0.1 Offset:0.4 -1 0.4"),
new NxOgre::CubeShape(0.1, 1, 0.1, "mass: 0.1 Offset:-0.4 -1 0.4"),
new NxOgre::CubeShape(0.1, 1, 0.1, "mass: 0.1 Offset:-0.4 -1 -0.4"),
new NxOgre::CubeShape(0.1, 1, 0.1, "mass: 0.1 Offset:0.4 -1 -0.4")),
Ogre::Vector3(-6.5, 0, 6), "");


The problem is that the offset is not moving the shapes anywhere.

Could anybody point me in the right direction? I tried using:
NxOgre::Shapeparams params;

but there was no position variable inside the params.

Thanks for the help,

- Ricardo

skumancer

30-03-2008 22:01:08

Ok, the reason it was not working is because I was trying to give a mass to the shape in the Shapeparams.

It is now working like this:
scene->createBody("table_rectangle.mesh",
new NxOgre::CompoundShape(new NxOgre::CubeShape(0.8, 0.2, 0.8, "Offset:0 2 0"),
new NxOgre::CubeShape(0.1, 1, 0.1, "Offset:0.4 -1 0.4"),
new NxOgre::CubeShape(0.1, 1, 0.1, "Offset:-0.4 -1 0.4"),
new NxOgre::CubeShape(0.1, 1, 0.1, "Offset:-0.4 -1 -0.4"),
new NxOgre::CubeShape(0.1, 1, 0.1, "Offset:0.4 -1 -0.4")),
Ogre::Vector3(-6.5, 0, 6), "mass: 10");


Hope this helps somebody else!

skumancer

30-03-2008 22:53:12

The problem I'm having now is that, even though I am adding 5 shapes (tabletop and the 4 legs) only 4 shapes are showing up.

Any ideas??

- Ricardo

betajaen

30-03-2008 22:56:16

You need to attach each leg mesh to the SceneNode as you normally would in Ogre.

skumancer

30-03-2008 23:04:50

Well, what I did is use just ONE mesh (the whole table) and define multiple shapes that span the legs and tabletop.

Its partially working, but for some reason, the 4th leg (shape) is not appearing. I'm checking this in the RemoteDebugger and the shape is only composed of 4 shapes, even though I'm adding 5.

- Ricardo

skumancer

30-03-2008 23:19:00

So check this out:

scene->createBody("table_rectangle.mesh",
new NxOgre::CompoundShape(new NxOgre::CubeShape(1.4, 0.25, 2, "Offset:0 1.12 0"),
new NxOgre::CubeShape(0.2, 1.1, 0.16, "Offset: 0.6 0.5 0.92"),
new NxOgre::CubeShape(0.2, 1.1, 0.16, "Offset:-0.6 0.5 0.92"),
new NxOgre::CubeShape(0.2, 1.1, 0.16, "Offset:-0.6 0.5 -0.92"),
new NxOgre::CubeShape(0.2, 1.1, 0.16, "Offset: 0.6 0.5 -0.92"),
new NxOgre::CubeShape(0.2, 1.1, 0.16, "Offset: 0.6 0.5 0.92")),
Ogre::Vector3(-6.5, 0, 6), "mass: 2");


That code, which includes the tabletop and 5 (yes FIVE) legs, shows correctly in the RemoteDebugger and the table behaves like it should.

Strange? I thought so...

-Ricardo

betajaen

30-03-2008 23:27:17

Obviously, You have a duplicate leg.

Table top:

new NxOgre::CubeShape(1.4, 0.25, 2, "Offset:0 1.12 0")

Legs:

new NxOgre::CubeShape(0.2, 1.1, 0.16, "Offset: 0.6 0.5 0.92"),
new NxOgre::CubeShape(0.2, 1.1, 0.16, "Offset:-0.6 0.5 0.92"),
new NxOgre::CubeShape(0.2, 1.1, 0.16, "Offset: 0.6 0.5 -0.92"),
new NxOgre::CubeShape(0.2, 1.1, 0.16, "Offset: -0.6 0.5 -0.92")

skumancer

31-03-2008 00:53:59

I know that, the point I was trying to make is that, if I DON'T put that duplicate leg, only 3 legs are ever going to appear in the RemoteDebugger.

It simply makes no sense.

- Ricardo

novaumas

31-03-2008 01:17:04

In NxOgreShapeBluePrintsPrimitives.cpp you should probably change all the appearances of:

CompoundShape::CompoundShape(
ShapeBlueprint* a,
ShapeBlueprint* b,
ShapeBlueprint* c,
ShapeBlueprint* d
)
)
{
NxShapeIndex id = mShapeBlueprints.count();
mShapeBlueprints.insert(id, a);
mShapeBlueprints.insert(id++, b);
mShapeBlueprints.insert(id++, c);
mShapeBlueprints.insert(id++, d);
}


to


CompoundShape::CompoundShape(
ShapeBlueprint* a,
ShapeBlueprint* b,
ShapeBlueprint* c,
ShapeBlueprint* d
{
NxShapeIndex id = mShapeBlueprints.count();
mShapeBlueprints.insert(id, a);
mShapeBlueprints.insert(++id, b);
mShapeBlueprints.insert(++id, c);
mShapeBlueprints.insert(++id, d);
}


Notice all those id++

Hope that helps!

skumancer

31-03-2008 08:00:41

That did it, excellent!

Thank you very much!!

- Ricardo

betajaen

31-03-2008 09:43:27

Good find!

toglia

07-04-2008 02:09:40

Same thing happening here, I will do what novaumas says when I have some time. This is some great comunity!