Jump to content
  • Advertisement
Sign in to follow this  
Calin

[.net] Porting some code to C# and MDX [solved]

This topic is 4550 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to port my C++ picking class to my brand new C# engine :) Basically I managed to port everything except a function what deals with reading from index and vertex buffers. The main problem is I can't find the MDX corespondent for some native DX structures. I'd really appreciate if a seasoned veteran would help me with this. Here's the code:
UINT16 i0, i1, i2;

LPDIRECT3DINDEXBUFFER9 pIB;
LPDIRECT3DVERTEXBUFFER9 pVB;
Terrain.m_pMesh->GetIndexBuffer(&pIB);
Terrain.m_pMesh->GetVertexBuffer(&pVB);


WORD * pIndicesMs;
rslt=Terrain.m_pMesh->LockIndexBuffer(D3DLOCK_READONLY, reinterpret_cast< VOID** >( &pIndicesMs ) );
if(FAILED(rslt)) { LogDX("Failed to Lock the Mesh IndexBuffer 'loading2.jpg' \n",rslt); }

i0 = pIndicesMs[TerrainFaceIndex * 3 + 0 ];
i1 = pIndicesMs[TerrainFaceIndex * 3 + 1 ];
i2 = pIndicesMs[TerrainFaceIndex * 3 + 2 ];
Terrain.m_pMesh->UnlockIndexBuffer( );





and this:
// Get vertex description
D3DVERTEXBUFFER_DESC desc;
pVB->GetDesc(&desc);

// Get the size of each vertex from FVF
UINT uStride = D3DXGetFVFVertexSize(desc.FVF);

// Lock vertex buffer to get at the raw bits
void* pvData;
pVB->Lock(0, 0, &pvData, 0);


struct VERTEX
{
float x, y, z;
};

const UINT i1Vertex = i0;
const UINT i2Vertex = i1;
const UINT i3Vertex = i2;
VERTEX* aVertex = (VERTEX*)((BYTE*)pvData + uStride * i1Vertex);
VERTEX* bVertex = (VERTEX*)((BYTE*)pvData + uStride * i2Vertex);
VERTEX* cVertex = (VERTEX*)((BYTE*)pvData + uStride * i3Vertex);


// Unlock vertex buffer when done
pVB->Unlock();




[Edited by - Calin on May 7, 2006 3:26:47 PM]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!