Sign in to follow this  
chennaiaras

loading X file in window

Recommended Posts

Hi all,

I am trying to load an X file(globe.X) into a window.

This is my coding ..


// set camera
createcamera(1.0f,750.0f);
cameraposition(D3DXVECTOR3(0.0f,0.0f,-450.0f));
camerafocus(D3DXVECTOR3(0.0f,0.0f,0.0f));




bool loadglobe() {
hr=D3DXLoadMeshFromX("globe.X", D3DXMESH_SYSTEMMEM, d3ddev, &gadjacencybuffer, &gmtrlbuffer, NULL, &gnummaterials, &gpymesh);

if(FAILED(hr)) return false;

D3DXMATERIAL* gmatxmaterials=(D3DXMATERIAL*)gmtrlbuffer->GetBufferPointer();
gmatmaterials = new D3DMATERIAL9[gnummaterials];

for(DWORD i=0; i<nummaterials; i++) {
gmatmaterials[i]=gmatxmaterials[i].MatD3D;
gmatmaterials[i].Ambient=gmatmaterials[i].Diffuse;
}
return true;
}



It gives the output a plain black screen.. The X file is loading since the variable hr works..

Thanks,
aras

Share this post


Link to post
Share on other sites
Could be a lot of things.

First: where do you set the value for nummaterials? You should be using gnummaterials.

Is the camera pointed at the mesh? Is the mesh large enough to see at the camera position? Is your camera created correctly? Do you set the projection and viewport correctly? Do you draw the mesh? What renderstates do you set when you draw the mesh? If you create a mesh with D3DXCreateSphere/Cube/etc., does it appear correctly?

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