Author Topic: Mixed up vertex indices  (Read 4070 times)

Offline zed

  • byte
  • *
  • Posts: 12
    • View Profile
Mixed up vertex indices
« on: July 01, 2008, 01:28:43 pm »
Hi!

Is there any way I can make jPCT preserve the vertex indices as I load a file? I've created a 3ds file containing 3 models and I need to do some transformations on them that depend on special vertices in the models. My problem is that the models are displayed correctly, but the vertex indices don't match my 3ds file. So e.g. when I want to access vertex #57 in model #3 I don't get the expected vertex. I'm using a GenericVertexController for accessing the vertices by the way.

I'd appreciate any help. Thanks!

zed

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11746
    • View Profile
    • http://www.jpct.net
Re: Mixed up vertex indices
« Reply #1 on: July 01, 2008, 02:39:10 pm »
You may try to disable vertex optimizations: http://www.jpct.net/doc/com/threed/jpct/Loader.html#setVertexOptimization(boolean)

That may help with the indices but it may also reduce performance a little bit (depending on the model).

Offline zed

  • byte
  • *
  • Posts: 12
    • View Profile
Re: Mixed up vertex indices
« Reply #2 on: July 01, 2008, 02:41:09 pm »
I've already tried that. Doesn't have any effect.

This is not normal behaviour, is it?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11746
    • View Profile
    • http://www.jpct.net
Re: Mixed up vertex indices
« Reply #3 on: July 01, 2008, 02:44:36 pm »
And you've done that before loading the model? It is normal behaviour as far as i'm not making any statements/assumptions about how vertex numbers are translated or not. To be honest, i have no idea how a vertex number in 3ds translates to a number in the saved file.
« Last Edit: July 01, 2008, 05:32:34 pm by EgonOlsen »

Offline zed

  • byte
  • *
  • Posts: 12
    • View Profile
Re: Mixed up vertex indices
« Reply #4 on: July 01, 2008, 03:07:01 pm »
I've done it before loading the model, yes.

I assume that the vertex numbers should stay the same. I had to go quite a long way round to get a 3ds model, since I don't have 3DS MAX installed. So I modeled the whole thing in Maya, exported it to FBX, imported the FBX to Wings3D and exported it again as 3ds. The vertex numbers stayed the same throughout the whole process. I also get the same vertex numbers when inspecting the 3ds file with Wings3D. Only when importing to jPCT they get mixed up somehow...

The thing is, I need to be able to mark special spots on an object, so that I can attach other objects to these spots later on. I figured the best way to do so, was to specify vertices as reference points, which is why I obviously run into troubles when the vertex indices change. Any other suggestions how to solve this issue?
« Last Edit: July 01, 2008, 03:21:57 pm by zed »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11746
    • View Profile
    • http://www.jpct.net
Re: Mixed up vertex indices
« Reply #5 on: July 01, 2008, 05:35:11 pm »
Can you give me the vertex count of

a) your model in 3ds

and

b) the loaded model (Object3D.getMesh().getVertexCount()/Object3D.getMesh().getUniqueVertexCount())?

Offline zed

  • byte
  • *
  • Posts: 12
    • View Profile
Re: Mixed up vertex indices
« Reply #6 on: July 01, 2008, 06:08:52 pm »
Alright, here we go. These are the vertex counts for one of the 3 objects in the file.

- Number of vertices retrieved via Wings3D: 62

- Object3D.getMesh().getVertexCount(): 360

- Object3D.getMesh().getUniqueVertexCount(): 62 - before building, 70 - after building

Switching vertex optimization on or off doesn't affect these values.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11746
    • View Profile
    • http://www.jpct.net
Re: Mixed up vertex indices
« Reply #7 on: July 01, 2008, 06:36:26 pm »
Looks fine to me. The 8 additional vertices after building are for the bounding box, so nothing to worry about. The loader adds vertices  starting from 0 to infinity...i don't see why there shouldn't appear in the order that they have in the file. Are you creating triangle strips for the object after loading it?

Offline zed

  • byte
  • *
  • Posts: 12
    • View Profile
Re: Mixed up vertex indices
« Reply #8 on: July 02, 2008, 12:14:27 am »
Nope, I don't create any triangle strips either... The funny thing is, that the models are properly displayed and only the vertex indices are mixed up. I've also tried different ways of exporting and converting by now. Without success unfortunately. I get exactly the same results everytime.

Seems like I'm kinda stuck here...

Offline JavaMan

  • long
  • ***
  • Posts: 231
    • View Profile
Re: Mixed up vertex indices
« Reply #9 on: July 02, 2008, 01:06:52 am »
Maybe you should find out what the vertex indexes for the vertexes you need to know of in getDestinationMesh inside a VertexController is. Assuming jpct always tags the vertexes with the same indexe when you import the model, then once you figure out which index in the SimpleVector[] from getDestinationMesh they would stay the same and you could use them where you need it. Also, if your looking for a definite vector e.g. 100,30,40, you could look through the PolygonManager of the object, reading each polygon and then checking the values for the vertexes of the Polygons. When you find it, just somehow record its polygon number and which vertex it is of the polygon 1,2,3.

Maybe this will help
Jman

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11746
    • View Profile
    • http://www.jpct.net
Re: Mixed up vertex indices
« Reply #10 on: July 02, 2008, 08:32:51 pm »
Yes, it would be interesting to know in which way the indices differ. Currently, i see no reason why they should... ???