Physics-Renderer connection

Physics-Renderer connection

I'm trying to import an .hkx file exported from Maya and get the physics world into my application. I also want to know which node in the render scene graph should be moved according to each rigid body from the physics engine.
Does this information may be extracted from the hkx file using the hkLoader? How should the rendering object to physics object mapping should be saved using Havok exporters?

Thanks
Yinon

4 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.

Hey yinono,

In order to find rigid bodies you can use the findRigidBodyByName() call on the hkpPhysicsData returned from hkpHavokSnapshot::load().

You can also iterate through all the bodies in the hkx file like so:

	for (int i=0; i < physicsData->getPhysicsSystems().getSize(); i++ )
	{
		const hkArray& bodies = physicsData->getPhysicsSystems()[i]->getRigidBodies();
		for ( int j=0; j < bodies.getSize(); j++ )
		{
			// Do something with bodies[j]...
		}
	}

Once you get access to the pointers to the rigid bodies, you can look after these in whatever way fits your game engine's design.

Daniel

Hi daniel, thank you for the quick reply.
My question is, is there some field of the rigid body imported from the hkx file, that let me identify which Maya node there where connected to (or some other method to identify which node of the renderer each rigid body should affect)

Thanks
YInon

Hi Yinon,

The scene data from Maya is exported to the hkx file. When exporting, if you use the "View XML" filter you can see this under "Scene Data". To access the scene data from code, you could try something like this:

	// Load the file
	hkLoader* m_loader = new hkLoader();
	hkRootLevelContainer* container = m_loader->load(filename);
	
	// Grab the scene data
	hkxScene* scene = reinterpret_cast( container->findObjectByType( hkxSceneClass.getName() ));

Once you have the hkxScene, you can get hkxNodes with hkxScene::findNodeByName(). With a good naming system you should be able to find out how these are tied to the rigid bodies in the hkpPhysicsData.

Another option would be to write your own filter but that would require a significant amount of work so if the above approach doesn't give you the results you'd like then you can start thinking about custom filters.

Daniel

Melden Sie sich an, um einen Kommentar zu hinterlassen.