Jump to content
  • Advertisement
Sign in to follow this  
Tenshi_rdk

Why does my .x model not show ?

This topic is 4355 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

Hi guys , in the article posted here http://www.gamedev.net/reference/articles/article2079.asp I tried to implement the drawing of x files into my own app but , i cannot get my model to show at ALL..what the heck am i doing wrong ? I`ll try and show some code ..but PLEASE HELP ME PLEASE !! OK first i set the global vars: CModel* g_pModel= NULL; // A model object to work with Then i load the file like so : SAFE_DELETE(g_pModel); g_pModel = new CModel(gd3dDevice); g_pModel->LoadXFile("tiny.x"); Then I draw it: HR(gd3dDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER |D3DCLEAR_STENCIL, 0x0099FF, 0.0f, 0)); HR(gd3dDevice->BeginScene()); //draw the model //Update the model g_pModel->Update(1); //what should this be ? or does it not matter ? g_pModel->Draw(); HR(gd3dDevice->EndScene()); // Present the backbuffer. HR(gd3dDevice->Present(0, 0, 0, 0)); BUT NOTHING SHOWS !!?? This is my camera and projection setup -> // Sets up the camera 1000 units back looking at the origin. D3DXMATRIX V; D3DXVECTOR3 pos(0.0f, 0.0f, -1000.0f); D3DXVECTOR3 up(0.0f, 1.0f, 0.0f); //to rotate VIEW ANGLE D3DXVECTOR3 target(0.0f, 0.0f, 0.0f); D3DXMatrixLookAtLH(&V, &pos, &target, &up); HR(gd3dDevice->SetTransform(D3DTS_VIEW, &V)); // The following code defines the volume of space the camera sees. D3DXMATRIX P; RECT R; GetClientRect(mhMainWnd, &R); float width = 800; float height = 600; D3DXMatrixPerspectiveFovLH(&P, D3DX_PI*0.25f, width/height, 1.0f, 2500.0f); HR(gd3dDevice->SetTransform(D3DTS_PROJECTION, &P)); And this is my render states ---> // This line of code disables Direct3D lighting. HR(gd3dDevice->SetRenderState(D3DRS_LIGHTING, false)); // Turn on the zbuffer gd3dDevice->SetRenderState(D3DRS_ZENABLE, TRUE); // ***** // Culling gd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); // **** // The following code specifies an alpha test and reference value. HR(gd3dDevice->SetRenderState(D3DRS_ALPHAREF, 10)); HR(gd3dDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATER)); // The following code is used to setup alpha blending. HR(gd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE)); HR(gd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1)); HR(gd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA)); HR(gd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA)); gd3dDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); //***** // Indicates that we are using 2D texture coordinates. HR(gd3dDevice->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2)); So basically ..i`m lost ..please HELP !!? [Edited by - Tenshi_rdk on October 20, 2006 5:39:14 PM]

Share this post


Link to post
Share on other sites
Advertisement
it's been awhile since i've used the DirectX API

you're loading tiny.x and setting camera 1000 away? Maybe it's too small to show up? Try scaling it or loading a different model?

Share this post


Link to post
Share on other sites
How do i scale it ?
And i saw somewhere i need to setup a WORLD MATRIX ??
What is that , is it really nessecary ?

Or how do i translate my model to be 100% sure it's at 0,0,0 coordinates ?

Please ! THANKS !

Share this post


Link to post
Share on other sites
i just got my model to show !!!

the problem was with this ..
HR(gd3dDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER |D3DCLEAR_STENCIL, 0x00000000, 0.0f, 0));

i had to change it to (the z value)

HR(gd3dDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER |D3DCLEAR_STENCIL, 0x00000000, 1.0f, 0));

but i`m sure I fiddled with it before...can someone explain to me why this happened ?

i Dont understand it..PLEASE ( for future reference )

Share this post


Link to post
Share on other sites
clearing the z buffer (depth buffer) to 0.0f means that every pixel drawn will(?) fail the depth test (by default less than or equal to) and not be drawn to the screen

e.g.

draw a cube, the pixels it will have z values of like...... 100, 230.56f, (greater than 0), ...

the depth test is: draw the pixel if its less than or equal to the current pixel (0.0f)...
draw if 100 <= 0
draw if 230.56f <= 0

setting the z to 1.0f in the clear function, means each pixel will be its maximum value... from the projection matrix i think

Share this post


Link to post
Share on other sites
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!