Author Topic: How can I retrieve mesh data from a loaded .3ds file ?  (Read 5392 times)

Offline Dominic

  • byte
  • *
  • Posts: 9
    • View Profile
How can I retrieve mesh data from a loaded .3ds file ?
« on: June 13, 2007, 10:33:48 pm »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: How can I retrieve mesh data from a loaded .3ds file ?
« Reply #1 on: June 14, 2007, 12:00:53 am »
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.

Offline Dominic

  • byte
  • *
  • Posts: 9
    • View Profile
Re: How can I retrieve mesh data from a loaded .3ds file ?
« Reply #2 on: June 14, 2007, 03:27:51 pm »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: How can I retrieve mesh data from a loaded .3ds file ?
« Reply #3 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?

Offline Dominic

  • byte
  • *
  • Posts: 9
    • View Profile
Re: How can I retrieve mesh data from a loaded .3ds file ?
« Reply #4 on: June 14, 2007, 05:39:47 pm »
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.  :)

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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: How can I retrieve mesh data from a loaded .3ds file ?
« Reply #5 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.

Offline Dominic

  • byte
  • *
  • Posts: 9
    • View Profile
Re: How can I retrieve mesh data from a loaded .3ds file ?
« Reply #6 on: June 15, 2007, 03:32:42 pm »
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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: How can I retrieve mesh data from a loaded .3ds file ?
« Reply #7 on: June 15, 2007, 03:38:06 pm »
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...