Scaling extended mesh to match d3d model

Scaling extended mesh to match d3d model

I'm looking for a way to scale my terrain's rigid body (which is loaded in from a .hkt file as a hkpMoppBvTreeShape) to match the size of the d3d model in my engine. Currently, the body is a lot smaller than it's corresponding model. I need a way to either export the .hkt file so it matches the model size or scale thehkpRigidBody's shapein havok.
Here's the code, borrowed from the CompressedMeshDemo.cpp demo, for how i'm loading in my terrain as ahkpMoppBvTreeShape:

		const hkpShape* m_terrainShape;
		class hkAabb m_bounds;
		hkSerializeUtil::ErrorDetails loadError;

		// Load the file
		hkResource* loadedData = hkSerializeUtil::load( filename.c_str() );

		// Get the top level object in the file, which we know is a hkRootLevelContainer
		hkRootLevelContainer* container = loadedData->getContents();

		// Get the physics data
		hkpPhysicsData* physicsData = static_cast( container->findObjectByType( hkpPhysicsDataClass.getName() ) );

		// Add all the physics systems to the world
		for ( int i = 0; i < physicsData->getPhysicsSystems().getSize(); ++i )
			physicsWorld->addPhysicsSystem( physicsData->getPhysicsSystems()[i] );

		rigidBody = physicsData->getPhysicsSystems()[0]->getRigidBodies()[0];
		m_terrainShape = rigidBody->getCollidable()->getShape();
		m_terrainShape->getAabb( rigidBody->getTransform(), 0.1f, m_bounds );
		if ( m_terrainShape->m_type == HK_SHAPE_MOPP )
			m_terrainShape = ((hkpMoppBvTreeShape*)m_terrainShape)->getChild();

In the pdf guide it says something about a hkpExtendedMeshShape::TrianglesSubpart::setScaling() to scale extended meshes, does anyone know if I can use that here?Any answers or tips are appreciated.

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hey epsylonic,

To scale hkpExtendedMeshShapes, you could certainly call TrianglesSubpart::setScaling(), but I'd perhaps suggest using hkpShapeScalingUtility::scaleShape() instead. This function will support scaling of any shape type and is probably the cleanest/easiest option for general physics shape scaling.


Developer Support Engineer

Leave a Comment

Please sign in to add a comment. Not a member? Join today