|
![]() |
#1 |
Member
Advanced member
Join Date: May 2006
Posts: 36
|
![]()
Is it possible to get the rotation of an object relative to the origin? Simular to the get_centre function.
For example, say you have 2 boxes in a group. You rotate that group on the x-axis by pi. Is there a way that I can get the rotation about the x,y,z axis? So for the example here I should get rotation (3.14,0,0). If we rotate the group again in the same direction on the same axis by pi again, then we should get [0,0,0]. |
![]() |
![]() |
![]() |
#2 |
Administrator
Professional user
Join Date: Jun 2003
Posts: 4,541
|
![]()
Sorry, this is not currently possible since the vertices are rotated in the global space.
|
![]() |
![]() |
![]() |
#3 |
Member
Advanced member
Join Date: May 2006
Posts: 36
|
![]()
Ok, I think its possible to do this ... check my math and let me know what u think.
Have a group that is to be copied. The copies of the group are to be translated and rotated. I think it is possible to get the rotation of the groups by doing the following: * translating the copy back to the origin (where the location of the original is) * calculate the rotation of the x,y,z axis via the location of vertaces. -> ie, take the first vertex from the copy and the first vertex from the original and apply the math below ![]() The above math is derived from the information found at the link below. http://www.tpub.com/math2/5.htm So what do you think? Does this sound feasible? I need functions that do the following
I know there are functions available in the ac3d headers that do the first 2. So can I use the Math.h functions to get arc tan or is there something available in the headers for that? (Update) I've answered my own question here - I just tried atan and Math.h works! Last edited by conzar; 13th June 2006 at 08:55 PM. |
![]() |
![]() |
![]() |
#4 |
Member
Advanced member
Join Date: May 2006
Posts: 36
|
![]()
Arg. Looks like the math above is flawed b/c one doesn't know in which order the object was rotated.
So I have come up w/ another possible solution. Here it is: Create a plugin that records the rotations applied to an object as well as which order the rotations were applied. I think this is a simple solution; none-the-less, its a solution. I'll report back in a few days ... |
![]() |
![]() |
![]() |
#5 |
Member
Advanced member
Join Date: May 2006
Posts: 36
|
![]()
Hey.
So I can't seem to find a function call to rotate an object. The only functions I found that seemed close are listed below. Code:
set_global_matrix_rotate(float rx, float ry, float rz) void rotate_object(ACObject *ob) Code:
ac_rotate_object(ACObject *ob, float rx, float ry, float rz) Thanks |
![]() |
![]() |
![]() |
#6 |
Member
Expert member
Join Date: Aug 2003
Location: Eslöv, Sweden
Posts: 93
|
![]()
Can't you use the 2 function calls in the way you're requesting?
void my_rotate_object(ACObject *ob, float rx, float ry, float rz) { set_global_matrix_rotate(rx,ry,rz); rotate_object(ob); recordRotationSomehow(rx,ry,rz); } Last edited by PerFnurt; 7th September 2006 at 10:24 AM. |
![]() |
![]() |
![]() |
Thread Tools | |
Display Modes | |
|
|