Problems with trianglemesh collisions

zunou
Posts: 2
Joined: Tue Jul 26, 2011 2:58 am

Problems with trianglemesh collisions

Post by zunou »

Hello, for some days, I'm using bullet physics 2.77 on wii, I have managed to operate all types of collision, but I can`t implement the triangle collision, I don`t know what I'm doing wrong
this is what I'm doing:

obj->num_i is the number of triangles
obj->i[] is the index array
obj->v[] is the vertex arra
y

Code: Select all

                int e=0;
		
		obj->_btTriangleMesh = new btTriangleMesh();
		int v1;
		int v2;
		int v3;
	
		
		while(e!=obj->num_i)
		{
			v1= obj->i[e*3];
			  v2= obj->i[e*3+1];
			  v3= obj->i[e*3+2];
						
			btVector3 vertex0(obj->v[3*v1], obj->v[3*v1+1], obj->v[3*v1+2]);
			btVector3 vertex1(obj->v[3*v2], obj->v[3*v2+1], obj->v[3*v2+2]);
			btVector3 vertex2(obj->v[3*v3], obj->v[3*v3+1], obj->v[3*v3+2]);
		    
						
			
			obj->_btTriangleMesh->addTriangle( vertex0, vertex1, vertex2, 1 );
			
			++e;
		}

		
		_btCollisionShape = new btBvhTriangleMeshShape( obj->_btTriangleMesh, 1, 1 );
But doing this the program crashes, does anyone could tell me where it may be wrong?

Thanks :)
zunou
Posts: 2
Joined: Tue Jul 26, 2011 2:58 am

Re: Problems with trianglemesh collisions

Post by zunou »

I've solved, the code was correct, the problem was a variable num_i :lol: .
wow this forum is dead, there is no activity :?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Problems with trianglemesh collisions

Post by Erwin Coumans »

You are posting in the wrong forum. Don't use the general forum.