unreal models texture format??

Started by
5 comments, last by orenk2k 23 years ago
Hello. i''m working on unreal tournament model viewer and i have a little problem, i read all the info form the model files, and draw it on screen but from some resone i didn''t understand the idea of storing the UV texture coords in a ''char'' variable. i get some values of U = 178 , V = 56 and so on, my question is: HOW DO I CONVERT THOSE VALUES TO BE USED IN MY glTexCoord function? (float vars!) --> Thanks alot <--
orenk2k
Advertisement
A char takes a fourth of the place of a float, that''s why people store texcoords in chars. Conversion is easy, divide by 256.0, that''s it.

U_float = (float)U_char/256.0;
V_float = (float)V_char/256.0;

- JL
well, i tried this ofcourse!, but my texture image size isn''t 256 x 256 it''s
252 x 195. and it''s not looking good at all, any ideas??

--> thanks <--
orenk2k
Texture coordinates in a 3d file (unreal''s, quakes, whatever) are independent of texture resolution. They just tell you how the mapping plane is applied to the polygons. The 255 in a u/v char doesn''t mean you have to use 256*256 textures, it''s just the maximal range of a char and corresponds to 0.9999... float.
If your texture isn''t square and has a weird aspect ratio, then it''s upon you to adjust texture coordinates to prevent bad distortions.

-JL
this is my code:

A = (frame * header.numofVertices) + triangles.iVertex[0];
B = (frame * header.numofVertices) + triangles.iVertex[1];<br>C = (frame * header.numofVertices) + triangles.iVertex[2];<br><br>TexCoord[0][0] = (float)(triangles.mTex[0][0])/255;<br>TexCoord[0][1] = (float)(triangles.mTex[0][1])/255;<br><br>TexCoord[1][0] = (float)(triangles.mTex[1][0])/255;<br>TexCoord[1][1] = (float)(triangles.mTex[1][1])/255;<br><br>TexCoord[2][0] = (float)(triangles.mTex[2][0])/255;<br>TexCoord[2][1] = (float)(triangles.mTex[2][1])/255;<br><br>glTexCoord2d(TexCoord[0][0] , TexCoord[0][1]);<br>glVertex3f(x+(points<A href='http://.x*scale),y+(points[A].y*scale),z+(points[A].z*scale));<br><br>glTexCoord2d(TexCoord[1][0] , TexCoord[1][1]);<br>glVertex3f(x+(points<b>.x*scale),y+(points.y*scale),z+(points.z*scale));<br> <br>glTexCoord2d(TexCoord[2][0] , TexCoord[2][1]);<br>glVertex3f(x+(points[C].x*scale),y+(points[C].y*scale),z+(points[C].z*scale));<br><br>ofcourse with the (glBegin(GL_TRIANGLES) and glEnd)<br>do you see something wrong?? , because i don''t. as you said char is 0 to 255 so i use /255 to get the ratio!. well any help (maybe the syntax!) will be great!!!.<br><br>–&gt; THANKS ALOT <–<br> </b> </i> ' Target=_Blank>Link</a>
orenk2k
(hey why the code cut away??!) well this is the rest of the code:

glTexCoord2d(TexCoord[0][0] , TexCoord[0][1]);
glVertex3f(x+(points<A href='http://.x*scale),y+(points[A].y*scale),z+(points[A].z*scale));<br>
glTexCoord2d(TexCoord[1][0] , TexCoord[1][1]);
glVertex3f(x+(points.x*scale),y+(points.y*scale),z+(points.z*scale));<br> <br>glTexCoord2d(TexCoord[2][0] , TexCoord[2][1]);<br>glVertex3f(x+(points[C].x*scale),y+(points[C].y*scale),z+(points[C].z*scale));<br> </b> ' Target=_Blank>Link</a>
orenk2k
orenk2k : Could you send me some specifications(structure/file reading code/your code?/links..anything would be useful) of UT models.. can your program also open levels? ... could you post some images...
TNX
email : mirko.teran@guest.arnes.si

There are more worlds than the one that you hold in your hand...
You should never let your fears become the boundaries of your dreams.

This topic is closed to new replies.

Advertisement