Hi!
Here is my current code(much is commented-out cause im debugging some
)
// Dark GDK - The Game Creators - www.thegamecreators.com
// the wizard has created a very simple project that uses Dark GDK
// it contains the basic code for a GDK application
// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.h"
#include "globstruct.h"
#include "global.h"
/*
n0_simpleVertex
For å holde 3d-punkt data, med XYZ.
*/
struct n0_simpleVertex
{
float x;
float y;
float z;
};
/* Prototyper for å lage egene vertices */
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 );
/*
n0_CreateNewObject
int obj - Objekt nummer
int noVer - Antall vertices
int noInd - Antall indekser
n0_simpleVertex verList[] - Array med alle vertex data
int indList[] - Array med alle index data
*/
void n0_CreateNewObject( int objnr, int noVer, int noInd, n0_simpleVertex verList[] , int indList[] )
{
CreateNewObject( objnr , "" , 1 );
sObject* obj = dbGetObject( objnr );
SetupMeshFVFData( obj->pFrame->pMesh , D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1 , noVer , noInd );
for( int vIndex = 0; vIndex < noVer; ++vIndex )
{
SetupStandardVertex( obj->pFrame->pMesh->dwFVF , obj->pFrame->pMesh->pVertexData , vIndex , verList[vIndex].x , verList[vIndex].y , verList[vIndex].z , 0.0f , 0.0f , -1.0f , 0 , 0.0f , 0.0f );
}
for( int iIndex = 0; iIndex < noInd; ++iIndex )
{
obj->pFrame->pMesh->pIndices[ iIndex ] = indList[ iIndex ];
}
obj->pFrame->pMesh->iPrimitiveType = D3DPT_TRIANGLELIST;
obj->pFrame->pMesh->iDrawVertexCount = 3; //noVer;
obj->pFrame->pMesh->iDrawPrimitives = 1; //obj->pFrame->pMesh->dwIndexCount / 3;
SetNewObjectFinalProperties( objnr , 0.0f );
SetTexture( objnr , 0 );
//// Lager objektet
//CreateNewObject( obj , "" , 1 );
//// Peker til objekt-data
//sObject* pObject = dbGetObject( obj );
//// Peker til mesh-data
//sMesh* pMesh = pObject->pFrame->pMesh;
//// Setter opp FVF-format
//SetupMeshFVFData( pMesh , D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1, noVer , noInd);
//for(int x=0; x < noVer + 0; x++)
//{// Index
// SetupStandardVertex ( pMesh->dwFVF , pMesh->pVertexData , x , verList[x].x , verList[x].y , verList[x].z , 0.0f , 0.0f , -1.0f , 0 , 0.0f , 0.0f );
//}
//// Skriver index-data
//for(int x=0; x < noInd + 0; x++)
//{
// pMesh->pIndices[x] = indList[x];
//}
//pMesh->iPrimitiveType = D3DPT_TRIANGLELIST;
//pMesh->iDrawVertexCount = noVer;
//// pMesh->dwIndexCount = noInd;
//pMesh->iDrawPrimitives = pMesh->dwIndexCount / 3;
//// dbLoadImage("C:\gress.bmp" , 1);
//SetNewObjectFinalProperties( obj , 0.0f );
//SetTexture( obj , 0 );
}
// the main entry point for the application is this function
void DarkGDK ( void )
{
// turn on sync rate and set maximum rate to 60 fps
dbSyncOn ( );
dbSyncRate ( 60 );
//const int kol = 100;
//const int rad = 100;
//const int square = 10;
//const int vArraySize = (kol + 1) * (rad + 1);
//const int iArraySize = kol * rad * 6;
n0_simpleVertex vArray[2];
vArray[0].x = 0.0; vArray[0].y = 0.0; vArray[0].z = 0.0; // A
vArray[0].x = 1.0; vArray[0].y = 1.0; vArray[0].z = 0.0; // B
vArray[0].x = 1.0; vArray[0].y = 0.0; vArray[0].z = 0.0; // C
n0_CreateNewObject( 1 , 2 + 1 , 0 , vArray , NULL );
//n0_simpleVertex vertexArray[vArraySize];
//int indexArray[iArraySize];
//// Loop for å fylle inn vertex-arrayen
//int teller = 0;
//for(int d = 0; d < kol + 1; ++d)
//{
// for(int a = 0; a < rad + 1; ++a)
// {
// // Fylle inn vertex-array
// vertexArray[teller].x = d * square;
// vertexArray[teller].y = 0;
// vertexArray[teller].z = a * square;
// ++teller;
// }
//}
//// Loop for å fylle inn index-arrayen
//teller = 0;
//for(int j = 0; j < kol; ++j)
//{
// for(int r = 0; r < rad; ++r)
// {
// // Fylle inn index-array
// indexArray[teller] = 1 + r + j * (rad + 1) ; ++teller;
// indexArray[teller] = rad + 2 + r + j * (rad + 1) ; ++teller;
// indexArray[teller] = (rad + 1) + r + j * (rad + 1) ; ++teller;
// indexArray[teller] = 1 + r + j * (rad + 1) ; ++teller;
// indexArray[teller] = r + (j + 1) * (rad + 1); ++teller;
// indexArray[teller] = r + j * (rad + 1) ; ++teller;
// }
//}
//dbMakeObjectCube( 2 , 25.0f );
//n0_CreateNewObject( 1 , vArraySize + 1, iArraySize + 1, vertexArray , indexArray );
//CreateNewObject( 10 , "" , 1 );
//sObject* obj = dbGetObject( 10 );
//SetupMeshFVFData( obj->pFrame->pMesh , D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1 , 3 , 0 );
//SetupStandardVertex( obj->pFrame->pMesh->dwFVF , obj->pFrame->pMesh->pVertexData , 0 , 0.0f , 0.0f , 0.0f , 0.0f , 0.0f , -1.0f , 0 , 0.0f , 0.0f );
//SetupStandardVertex( obj->pFrame->pMesh->dwFVF , obj->pFrame->pMesh->pVertexData , 1 , 1.0f , 1.0f , 0.0f , 0.0f , 0.0f , -1.0f , 0 , 0.0f , 0.0f );
//SetupStandardVertex( obj->pFrame->pMesh->dwFVF , obj->pFrame->pMesh->pVertexData , 2 , 1.0f , 0.0f , 0.0f , 0.0f , 0.0f , -1.0f , 0 , 0.0f , 0.0f );
//obj->pFrame->pMesh->iPrimitiveType = D3DPT_TRIANGLELIST;
//obj->pFrame->pMesh->iDrawVertexCount = 3;
//obj->pFrame->pMesh->iDrawPrimitives = 1;
//SetNewObjectFinalProperties( 10 , 0.0f );
//SetTexture( 10 , 0 );
// our main loop
while ( LoopGDK ( ) )
{
if( dbSpaceKey() )
{
dbSetObjectCull( 1 , true );
} else {
dbSetObjectCull( 1 , false );
}
if( dbObjectExist( 1 ) )
{
dbText( 0 , 0 , "LOL" );
}
dbShowObject( 1 );
// update the screen
dbSync ( );
}
// return back to windows
return;
}
It worked before I did something, this is pretty stripped down version that I have taken out from the program and im trying to get it to work again( debugging in a new empty project with only this code, so there isnt anything else in my sourcecode that what I have posted). Still the object wont appear but it exists
help please?
Keep it simple.
Questions? Mail me