Java-Gaming.org Hi !
 Featured games (84) games approved by the League of Dukes Games in Showcase (595) Games in Android Showcase (168) games submitted by our members Games in WIP (646) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
 Show Posts Pages: [1]
1  Game Development / Newbie & Debugging Questions / Trying to use Java3D quats with Jogl, but not quite working right on: 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 );   }`
 2 Java Game APIs & Engines / JOGL Development / Re: Serializable Classes in jogl ? on: 2009-03-02 21:47:43 I did think about doing this, however I successfully recompiled the gluegen-rt.jar and jogl.jar with changes made to the actual TextureData class. Now the class can be serialized. I wrote Ken a private message to see if he thinks this change would be worth putting in the source code for jogl
 3 Java Game APIs & Engines / JOGL Development / Serializable Classes in jogl ? on: 2009-03-02 19:26:27 Before I start down the road of trying to implement the fix myself, is there anything that has been done with serialization in regards to JOGL? In particular I'm trying to serialize an object that contains the TextureData class and am having issues with that class. I was going to write a wrapper class around it, however there are some fields which are private in the class that I cannot get to in order to preserve their state...Thx,Boltimuss
 4 Java Game APIs & Engines / JOGL Development / Re: Using JOGL for GPGPU but it runs slow :( on: 2007-11-06 17:17:58 Thx for your input Chris!QuoteI'd make sure that you are using the texSubImage calls as they don't incur the same setup and initialization that the standard texImage calls doI don't use texSubImage, and will check it out.Quoteif you are reading that out to a Java buffer then feeding that back into the next function as a texture that will tank performance right there.Yeah I *WAS* doing that.. hehe I would read the result into a FloatBuffer, then reload it into a texture later on down the road. So what I gather from you, is simply keep the result loaded in some texture that I can reference later? I'll look into the FBO idea you mentioned.Thanks for your input. ~Bolt
5  Java Game APIs & Engines / JOGL Development / Using JOGL for GPGPU but it runs slow :( on: 2007-11-06 16:03:56
So I am using JOGL to try and run some code written in Java faster, however the code actually takes longer while using the GPU versus just using the CPU. I arranged my code so that alot of stuff occurs only once such that when I get new data all i have to do is update the textures and then render. Anyhow, without posting too much code here is one of the shaders I'm using.. If you want to see more code I can post the GLEventlistener that I'm using, but for now i'll start with this..

As you can guess, this function peforms a dotproduct on some data...

 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  42 `public void calcDotProd(int index1, int index2)  {     String[] shaderSource = {"uniform sampler2D instance1;" +                           "uniform sampler2D instance2;" +                           "uniform sampler2D numValues;" +                       "void main(void) { " +                       "   vec4 values1 = texture2D(instance1, gl_TexCoord[0].st);" +                       "   vec4 values2 = texture2D(instance2, gl_TexCoord[0].st);" +                       "   gl_FragColor[0] = dot(values1,values2);" +                       "}" };             // create the arraylist that holds all the needed data      ArrayList shaderVars = new ArrayList(4);      ArrayList data = new ArrayList(4);      SerialFloatBuffer tempB = new SerialFloatBuffer(this.internalData.get(index1).capacity());      float[] tempF = new float[1];      tempF[0] = internalData.get(index1).capacity();      tempB.setBuffer(FloatBuffer.wrap(tempF));      data.add(0,internalData.get(index1));      data.add(1,internalData.get(index2));      data.add(2,tempB);      shaderVars.add(0,"");      shaderVars.add(1,"instance1");      shaderVars.add(2,"instance2");      shaderVars.add(3,"numValues");            // create the core      if ((currentCore == null) || (currentCore.coreRenderer == null) || (currentCore.coreRenderer.getRenderer().firstTime))      {         currentCore = new Core(shaderSource, data, shaderVars, true);         dotProdResult.setBuffer( currentCore.execute().getBuffer());         currentCore.coreRenderer.getRenderer().firstTime = false;      }              else      {         currentCore.addData(data, true);         dotProdResult.setBuffer( currentCore.execute().getBuffer());      }              return;  }`
 Pages: [1]
 deepthought (47 views) 2015-06-30 15:39:44 deepthought (50 views) 2015-06-30 15:39:09 deepthought (62 views) 2015-06-30 15:36:52 Za\'Anzabar (35 views) 2015-06-29 05:44:54 TritonDreyja (46 views) 2015-06-24 17:10:40 CopyableCougar4 (46 views) 2015-06-23 00:34:45 BurntPizza (51 views) 2015-06-21 20:36:46 cookiecompiler (93 views) 2015-06-11 15:42:53 cookiecompiler (55 views) 2015-06-11 15:41:14 NegativeZero (79 views) 2015-06-11 09:49:18
 princec 30x wessles 22x BurntPizza 19x CopyableCougar4 19x opiop65 17x Riven 16x nsigma 15x ags1 14x EgonOlsen 14x theagentd 12x KaiHH 12x SauronWatchesYou 11x KevinWorkman 11x Archive 11x sunburn 11x NegativeZero 10x
 How Do I Expand My Game?by bashfrog2015-06-14 11:34:43List of Learning Resources2015-05-31 05:37:30Intersection Methodsby Roquen2015-05-29 08:19:33List of Learning Resources2015-05-05 10:20:32How 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:14
 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