Question

I wrote a simple program to load a directX .x mesh file. My loaded image is displayed like this .

But the one which the MeshViewer shows is like this .

What should be done to get the 3D look? Which call in the DirectX library should I make?

Was it helpful?

Solution

Are you loading the same file into the viewer as into your own application? 'Cause it actually looks like you don't have any normals in the mesh. If your using the same file as the viewer, they should be in the mesh file though.

Other than that, your lighting is incredibly bright (all values at 1.0), I would set the diffuse values to 0.0 and try setting the ambient to 0.5 red. Then at least you can tell if your light is working.

OTHER TIPS

Looks like you haven't set any light.

You have to load the materials defined in the mesh, and set at least one light.

Once you've set a light, the rendering code using the fixed pipeline in DirectX 9 looks like this:

// NumMaterials and ShipMaterialshave already been loaded with the call to D3DXLoadMeshFromX
D3DXMATERIAL* ShipMats = (D3DXMATERIAL*) ShipMaterials->GetBufferPointer();
device->SetTexture(0, NULL); // assume a mesh with no texture
for (DWORD i = 0; i < NumMaterials; ++i) 
{
    device->SetMaterial(&ShipMats[i].MatD3D);
    this->pShipMesh->DrawSubset(i);
}

If you still don't see anything, set a material you've defined yourself.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top