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)

« on: March 15, 2013, 08:28:46 AM »
Hi.

I Need Write a Script that rotate skinmesh about Y-axis. who can write this script and Completely explain it?

I know write some scripts in 3drad but I don't Know how work iObjectOrientation Function.

Thanks
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0

possible way, if we found will make a way.
« Reply #1 on: March 15, 2013, 09:00:07 AM »
.
« Last Edit: March 15, 2013, 10:23:40 PM by Devashish »
« Reply #2 on: March 15, 2013, 09:56:49 AM »
thank, But don't work this script.

Code: [Select]
void Main()
{
  float fAngel = 10;

  Quaternion ObjectRotation;
  iObjectOrientation(OBJ_0,ObjectRotation);
  ObjectRotation.y += fAngel;
  iObjectOrientationSet(OBJ_0,ObjectRotation);
  iQuaternionToEulerAngles(ObjectRotation,0,10,0);
}
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0

possible way, if we found will make a way.
« Reply #3 on: March 15, 2013, 11:14:08 AM »
I'm not entirely sure what you mean, Behda. You're Google Translate English is not very clear.

Quaternation ori;
void main()
{ iObjectOrientation(OBJ_0, ori);
ori.y= ori.y + any angle
iObjectOrientationSet(OBJ_0, ori);
}

I would not recommend using something like this. A Quaternion consists of four elements and is very confusing. I doubt this will work.
« Last Edit: March 15, 2013, 12:04:18 PM by RobertooMolvadoo »
Rocket Rumble, a 3D Rad puzzle game:
http://www.3drad.com/forum/index.php?topic=9896.0
« Reply #4 on: March 15, 2013, 11:34:51 AM »
That doesn't work, either, Robertoo. Quaternions aren't that obvious. XYZ is a direction vector of the axis of rotation, and w is the rotation around that axis. The 4 values are normalized, so about the only practical use in directly manipulating a quat's properties is q.w*=-1, which inverts a quat, which is useful to 'subtract' one rotation from another.

Here's 2 ways
Code: [Select]
Quaternion qInc, q;
void Main() {
if(iInitializing()) iQuaternionFromEulerAngles(qInc,0,10,0,"xyz");
else {
iObjectOrientation(OBJ_0,q);
iQuaternionMultiply(q,q,qInc); // Quaternions are weird. To add rotations, multiply quaternions.
iObjectOrientationSet(OBJ_0,q);
}
}

Code: [Select]
float f= 0;
Quaternion q;
void Main() {
iQuaternionFromEulerAngles(q,0,f,0,"xyz");
iObjectOrientationSet(OBJ_0,q);
f+= 10; if(f>=360) f-= 360;
}
« Reply #5 on: March 15, 2013, 12:05:11 PM »
That doesn't work, either, Robertoo. Quaternions aren't that obvious. XYZ is a direction vector of the axis of rotation, and w is the rotation around that axis.

Not sure what you're talking about. What doesn't work either?
Rocket Rumble, a 3D Rad puzzle game:
http://www.3drad.com/forum/index.php?topic=9896.0
« Reply #6 on: March 15, 2013, 12:11:07 PM »
Thanks chronocide. :D

good job  ;D
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0

possible way, if we found will make a way.
« Reply #7 on: March 15, 2013, 12:32:55 PM »
..
« Last Edit: November 15, 2013, 05:07:03 AM by Leonopteryx »
Using 3D Rad 7.22
« Reply #8 on: March 15, 2013, 01:14:35 PM »
Not sure what you're talking about. What doesn't work either?
In both cases, quat.y+= n, because quat.y isn't an angle, it's a direction component, which needs to be normalized with quat's x z & w.
« Reply #9 on: March 15, 2013, 02:54:54 PM »
Why struggle with Quaternions when you can use Rotataternions?

http://www.3drad.com/forum/index.php?topic=10222.msg90106#msg90106
« Reply #10 on: March 15, 2013, 04:52:37 PM »
..
« Last Edit: November 15, 2013, 05:07:13 AM by Leonopteryx »
Using 3D Rad 7.22
« Reply #11 on: March 15, 2013, 05:05:26 PM »
The functions give local and global rotations. The difference is in the order of the parameters for the Quat multiplication. But I guess you missed the (n,n,p) (p,p,n) point, not that it matters.
Global and Local rotations are vastly different.

Quat multiplication is the ONLY way to do it, so code can look remarkably similar. Not that that matters either. The functions encapsulate this to make rotation for "local and global" easy for everyone, without having to worry about Quaternions at all.

What's a 'no comment' comment mean anyway?
« Last Edit: March 15, 2013, 05:24:30 PM by XingBat »
« Reply #12 on: March 15, 2013, 05:32:56 PM »
..
« Last Edit: November 15, 2013, 05:07:25 AM by Leonopteryx »
Using 3D Rad 7.22
« Reply #13 on: March 15, 2013, 06:17:40 PM »
be easy on him Leon... he's obviously got a lot to learn...

all that hype... very little substance... to be honest, i didn't expect too much...
i didn't even take the time to look at it based on what i read and who wrote it...

Quote
Quat multiplication is the ONLY way to do it
he obviously isn't familiar with jestermon's LocalToParent() function either...

--Mike
« Last Edit: March 15, 2013, 06:21:44 PM by Mike Hense »
« Reply #14 on: March 15, 2013, 06:26:26 PM »
The functions give local and global rotations. The difference is in the order of the parameters for the Quat multiplication. But I guess you missed the (n,n,p) (p,p,n) point, not that it matters.
Global and Local rotations are vastly different.
Right - I think - quat multiplication is non-culmulative. q1*q2 does not equal q2*q1. They produce different results.
Pages: [1] 2 3