NewtonConvexHull problem

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Guest

NewtonConvexHull problem

Post by Guest »

We are working on a game for a class using the newton engine for physics. We are having trouble getting the NewtonConvexHull to fit around our milkshape model. If anyone could help us that would be great.
ASD

Post by ASD »

I can help you, I'm using Newton engine with Irrlicht and have sucsessfully passed throu many problems, and convex hulls to :) What is the problem?
EvilleJedi

Post by EvilleJedi »

I don't know what the original posters problem is but I am trying to get the vertice cloud information from the mesh

Code: Select all

scene::IMeshBuffer*      mb      = NULL;
video::S3DVertex*      mb_vertices   = NULL;
int bufferCount = mesharray[1]->getMesh(0)->getMeshBufferCount ( );
		for ( int i = 0; i < bufferCount; i++ )
		{
			mb = mesharray[1]->getMesh(0)->getMeshBuffer ( i );
			mb_vertices = (video::S3DVertex*)mb->getVertices ( );
		}
	void *vertex = mb->getVertices(); 
	core::vector3df vertices;
	Float* Verts;
        // find center of vertices in array
        for(u16 j=0; j < mb->getVertexCount(); j++)
	{
            vertices = ((video::S3DVertex*)vertex)[j].Pos;	
	    //Verts=????
	}
PObjectArray[1]->collision = NewtonCreateConvexHull(nWorld, mb->getVertexCount(),Verts, 128, NULL);
even though its sorta cobbled together from other posts
that is where I get stuck, how to convert from the vertices themselves to the data in memory
hansmbakker
Posts: 41
Joined: Mon Feb 16, 2004 7:37 pm

Post by hansmbakker »

asd, is your code open source?

i'd like to use the newton engine with it's vehicles and buoyancy but i don't know where to start. It would be a great help if I could have a look in your project and your code.

I have read merciors tutorial but i still find it very hard, because there are so few 'bridging-tutorials' for combinig newton and irrlicht. I also don't exactly understand how to use matrices and vertices which you have to use to fil a NewtonConvexHull.

Please, can I have a look in you code?
Guest

Post by Guest »

This is the code sniuppet which shows how I creates NewtonConvexHull
i_WranglerRigidBodyMesh = smgr->getMesh("D:\\3DDevelop\\irrlicht-0.7\\examples\\02.Quake3Map\\Debug\\media\\Wrangler\\wranglerrigidbody.3ds");
int imb, v_c, i_c;
int c1i;
IMeshBuffer *m_b;
u16* indices;
float vert[1236][3];
v_c=0;
for (imb=0; imb<i_WranglerRigidBodyMesh->getMesh(0)->getMeshBufferCount(); imb++)
{
m_b = i_WranglerRigidBodyMesh->getMesh(0)->getMeshBuffer(imb);
video::S3DVertex* vertices = (irr::video::S3DVertex*)m_b->getVertices();
i_c = m_b->getIndexCount();
indices = m_b->getIndices();

for (i_c=0; i_c<m_b->getIndexCount(); i_c++)
{
c1i = indices[i_c];
vert[i_c][0] = vertices[c1i].Pos.X;
vert[i_c][1] = vertices[c1i].Pos.Y;
vert[i_c][2] = vertices[c1i].Pos.Z;
v_c++;
}
}

n_WranglerCol = NewtonCreateConvexHull(nWorld, 1236, &vert[0][0], 12, NULL);

vert array must be [x][3], where x - number of indeces(or vertices, I don't remember) in your mesh
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

Post by keless »

"vert array must be [x][3], where x - number of indeces(or vertices, I don't remember) in your mesh "

it looks like its the number of indices, since 3 would be the verts (x,y,z)
a screen cap is worth 0x100000 DWORDS
Post Reply