Java-Gaming.org Hi !
 Featured games (84) games approved by the League of Dukes Games in Showcase (575) Games in Android Showcase (154) games submitted by our members Games in WIP (622) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
Pages: [1]
 ignore  |  Print
 Trying to use Java3D quats with Jogl, but not quite working right  (Read 612 times) 0 Members and 1 Guest are viewing this topic.
Boltimus

Junior Newbie

 « Posted 2011-11-10 21:02:46 »

Hello everyone, rather than trying to recreate a quaternion library, I thought I would simply try to use what was in Java3D. I'm simply trying to get a sphere to rotate in all 3 axes: roll, pitch, and yaw... but am having difficulties.... The code is below. Here is what is happening ... I can pitch (rotate around x-axis) fine, but if I roll to the right or left by 90 degrees and then pitch, the ball appears to yaw.

 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41 `private void drawBall( GL2 gl )   {            /* now add the texture */      rdsTexture.enable( gl );      rdsTexture.bind( gl );            /* rotate for inclination and toolface */      AxisAngle4f pitchAA = new AxisAngle4f( 1.0f , 0 , 0 , ( float ) Math.toRadians( pitch + 90 ) );      Quat4f pitchQuat = new Quat4f( );      pitchQuat.set( pitchAA );            AxisAngle4f rollAA = new AxisAngle4f( 0 , 0 , 1.0f , ( float ) Math.toRadians( roll + 180 ) );      Quat4f rollQuat = new Quat4f( );      rollQuat.set( rollAA );            AxisAngle4f yawAA = new AxisAngle4f( 0 , 1.0f , 0 , ( float ) Math.toRadians( yaw ) );      Quat4f yawQuat = new Quat4f( );      yawQuat.set( yawAA );            result.mul( yawQuat , pitchQuat );      result.mul( rollQuat );            float[ ] m = new float[ 16 ];      gl.glGetFloatv( GL2.GL_MODELVIEW_MATRIX , m , 0 );      Transform3D transform = new Transform3D( m );       transform.setRotation( result );      Matrix4f m4 = new Matrix4f( );      transform.get( m4 );            float[ ] modelView = new float[ ] { m4.m00 , m4.m01 , m4.m02 , m4.m03 , m4.m10 , m4.m11 , m4.m12 , m4.m13 ,            m4.m20 , m4.m21 , m4.m22 , m4.m23 , m4.m30 , m4.m31 , m4.m32 , m4.m33 , };            /* the default view is straight and level */      gl.glMultMatrixf( modelView , 0 );            /* draw a sphere */      GLUquadric quadric = glu.gluNewQuadric( );      glu.gluQuadricTexture( quadric , true );      glu.gluSphere( quadric , 6.0f , 64 , 64 );   }`
gouessej
 « Reply #1 - Posted 2011-11-10 22:07:16 »

Hi

This is a problem of gimbal lock. Ardor3D has a workaround to use Euler's angles without gimbal lock, it is based on singularities on poles. Otherwise, you can use non eulerian transforms:
http://www.javafr.com/codes/JOGL-SYSTEME-ANTI-GIMBAL-LOCK-APPLIQUE-CUBE_53349.aspx

Pages: [1]
 ignore  |  Print

You cannot reply to this message, because it is very, very old.

 BurntPizza (26 views) 2015-04-23 03:42:11 theagentd (29 views) 2015-04-22 16:23:07 Riven (44 views) 2015-04-16 10:48:47 Duke0200 (52 views) 2015-04-16 01:59:01 Fairy Tailz (38 views) 2015-04-14 20:13:12 Riven (41 views) 2015-04-12 21:36:37 bus hotdog (58 views) 2015-04-10 02:39:32 CopyableCougar4 (61 views) 2015-04-10 00:51:04 BurntPizza (60 views) 2015-04-06 22:06:58 ags1 (62 views) 2015-04-02 10:58:48
 theagentd 30x BurntPizza 16x wessles 15x 65K 11x Rayvolution 11x alwex 11x kingroka123 11x KevinWorkman 9x kevglass 8x phu004 8x Roquen 7x chrislo27 7x Hanksha 7x Riven 7x Olo 7x ra4king 7x
 How to: JGO Wikiby Mac702015-02-17 20:56:162D Dynamic Lighting2015-01-01 20:25:42How do I start Java Game Development?by gouessej2014-12-27 19:41:21Resources for WIP gamesby kpars2014-12-18 10:26:14Understanding relations between setOrigin, setScale and setPosition in libGdx2014-10-09 22:35:00Definite guide to supporting multiple device resolutions on Android (2014)2014-10-02 22:36:02List of Learning Resources2014-08-16 10:40:00List of Learning Resources2014-08-05 19:33:27
 java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org