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!
vt is the reference number for a texture vertex in the face element. It always follows the first slash. vn is an optional argument. vn is the reference number for a vertex normal in the face element. It must always follow the second slash.
Vertex colors are not part of the original OBJ file format specification.
An OBJ file (. obj) contains information about the geometry of 3D objects. The files are used for exchanging information, CAD, and 3D printing. OBJ files can support unlimited colors, and one file can define multiple objects.
Just install the software OBJ Viewer To begin viewing 3D files, simply do the following Install the extension OBJ Viewer Click on the extension icon Choose the 3D file you wish to open Begin viewing your 3D files online today! This 3D viewer works for both STL and OBJ file formats.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With