Mixed up vertex indices

Started by zed, July 01, 2008, 01:28:43 PM

Previous topic - Next topic

zed

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

EgonOlsen

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).

zed

I've already tried that. Doesn't have any effect.

This is not normal behaviour, is it?

EgonOlsen

#3
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.

zed

#4
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?

EgonOlsen

Can you give me the vertex count of

a) your model in 3ds

and

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

zed

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.

EgonOlsen

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?

zed

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...

JavaMan

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

EgonOlsen

Yes, it would be interesting to know in which way the indices differ. Currently, i see no reason why they should... ???