Havok integration for OGRE - HkOgre + 2 & 1/2 Demos

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!
barius
Gnoblar
Posts: 1
Joined: Fri Sep 21, 2012 11:22 am

Re: Havok integration for OGRE - HkOgre + 2 & 1/2 Demos

Post by barius »

Hi,

I've been googling around searching for a havok-ogre integration library, and finally found this one. Good job!
You wrote that this demo application crashes when using Havok with SIMD support, and that is caused by 16-byte alignment issue. It's mentioned in the Havok User Guide 1.3.3.1.

You have code in the hkOgreMath.h :

Code: Select all

static hkVector4 ogreVec3ToHk(Ogre::Vector3 v)
		{
			return hkVector4(v.x, v.y, v.z);
		}
which is incorrect and will cause memory allocation problem during runtime. However, Havok without SIMD doesn't care about byte alignment so this demo works perfectly.

Hope that helps. :D
drwbns
Orc Shaman
Posts: 788
Joined: Mon Jan 18, 2010 6:06 pm
Location: Costa Mesa, California
x 24

Re: Havok integration for OGRE - HkOgre + 2 & 1/2 Demos

Post by drwbns »

Do you have a patch for it?
User avatar
Mind Calamity
Ogre Magi
Posts: 1255
Joined: Sat Dec 25, 2010 2:55 pm
Location: Macedonia
x 81

Re: Havok integration for OGRE - HkOgre + 2 & 1/2 Demos

Post by Mind Calamity »

Yeah, a patch would be great. Anyway, I updated the sample framework to support the latest OGRE 1.9 from the repository. (Some changes in how the SdkTrays and input in general work).
BitBucket username changed to iboshkov (from MindCalamity)
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt
nickG
Greenskin
Posts: 122
Joined: Fri Jan 20, 2012 6:44 pm
Location: Russia,Moscow
x 1

Re: Havok integration for OGRE - HkOgre + 2 & 1/2 Demos

Post by nickG »

"Static Geometry collision" working only with Ogre->CreateStaticGeometry?
or compatable with Ogre->CreateEntity?
User avatar
Mind Calamity
Ogre Magi
Posts: 1255
Joined: Sat Dec 25, 2010 2:55 pm
Location: Macedonia
x 81

Re: Havok integration for OGRE - HkOgre + 2 & 1/2 Demos

Post by Mind Calamity »

nickG wrote:"Static Geometry collision" working only with Ogre->CreateStaticGeometry?
or compatable with Ogre->CreateEntity?
Well, to use static geometry you need to create it and add an entity to it, and the function that creates collision shapes/meshes takes an entity, so it doesn't matter whether you use static geometry or just an entity, the example shows how to use it because it improves performance.

In short, feel free to just do this:

Code: Select all

      Ogre::Entity* myEntity = mSceneMgr->createEntity("name", "ogrehead.mesh");
      // Create the collision shape and rigid body of our level.
      hkpBvTreeShape* groundShape = HkOgre::Cooker::processOgreMesh(myEntity);
      hkpRigidBodyCinfo ci;
      ci.m_shape = groundShape;
      ci.m_motionType = hkpMotion::MOTION_FIXED;
      ci.m_position = hkVector4( 0.0f, 0.0f, 0.0f );
      ci.m_qualityType = HK_COLLIDABLE_QUALITY_FIXED;
      hkpRigidBody* groundBody = new hkpRigidBody(ci);

      mWorld->markForWrite();
      // Add the ground geometry to the physical world.
      mWorld->addEntity(groundBody)->removeReference();

      // Remove the reference to our physical
      // shape because it's unneeded.
      groundShape->removeReference();
      mWorld->unmarkForWrite();
That would work perfectly.

Another update: drwbns got the terrain collision building working (a big thank you to them :)), so I need to get to adding that in the primary repository as soon as I can. (Friday, or during the weekend).
BitBucket username changed to iboshkov (from MindCalamity)
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt
drwbns
Orc Shaman
Posts: 788
Joined: Mon Jan 18, 2010 6:06 pm
Location: Costa Mesa, California
x 24

Re: Havok integration for OGRE - HkOgre + 2 & 1/2 Demos

Post by drwbns »

I also added another useful feature that cuts down loading times :) - It builds the terrain MOPP code only if it can't find it on disc , otherwise it just loads the ~15 Mb file

Code: Select all

hkpBvTreeShape* loadBVTreeShape(const char *filename) {
	hkSerializeUtil::ErrorDetails loadError;
	hkResource * result = hkSerializeUtil::load(filename, &loadError);
	//HK_ASSERT2(0xa6451543, *result, "Could not load file. The error is:\n" << loadError.defaultMessage.cString() ); // Not working for some reason
	if ( result )
		return result->getContents<hkpBvTreeShape>(); 
	else return NULL;
}
void saveBVTreeShape(const char *filename, hkpBvTreeShape & bvtreeShape) {
			hkStopwatch saveTime;
		{
			saveTime.start();

			hkResult result;
			result = hkSerializeUtil::save(&bvtreeShape, hkpBvTreeShapeClass, hkOstream(filename).getStreamWriter() );
			
			HK_ASSERT2(0xa6451543, result == HK_SUCCESS, "Could not save bvtreeShape" );

			saveTime.stop();
		}
}
used like so -

Code: Select all

	hkpBvTreeShape * bvtree = loadBVTreeShape("terrain.hvk");
	if(bvtree == HK_NULL) {
		bvtree = HkOgre::Heightfield::processOgreTerrainGroup(mTerrainGroup); // only when using bvtree
		saveBVTreeShape("terrain.hvk", *bvtree);
	}
drwbns
Orc Shaman
Posts: 788
Joined: Mon Jan 18, 2010 6:06 pm
Location: Costa Mesa, California
x 24

Re: Havok integration for OGRE - HkOgre + 2 & 1/2 Demos

Post by drwbns »

I uploaded a vid demoing whats possible with the hkOgre::ProcessOgreTerrain function -

http://www.youtube.com/watch?v=C4-yxzlI6Po
nickG
Greenskin
Posts: 122
Joined: Fri Jan 20, 2012 6:44 pm
Location: Russia,Moscow
x 1

Re: Havok integration for OGRE - HkOgre + 2 & 1/2 Demos

Post by nickG »

Mind Calamity wrote:
nickG wrote:"Static Geometry collision" working only with Ogre->CreateStaticGeometry?
or compatable with Ogre->CreateEntity?
Well, to use static geometry you need to create it and add an entity to it, and the function that creates collision shapes/meshes takes an entity, so it doesn't matter whether you use static geometry or just an entity, the example shows how to use it because it improves performance.

In short, feel free to just do this:

Code: Select all

      Ogre::Entity* myEntity = mSceneMgr->createEntity("name", "ogrehead.mesh");
      // Create the collision shape and rigid body of our level.
      hkpBvTreeShape* groundShape = HkOgre::Cooker::processOgreMesh(myEntity);
      hkpRigidBodyCinfo ci;
      ci.m_shape = groundShape;
      ci.m_motionType = hkpMotion::MOTION_FIXED;
      ci.m_position = hkVector4( 0.0f, 0.0f, 0.0f );
      ci.m_qualityType = HK_COLLIDABLE_QUALITY_FIXED;
      hkpRigidBody* groundBody = new hkpRigidBody(ci);

      mWorld->markForWrite();
      // Add the ground geometry to the physical world.
      mWorld->addEntity(groundBody)->removeReference();

      // Remove the reference to our physical
      // shape because it's unneeded.
      groundShape->removeReference();
      mWorld->unmarkForWrite();
That would work perfectly.

Another update: drwbns got the terrain collision building working (a big thank you to them :)), so I need to get to adding that in the primary repository as soon as I can. (Friday, or during the weekend).
Thanks for reply,i found bug in my code
Post Reply