Adding a triangle mesh to the world.

Adding a triangle mesh to the world.

For some reason, i can't add the triangle mesh to the world with "pWorld->addEntity(Tree)";

here's my mesh creation code.

hkpMoppBvTreeShape* Cor_Triangle_RB::CreateTriangleMeshLevel(irr::scene::IAnimatedMesh* mesh,irr::core::vector3df scale)
	hkpExtendedMeshShape* meshShape = new hkpExtendedMeshShape(0.0f);

	for (irr::u32 i = 0; i < mesh->getMeshBufferCount(); ++i)
		irr::scene::IMeshBuffer* mb = mesh->getMeshBuffer(i);

		irr::video::S3DVertex* vertices = (video::S3DVertex*)mb->getVertices();
		irr::f32* vertexBuffer = new f32[mb->getVertexCount() * 3];
		irr::u16* indexBuffer = mb->getIndices();

		int tmpCount = 0;

		for (irr::u32 x = 0; x < mb->getVertexCount(); ++x)
			vertexBuffer[tmpCount] = vertices[x].Pos.X * scale.X;
			vertexBuffer[tmpCount+1] = vertices[x].Pos.Y * scale.Y;
			vertexBuffer[tmpCount+2] = vertices[x].Pos.Z * scale.Z;


		hkpExtendedMeshShape::TrianglesSubpart part;

		part.m_vertexBase = vertexBuffer;
		part.m_vertexStriding = sizeof(float) * 3;
		part.m_numVertices = mb->getVertexCount();

		part.m_indexBase = indexBuffer;
		part.m_indexStriding = sizeof(unsigned short) * 3;
		part.m_numTriangleShapes = mb->getIndexCount() / 3;
		part.m_stridingType = hkpExtendedMeshShape::INDICES_INT16;


	hkpMoppCompilerInput cmi;
	hkpMoppCode* code = hkpMoppUtility::buildCode(meshShape, cmi);

	hkpMoppBvTreeShape* moppBvShape = new hkpMoppBvTreeShape(meshShape, code);

	return moppBvShape;

now when i try to add it to the world after creating it:

1>c:usersrodocumentsvisual studio 2008projectsmonster hunterhavok_trialhavok.cpp(87) : error C2664: 'hkpWorld::addEntity' : cannot convert parameter 1 from 'hkpMoppBvTreeShape *' to 'hkpEntity *'

	hkpMoppBvTreeShape* Tree = TriMeshWorld->CreateTriangleMeshLevel(Light_Node->getMesh(),vector3df(15.24f,15.24f,7.62));

this is how i'm adding it to the world, as u can see, an error. So any ideas?
2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

You can't add hkpShapes directly to the world, you need to create a rigid body that uses this shape.


hkpMoppBvTreeShape* Tree = TriMeshWorld->CreateTriangleMeshLevel(Light_Node->getMesh(),vector3df(15.24f,15.24f,7.62));  
hkpRigidBodyCinfo rigidBodyInfo;  
rigidBodyInfo.m_motionType = hkpMotion::SOME_MOTION_TYPE;  
rigidBodyInfo.m_shape = Tree;  
rigidBodyInfo.m_position = Some_Vector4_Representing_Position_Of_Rigid_Body;  
//create new rigid body with supplied info  
hkpRigidBody* rigidBody = new hkpRigidBody(rigidBodyInfo);


Oh, and when you paste code, don't forget to choose the language that it is in.
Otherwise it becomes kind of unreadable, like your


that became


Hope that helps,

Leave a Comment

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