3D Rad - Free 3D game maker - Forum

This forum is now archived!

This forum is locked, and is a read-only version. A new community-ran forum can be found at classdev.net

News:

The 3DRad community can be found at classdev.net.

Pages: 1 [2] 3

Author Topic: Quaternion Script  (Read 1646 times)

« Reply #15 on: March 15, 2013, 06:36:39 PM »
you guys love to complicate things unneccesarily...

LocalToParent() allows you to totally disregard quaternion calculations and work with integers to rotate things around the global space...

and if you need to rotate something around a local space, simply make it a child, and when the parent rotates, the child will use the parents orientation as its basis for its rotation... instant local space rotations...

xingbatty's wrapping of quats into functions are  a lot less than the super duper spectacular hype he was spouting...

and,  your use of vector math isn't really necessary when there's a so much easier way to do it...
unless you feel you need the excercise...


--Mike

« Last Edit: March 15, 2013, 06:38:43 PM by Mike Hense »
« Reply #16 on: March 15, 2013, 06:39:12 PM »
Well, nice try XingBat
You are using exactly the same code as chronocide -
No, actually he's provided a more complete package of functions for rotating an object.

LocalToParent involves two objects. We're just working with a single, spinning object here. So only a couple lines of code are needed, and I think xing pretty much summed up the possible single-spinning-object variations.
« Last Edit: March 15, 2013, 06:46:08 PM by chronocide »
« Reply #17 on: March 15, 2013, 06:51:13 PM »
Quote
LocalToParent involves two objects

only if you need to rotate around a local space... orientations around the global space only requires one object...

and even the, the pivot object can be a simple cube...


the real point here is that the logic is soooooo much simpler... as is the code...

Code: [Select]
int x,y,z;

void Main()
{
   LocalToParent(OBJ_22,OBJ_22,Vector3(0,1,0),Vector3(0,0,0.01));
   LocalToParent(OBJ_22,OBJ_0,Vector3(90,y*10,0),Vector3(0,6,0));
   y+=1;
}

think about it for a second...

--Mike
« Last Edit: March 15, 2013, 06:56:22 PM by Mike Hense »
« Reply #18 on: March 15, 2013, 06:57:56 PM »
You're adding a cube, and
Code: [Select]
void LocalToParent(int PARENT, int OBJ, Vector3 rotation, Vector3 translation){
Vector3 parentLocation;
Quaternion parentOrientation;
Quaternion newOrientation;
Quaternion objectOrientation;
Vector3 forward, location, newLocation;
float x,y,z,ud,lr,fb;
x = rotation.x; y = rotation.y; z = rotation.z;
fb = translation.z; lr = translation.x; ud = translation.y;
iObjectLocation(PARENT, parentLocation);
iObjectOrientation(PARENT,parentOrientation);
iObjectOrientationSet(OBJ,parentOrientation);
iVectorRotate(forward,Vector3(lr,ud,fb),parentOrientation);
newLocation = parentLocation + forward;
iObjectLocationSet(OBJ,newLocation);
iQuaternionFromEulerAngles(newOrientation,x,y,z,"xyz");
iQuaternionMultiply(newOrientation,newOrientation,parentOrientation);
iObjectOrientationSet(OBJ,newOrientation);
}
to do this
Code: [Select]
iQuaternionFromEulerAngles(q,0,f,0,"xyz");   iObjectOrientationSet(OBJ_0,q);-oh, right, local - then also needed is iQuaternionMultiply and iObjectOrientation
For a relative position, like LocalToParent provides, iVectorRotate, using the new orientation and desired offset vector
« Last Edit: March 15, 2013, 07:03:27 PM by chronocide »
« Reply #19 on: March 15, 2013, 07:05:43 PM »
you don't have to write the LocalToParent  function... Jestermon already provided that for you...  all you have to do is use it... 

one,  simple to use function that provides you with a cornucopia of functionality, without the pain of all the math....

in addition to worry free rotations you can even make an object (any object) move itself around the world...


Quote
iQuaternionFromEulerAngles(q,0,f,0,"xyz");   iObjectOrientationSet(OBJ_0,q);

nope...  look at the code i showed you... you don't need anything else... why would you need to quat mult anything...


but hey... listen... just like before,  you think you know it all... so it's best that you do it the way you want... i really don't know why i waste my time trying to show anything to you... all you do is make foolish arguments...

you'll learn eventually...

wait until you discover some of the inherent issues with quat to and from euler angles that people here with much more experience using 3DRAD than you do have already run into...

--Mike




« Last Edit: March 15, 2013, 07:12:09 PM by Mike Hense »
« Reply #20 on: March 15, 2013, 07:24:37 PM »
If you'd be adding a script and another object to rotate an object, you might as well use a Transform object.
« Reply #21 on: March 15, 2013, 07:26:39 PM »
try it... you'll see why i don't use it and why i also don't use the iObjectChildTransform() function...

--Mike
« Last Edit: March 15, 2013, 07:28:29 PM by Mike Hense »
« Reply #22 on: March 15, 2013, 07:32:49 PM »
I'm not going to get into an argument again, it's really not worth wasting time on.

chronocide and fourdee seem to be the only ones to understand the underlying maths around quaternions. chronocide based on his excellent comprehension of quaternions not being cumulative, and fourdee for his own very implementation of quaternions in his Tron game. Using someone else's functions does not mean you understand them, only that one knows how to use them.

Some don't even bother to read the code, and make a judgment call on "hearsay".

LocalToParent is excellent, but is designed for local translation and rotation. (Parent/Child relationships included). My functions don't aim to replace it, but rather to simply offer extra functions to help make life easier for those who do not understand quaternions or how to apply them. If anyone wishes to use them, then by all means do. If not; then who cares.

Rotataternions are my idea of a play on words on Quaternion. A little joke that seems to fly over most folks heads, and misread it as bragging. No loss.
« Last Edit: March 26, 2013, 08:09:28 AM by XingBat »
« Reply #23 on: March 15, 2013, 07:35:19 PM »
why would you need to quat mult anything...
Like I posted earlier, quat multiplication is rotation addition. You multiply the current orientation by the rotation amount to get the new orientation. Your mess of another dummy object about which to rotate, and all the commands executed in LocalToParent, aren't needed to simply spin an object. LocalToParent is overkill in this case.

try it... you'll see why i don't use it and why i also don't use the iObjectChildTransform() function...
I was referring to the Transform object, not the iObjectChildTransform function.
« Last Edit: March 15, 2013, 07:37:36 PM by chronocide »
« Reply #24 on: March 15, 2013, 07:44:04 PM »
@XingBatty...
Quote
chronocide and fourdee seem to be the only ones to understand the underlying maths around quaternions

AHAHAHAHAHAHAAAAAAAA!!!!  i'm sorry kid... but you're just plain delusional...

second...

you, and anyone who chooses to use your magnificent cure all functions, will eventually run into the same problems that those who actually know what they're talking about have discovered months... no, make that years ago... 

your functions dependence on iQuaternionFromEulerAngles() guarantees this...

but you keep on floating around in your world of make believe... thinking that you're the only one here who "understands the underlying maths around quaternions"...

@Chronicide...
ok... then, like i said above... do it whichever way you want...  i really could care less  which way you choose...

Quote
I was referring to the Transform object, not the iObjectChildTransform function.
i know you were referring to the transform object... read what i said again, s  l  o  w  l  y....

jeeeeez.. you two geniuses... it's is like the blind leading the blind...



--Mike

« Last Edit: March 15, 2013, 07:46:07 PM by Mike Hense »
« Reply #25 on: March 15, 2013, 07:51:08 PM »
I'm not going to fight with you Mike. When I say the two guys seem to be the only ones to understand Quaternions, I mean among the active members of the forum. Users like Rush3fan, AllanF, Shadmar and others of their ilk would also be at home with quaternions, but they are not currently active, and were not mentioned in passing. Nuff said, Let me leave you to do whatever you wish, I'm not taking the "fight" bait this time. 
« Reply #26 on: March 15, 2013, 08:01:07 PM »
iQuaternionTo and From Euler angles is buggy... i think that that was settled upon a looong time ago...

and where do you see me fighting with em... i already said twice above that they're free to do whatever they wish...  i'm merely trying to pointout to them that they could use your LocalToParent() function and avoid all the issues that dealing with quaternions raises in RAD...

btw..

what's the problem over at the foundry... nothing permanent i hope...

--Mike
« Last Edit: March 15, 2013, 08:06:31 PM by Mike Hense »
« Reply #27 on: March 15, 2013, 08:03:48 PM »
South African foreign exchange clamp down. Credit card should go through soon, then things should be up again.
« Reply #28 on: March 15, 2013, 08:34:04 PM »
your functions dependence on iQuaternionFromEulerAngles() guarantees this...

You've overlooked the fact that LocalToParent also depends on iQuaternionFromEulerAngles:
Code: [Select]
void LocalToParent(int PARENT, int OBJ, Vector3 rotation, Vector3 translation){
Vector3 parentLocation;
Quaternion parentOrientation;
Quaternion newOrientation;
Quaternion objectOrientation;
Vector3 forward, location, newLocation;
float x,y,z,ud,lr,fb;
x = rotation.x; y = rotation.y; z = rotation.z;
fb = translation.z; lr = translation.x; ud = translation.y;
iObjectLocation(PARENT, parentLocation);
iObjectOrientation(PARENT,parentOrientation);
iObjectOrientationSet(OBJ,parentOrientation);
iVectorRotate(forward,Vector3(lr,ud,fb),parentOrientation);
newLocation = parentLocation + forward;
iObjectLocationSet(OBJ,newLocation);

iQuaternionFromEulerAngles(newOrientation,x,y,z,"xyz"); // <=- <=- <=-

iQuaternionMultiply(newOrientation,newOrientation,parentOrientation);
iObjectOrientationSet(OBJ,newOrientation);
}
So, in what way has it been established that iQuaternion*EulerAngles is buggy? Personally, I suspect improper usage, as it's easy to confuse eulers with direction vectors.


i'm merely trying to pointout to them that they could use your LocalToParent() function and avoid all the issues that dealing with quaternions raises in RAD
If you got issues with quaternions, take it up with the quaternions.
« Last Edit: March 15, 2013, 08:43:51 PM by chronocide »
« Reply #29 on: March 15, 2013, 08:45:16 PM »
then use the method you like best... ok...

Quote
If you got issues with quaternions, take it up with the quaternions.
i got no issues with quaternions...  i can see that there is no need to use em directly here... 

LocalToParent() is a time tested function that is simple to use and provides exactly what needs to be done... why make it unnecessarily complicated...

i think that's what i told you waaaay above... you weren't  listening, were you...

--Mike

« Last Edit: March 15, 2013, 08:50:26 PM by Mike Hense »
Pages: 1 [2] 3