resizing new bodies based on existing blueprint

Arcanor

04-03-2008 15:38:59

Is it possible to create a blueprint and then use that blueprint (after setting it to be shared with "setShared(true)") to create multiple bodies but have them be scaled differently from the original blueprint?

Arcanor

10-03-2008 02:53:05

bump?

An example of why I'd want to do this is let's say I want to make a group of fish, all from the same mesh, but with random sizes. How could I do this without having to explicitly create a blueprint for each possible size?

betajaen

10-03-2008 09:14:41

It's not really to do with the Blueprint as such. It's to do with the Mesh, you would have to re size the vertices every time you want a new scale. This usually requires de-compiling the mesh (at least once), run through the vertices and multiply them by the scale, and then cook it again.

That's certainly something you don't want to be doing every frame.

Arcanor

10-03-2008 12:51:40

It wouldn't have to be every frame. Only when creating a new fish. But if it were just the mesh I could simply call setScale() on the Ogre entity at runtime. This would allow me to do something like have a monster's or character's size change when drinking a potion of strength, etc. Unfortunately that doesn't affect the related physics body(s).

The 2.7.3 SDK provides a function NxScaleCookedConvexMesh(), but unfortunately it doesn't seem NxOgre uses it. I may be able to directly access this function to do what I need, since at present I'm using a lot of convex meshes (as placeholders until we can make more customized and well-thought-out collision bodies).

Suggestion for NxOgre:

The SDK also provides a resize() function for NxArrays. This could allow an optional "scale" argument to NxOgre's createBody() and other similar functions which create different things from their blueprints. Then when you create the NxShapeDesc you could scale it appropriately. (This was exactly the functionality I was hoping to use.)

betajaen

10-03-2008 13:13:18

There is a massive new class being written at the moment called "ManualMesh" very similar in design and usage to the Ogre::ManualObject, which allows you to do such things as well as many functions to adjust meshes regardless of the type of mesh used (Triangle,Convex,Soft,Cloth and Skeleton), and another MeshBuilder class to enhance it.


But for now, you'll have to use some PhysX functions directly. I believe 0.9 has some sort of MemoryResourceStream which you can cook to and read from. Use that Convex Scale function and cook to a MemoryResourceStream, then you can get NxOgre to read the scaled-cooked convex mesh from that.

And I believe I've added a re size function to the primitive shapes in my copy of Bleeding for ' 20.