Go Back   AC3D Forums > Technical > AC3D Developers
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 12th June 2006, 09:42 PM   #1
conzar
Member
Advanced member
 
conzar's Avatar
 
Join Date: May 2006
Posts: 36
Question Get Rotation of a Group or Object

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].
conzar is offline   Reply With Quote
Old 13th June 2006, 04:05 AM   #2
Andy
Administrator
Professional user
 
Andy's Avatar
 
Join Date: Jun 2003
Posts: 4,563
Default Re: Get Rotation of a Group or Object

Sorry, this is not currently possible since the vertices are rotated in the global space.
Andy is offline   Reply With Quote
Old 13th June 2006, 08:35 PM   #3
conzar
Member
Advanced member
 
conzar's Avatar
 
Join Date: May 2006
Posts: 36
Default Re: Get Rotation of a Group or Object

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
  • translate group to origin
  • Get a specific vertex in a group (the first one)
  • arc tan function

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.
conzar is offline   Reply With Quote
Old 21st June 2006, 11:11 PM   #4
conzar
Member
Advanced member
 
conzar's Avatar
 
Join Date: May 2006
Posts: 36
Default Re: Get Rotation of a Group or Object

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 ...
conzar is offline   Reply With Quote
Old 25th June 2006, 04:19 PM   #5
conzar
Member
Advanced member
 
conzar's Avatar
 
Join Date: May 2006
Posts: 36
Default Re: Get Rotation of a Group or Object

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)
What I would like to have is something like
Code:
ac_rotate_object(ACObject *ob, float rx, float ry, float rz)
Is there anything like that?

Thanks
conzar is offline   Reply With Quote
Old 7th September 2006, 06:45 AM   #6
PerFnurt
Member
Expert member
 
Join Date: Aug 2003
Location: Eslöv, Sweden
Posts: 93
Default Re: Get Rotation of a Group or Object

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);
}
__________________
/Per

www.perfnurt.se

Last edited by PerFnurt; 7th September 2006 at 10:24 AM.
PerFnurt is offline   Reply With Quote
Old 26th September 2006, 09:14 AM   #7
conzar
Member
Advanced member
 
conzar's Avatar
 
Join Date: May 2006
Posts: 36
Default Re: Get Rotation of a Group or Object

Hot dang your right. Just saw your post today ... so I'll try that tonight.

Thanks
conzar is offline   Reply With Quote
Old 26th September 2006, 08:54 PM   #8
conzar
Member
Advanced member
 
conzar's Avatar
 
Join Date: May 2006
Posts: 36
Default Re: Get Rotation of a Group or Object

Humm. Seems like the above code rotates an object about the origin. How would I rotate it about the center of the object? I would like the same functionality as the rotate buttons on the left side bar.

Thanks.
conzar is offline   Reply With Quote
Old 26th September 2006, 09:38 PM   #9
Dennis
Senior Member
Professional user
 
Dennis's Avatar
 
Join Date: Jul 2003
Posts: 899
Default Re: Get Rotation of a Group or Object

Quote:
Originally Posted by conzar View Post
Humm. Seems like the above code rotates an object about the origin. How would I rotate it about the center of the object? I would like the same functionality as the rotate buttons on the left side bar.
You'll want to move the object to the origin, rotate it, then move it back to its original position. The rotation function exposed through the SDK doesn't handle the translation part of the equation.

Alternatively, you could call the code that AC3D uses when you use the left side bar rotate function. Check out the ac3d.tcl file in the "scripts" directory and look for "ac3d rotate_axis_angle". This snippet might help:

Code:
// Specify axis where 0 = x, 1 = y, 2 = z
int axis = 1;
float degrees = 90.0f;
tcl_command( "ac3d rotate_axis_angle %d %g", axis, degrees );
The above code should rotate the selected geometry 90 degrees around the Y axis, relative to the object/selection center. Note that this is off the cuff and untested.

Good luck
Dennis is offline   Reply With Quote
Old 27th September 2006, 01:56 PM   #10
conzar
Member
Advanced member
 
conzar's Avatar
 
Join Date: May 2006
Posts: 36
Default Re: Get Rotation of a Group or Object

Yep. That did the trick.

Thanks!!!!
conzar is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -4. The time now is 10:02 AM.


AC3D Forum
(C) Inivis Limited 2020