How can I retrieve mesh data from a loaded .3ds file ?

Started by Dominic, June 13, 2007, 10:33:48 PM

Previous topic - Next topic

Dominic

Hi,
I need the geometry of a model that I load from a .3ds file. I need two arrays : One that contains the vertices and the other one that contains the indices of the vertices forming the triangles of the model in the first array. Is it possible to obtain those informations from JPCT ? Or at least the vertices of each triangle ?

Thank you very much.

EgonOlsen

You can use the methods provided by the GenericVertexController, or (and that's what i prefer), you can obtain the objects PolygonManager and get the data from there. Just keep in mind that the PolygonManager gives you the data in world space. But as long as you don't rotate or translate your mesh, object and world space match.

Dominic

Thanks, with that it will be possible to have the polygon list.  :)

But is it possible to have it in the form of two arrays ? One containning all the vertices and the other containing the vertex indices ? That's the format I need. Otherwise, I will have to translate between the two.

Thank you again.

EgonOlsen

No, that's not possible atm. If all you need are the actual coordinates, the PolygonManager will do. If you really need the indices into the vertex-array (which is basically what the vertex controller returns), you'll have to recreate it yourself. Maybe its possible to add such a method in the next version...i'll have a look at it. What exactly do you need it for?

Dominic

I need it for collision detection (more advanced than what is included in JPCT). I will translate between the two formats in the mean time. That's not very complicated, it's just very slow...  But of course if I can get the data directly in the right format in the next version, it will load a lot faster since I won't have to verify if a vertex is already present in the vertex buffer before adding it.

Thank you.

P.S.: Sorry for not answering about the new version using less memory. I was busy with other priorities, so I completly forgot about that. I'm using the new version now. Thanks a lot for that.  :)

Quote from: EgonOlsen on June 14, 2007, 05:28:18 PM
No, that's not possible atm. If all you need are the actual coordinates, the PolygonManager will do. If you really need the indices into the vertex-array (which is basically what the vertex controller returns), you'll have to recreate it yourself. Maybe its possible to add such a method in the next version...i'll have a look at it. What exactly do you need it for?

EgonOlsen

I see...the vertices as returned by the GenericVertexController are unique (if the model is loaded/created that way which is default). So maybe this approach is faster? I'm not sure, but it's worth a try.

Dominic

Quote from: EgonOlsen on June 15, 2007, 12:00:06 AM
I see...the vertices as returned by the GenericVertexController are unique (if the model is loaded/created that way which is default). So maybe this approach is faster? I'm not sure, but it's worth a try.

Ok. But how do I get the indices then ? I can't find it in the javaDOCs.

Thanks

EgonOlsen

You can get the polygons that belong to a vertex. That way, it should be possible to build the list the other way round. I'm not sure if it's really better or faster...it's just an idea...