• Advertisement
Sign in to follow this  

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

This topic is 4368 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;


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

// 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

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

Share this post

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

  • Advertisement