Archived

This topic is now archived and is closed to further replies.

transforming points

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

what function do i use to transform a 3d point? currently i tryed using D3DXVec3TransformNormal doesnt seem to work properly, D3DXVec3TransformCoord also seems to do a better job, but still dosent seem to be working properly, same with D3DXVec3Transform here is my current code for transforming my cameras frustrum to world coordinates:
	BOUNDS frustum; //object coordinates
	BOUNDS worldFrustum; //world coordinates
 
	frustum.points[0] = D3DXVECTOR3(-55,55,55); //top foward left
	frustum.points[1] = D3DXVECTOR3(15,15,55); //top foward right
	frustum.points[2] = D3DXVECTOR3(-55,-55,55); //bottom foward left
	frustum.points[3] = D3DXVECTOR3(55,-55,55); //bottom foward right

	frustum.points[4] = D3DXVECTOR3(-55,55,-55); //top back left
	frustum.points[5] = D3DXVECTOR3(55,55,-55); //top back right
	frustum.points[6] = D3DXVECTOR3(-55,-55,-55); //bottom back left
	frustum.points[7] = D3DXVECTOR3(55,-55,-55); //bottom back right
 
void Camera::TransformBounds()
{
    // For our world matrix, we will just leave it as the identity
	D3DXMATRIXA16 matRotation;
	D3DXMATRIXA16 matTranslation;
    D3DXMATRIXA16 matWorld;
	D3DXMatrixIdentity( &matWorld );

	//get rotation of camera
	D3DXVECTOR3 rotation = eye - position;
	D3DXVec3Normalize( &rotation, &rotation );

	D3DXMatrixRotationYawPitchRoll( &matRotation, rotation.x, rotation.y, rotation.z);
	D3DXMatrixTranslation( &matTranslation, position.x, position.y, position.z);

	D3DXMatrixMultiply( &matWorld, &matRotation, &matTranslation );

	//transform object bounds to world bounds
	D3DXVECTOR4 temp;
	for(int i=0; i < 8; i++)
	{
		D3DXVec3Transform( &temp, &frustum.points, &matWorld );
		worldFrustum.points[i].x = temp.x;
		worldFrustum.points[i].y = temp.y;
		worldFrustum.points[i].z = temp.z;
	}
}
 
the code seems to be right, but the expected results dont seem to be, so if you see anything wrong plz point it out thanks

Share this post


Link to post
Share on other sites