Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (535)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Java Game APIs & Engines / OpenGL Development / Re: Issues drawing object from VBO on: 2011-06-29 04:20:55
Nevermind, all the OpenGl code was correct, it was a bug in my matrixStack implementation, specifically that it wasn't pushing copies to the stack, but pointers.  Thus, all of my transforms stacked on top of eachother until the model was unrecognizable.
2  Java Game APIs & Engines / OpenGL Development / Issues drawing object from VBO on: 2011-06-25 21:41:23
Hey guys, I'm currently trying to port this tutorial (http://www.arcsynthesis.org/gltut/Positioning/Tut06%20Fun%20with%20Matrices.html) to lwjgl, but I'm having some issues when it comes to actually drawing the object, and instead of looking like this:


It looks like this:


I think the issue might have something to do with the way the index data is being buffered/read, but I really have no idea.  Any help would be greatly appreciated.

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  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
179  
180  
181  
182  
183  
184  
185  
186  
187  
188  
189  
190  
191  
192  
193  
194  
195  
196  
197  
198  
199  
200  
201  
202  
203  
204  
205  
206  
207  
208  
209  
210  
211  
212  
213  
214  
215  
216  
217  
218  
219  
220  
221  
222  
223  
224  
225  
226  
227  
228  
229  
230  
231  
232  
233  
234  
235  
236  
237  
238  
239  
240  
241  
242  
243  
244  
245  
246  
247  
248  
249  
250  
251  
252  
253  
254  
255  
256  
257  
258  
259  
260  
261  
262  
263  
264  
265  
266  
267  
268  
269  
270  
271  
272  
273  
274  
275  
276  
277  
278  
279  
280  
281  
282  
283  
284  
285  
286  
287  
288  
289  
290  
291  
292  
293  
294  
295  
296  
297  
298  
299  
300  
301  
302  
303  
304  
305  
306  
307  
308  
309  
310  
311  
312  
313  
314  
315  
316  
317  
318  
319  
320  
321  
322  
323  
324  
325  
326  
327  
328  
329  
330  
331  
332  
333  
334  
335  
336  
337  
338  
339  
340  
341  
342  
343  
344  
345  
346  
347  
348  
349  
350  
351  
352  
353  
354  
355  
356  
357  
358  
359  
360  
361  
362  
363  
364  
365  
366  
367  
368  
369  
370  
371  
372  
373  
374  
375  
376  
377  
378  
379  
380  
381  
382  
383  
384  
385  
386  
387  
388  
389  
390  
391  
392  
393  
394  
395  
396  
397  
398  
399  
400  
401  
402  
403  
404  
405  
406  
407  
408  
409  
410  
411  
412  
413  
414  
415  
416  
417  
418  
419  
420  
421  
422  
423  
424  
425  
426  
427  
428  
429  
430  
431  
432  
433  
434  
435  
436  
437  
438  
439  
440  
441  
442  
443  
444  
445  
446  
447  
448  
449  
450  
451  
452  
453  
454  
455  
456  
457  
458  
459  
460  
461  
462  
463  
464  
465  
466  
467  
468  
469  
470  
471  
472  
473  
474  
475  
476  
477  
478  
479  
480  
481  
482  
483  
484  
485  
486  
487  
488  
489  
490  
491  
492  
493  
494  
495  
496  
import org.lwjgl.opengl.*;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL20.*;
import static org.lwjgl.opengl.ARBVertexBufferObject.*;
import static org.lwjgl.opengl.ARBVertexArrayObject.*;

import org.lwjgl.util.vector.*;
import org.lwjgl.BufferUtils;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;


public class DrawRobot {
   private Matrix4f cameraToClipMatrix;
   private int program, positionAttrib, colorAttrib, modelToCameraMatrixUnif, cameraToClipMatrixUnif, vertexBuffObj, indexBuffObj, vao;
   private float fFrustumScale;
   private final int numberOfVerticies = 24;
   IntBuffer indexDatBuff;
   
   private final float[] RED_COLOR = { 1.0f, 0.0f, 0.0f, 1.0f };
   private final float[] GREEN_COLOR = { 0.0f, 1.0f, 0.0f, 1.0f };
   private final float[] BLUE_COLOR = { 0.0f, 0.0f, 1.0f, 1.0f };
   private final float[] YELLOW_COLOR = { 1.0f, 1.0f, 0.0f, 1.0f };
   private final float[] CYAN_COLOR = { 0.0f, 1.0f, 1.0f, 1.0f };
   private final float[] MAGENTA_COLOR = { 1.0f, 0.0f, 1.0f, 1.0f };
   
   private final float[] vertexData = {
         //Front
        +1.0f, +1.0f, +1.0f,
         +1.0f, -1.0f, +1.0f,
         -1.0f, -1.0f, +1.0f,
         -1.0f, +1.0f, +1.0f,

         //Top
        +1.0f, +1.0f, +1.0f,
         -1.0f, +1.0f, +1.0f,
         -1.0f, +1.0f, -1.0f,
         +1.0f, +1.0f, -1.0f,

         //Left
        +1.0f, +1.0f, +1.0f,
         +1.0f, +1.0f, -1.0f,
         +1.0f, -1.0f, -1.0f,
         +1.0f, -1.0f, +1.0f,

         //Back
        +1.0f, +1.0f, -1.0f,
         -1.0f, +1.0f, -1.0f,
         -1.0f, -1.0f, -1.0f,
         +1.0f, -1.0f, -1.0f,

         //Bottom
        +1.0f, -1.0f, +1.0f,
         +1.0f, -1.0f, -1.0f,
         -1.0f, -1.0f, -1.0f,
         -1.0f, -1.0f, +1.0f,

         //Right
        -1.0f, +1.0f, +1.0f,
         -1.0f, -1.0f, +1.0f,
         -1.0f, -1.0f, -1.0f,
         -1.0f, +1.0f, -1.0f,


         GREEN_COLOR[0], GREEN_COLOR[1], GREEN_COLOR[2], GREEN_COLOR[3],
         GREEN_COLOR[0], GREEN_COLOR[1], GREEN_COLOR[2], GREEN_COLOR[3],
         GREEN_COLOR[0], GREEN_COLOR[1], GREEN_COLOR[2], GREEN_COLOR[3],
         GREEN_COLOR[0], GREEN_COLOR[1], GREEN_COLOR[2], GREEN_COLOR[3],
         
         BLUE_COLOR[0], BLUE_COLOR[1], BLUE_COLOR[2], BLUE_COLOR[3],
         BLUE_COLOR[0], BLUE_COLOR[1], BLUE_COLOR[2], BLUE_COLOR[3],
         BLUE_COLOR[0], BLUE_COLOR[1], BLUE_COLOR[2], BLUE_COLOR[3],
         BLUE_COLOR[0], BLUE_COLOR[1], BLUE_COLOR[2], BLUE_COLOR[3],
         
         RED_COLOR[0], RED_COLOR[1], RED_COLOR[2], RED_COLOR[3],
         RED_COLOR[0], RED_COLOR[1], RED_COLOR[2], RED_COLOR[3],
         RED_COLOR[0], RED_COLOR[1], RED_COLOR[2], RED_COLOR[3],
         RED_COLOR[0], RED_COLOR[1], RED_COLOR[2], RED_COLOR[3],
         
         YELLOW_COLOR[0], YELLOW_COLOR[1], YELLOW_COLOR[2], YELLOW_COLOR[3],
         YELLOW_COLOR[0], YELLOW_COLOR[1], YELLOW_COLOR[2], YELLOW_COLOR[3],
         YELLOW_COLOR[0], YELLOW_COLOR[1], YELLOW_COLOR[2], YELLOW_COLOR[3],
         YELLOW_COLOR[0], YELLOW_COLOR[1], YELLOW_COLOR[2], YELLOW_COLOR[3],
         
         CYAN_COLOR[0], CYAN_COLOR[1], CYAN_COLOR[2], CYAN_COLOR[3],
         CYAN_COLOR[0], CYAN_COLOR[1], CYAN_COLOR[2], CYAN_COLOR[3],
         CYAN_COLOR[0], CYAN_COLOR[1], CYAN_COLOR[2], CYAN_COLOR[3],
         CYAN_COLOR[0], CYAN_COLOR[1], CYAN_COLOR[2], CYAN_COLOR[3],
         
         MAGENTA_COLOR[0], MAGENTA_COLOR[1], MAGENTA_COLOR[2], MAGENTA_COLOR[3],
         MAGENTA_COLOR[0], MAGENTA_COLOR[1], MAGENTA_COLOR[2], MAGENTA_COLOR[3],
         MAGENTA_COLOR[0], MAGENTA_COLOR[1], MAGENTA_COLOR[2], MAGENTA_COLOR[3],
         MAGENTA_COLOR[0], MAGENTA_COLOR[1], MAGENTA_COLOR[2], MAGENTA_COLOR[3],
   };
   
   private final int indexData[] = {
         0, 1, 2,
         2, 3, 0,

         4, 5, 6,
         6, 7, 4,

         8, 9, 10,
         10, 11, 8,

         12, 13, 14,
         14, 15, 12,

         16, 17, 18,
         18, 19, 16,

         20, 21, 22,
         22, 23, 20,  
   };
   
   DrawRobot(int w, int h)   {
      // Set up opengl environment
     glViewport(0, 0, w, h);
      glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
      glClearDepth(1.0f);
     
      glEnable(GL_DEPTH_TEST);
      glDepthMask(true);
      glDepthFunc(GL_LEQUAL);
      glDepthRange(0.0f, 1.0f);
     
      glEnable(GL_CULL_FACE);
      glCullFace(GL_BACK);
      glFrontFace(GL_CW);
     
      programInit();
      VAOInit();
      robot();
   }
   
   private float calcFrustrumscale(float fDegFOV)   {
      final float degToRad = 3.14159f * 2.0f / 360.0f;
      float fRadFOV = fDegFOV * degToRad;
      return (float) Math.atan(fRadFOV);
   }
   
   private void programInit()   {
      ShaderLoader loader = new ShaderLoader("src/shaders/PosColorLocalTransform.vert", "src/shaders/ColorPassthrough.frag");
      if (!loader.getBuildStatus())   {
         System.out.println("Failed to load shaders.  Exiting.");
         Display.destroy();
         System.exit(0);
      }
      program = loader.getProgram();
      positionAttrib = glGetAttribLocation(program, "position");
      colorAttrib = glGetAttribLocation(program, "color");
     
      modelToCameraMatrixUnif = glGetUniformLocation(program, "modelToCameraMatrix");
      cameraToClipMatrixUnif = glGetUniformLocation(program, "cameraToClipMatrix");
     
      // Set up camera to clip space translation matrix
     float fzNear = 1.0f, fzFar = 100.0f;
      fFrustumScale = calcFrustrumscale(45.0f);
      cameraToClipMatrix = new Matrix4f();
      cameraToClipMatrix.m00 = fFrustumScale;
      cameraToClipMatrix.m11 = fFrustumScale;
      cameraToClipMatrix.m22 = (fzFar + fzNear) / (fzNear - fzFar);
      cameraToClipMatrix.m23 = -1.0f;
      cameraToClipMatrix.m32 = (2 * fzFar * fzNear) / (fzNear - fzFar);
     
      FloatBuffer buf = BufferUtils.createFloatBuffer(16);
      cameraToClipMatrix.store(buf);
      buf.flip();
     
     
      glUseProgram(program);
      glUniformMatrix4(cameraToClipMatrixUnif, false, buf);
      glUseProgram(0);
   }
   
   private void VAOInit()   {
      IntBuffer vertBuff = BufferUtils.createIntBuffer(1);
      glGenBuffersARB(vertBuff);
      vertexBuffObj = vertBuff.get(0);
     
      FloatBuffer vertexDatBuff = BufferUtils.createFloatBuffer(vertexData.length);
      vertexDatBuff.put(vertexData);
      vertexDatBuff.flip();
     
      glBindBufferARB(GL_ARRAY_BUFFER_ARB, vertexBuffObj);
      glBufferDataARB(GL_ARRAY_BUFFER_ARB, vertexDatBuff, GL_STATIC_DRAW_ARB);
      glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
     
      IntBuffer indexBuff = BufferUtils.createIntBuffer(1);
      glGenBuffersARB(indexBuff);
      indexBuffObj = indexBuff.get(0);
     
      indexDatBuff = BufferUtils.createIntBuffer(indexData.length);
      indexDatBuff.put(indexData);
      indexDatBuff.flip();
     
      glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, indexBuffObj);
      glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, indexDatBuff, GL_STATIC_DRAW_ARB);
      glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
     
      IntBuffer vaoBuff = BufferUtils.createIntBuffer(1);
      glGenVertexArrays(vaoBuff);
      vao = vaoBuff.get(0);
      glBindVertexArray(vao);
     
      int colorDataOffset = 4 * 3 * numberOfVerticies; // 4 bytes * 3 points * obvious
     glBindBufferARB(GL_ARRAY_BUFFER_ARB, vertexBuffObj);
      glEnableVertexAttribArray(positionAttrib);
      glEnableVertexAttribArray(colorAttrib);
      glVertexAttribPointer(positionAttrib, 3, GL_FLOAT, false, 0, 0);
      glVertexAttribPointer(colorAttrib, 4, GL_FLOAT, false, 0, colorDataOffset);
      glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, indexBuffObj);
     
      glBindVertexArray(0);
   }
   
   private float clamp(float fValue, float fMin, float fMax)   {
      if (fValue < fMin)
         return fMin;
      if (fValue > fMax)
         return fMax;
     
      return fValue;
   }
   
   void reshape (int w, int h)
   {
      cameraToClipMatrix.m00 = fFrustumScale * (h / (float)w);
      cameraToClipMatrix.m11 = fFrustumScale;

      glUseProgram(program);
      FloatBuffer buf = BufferUtils.createFloatBuffer(16);
      cameraToClipMatrix.store(buf);
      buf.flip();
      glUniformMatrix4(cameraToClipMatrixUnif, false, buf);
      glUseProgram(0);

      glViewport(0, 0, w, h);
   }
   
   // Defines block for robot
 
        private final float STANDARD_ANGLE_INCREMENT = 11.25f;
   private final float SMALL_ANGLE_INCREMENT = 9.0f;
   
   Vector3f      posBase;
   float         angBase;

   Vector3f      posBaseLeft, posBaseRight;
   float         scaleBaseZ;

   float         angUpperArm;
   float         sizeUpperArm;

   Vector3f      posLowerArm;
   float         angLowerArm;
   float         lenLowerArm;
   float         widthLowerArm;

   Vector3f      posWrist;
   float         angWristRoll;
   float         angWristPitch;
   float         lenWrist;
   float         widthWrist;

   Vector3f      posLeftFinger, posRightFinger;
   float         angFingerOpen;
   float         lenFinger;
   float         widthFinger;
   float         angLowerFinger;
   // End Defines
 
   private void robot()   {
      posBase = new Vector3f(3.0f, -5.0f, -40.0f);
      angBase = -45.0f;
      posBaseLeft = new Vector3f(2.0f, 0.0f, 0.0f);
      posBaseRight = new Vector3f(-2.0f, 0.0f, 0.0f);
      scaleBaseZ = 3.0f;
      angUpperArm = -33.75f;
      sizeUpperArm = 9.0f;
      posLowerArm = new Vector3f(0.0f, 0.0f, 8.0f);
      angLowerArm = 146.25f;
      lenLowerArm = 5.0f;
      widthLowerArm = 1.5f;
      posWrist = new Vector3f(0.0f, 0.0f, 5.0f);
      angWristRoll = 0.0f;
      angWristPitch = 67.5f;
      lenWrist = 2.0f;
      widthWrist = 2.0f;
      posLeftFinger = new Vector3f(1.0f, 0.0f, 1.0f);
      posRightFinger = new Vector3f(-1.0f, 0.0f, 1.0f);
      angFingerOpen = 180.0f;
      lenFinger = 2.0f;
      widthFinger = 0.5f;
      angLowerFinger = 45.0f;
   }
   
   public void Draw()
   {
      MatrixStack modelToCameraStack = new MatrixStack();

      glUseProgram(program);
      glBindVertexArray(vao);

      modelToCameraStack.translate(posBase);
      modelToCameraStack.rotateY(angBase);

      //Draw left base.
     {
         modelToCameraStack.push();
         modelToCameraStack.translate(posBaseLeft);
         modelToCameraStack.scale(new Vector3f(1.0f, 1.0f, scaleBaseZ));
         glUniformMatrix4(modelToCameraMatrixUnif, false, modelToCameraStack.top());
         glDrawElements(GL_TRIANGLES, indexData.length, GL_UNSIGNED_INT, 0);
         modelToCameraStack.pop();
      }

      //Draw right base.
     {
         modelToCameraStack.push();
         modelToCameraStack.translate(posBaseRight);
         modelToCameraStack.scale(new Vector3f(1.0f, 1.0f, scaleBaseZ));
         glUniformMatrix4(modelToCameraMatrixUnif, false, modelToCameraStack.top());
         glDrawElements(GL_TRIANGLES, indexData.length, GL_UNSIGNED_INT, 0);
         modelToCameraStack.pop();
      }

      //Draw main arm.
     DrawUpperArm(modelToCameraStack);

      glBindVertexArray(0);
      glUseProgram(0);
   }
   
   void DrawFingers(MatrixStack modelToCameraStack)
   {
      //Draw left finger
     modelToCameraStack.push();
      modelToCameraStack.translate(posLeftFinger);
      modelToCameraStack.rotateY(angFingerOpen);

      modelToCameraStack.push();
      modelToCameraStack.translate(new Vector3f(0.0f, 0.0f, lenFinger / 2.0f));
      modelToCameraStack.scale(new Vector3f(widthFinger / 2.0f, widthFinger/ 2.0f, lenFinger / 2.0f));
      glUniformMatrix4(modelToCameraMatrixUnif, false, modelToCameraStack.top());
      glDrawElements(GL_TRIANGLES, indexData.length, GL_UNSIGNED_INT, 0);
      modelToCameraStack.pop();

      {
         //Draw left lower finger
        modelToCameraStack.push();
         modelToCameraStack.translate(new Vector3f(0.0f, 0.0f, lenFinger));
         modelToCameraStack.rotateY(-angLowerFinger);

         modelToCameraStack.push();
         modelToCameraStack.translate(new Vector3f(0.0f, 0.0f, lenFinger / 2.0f));
         modelToCameraStack.scale(new Vector3f(widthFinger / 2.0f, widthFinger/ 2.0f, lenFinger / 2.0f));
         glUniformMatrix4(modelToCameraMatrixUnif, false, modelToCameraStack.top());
         glDrawElements(GL_TRIANGLES, indexData.length, GL_UNSIGNED_INT, 0);
         modelToCameraStack.pop();

         modelToCameraStack.pop();
      }

      modelToCameraStack.pop();

      //Draw right finger
     modelToCameraStack.push();
      modelToCameraStack.translate(posRightFinger);
      modelToCameraStack.rotateY(-angFingerOpen);

      modelToCameraStack.push();
      modelToCameraStack.translate(new Vector3f(0.0f, 0.0f, lenFinger / 2.0f));
      modelToCameraStack.scale(new Vector3f(widthFinger / 2.0f, widthFinger/ 2.0f, lenFinger / 2.0f));
      glUniformMatrix4(modelToCameraMatrixUnif, false, modelToCameraStack.top());
      glDrawElements(GL_TRIANGLES, indexData.length, GL11.GL_UNSIGNED_INT, 0);
      modelToCameraStack.pop();

      {
         //Draw right lower finger
        modelToCameraStack.push();
         modelToCameraStack.translate(new Vector3f(0.0f, 0.0f, lenFinger));
         modelToCameraStack.rotateY(angLowerFinger);

         modelToCameraStack.push();
         modelToCameraStack.translate(new Vector3f(0.0f, 0.0f, lenFinger / 2.0f));
         modelToCameraStack.scale(new Vector3f(widthFinger / 2.0f, widthFinger/ 2.0f, lenFinger / 2.0f));
         glUniformMatrix4(modelToCameraMatrixUnif, false, modelToCameraStack.top());
         glDrawElements(GL_TRIANGLES, indexData.length, GL_UNSIGNED_INT, 0);
         modelToCameraStack.pop();

         modelToCameraStack.pop();
      }

      modelToCameraStack.pop();
   }

   void DrawWrist(MatrixStack modelToCameraStack)
   {
      modelToCameraStack.push();
      modelToCameraStack.translate(posWrist);
      modelToCameraStack.rotateZ(angWristRoll);
      modelToCameraStack.rotateX(angWristPitch);

      modelToCameraStack.push();
      modelToCameraStack.scale(new Vector3f(widthWrist / 2.0f, widthWrist/ 2.0f, lenWrist / 2.0f));
      glUniformMatrix4(modelToCameraMatrixUnif, false, modelToCameraStack.top());
      glDrawElements(GL_TRIANGLES, indexData.length, GL_UNSIGNED_INT, 0);
      modelToCameraStack.pop();

      DrawFingers(modelToCameraStack);

      modelToCameraStack.pop();
   }

   void DrawLowerArm(MatrixStack modelToCameraStack)
   {
      modelToCameraStack.push();
      modelToCameraStack.translate(posLowerArm);
      modelToCameraStack.rotateX(angLowerArm);

      modelToCameraStack.push();
      modelToCameraStack.translate(new Vector3f(0.0f, 0.0f, lenLowerArm / 2.0f));
      modelToCameraStack.scale(new Vector3f(widthLowerArm / 2.0f, widthLowerArm / 2.0f, lenLowerArm / 2.0f));
      glUniformMatrix4(modelToCameraMatrixUnif, false, modelToCameraStack.top());
      glDrawElements(GL_TRIANGLES, indexData.length, GL_UNSIGNED_INT, 0);
      modelToCameraStack.pop();

      DrawWrist(modelToCameraStack);

      modelToCameraStack.pop();
   }

   void DrawUpperArm(MatrixStack modelToCameraStack)
   {
      modelToCameraStack.push();
      modelToCameraStack.rotateX(angUpperArm);

      {
         modelToCameraStack.push();
         modelToCameraStack.translate(new Vector3f(0.0f, 0.0f, (sizeUpperArm / 2.0f) - 1.0f));
         modelToCameraStack.scale(new Vector3f(1.0f, 1.0f, sizeUpperArm / 2.0f));
         glUniformMatrix4(modelToCameraMatrixUnif, false, modelToCameraStack.top());
         glDrawElements(GL_TRIANGLES, indexData.length, GL_UNSIGNED_INT, 0);
         modelToCameraStack.pop();
      }

      DrawLowerArm(modelToCameraStack);

      modelToCameraStack.pop();
   }
   
   void AdjBase(boolean bIncrement)
   {
      angBase += bIncrement ? STANDARD_ANGLE_INCREMENT : -STANDARD_ANGLE_INCREMENT;
      angBase = angBase % 360.0f;
   }

   void AdjUpperArm(boolean bIncrement)
   {
      angUpperArm += bIncrement ? STANDARD_ANGLE_INCREMENT : -STANDARD_ANGLE_INCREMENT;
      angUpperArm = clamp(angUpperArm, -90.0f, 0.0f);
   }

   void AdjLowerArm(boolean bIncrement)
   {
      angLowerArm += bIncrement ? STANDARD_ANGLE_INCREMENT : -STANDARD_ANGLE_INCREMENT;
      angLowerArm = clamp(angLowerArm, 0.0f, 146.25f);
   }

   void AdjWristPitch(boolean bIncrement)
   {
      angWristPitch += bIncrement ? STANDARD_ANGLE_INCREMENT : -STANDARD_ANGLE_INCREMENT;
      angWristPitch = clamp(angWristPitch, 0.0f, 90.0f);
   }

   void AdjWristRoll(boolean bIncrement)
   {
      angWristRoll += bIncrement ? STANDARD_ANGLE_INCREMENT : -STANDARD_ANGLE_INCREMENT;
      angWristRoll = angWristRoll % 360.0f;
   }

   void AdjFingerOpen(boolean bIncrement)
   {
      angFingerOpen += bIncrement ? SMALL_ANGLE_INCREMENT : -SMALL_ANGLE_INCREMENT;
      angFingerOpen = clamp(angFingerOpen, 9.0f, 180.0f);
   }
   
   void display()   {
      glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
      glClearDepth(1.0f);
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      Draw();
      Display.update();
   }
}
Pages: [1]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Dwinin (6 views)
2014-07-29 10:59:34

E.R. Fleming (20 views)
2014-07-29 03:07:13

E.R. Fleming (8 views)
2014-07-29 03:06:25

pw (39 views)
2014-07-24 01:59:36

Riven (39 views)
2014-07-23 21:16:32

Riven (26 views)
2014-07-23 21:07:15

Riven (28 views)
2014-07-23 20:56:16

ctomni231 (59 views)
2014-07-18 06:55:21

Zero Volt (50 views)
2014-07-17 23:47:54

danieldean (42 views)
2014-07-17 23:41:23
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!