@ IanM,
Thanks for all that. Will do a rewrite of some of my terrain creation code

.
Quick question:
There are many possible configurations for setting up the indexes to point to the vertices.
// Set up the indexes to point to the vertices
// First poly
pMesh->pIndices[0] = 0;
pMesh->pIndices[1] = 1;
pMesh->pIndices[2] = 2;
// Second poly
pMesh->pIndices[3] = 0;
pMesh->pIndices[4] = 2;
pMesh->pIndices[5] = 3;
or for example:
// Set up the indexes to point to the vertices
// First poly
pMesh->pIndices[0] = 2;
pMesh->pIndices[1] = 3;
pMesh->pIndices[2] = 0;
// Second poly
pMesh->pIndices[3] = 1;
pMesh->pIndices[4] = 2;
pMesh->pIndices[5] = 0;
If we are creating an object mesh, is there some sequence that is optimised for speed of rendering ?
Also, could some other shape rather than triangles (pMesh->iPrimitiveType = D3DPT_TRIANGLELIST; ) be used as the primitive.
For example, a water mesh or cloud layer mesh would only have to be made from squares rather than triangles. If this is possible within DGDK, would it provide any significant speed improvement?
EDIT: Santa Claus helps those that help themselves

, just had to give it a try.
It looks like lines are possible:
#include "DarkGDK.h"
bool CreateNewObject( int iID, LPSTR pName, int iFrame );
sObject* dbGetObject( int iID );
bool SetupMeshFVFData( sMesh* pMesh, DWORD dwFVF, DWORD dwVertexCount, DWORD dwIndexCount );
bool SetupStandardVertex( DWORD dwFVF, BYTE* pVertex, int iOffset, float x, float y, float z, float nx, float ny, float nz, DWORD dwDiffuseColour, float tu, float tv );
bool SetNewObjectFinalProperties( int iID, float fRadius );
void SetTexture( int iID, int iImage );
sMesh* CreateBlankObject(int obj, DWORD Fvf, int NumberOfVertices, int NumberOfIndexes, bool Initialise = false)
{
CreateNewObject( obj , "" , 1 );
sObject* pObject = dbGetObject( obj );
sMesh* pMesh = pObject->pFrame->pMesh;
SetupMeshFVFData( pMesh , Fvf, NumberOfVertices , NumberOfIndexes);
if (Initialise)
{
ZeroMemory(pMesh->pVertexData, pMesh->dwFVFSize * NumberOfVertices);
if (NumberOfIndexes > 0)
{
ZeroMemory(pMesh->pIndices, sizeof(WORD) * NumberOfIndexes);
}
}
//pMesh->iPrimitiveType = D3DPT_TRIANGLELIST;
//pMesh->iPrimitiveType = D3DPT_QUADLIST;
pMesh->iPrimitiveType = D3DPT_LINELIST;
pMesh->iDrawVertexCount = NumberOfVertices;
if (NumberOfIndexes > 0)
{
//pMesh->iDrawPrimitives = NumberOfIndexes / 3; // for triangles
//pMesh->iDrawPrimitives = NumberOfIndexes / 4; // for quads
pMesh->iDrawPrimitives = NumberOfIndexes / 2; // for lines
}
else
{
//pMesh->iDrawPrimitives = NumberOfVertices / 3; // for triangles
//pMesh->iDrawPrimitives = NumberOfVertices / 4; // for quads
pMesh->iDrawPrimitives = NumberOfVertices / 2; // for lines
}
return pMesh;
}
void FinaliseObject(int obj)
{
SetNewObjectFinalProperties( obj , 0.0f );
SetTexture( obj , 0 );
}
struct MyVertex
{
float x, y, z;
float nx, ny, nz;
float tu0, tv0;
};
const DWORD MyFvf = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1;
void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 60 );
sMesh* pMesh = CreateBlankObject( 1, MyFvf , 3 , 0, false );
// Use the standard vertex function - don't use where > 1 texture coord is needed though, because it's broken
//SetupStandardVertex(MyFvf, pMesh->pVertexData, 0, -1.0, 1.0, 0.0, 0.0, 0.0, -1.0, 0, 0.0, 0.0); // for lines, triangles, quads
//SetupStandardVertex(MyFvf, pMesh->pVertexData, 1, 1.0, 1.0, 0.0, 0.0, 0.0, -1.0, 0, 0.0, 0.0); // for lines, triangles, quads
//SetupStandardVertex(MyFvf, pMesh->pVertexData, 2, 1.0, -1.0, 0.0, 0.0, 0.0, -1.0, 0, 0.0, 0.0); // for triangles, quads
//SetupStandardVertex(MyFvf, pMesh->pVertexData, 3, -1.0, -1.0, 0.0, 0.0, 0.0, -1.0, 0, 0.0, 0.0); // for quads
// Or use a structure
MyVertex* v = (MyVertex*)pMesh->pVertexData;
v[0].x = -1.0; v[0].y = 1.0; v[0].z = 0.0; v[0].nx = 0.0, v[0].ny = 0.0, v[0].nz = -1.0; v[0].tu0 = 0.0; v[0].tv0 = 0.0; // for lines, triangles, quads
v[1].x = 1.0; v[1].y = 1.0; v[1].z = 0.0; v[1].nx = 0.0, v[1].ny = 0.0, v[1].nz = -1.0; v[1].tu0 = 0.0; v[1].tv0 = 0.0; // for lines, triangles, quads
//v[2].x = 1.0; v[2].y = -1.0; v[2].z = 0.0; v[2].nx = 0.0, v[2].ny = 0.0, v[2].nz = -1.0; v[2].tu0 = 0.0; v[2].tv0 = 0.0; // for triangles, quads
//v[3].x = -1.0; v[3].y = -1.0; v[3].z = 0.0; v[3].nx = 0.0, v[3].ny = 0.0, v[3].nz = -1.0; v[3].tu0 = 0.0; v[3].tv0 = 0.0; // for quads
FinaliseObject(1);
dbSetObjectCull(1, 0);
while ( LoopGDK ( ) )
{
dbSync ( );
}
return;
}
Quads are not working.
D3DPT_QUADLIST is an "undeclared identifier"
If one were to activate this mode, would it break some of the default DGDK functions ?