Need help NewtonCreateSphere

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
Post Reply
anandh
Posts: 61
Joined: Thu Sep 14, 2006 12:40 pm
Contact:

Need help NewtonCreateSphere

Post by anandh »

Hi,
I have .3ds ball mesh,did u know how to calculate
dFloat radiusX,radiusY, radiusZ - sphere radius along x axis from my ball scenode
regards
anandh
roxaz
Posts: 575
Joined: Tue Jan 23, 2007 8:35 pm
Location: LT

Post by roxaz »

for any objects to create collision i use NewtonCreateConvexHull(). Its very hard to calculate exact values of models. I gues only possible way is to set random values, turn on debug geometry and then adjust values till you got it perfect. Anyway for NewtonCreateConvexHull() use this:

Code: Select all

NewtonCollision *PIN::getConvexCollision(IMesh *MyMesh)
{
	// Init stuff 

	int BufferCount = MyMesh->getMeshBufferCount(); 
	IMeshBuffer *mb = 0;
	float *varray = 0; 

	// Loop through all vertices and add them to an array of float that newton wants. 

	for (int bi = 0 ; bi < BufferCount ; bi++) 
	{ 
		mb = MyMesh->getMeshBuffer(bi); 
		int VerticeCount = mb->getVertexCount(); 
		varray = new float[VerticeCount*3]; 
		switch(mb->getVertexType()) 
		{ 
			case EVT_STANDARD: 
			{ 
				S3DVertex* Vertices = (S3DVertex*)mb->getVertices(); 
				for (int ii = 0 ; ii < VerticeCount ; ii++) 
				{ 
					varray[(ii*3)] = Vertices[ii].Pos.X * IrrToNewton; 
					varray[(ii*3)+1] = Vertices[ii].Pos.Y * IrrToNewton; 
					varray[(ii*3)+2] = Vertices[ii].Pos.Z * IrrToNewton; 
				} 
			break; 
			} 
			case EVT_2TCOORDS: 
			{ 
				S3DVertex2TCoords* Vertices = (S3DVertex2TCoords*)mb->getVertices(); 
				for (int ii = 0 ; ii < VerticeCount ; ii++) 
				{ 
					varray[(ii*3)] = Vertices[ii].Pos.X * IrrToNewton; 
					varray[(ii*3)+1] = Vertices[ii].Pos.Y * IrrToNewton; 
					varray[(ii*3)+2] = Vertices[ii].Pos.Z * IrrToNewton; 
				} 
			break; 
			} 
		} 
	}

	NewtonCollision *collision = NewtonCreateConvexHull(pWorld, mb->getVertexCount(), varray, sizeof(float)*3, 0);

	return collision;
}
if you are not using IrrToNewton - delete it or declare const float IrrToNewton = 1;
white tiger
Posts: 269
Joined: Tue Oct 31, 2006 3:24 pm
Contact:

Post by white tiger »

they are half the size of the bounding box respectively on x,y,z :)
Post Reply