Now I'm almost done but got a smidgen problem.
My first Limb is not showing up in the final object. It runs through the code as if it is setting the limb up, it does that with all of them.
The main function that builds the entire object:
void _GDK_PM::GDK_build_object()
{
iLimbCount = map_size * 3;
ObjID = GDK_free_object();
CreateNewObject( ObjID, "", 1 );
pObject = dbGetObject( ObjID );
GDK_dbo_floor();
GDK_dbo_wall();
GDK_dbo_roof();
SetNewObjectFinalProperties( ObjID, 10.0f );
SetTexture( ObjID, 0 );
dbConvertObjectFVF( ObjID, D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR );
int loop, type;
int wall_off = map_size;
int roof_off = wall_off + map_size;
for ( loop = 0; loop < map_size; loop ++ )
{
type = pSegList[loop].faces[0].type;
int limb = loop + 1;
if ( type == PM_RFACE )
{
if ( textures[0] ) dbTextureLimb( ObjID, limb, textures[0] );
else dbColorLimb( ObjID, limb, 0xffffff );
if ( textures[1] ) dbTextureLimb( ObjID, limb + wall_off, textures[1] );
else dbColorLimb( ObjID, limb + wall_off, 0xff8800 );
if ( textures[2] ) dbTextureLimb( ObjID, limb + roof_off, textures[2] );
else dbColorLimb( ObjID, limb + roof_off, 0xff0000 );
}
else
{
if ( textures[3] ) dbTextureLimb( ObjID, limb, textures[3] );
else dbColorLimb( ObjID, limb, 0x00ffff );
if ( textures[4] ) dbTextureLimb( ObjID, limb + wall_off, textures[4] );
else dbColorLimb( ObjID, limb + wall_off, 0x00ff88 );
if ( textures[5] ) dbTextureLimb( ObjID, limb + roof_off, textures[5] );
else dbColorLimb( ObjID, limb + roof_off, 0x00ff00 );
}
}
dbSetObjectSpecular( ObjID, 0xffffff );
dbSetObjectSpecularPower( ObjID, 5 );
}
And the function that I'm having the problem with:
void _GDK_PM::GDK_dbo_floor()
{
int iVerts, iIndices, loop;
sFrame *pFrame = 0;
for ( curr_seg = 0; curr_seg < map_size; curr_seg++ )
{
// get the mesh size
iVerts = pSegList[curr_seg].verts.size();
iIndices = pSegList[curr_seg].faces.size() * 3;
// create a new frame? (Not if very first mesh to add)
if ( curr_seg == 0)
pFrame = pObject->pFrame;
else
pFrame = CreateNewFrame( pObject, "", true );
// setup the new mesh data
sMesh *pMesh = pFrame->pMesh;
SetupMeshFVFData( pMesh, D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1, iVerts, iIndices );
// add verts
_VERT *v = &pSegList[curr_seg].verts[0];
int size = pSegList[curr_seg].verts.size();
for ( loop = 0; loop < size; loop++ )
{
SetupStandardVertex(pMesh->dwFVF, pMesh->pVertexData, loop,
v->x, v->y, v->z, v->nx, v->ny, v->nz, 0xffffff, v->s, v->t );
v++;
}
// add faces
size = pSegList[curr_seg].faces.size();
_FACE * f = &pSegList[curr_seg].faces[0];
for ( loop = 0; loop < size; loop++ )
{
pMesh->pIndices[loop*3] = f->v1;
pMesh->pIndices[loop*3+1] = f->v2;
pMesh->pIndices[loop*3+2] = f->v3;
f++;
}
// finalise limb
pMesh->iPrimitiveType = D3DPT_TRIANGLELIST;
pMesh->iDrawVertexCount = iVerts;
pMesh->iDrawPrimitives = pSegList[curr_seg].faces.size();
} // EOF for ( curr_seg
}
It's this bit
// create a new frame? (Not if very first mesh to add)
if ( curr_seg == 0)
pFrame = pObject->pFrame;
else
pFrame = CreateNewFrame( pObject, "", true );
that I'm unsure about. I just assumed that when the object is created then the first limb was already set.
And yet my final object has a missing limb...
Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!