Texture Map with Lighting, stops my 3d objects from showing!

Started by
10 comments, last by johnnyBravo 20 years, 7 months ago
ill try and do what you said on learning it better.

But just one more thing. Ive gotten rid of all the scale , rotate stuff etc. I just want to make sure this code is right.

world function again
float constants[4] = {0, 0.5f, 1.0f, 2.0f};lp_Device->SetVertexShaderConstantF( 0, (float*)&constants, 1 );D3DXMATRIX matWorld, matView, matProj;//view settingD3DXMatrixLookAtLH( &matView, &D3DXVECTOR3( 50, -10, 10 ), &D3DXVECTOR3( 0, 0, 0 ), &D3DXVECTOR3( 0, 1, 0 ));lp_Device->SetTransform( D3DTS_VIEW, &matView );////projection setting		D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/2, 1.0f, 1, 500 );lp_Device->SetTransform( D3DTS_PROJECTION, &matProj );////world setting...D3DXMatrixTranslation(&matWorld ,x , y, z);//D3DXMatrixMultiply(&matWorld,&matWorld,&matView);D3DXMatrixMultiply( &matWorld, &matWorld, &matProj );	D3DXMatrixTranspose( &matWorld, &matWorld );//lp_Device->SetVertexShaderConstantF( 4, (float*)&matWorld, 4 );float color[4] = {1,1,1,0};lp_Device->SetVertexShaderConstantF( 8, (float*)&color, 1 );float lightDir[4] = {-1,0,1,0}; // fatter slicelp_Device->SetVertexShaderConstantF( 12, (float*)&lightDir, 1 );




[edited by - johnnyBravo on September 24, 2003 6:06:27 AM]
Advertisement
The moment you use "SetTransform" you''re using the fixed function pipeline. That means that you cannot use vertex shaders at all (so you can''t do "SetVertexShaderConstantF"). You either have to use the fixed function pipeline or use vertex shaders. You can''t mix and match the two. So if you''re using the fixed function pipeline, you "World()" function will look like this:

D3DXMATRIX matWorld, matView, matProj;D3DXMatrixLookAtLH( &matView, &D3DXVECTOR3( 50, -10, 10 ), &D3DXVECTOR3( 0, 0, 0 ), &D3DXVECTOR3( 0, 1, 0 ));lp_Device->SetTransform( D3DTS_VIEW, &matView );D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/2, 1.0f, 1, 500 );lp_Device->SetTransform( D3DTS_PROJECTION, &matProj );//world setting...D3DXMatrixTranslation(&matWorld ,x , y, z);//lp_Device->SetTransform( D3DTS_WORLD, &matWorld );


I assume you want to use some kind of lighting because you''re setting some lighting constants in the shaders. To do this with the fixed function pipeline, you have to create a D3DLIGHT9 structure and fill it in. Then call "SetLight". Make sure that lighting is enabled by calling: lp_Device->SetRenderState( D3DRS_LIGHTING, TRUE ); somewhere during initialization of the app.

Good luck,
neneboricua

This topic is closed to new replies.

Advertisement