Texture Mapping in Project 3:
-
myply.h: replace the myPlyVertex definition with:
typedef struct myPlyVertex {
Dbl x;
Dbl y;
Dbl z;
Dbl u;
Dbl v;
int r;
int g;
int b;
Dbl nx;
Dbl ny;
Dbl nz;
} myPlyVertex;
-
myply.h:
change numVertexProperties from 6 to 8 and
replace vertex_property declaration with:
static struct PlyProperty vertex_property[8]=
{
{"x",0,Float64,0,0,0,0,0},
{"y",0,Float64,sizeof(Dbl),0,0,0,0},
{"z",0,Float64,2*sizeof(Dbl),0,0,0,0},
{"texture_u",0,Float64,3*sizeof(Dbl),0,0,0,0},
{"texture_v",0,Float64,4*sizeof(Dbl),0,0,0,0},
{"color_r",0,Int32,5*sizeof(Dbl),0,0,0,0},
{"color_g",0,Int32,5*sizeof(Dbl)+sizeof(int),0,0,0,0},
{"color_b",0,Int32,5*sizeof(Dbl)+2*sizeof(int),0,0,0,0},
};
-
Mesh.h: add the following definition:
void getTextureCoord(int vNum, Dbl *texture);
-
Mesh.cpp: add the following
routine
void Mesh::getTextureCoord(int vNum, Dbl* texture)
{
if (vNum < 0 || vNum >= thePlyMesh.numVertices)
{
printf("Invalid vertex number.\n");
return;
}
*texture = thePlyMesh.theVertices[vNum].u;
*texture = thePlyMesh.theVertices[vNum].v;
return;
}
-
Use the code from project 2 to read in the texture map.
-
Report any difficulties to me.