forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

(got it) D3DXVec3TransformCoord & D3DXMatrixRotationAxis

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Stellar



Joined: 12 Dec 2005
Posts: 48

PostPosted: Fri Jan 20, 2006 3:17 am    Post subject: (got it) D3DXVec3TransformCoord & D3DXMatrixRotationAxis Reply with quote

I didnt know if there were higher level functions already written for this, but if not, i did it from scratch :)

D3DXMATRIX * D3DXMatrixRotationAxis(
D3DXMATRIX * pOut,
CONST D3DXVECTOR3 * pV,
FLOAT Angle
);

D3DXVECTOR3 * D3DXVec3TransformCoord(
D3DXVECTOR3 * pOut,
CONST D3DXVECTOR3 * pV,
CONST D3DXMATRIX * pM
);

____________________________________________

UPDATE: this is what i got for transform
Code:

ScePspFVector3 Vector3TransformCoord(
   ScePspFVector3 vector,
   ScePspFMatrix4 matrix
)
{
   ScePspFVector3 temp;

   temp.x = matrix.x.x * vector.x + matrix.x.y * vector.y + matrix.x.z * vector.z;
   temp.y = matrix.y.x * vector.x + matrix.y.y * vector.y + matrix.y.z * vector.z;
   temp.z = matrix.z.x * vector.x + matrix.z.y * vector.y + matrix.z.z * vector.z;

   return temp;
}


and heres the code for rotate, but i havent tried the functions yet.

Code:

ScePspFMatrix4 XlMatrixRotationAxis(
   ScePspFVector3 vector,
   float angle
)
{
   ScePspFMatrix4 temp;

   float sin_a = sin( angle );
   float cos_a = cos( angle );

   float x_y = vector.x * vector.y;
   float x_z = vector.x * vector.z;
   float y_z = vector.y * vector.z;

   temp.x.x = 1 + ( 1 - cos_a ) * ( vector.x * vector.x - 1 );
   temp.x.y = -vector.z * sin_a + ( 1 - cos_a ) * x_y;    
   temp.x.z =  vector.y * sin_a + ( 1 - cos_a ) * x_z;
   temp.x.w = 0;
   
   temp.y.x =  vector.z * sin_a + ( 1 - cos_a ) * x_y;
   temp.y.y = 1 + ( 1 - cos_a ) * ( vector.y * vector.y - 1 );
   temp.y.z = -vector.x * sin_a + ( 1 - cos_a ) * y_z;
   temp.y.z = 0;

   temp.z.x = -vector.y * sin_a + ( 1 - cos_a ) * x_z;
   temp.z.y =  vector.x * sin_a + ( 1 - cos_a ) * y_z;
   temp.z.z = 1 + ( 1 - cos_a ) * ( vector.z * vector.z -1 );
   temp.z.w = 0;
   
   temp.w.x = 0;         
   temp.w.y = 0;
   temp.w.z = 0;
   temp.w.w = 1;

   return temp;
}



thanks,
-stellar
_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group