How can I move more than one object on direct3d?

Ok basically I'm new to direct3d and have made a triangle pyramid (with texture) and also a sphere but my triangle is inside the sphere and whenevr I translate an object it translates both of them

All i want to do is seperate both objects and tell the program to just move one so I can move the pyramid away from inside the sphere.

How can the program tell what it needs to move, please help

Also I can't scale my object

----------------------------------

VOID SetupMatricesObject()
{
// For our world matrix, we will just rotate the object about the y-axis.
D3DXMATRIXA16 matWorld;
D3DXMATRIXA16 matScale;
D3DXMATRIXA16 matRotation;
D3DXMATRIXA16 matTranslation;

// Set up the rotation matrix to generate 1 full rotation (2*PI radians)
// every 1000 ms. To avoid the loss of precision inherent in very high
// floating point numbers, the system time is modulated by the rotation
/// period before conversion to a radian angle.
UINT iTime = timeGetTime() % 3000;
FLOAT fAngle = iTime * (2.0f * D3DX_PI) / 3000.0f;
FLOAT tAngle = 130;

D3DXMatrixIdentity (&matWorld);



D3DXMatrixRotationX( &matRotation, tAngle );
g_pd3dDevice->SetTransform( D3DTS_WORLD, &matRotation );



D3DXMatrixScaling( &matScale, 500000.0f, 50.0f, 0.5f );
D3DXMatrixTranslation(&matTranslation, 0.0f, 0.0f, 0.0f);
D3DXMatrixMultiply (&matWorld, &matTranslation, &matScale);

g_pd3dDevice->SetTransform( D3DTS_WORLD, &matRotation );
//g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );

}
You can combine the scaling, rotation and translation matrices into a single matrix. The order in which you multiply the matrices is important:
D3DXMatrixScaling( &matScale, 500000.0f, 50.0f, 0.5f );
D3DXMatrixRotationX( &matRotation, tAngle );
D3DXMatrixTranslation(&matTranslation, 0.0f, 0.0f, 0.0f);
D3DXMatrixMultiply (&matWorld, &matScale, &matRotation);
D3DXMatrixMultiply (&matWorld, &matWorld, &matTranslation);
g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
If you have other questions, contact me at
http://www.cgdev.net
Last edited on
Topic archived. No new replies allowed.