Artist Pipeline (from Max/Maya) - Dynamica? .Bullet?

Physics APIs, Physics file formats, Maya, Max, XSI, Cinema 4D, Lightwave, Blender, thinkingParticles™ and other simulation tools, exporters and importers
Post Reply
Topher
Posts: 10
Joined: Mon Dec 06, 2010 2:30 pm

Artist Pipeline (from Max/Maya) - Dynamica? .Bullet?

Post by Topher »

Hi,

I've recently added Bullet to our in-house engine but at present for shapes I've got everything using the same .bullet file I created with the serialiser. I'm curious what a typical or expected pipeline for artists to define the collision shape of a model would be for most people, or how I could make use of dynamica to help this. Our alternative is to create shapes in code with our own defined data exported from Maya for each model, which just seems like a duplication of work if the serialisation features are there.

- Is dynamica's bullet export suppose to be used for defining the collision shapes of models, or is it purely for loading an entire bullet world?

- Is there a way to instance shapes from a bullet file rather than just point to the data buffer of the file? For example if we want multiple instances of the same object using the same bullet file, however with different scale values on each instance of the shape. Is the only real solution to load the file into multiple separate buffers?

- Why does the dynamica bullet export produce a world with lots of shapes and rigidy bodies? If I serialise my own shape for testing, I can serialise just a shape. Dynamica seems to export a lot more than just my current selection.

- If .bullet serial files and dynamica are not the way to go, what is recommended?

Thanks in advance!
- Christopher
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Artist Pipeline (from Max/Maya) - Dynamica? .Bullet?

Post by Erwin Coumans »

Topher wrote:I've recently added Bullet to our in-house engine but at present for shapes I've got everything using the same .bullet file I created with the serialiser. I'm curious what a typical or expected pipeline for artists to define the collision shape of a model would be for most people, or how I could make use of dynamica to help this.
You should be able to export/serialize a single collision object with its shape into its own .bullet file.
Topher wrote: - Is dynamica's bullet export suppose to be used for defining the collision shapes of models, or is it purely for loading an entire bullet world?
Both should be possible. It is called: export all or export selection.
Topher wrote: - Is there a way to instance shapes from a bullet file rather than just point to the data buffer of the file? For example if we want multiple instances of the same object using the same bullet file, however with different scale values on each instance of the shape. Is the only real solution to load the file into multiple separate buffers?
When you use the btBulletWorldImporter, it will create instances for btCollisionShape. You can instance and re-use those btCollisionShape as many times as you like.
Topher wrote: - Why does the dynamica bullet export produce a world with lots of shapes and rigidy bodies? If I serialise my own shape for testing, I can serialise just a shape. Dynamica seems to export a lot more than just my current selection.
Not sure what is happening. Which extra shapes are created? For a btConvexHullShape, Dynamica creates a btCompoundShape for a local offset. We could add an option to disable this.
It could help if you attach a zipped Maya .mb and .bullet file, so we can discuss it more in detail.

.bullet serialization should be the way to go. If there are issues, we can sort them out.
Thanks,
Erwin
Topher
Posts: 10
Joined: Mon Dec 06, 2010 2:30 pm

Re: Artist Pipeline (from Max/Maya) - Dynamica? .Bullet?

Post by Topher »

Sorry I didn't get back sooner, we had a shift in the schedule and then I was on holiday :)

I've looked into this some more after reading your comments...
Erwin Coumans wrote: You should be able to export/serialize a single collision object with its shape into its own .bullet file.

Both should be possible. It is called: export all or export selection.
I believe initially I was confused because it was exporting (serialising really) a bullet world, including rigid bodies. I ideally just wanted all the shapes, however I realise now this is just as good as my current method is to loop through all rigid bodies, take their shape and transform then add that shape to a compound shape for our object using the .bullet file.

Essentially this:

Code: Select all

// Import shape
btBulletWorldImporter lImporter(0);
cScratchFile lFile( lpcCollisionFile );
mpBulletSerialisedData = (U8*)lpPartition->Alloc( lFile.GetSize() );
memcpy( mpBulletSerialisedData, lFile.GetBuffer(), lFile.GetSize() );

lImporter.loadFileFromMemory( (char*)mpBulletSerialisedData, lFile.GetSize() );
	
// Get imported shape
mpShape = new(lpPartition->Alloc( sizeof( btCompoundShape ) ) ) btCompoundShape();
for( S32 i = 0; i < lImporter.getNumRigidBodies(); ++i )
{
    btCollisionObject* lpRigidBody = lImporter.getRigidBodyByIndex(i);
    ASSERT(lpRigidBody);

    btCollisionShape* lpCollisionShape = lpRigidBody->getCollisionShape();
    ASSERT(lpCollisionShape);

    btTransform lLocalTransform = lpRigidBody->getWorldTransform();

    ((btCompoundShape*)mpShape)->addChildShape( lLocalTransform, lpCollisionShape );
}

// Define rigidbody and add the compound shape...
When you use the btBulletWorldImporter, it will create instances for btCollisionShape. You can instance and re-use those btCollisionShape as many times as you like.
At the moment the only way I can see to do this is to de-serialise every time we use a bullet file associated with one of our entities. Ideally we'd like to only load unique files once and instance the shapes from this de-serialised data for performance. I can't think of a way to do this at the moment because I assume bullet shapes and compound shapes are all linked up via pointers and so on, not owning the data itself.

Am I going about this the wrong way?

Additionally this is another issue for scaling. Our designers and artists can apply scales to our entities that is then applied to any renderables contained within, we'd like this to also apply to the shapes in the bullet file without requiring them to create a new bullet file (we've got a sort of prefab system going on creating instances in an editor).

With my current understanding the only way to solve this I can see is to have a buffer of the de-serialised data per instance, which also requires de-serialising every time it is instanced.

Cheers!
Christopher
Topher
Posts: 10
Joined: Mon Dec 06, 2010 2:30 pm

Re: Artist Pipeline (from Max/Maya) - Dynamica? .Bullet?

Post by Topher »

Topher wrote: At the moment the only way I can see to do this is to de-serialise every time we use a bullet file associated with one of our entities. Ideally we'd like to only load unique files once and instance the shapes from this de-serialised data for performance. I can't think of a way to do this at the moment because I assume bullet shapes and compound shapes are all linked up via pointers and so on, not owning the data itself.

Am I going about this the wrong way?
Would really like to get an answer/suggestion for this. We're implementing projectiles now and this issue has become a problem for us going forward. Any ideas?
Post Reply