Jump to content
  • Advertisement
Sign in to follow this  
Thr3ad

Textured Mesh Rotation Problems

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

I have managed to load a mess and its texture which i created in 3dStudio Max and got it to display on screen. So I have now gone onto trying to get it to rotate around its 'Y' axis. I have managed to do this a bit but it rotates around the center of the right hand side, and when it gets so far round it shrinks and then disapears to come back a bit further into the rotation. This is what i am using and the code is crude but i am only learning right now.
D3DXMATRIX matView;
    D3DXMatrixLookAtLH( &matView, &D3DXVECTOR3( 0.0f, 3.0f,-100.0f ),
					//	&D3DXVECTOR3( 0.0f, -3.0f, 100.0f ),
						&D3DXVECTOR3( 0.0f, 0.0f, 0.0f ),
						&D3DXVECTOR3( 0.0f, 3.0f, 0.0f ) );
    pD3DDevice->SetTransform( D3DTS_VIEW, &matView );

    D3DXMATRIX matProj;
  //  D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/2, 1.0f, 1.0f, 100.0f );
	
	D3DXMatrixPerspectiveFovLH( &matProj, D3DXToRadian( 55.0f ), 800.0f / 600.0f,
		                        1.0f, 100.0f );

    pD3DDevice->SetTransform( D3DTS_PROJECTION, &matProj );

    D3DXMATRIX matWorld;
    D3DXMatrixRotationY( &matWorld, GetTickCount()/1000.0f );
    pD3DDevice->SetTransform( D3DTS_WORLD, &matWorld );

    for( DWORD i=0; i<m_dwNumMaterials; i++ )
    {
        // Set the material and texture for this subset
        pD3DDevice->SetMaterial( &pMeshMaterials );
        pD3DDevice->SetTexture( 0, pMeshTextures );

        // Draw the mesh subset
        pSysMemMesh->DrawSubset(i);
    }
is there a better and cleaner way to do this? Thanks for looking.

Share this post


Link to post
Share on other sites
Advertisement
Quote:

I have managed to do this a bit but it rotates around the center of the right hand side


Most probably your model wasn't situated at position 0,0,0 in 3DS Max when you exported it. Make sure it's in the center of the 'square grid' whet you export it.

Quote:

and when it gets so far round it shrinks and then disapears to come back a bit further into the rotation.


I guess it disappears because it gets out of your FOV.
try transforming this line:

D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/2, 1.0f, 1.0f, 100.0f );

into this

D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/2, 1.0f, 1.0f, 1000.0f );

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!