quake 2 texture coords problem

Started by
4 comments, last by AcidInjury 18 years, 3 months ago
hi guys, need a bit of help here. im following the quake 2 bsp doc on flipcode and succesfully loaded quake2 map up in diretx but haveing problem with the texture coords im following this u = x * u_axis.x + y * u_axis.y + z * u_axis.z + u_offset v = x * v_axis.x + y * v_axis.y + z * v_axis.z + v_offset where x, y, x is the vertex point. but my coords are in in the 1000's e.g. 1080 and not between 0.0 and 1.0 i cant seem to figure it out. tnx
Blaaaaa Blaaaa Blaa errrrr!!!! Bla?
Advertisement
Coordinates don't have to be clamped between -1.0f and 1.0f, they can be higher to display texture tiling, etc...
But values in the range of 1000 seem quite abnormal. Maybe you should normalize the coordinates or something. I've never encountered a problem with it.
The texture coordinates you have calculated are in pixels. You need to divide u by the width of the texture image and t by the height of the image.
Hello, may I ask what you are doing with Q2? That is one of my favorite games!

My experiences with Q2 file format is that it is not well documented, and the best way to figure out the BSP file format is to install a copy of Q2 and run the GPLed source Carmack generously released through a VC debugger.
at the moment thr only internet i hsve id through the use of my mobile phone so downloading any thing big is out of the question, q2 is one of my fav games also, basically im writing a game engine and adding q2 and q3 map loading though the use of scripting :)
Blaaaaa Blaaaa Blaa errrrr!!!! Bla?
I believe you have to divide the resulting u and v values by the width and height of the texture for that face.

u = (x * u_axis.x + y * u_axis.y + z * u_axis.z + u_offset) / texWidth;
v = (x * v_axis.x + y * v_axis.y + z * v_axis.z + v_offset) / texHeight;

See if that fixes it.

This topic is closed to new replies.

Advertisement