Jump to content
  • Advertisement
Sign in to follow this  

OpenGL BSP Maps - Texture Mapping Vectors

This topic is 2970 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have been writing code to load and render BSP files. It was going great until i got to the texture mapping. No matter what i do, the textures end up tiling completely wrong. To calculate the texture coordinates (u, v) for the particular vertex i am using the following formula.

//Calculate texture coordinates
float u = TextureInfo[Faces[faceId].texinfo].textureVecsU.dotProduct(Vertexes[vertexIndice]) +

float v = TextureInfo[Faces[faceId].texinfo].textureVecsV.dotProduct(Vertexes[vertexIndice]) +

Where textureVecsU and vextureVecsV are the vectors for the texture plane and Vertexes[vertexIndice] points to a vector containing the vertex.

The code that reads in the vectors is:

BSPMap->TextureInfo.textureVecsU = readVector3fInvertZY(in);
BSPMap->TextureInfo.textureOffsetU = readFloat(in);
BSPMap->TextureInfo.textureVecsV = readVector3fInvertZY(in);
BSPMap->TextureInfo.textureOffsetV = readFloat(in);

Where (in) is the input stream, readFloat reads a float value from it in correct endian form and readVector3fInvertZY reads a vector struct and corrects the Z and Y coordinates for openGL. I cannot see what i am doing wrong at all and would appreciate any input. I am almost certain the vectors are read in at the correct point as the texture names are read in just after and come out fine.

Share this post

Link to post
Share on other sites
Don't worry, i found the answer.

Answer can be found here for anyone in the future who comes across the same problems and happens to come across this thread:

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!