[ODE] Trimesh creation problems

Sergey Beloshitsky sergey at rostok-games.com.ua
Thu Feb 10 12:39:20 MST 2005


David Rogers wrote:

> Thank for all your help Sergey! I'm still working on it but you've 
> helped me think through it.
>
> Now as a sequence, do you mean an array or a pointer(float [3] or 
> float *)? Now that I think about it, does that even make a difference?

you may use whatever  you want, for example I use
Vector3* vBuffer = tw_new Vector3[num_nodes*num_nodes];
unsigned int* iBuffer = tw_new unsigned 
int[(num_nodes-1)*(num_nodes-1)*2*3];

where Vector3 is a struct { float x; float y ; float z;}
Vector3 aso could be an array of 3 floats such as 
typedef float Vector3[3]

in these cases vertex_stride would be sizeof(Vector3) or what is equal 
sizeof(float)*3

here is some exaple code , perhaps it will help
numPoints = num_nodes*num_nodes;
Vector3* vBuffer = tw_new Vector3[numPoints];
// fill vBuffer
unsigned int* iBuffer = tw_new unsigned 
int[(num_nodes-1)*(num_nodes-1)*2*3];
// fill iBuffer


Create( vBuffer, 3*sizeof(float), numPoints, iBuffer, sizeof(unsigned 
int), (num_nodes-1)*(num_nodes-1)*2*3 )

Create(const void* vBuffer, const size_t vStride, const size_t vNum, 
const void* iBuffer, const size_t iStride, const size_t iNum)
{
    dTriMeshDataID TriMeshData = dGeomTriMeshDataCreate();
    // as long as dReal == floats
    dGeomTriMeshDataBuildSingle(TriMeshData,
        // Vertices
        vBuffer,
        vStride, (int) vNum,
        // Faces
        iBuffer,
        (int)iNum, iStride
        /*nBuffer*/
    );
    dGeomTriMeshSetData(m_GeomID,TriMeshData);
//    dVector3 v0,v1,v2;
//    for(int i=0;i<iNum/3;i++)
//      dGeomTriMeshGetTriangle(m_GeomID,i,&v0,&v1,&v2);
}

>
> Dave
>
> On Feb 9, 2005, at 12:33 PM, Sergey Beloshitsky wrote:
>
>     I have looked at your code, think problem is in your data, look at
>     example source code that work with TriMesh
>     also you may look at ode-doc at trimesh geom class, there is some
>     example code.
>     make sure that Lib3dsPoint is sequence of 3 floats/doubles(for
>     Double), it may also contain data at the end
>     Lib3dsFace(object->Model->meshes->faces) must contain chunks of 3
>     indexes to data in Lib3dsPoint
>
>     David Rogers wrote:
>
>         I tried that still with no luck. Perhaps it's my data, I'll
>         check on that unless anyone has any other ideas. For
>         reference, with dGeomTriMeshDataBuildSingle, here is a
>         screenshot of the trace.
>
>
>
>
>         dave
>
>
>         On Feb 9, 2005, at 8:06 AM, Sergey Beloshitsky wrote:
>
>         maybe you should chage dGeomTriMeshDataBuildDouble on
>         dGeomTriMeshDataBuildSingle
>         David Rogers wrote:
>
>         Hi all,
>
>         I'm using some 3ds models in my project and just using ODE for
>         collisions. Lib3ds is getting all the info for the models for
>         me and doing a great job at it. But when I call
>         dGeomTriMeshDataBuildDouble to put the data from my models in,
>         I get a crash. I've traced it back and it's somewhere deep
>         within OPCODE. More specifically, line 133 of
>         OPC_MeshInterface.h. Here is my problem code:
>
>         dTriMeshDataID Data;
>         int VertexStride = sizeof(Lib3dsPoint);
>         int TriStride = sizeof(Lib3dsFace);
>         gfloat *PointList = model_Get3DSPointList(object);
>
>
>         if(object->Model) {
>         Data = dGeomTriMeshDataCreate();
>
>         /* Crashes in this call */
>         dGeomTriMeshDataBuildDouble(Data,
>         object->Model->meshes->pointL, VertexStride,
>         object->Model->meshes->points,
>         object->Model->meshes->faceL, object->Model->meshes->faces,
>         TriStride);
>
>         object->TriMesh = dCreateTriMesh(space, Data, 0, 0, 0);
>         }
>
>         Any help would be greatly appreciated. If any more code/info
>         is needed, I can get it out there later today, it's too late
>         and I'm sleepy.
>
>         Thanks again!
>
>         Dave Rogers
>
>
>         "Final Score: Freedom 27, Liberty 15. It was noble effort for
>         Liberty which as you know has been playing hurt since the
>         Patriot Act."
>
>
>         ------------------------------------------------------------------------
>
>
>
>         _______________________________________________
>         ODE mailing list
>         ODE at q12.org
>         http://q12.org/mailman/listinfo/ode
>
>
>
>
>         -- Шукай в телефоні мій слід...
>
>
>         "Final Score: Freedom 27, Liberty 15. It was noble effort for
>         Liberty which as you know has been playing hurt since the
>         Patriot Act."
>
>
>
>     -- 
>     Шукай в телефоні мій слід...
>
>
> "Final Score: Freedom 27, Liberty 15. It was noble effort for Liberty 
> which as you know has been playing hurt since the Patriot Act."
>


-- 
Шукай в телефоні мій слід...



More information about the ODE mailing list