Sign in to follow this  
Anddos

modifying terrain triangles

Recommended Posts

I want the effect of the triangles around the intersected triangle to be affected,not just the intersected triangle on the terrian, so far the intersect triangle just changes on the y position, i cannot for the life of me think how todo it so all the triangles around the intersected triangle stay connected and so it just dosent look like huge cracks etc..
 
DWORD WINAPI LockThread(LPVOID Param)
{
//MessageBox(NULL,"Thread Started","",0);
BYTE* lpbVb;
int numIndices;
BYTE *lpIB;
DWORD idxVbVert0, idxVbVert1, idxVbVert2;
D3DINDEXBUFFER_DESC ibdesc;
    LPDIRECT3DINDEXBUFFER9 lpIndexBuffer = NULL;
 
 
while(1)
{
mesh->LockVertexBuffer(D3DLOCK_READONLY, (VOID**)&lpbVb);
mesh->LockIndexBuffer ( D3DLOCK_READONLY, (VOID**)&lpIB);
mesh->GetIndexBuffer( &lpIndexBuffer );
lpIndexBuffer->GetDesc( &ibdesc );
if(ibdesc.Format == D3DFMT_INDEX32)
{
//MessageBox(NULL,"ibdesc.Format 32","",0);
numIndices = ibdesc.Size / sizeof(DWORD);
}
else
{
//MessageBox(NULL,"ibdesc.Format 16","",0);
numIndices = ibdesc.Size / sizeof(WORD);
}
 
DWORD numBytesPerVertex = mesh->GetNumBytesPerVertex();
 
for(int i=0; i<numIndices; i += 3 )
{

idxVbVert0 = ((WORD*)lpIB)[ i ];
idxVbVert1 = ((WORD*)lpIB)[ i+1 ];
idxVbVert2 = ((WORD*)lpIB)[ i+2 ];
 
D3DXVECTOR3 v0 = *(D3DXVECTOR3*) &lpbVb[ idxVbVert0 * numBytesPerVertex ];
   D3DXVECTOR3 v1 = *(D3DXVECTOR3*) &lpbVb[ idxVbVert1 * numBytesPerVertex ];
D3DXVECTOR3 v2 = *(D3DXVECTOR3*) &lpbVb[ idxVbVert2 * numBytesPerVertex ];
 
if(i == FaceIndex*3)
{
//very slowly...
v0.y -= 0.000003f; 
v1.y -= 0.000003f;
v2.y -= 0.000003f; 
 
*(D3DXVECTOR3*) &lpbVb[ idxVbVert0 * numBytesPerVertex ] = v0;
*(D3DXVECTOR3*) &lpbVb[ idxVbVert1 * numBytesPerVertex ] = v1;
*(D3DXVECTOR3*) &lpbVb[ idxVbVert2 * numBytesPerVertex ] = v2;
}
 
}
 
mesh->UnlockVertexBuffer();
mesh->UnlockVertexBuffer();
 
}
return 0;
}
 
ignore the terrian texture for now , the code needs to be fixed for that
where the triangles have gone down is where the player was stood etc, only 1 triangle changes on the y axis atm..
uugx.jpg
Edited by Anddos

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this