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 

Help rotating objects

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



Joined: 19 Oct 2008
Posts: 23

PostPosted: Sun Oct 19, 2008 4:17 am    Post subject: Help rotating objects Reply with quote

Hi, I'm an amateur programmer who is doing a modified version of Llibplanar but I have a couple of problems that I am not able to solve, move and rotate objects relatively.

To move and rotate objects using the following functions:

Code:
void objectTranslate(Object3D *obj,float x,float y,float z){
   
    obj->translation[0][0] = x;
    obj->translation[0][1] = y * -1.0f;
    obj->translation[0][2] = z;
   
}


Code:
void objectRotate(Object3D *obj,float x,float y,float z){
   
    obj->rotation[0][0] = -x;
    obj->rotation[0][1] = -y;
    obj->rotation[0][2] = -z;
   
    // cuidado con pasarnos por encima
    while(obj->rotation[0][0] > PI) obj->rotation[0][0] -= PI_2;
    while(obj->rotation[0][1] > PI) obj->rotation[0][1] -= PI_2;
    while(obj->rotation[0][2] > PI) obj->rotation[0][2] -= PI_2;

    // y por debajo
    while(obj->rotation[0][0] < -PI) obj->rotation[0][0] += PI_2;
    while(obj->rotation[0][1] < -PI) obj->rotation[0][1] += PI_2;
    while(obj->rotation[0][2] < -PI) obj->rotation[0][2] += PI_2;

}


Code:
void objectRender(Object3D *obj){

   objectReset(obj);
   
   // aplicamos la rotacion a la matriz
    libVu0RotMatrix(obj->localToWorld[0],
                    obj->localToWorld[0],
                    obj->rotation[0]);               
    libVu0RotMatrix(obj->localToWorldRotation[0],
                    obj->localToWorldRotation[0],
                    obj->rotation[0]);
               
   // posicion
   libVu0TransMatrix(obj->localToWorld[0], obj->localToWorld[0], obj->translation[0]);

   actualobj=NULL;
    objectRender_Calc(obj);
    objectRender_Draw(obj);
}


EDIT: It seems that I get it :D
Back to top
View user's profile Send private message
LBGSHI



Joined: 07 Aug 2006
Posts: 136

PostPosted: Sun Oct 19, 2008 10:31 am    Post subject: Reply with quote

Glad we could be of help :)
_________________
I may be lazy, but I can...zzzZZZzzzZZZzzz...
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
ifcaro



Joined: 19 Oct 2008
Posts: 23

PostPosted: Mon Oct 20, 2008 9:32 am    Post subject: Reply with quote

I released it http://forums.ps2dev.org/viewtopic.php?p=75725#75725
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 -> PS2 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