I'm using Assimp to load 3D models into my program. Everything has gone dandy so far, except I've come across a Lightwave object that doesn't seem to make sense. Of course it renders nicely in Lightwave, but in Assimp there are no texture coordinates, no UV coordinates, but textures that end up getting loaded. But that doesn't help - they just sit in memory and never get used because - you guessed it - there are no texture coordinates.
I haven't found any helpful Assimp pages so far on this. Other models load fine and are properly texture-mapped. Is this a problem with Assimp?
Uses an object as a source for coordinates. Often used with an empty, this is an easy way to place a small image at a given point on the object. This object can also be animated, to move a texture around or through a surface. Position coordinate in camera space.
Does this happen with all Lightwave models, or just this one? Does your program render other models correctly?
I was also having the same issue as you, using assimp to read in an OBJ file (rather than a Lightwave data file) and render the thing in OpenGL. My renderer was pretty completely copied from the example on the assimp site. I did some investigation in to my renderer, and found that I didn't have any code to use the UVs! So, I added
if( mesh->mTextureCoords[0] != NULL ) {
glTexCoord2fv( &mesh->mTextureCoords[0][index].x );
}
right before where I draw a vertex, where
int index = face->mIndices[i];
and i is the loop control variable of a for loop.
The issue: The rendering code found on the assimp website doesn't do anything useful with UV coordinates. You have to add that in yourself.
Hope this isn't to late to help!
There are 8 texture coordinate slots... each one can be filled with a different texture or not... you merely need to check the first one
mesh->mTextureCoords[0]
cast it into an array like this "const struct aiVector3D*" and loop through the indexes mTextureCoords[0][t]
notice we loop t and its a 2d array
for (t = 0; t < mesh->mNumVertices; ++t) {
const struct aiVector3D* textureVec = &mesh->mTextureCoords[0][t];
printf("tex (%f,%f,%f)", textureVec->x, textureVec->y, textureVec->z );
}
Hope it helps! I was stuck here too! thinking it wasn't loading...
now: tex (0.159871,0.410298,0.000000)tex (0.034839,0.369741,0.000000)tex (0.147435,0.506447,0.000000)tex (0.018893,0.493014,0.000000)tex (0.159871,0.602596,0.000000)tex (0.034839,0.616288,0.000000)tex (0.196806,0.695823,0.000000)tex (0.082196,0.735817,0.000000)tex (0.257118,0.783297,0.000000)tex (0.159520,0.847968,0.000000)tex (0.314932,0.833907,0.000000)tex (0.318555,0.981848,0.000000)tex (0.554152,0.373114,0.000000)tex (0.557998,0.677465,0.000000)tex (0.442610,0.703479,0.000000)
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