[ODE] Loading trimesh from file

Rodrigo Hernandez kwizatz at aeongames.com
Tue Jul 11 17:03:16 MST 2006


Ecker, Bryan R wrote:

>Rodrigo Hernandez Wrote: 
>
>  
>
>>You have to load the model "manualy" and arrange the triangles 
>>into a vertex array, a triangle index array and a normal array
>>    
>>
>
>
>Ok - let me see if I understand the relationship between these 
>arrays, because this is where my confusion resides. You have a vertex
>array, which contains an array of 3D vertices - and the index array 
>which is an ordered list of references to the vertex array elements.
>So if I were to draw a quadrilateral made from 2 triangles:
>
>A         B
> o-------o
> |\      |
> | \     |
> |  \    |
> |   \   |
> |    \  |
> |     \ |
> |      \|
> o-------o
>C         D
>
>Then the vertex array would contain 4 vertices:
>
>v[0] = { a }
>v[1] = { b } 
>v[2] = { c }
>v[3] = { d }
>
>And my index array would contain six indices pointing to the elements
>in the vertex array:
>
>i[0] = 0;    // triangle 1 (acd)
>i[1] = 2;
>i[2] = 3;
>i[3] = 3;    // triangle 2 (dba)
>i[4] = 1;
>i[5] = 0;
>
>Correct?
>
>
>  
>
Not quite, I believe the ordering on the index array must be
counterclockwise like in OpenGL, so

i[0] = 0;    // triangle 1 (acd)
i[1] = 1;
i[2] = 3;
i[3] = 3;    // triangle 2 (dba)
i[4] = 2;
i[5] = 0;


Would be the way to go.

>  
>
>>That said, it is probably NOT a good idea to do this for large 
>>"buildings", or for meshes that have too much detail, if say 
>>inside your building you have a model of a plant, complete with 
>>leaves, base and all, doing per triangle collision tests on that 
>>mesh alone is going to cost a lot of CPU cycles, which results 
>>in lower frame refresh, and the simulation is likelly to slow 
>>down, instead use a bounding box for collision, while still 
>>rendering the detailed model.
>>    
>>
>
>
>
>I assume the same thing could be said about large scale terrains?
>
>Let me run this one by you and see if it makes sense - instead of
>loading a single model file - I load in two files, a model file,
>and drastically reduced collision geom file, which contains a very 
>simplistic version of the model - two floor polies, each wall is
>a two polies, the ceiling is two polies, and objects like boxes, 
>plants, sofas, refrigerators, cats, commodes, ceiling fans, bottles
>corpses, and vehicles - they would all be represented as a volume in
>space, using a simple primitive, like a simple 12-polygon box.
>
>Would that be a feasible alternative to creating a trimesh using every
>triangle in the original model?
>
>Or is there a better way than that?
>
>
>  
>
Yes!, thats exactly the way to go right now, the better way would be to
use convex objects to represent the collision mesh (and a BSP with
Portals for broad  collision detection phase), but thats not yet
functional in ODE, you could use boxes and build hollow cubes, if you
position them properly, you can even make windows and doorways into the
hollow cubes, just giving you some ideas here.




More information about the ODE mailing list