Forum Jump

Select Group :
Select Forum :
Sorted By :
Sort Order :
From The :
 
Thread Tools  Search this thread 
pjstyle
Total Points:
35
Registered User
October 1, 2008 7:08 AM PDT
Importing 3dsmax scene into direct3d environment

Hey there,

I am trying to import the data from a hkx, i have the following data imported so far:

- The havok world

- Geometry of objects

Now i have retrieved the rigid bodies connected to the objects in the scene, but when i try to add the rigid bodies to the havok world my game crashes. My log contains the following:

No thread memory manager specified.                                       You must specify a thread memory manager when initializing hkBaseSystem.
.\Entity\hkpEntity.cpp(262): [0x140a19b8] Assert : 'getWorld() == HK_NULL
removeReference() or destructor called while hkpEntity is still in simulation'

Here's a snippit from my import sourcecode:

void Game::Initialize()
{
	hkLoader loader;
	hkRootLevelContainer* container = loader.load("../../../GameAssets/Max Scenes/Scene.hkx");
	hkxScene* scene = (hkxScene*)container->findObjectByType("hkxScene");
	hkpPhysicsData* physicsData = (hkpPhysicsData*)container->findObjectByType("hkpPhysicsData");

	// Retrieve world
	m_world = new hkpWorld(*physicsData->getWorldCinfo());

	if(m_world != HK_NULL)
	{
		//
		// Register the box-box collision agent
		//
		{
			hkpAgentRegisterUtil::registerAllAgents(m_world->getCollisionDispatcher());
		}
		m_world->lock();

		for(int i=0;i<scene->m_numMeshes;i++)
		{
			char rigidBodyName[10];

			sprintf(rigidBodyName, "Box0%d", i + 1);
			hkxMesh* mesh = scene->m_meshes[i];
			hkpRigidBody* body = physicsData->findRigidBodyByName(rigidBodyName);
			
			if(body != HK_NULL)
			{
				SimpleHavocObject* obj = new SimpleHavocObject(
					m_device, 
					D3DXVECTOR3(1,0,0), 
					D3DXVECTOR3(0,0,0), 
					mesh);
				
				obj->SetRigidBody(body);
				// Add rigidbody to Havok world
				m_world->addEntity(body);		
				objects.push_back(obj);
			}
		}

		m_world->unlock();
	}
}

Thanks in advance,

Pieter Ted de Vries

sean.thurston
Total Points:
8,262
Status Points:
7,762
Brown Belt
October 1, 2008 12:07 PM PDT
Rate
 
|Best Answer
#1

Hi Pieter Ted de Vries,

The output there is becuase you didn't initialize thread memory. If you take a look at the ConsoleExampleMt, it shows how to setup the memory system. It is in the StandAloneDemos folder.

The second one there is an assert used for debugging purposes. There is a difference between asserts and crashes, just throwing that out there for everyone. What's going on with this one is that you are loading the your information from a packfile, which is fine. But, the packfiledata is then being freed when the initialize method exists. What you want to do is keep that packfiledata around until the end of the simulation. So, you might want to store it as a member variable of your simulation. You might need to call addReference() on it so that when the loader exits, it doesn't take the packfiledata with it.

There was a post about this buried in another thread: http://software.intel.com/en-us/forums/havok/topic/59587/page/2

It is like a few posts from the bottom. I'm glad this came up in its own thread though.

Let me know if that helps.

Thanks,
Sean



pjstyle
Total Points:
35
Registered User
October 1, 2008 1:09 PM PDT
Rate
 
#2 Reply to #1
Hi Sean,

I have made the hkLoader class a member variable of my game class and now i can add the rigid bodies to my Havok world. Thanks!

 

Regards,

Ted





Intel Software Network Forums Statistics

6668 users have contributed to 28284 threads and 87462 posts to date.
In the past 24 hours, we have 5 new thread(s) 32 new posts(s), and 37 new user(s).

In the past 3 days, the most popular thread for everyone has been Fortran and Matlab The most posts were made to Larger Test Data The post with the most views is Quoting - nabeels Hello e

Please welcome our newest member karolbe