Hi Guys,
Im currently working on a school project but im stuck, if worked on this problem for over 4 days now and i cant fix it.
Using Direct3D 9, Visual studio 2010,
im trying to make create a heightmap. Im using a bmp file.
Problem: the heightmap doesn't show up on my screen.
The Process:
-Read bmp file to char*
-Create mesh from char*
-Save mesh in LPD3DXMESH of class Heightmap
-Render all objects: heightmap, skybox, entitys
So i started the debugging by checking if my renderer even renders my heightmap.
The render function renders objects. the heightmap object is a so called child of object.
So my code to check this:
if( typeid(*pObject) == typeid(*heightmap) ){
_pLogger->log(LOGLEVEL_NOTICE, (char*) "Heightmap rendered");
}
And it logs the message every frame.
So that is not the problem, so i tried to read the mesh, but i dont know how.
Offcourse before all this i let my friends at school look at this problem but they dont know the problem either. and i did place some breakpoints in the code witch makes the mesh, but the data inputted there is correct. I also tried writing the mesh to a .x file but all it wrote was: "xof 0303bin 0032"
Some things you should know:
-bmp file is 4x4 pixels
-indexes are: 041 154 152 265 etc
-FillMode = wireframe
-cullmode = tried CCW and CW and NONE
and the pixels are read/drawn like this:
12 13 14 15
8 9 10 11
4 5 6 7
0 1 2 3
i think the problem is writing the vertices and indexes to memory, here is my code:
D3DXCreateMeshFVF(totalTriangles, totalVertices, D3DXMESH_MANAGED, D3DFVF_XYZ, _d3dDevice, &_pMesh);
void* pVertexBuffer;
void* pIndexBuffer;
_pMesh->LockVertexBuffer(0, &pVertexBuffer);
memcpy( pVertexBuffer, pVertices, totalVertices * sizeof(TTexVertex) );
_pMesh->UnlockVertexBuffer();
_pMesh->LockIndexBuffer(0, &pIndexBuffer);
memcpy( pIndexBuffer, IndexData, indexes * sizeof(DWORD) );
_pMesh->UnlockIndexBuffer();
_pModel = new Model();
_pModel->setMesh(_pMesh);
If you need some other code to help me, pleease tell me.
Thanks!
EDIT: typo