Quote: "I want to draw an object from one point to another point with 3 co-ords (ie. a rope) "
Here is a rehash of some code created by "IanM".
It creates a single line mesh (if one can call it that) and uses the "dbSetObjectEmissive ()" function to give it whatever color you want. The mesh should be able to be extended to as many segments as you require.
#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_LINELIST;
pMesh->iDrawVertexCount = NumberOfVertices;
if (NumberOfIndexes > 0)
{
pMesh->iDrawPrimitives = NumberOfIndexes / 2; // for lines
}
else
{
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;
};
const DWORD MyFvf = D3DFVF_XYZ ;
void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 60 );
sMesh* pMesh = CreateBlankObject( 1, MyFvf , 2 , 0, false );
// Use a structure
MyVertex* v = (MyVertex*)pMesh->pVertexData;
v[0].x = -1.0; v[0].y = 1.0; v[0].z = 0.0;
v[1].x = 1.0; v[1].y = 1.0; v[1].z = 0.0;
FinaliseObject(1);
dbSetObjectCull(1, 0);
dbSetObjectEmissive ( 1, dbRGB ( 255, 0, 0 ) );// Let us try RED color
while ( LoopGDK ( ) )
{
dbSync ( );
}
return;
}
I don't have the time at the moment to bundle it up nicely into a simple function call .......... Zuka do you have the time at the moment????
Anyway, hope it gives you some ideas.