Handling .obj files: Why is it possible to have more vertextextures (vt) than vertices (v)?
Asked Answered
M

3

9

I am working on a .obj handler in c++. Importing the data shouldn't be a Problem, but i do not understand why it is possible, that a .obj (e.g. exported from blender) has more 'vt' entries than 'v' entires. If someone could explain me that, i would be very happy!

Thanks!

Marcelo answered 5/1, 2015 at 10:14 Comment(0)
C
8

The number of position, normal and texture coordinates may be different because two vertices may share a coordinate in one space but differ in another.

Think of a box (8 verts) using 6 different rectangular shapes (one per face) in texture space -> that's 6*4=24 texture coordinates.

Edit: A common uv-map for a box looks like below (14 texture coordinates). I've annotated three different vertices: A, B and C. Note that in a box every vertex is adjacent to three faces which has to be true in the uv-map also. C gets a texture coordinate which is adjacent to three faces, but B has to be duplicated and A tripled to do so.

Box-uv

Copeck answered 5/1, 2015 at 10:19 Comment(3)
Thank you BeyelerStudios, not sure if i understood what you mean. A box has 8 3D-Points (our vertices). The texture i apply fits for all 6 shapes. In this case a face is defined by 4 vertices. If i want to find the rgb values for a vertice i can choose more than one? Sorry, i think i got you wrong :(Marcelo
Ah yeah, i understand you! The fact, that the texture does not need to be in one piece results in more vtextures than vertices. Thank you!Marcelo
This is a very good explanation, you should add this to wikipedia. The do not explain it at the moment :)!Marcelo
A
1

I found the source of the problem. I had prematurely optimized my program, and didn't realize that texture coordinates could be of a larger quantity than vertex coordinates due to the fact that textures are mapped per face rather than per vertex, so each vertex could have many texture coordinates mapped to it. Hopefully someone will learn from my mistakes.

Something I found strange though was initializing an sf::RenderWindow prior to running my .obj parser resulted in no error messages being thrown and the crash to be reported in a completely different area than it was actually happening.

Acquisition answered 27/1, 2017 at 20:6 Comment(0)
T
0

There is much confusion caused by the naming in the LWO format. The lines labelled 'v' are actually defining points and not vertices. When the faces are defined these points are converted into vertices, which gives a cube 24 vertices, but only 8 points.

Tribal answered 1/10, 2020 at 19:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.