FW: [ODE] Please correct my code (about Transform Geometry)~

Brian Clarkson brianclarkson at btconnect.com
Thu Feb 5 08:57:45 MST 2004


This works for me. I draw the boxes needed to define the shape of the rigidy
body in a 3d package so I have them as a
mesh. This method extracts the mesh details and caomputes the bounding box
so an ODE collision box can be created.

Brian..

int CMRigidBody::CreateGeomBoxes(CD3DFileObject* mesh)
{


     D3DVERTEX* pVertices;
     DWORD dwNumVertices;
     WORD* pIndices;
     DWORD dwNumIndices;
     char* pMeshType;

     D3DXVECTOR3 *box;
     if(mesh) {
        box = mesh->GetAABB();
     }

     D3DXVECTOR3 boxLength = box[1] - box[0];

     mesh->GetMeshGeometry2(&pVertices, &dwNumVertices, &pIndices,
&dwNumIndices , &pMeshType);

         m_GeomID = dCreateGeomTransform (m_SpaceID);
         dGeomID  geom = dCreateBox(0, (dReal) boxLength.x, (dReal)
boxLength.y, (dReal) boxLength.z);
         dGeomSetData (geom, this);
         dGeomSetPosition(geom, box[0].x + (boxLength.x/2.0f),
                                box[0].y + (boxLength.y/2.0f),
                                box[0].z + (boxLength.z/2.0f));
         dGeomTransformSetGeom (m_GeomID, geom);
         dGeomSetBody (m_GeomID,m_BodyID);


     return S_OK;

}


-----Original Message-----
From: ode-bounces at q12.org [mailto:ode-bounces at q12.org]On Behalf Of
CVAvGv
Sent: 05 February 2004 07:50
To: ode at q12.org
Subject: [ODE] Please correct my code (about Transform Geometry)~


I have a problem..and I don't know what is problem..T_T...
I tested Transform Geometry to make a chair...
But It wouldn't work as I expect...

I have a two box...
First one is what doesn't use Transform Geometry...it is just ordinary
box...so It works good..
Second one uses Transform Geometry....This wouldn't work! T_T (it penetrate
ground-_-;;)

I created second box like this :

	gs_bodyBigBox = dBodyCreate(gs_worldID);

	dMass massBigBox;
	dMassSetBox(&massBigBox, 1, 1.0f, 1.0f, 1.0f);
	dMassAdjust(&massBigBox, 0.1f);

	dBodySetPosition(gs_bodyBigBox, -1.0f, 7.0f, 0.0f);

	gs_geomBigBox = dCreateBox(0, 2.0f, 2.0f, 2.0f);
	dGeomTransformSetCleanup(gs_geomBigBoxT, 1);
	gs_geomBigBoxT = dCreateGeomTransform(gs_spaceID);
	dGeomTransformSetGeom(gs_geomBigBoxT, gs_geomBigBox);
	dGeomSetPosition(gs_geomBigBox, 0.0f, 0.0f, 0.0f);
	dBodySetMass(gs_bodyBigBox, &massBigBox);

	dGeomSetBody(gs_geomBigBoxT, gs_bodyBigBox);

and rendered like this :

	float matBigBox[4*4];
	float matBigBoxT[4*4];
	float matBigBoxE[4*4];
	ODEGeomGetTransform(matBigBoxT, gs_geomBigBoxT);
	dGeomID geomE = dGeomTransformGetGeom(gs_geomBigBoxT);
	ODEGeomGetTransform(matBigBoxE, geomE);
	Mat44Mul(matBigBox, matBigBoxE, matBigBoxT);
	SetModelViewMatrix(matBigBox, v);

	SetColor(1.0f, 1.0f, 1.0f, 1.0f);
	RenderBox(2.0f, 2.0f, 2.0f);



Please TEACH ME what is problem to play with this boxes happily~ (^^)

p.s. refer to :
source snip : http://www.honestee.net/test.cpp
exe test file : http://www.honestee.net/test.exe







---------------------------------------------------------------------
Get your own 30MB free email at http://www.empal.com
_______________________________________________
ODE mailing list
ODE at q12.org
http://q12.org/mailman/listinfo/ode




More information about the ODE mailing list