Game Development Reference
In-Depth Information
continue;
}
if (strcmp(buf,”TFLG”)==0){
ReadShort(fp,srf->tex->flag);
continue;
}
if (strcmp(buf,”TSIZ”)==0){
ReadFloat(fp,srf->tex->size.x);
ReadFloat(fp,srf->tex->size.y);
ReadFloat(fp,srf->tex->size.z);
srf->tex->size.z=-srf-tex->size.z;
continue;
}
if (strcmp(buf,”TCTR”)==0){
ReadFloat(fp,srf->tex->centre.x);
ReadFloat(fp,srf->tex->centre.y);
ReadFloat(fp,srf->tex->centre.z);
srf->tex->centre.z=-srf->tex->centre.z;
continue;
}
//If we got to here then the chunk was not found so skip by s
fseek(fp,s,SEEK_CUR);
}
return TRUE;
}
Generating texture coordinates
Most CGI packages store texture coordinates in the file. Lightwave until
version 6 stored details about the texture coordinates but forced the
developer to recreate the texture coordinates from this information. In this
section we will look at how to generate texture coordinates from the
details that Lightwave provides.
Generating the texture coordinates can be done using the texture size,
centre and mapping type. Toon3D stores the texture coordinates in the
POLYGON structure, inside an indexed array of type TVEC. As we know
from the texture mapping chapter, it is common practice to refer to texture
coordinates as ( u , v ), where u is a number from 0 to 1 that defines a
position across the bitmap texture from 0 to texture width in pixels, and v
is a number between 0 and 1 that defines a position down the bitmap
texture from 0 to texture height in pixels. The first step in creating the
Search Nedrilad ::




Custom Search