Show Posts
|
|
Pages: [1]
|
|
5
|
Java Game APIs & Engines / JOGL Development / Re: [UNSOLVED] 3D Models and Animation
|
on: 2008-02-13 21:23:57
|
As for not being able to find the source or API, you must not have looked hard enough. I found the source and many easy to understand tutorials with links on the home page (although I think to get the source you have to use subversion (but they have an easy tutorial on how to get that too)). True, i haven't done extensive research on JME, but i don't want to use JME, so that makes sense XD But i have done some research on using JME through LWJGL, which talkes back to JOGL, but that already sounded super inefficient. I have read about "Duke Bean'em", and i have the Collada model loader that was used there, too bad it doesn't support animations. But i'm going to write my own Collada model loader with animations. When i have succesfully written the model loader, i'll put the source on my website. Anyway, has anybody every heard about: JCollada? http://www.youtube.com/watch?v=yvKxQq__Wi8 <-- Youtube vid on JCollada http://www.xquaker.com/projects_jc.html <-- I cannot click the download, lol It seems to me that that is one nice library to have. But for some reason the guy put it offline.
|
|
|
|
|
7
|
Java Game APIs & Engines / JOGL Development / Re: Zoom In / Zoom Out
|
on: 2008-02-13 15:03:45
|
baldurk 02-09-2003, 02:43 AM there is no way to really 'zoom' in OpenGL. The camera stays at 0, 0, 0 looking along the z axis. Everything else moves around it. The best way to zoom out object a is to translate it further away, eg.
glTranslatef(APosX, APosY, APosZ); glTranslatef(0.0f, 0.0f, -Zoom); DrawObjectA();
then as zoom increases, the object gets further away
watch out though, anything drawn after that will be 'zoomed' as well. Yau 02-09-2003, 04:00 AM Actually u can zoom with OpenGL by altering ur viewing matrix using the gluPerspective(..) function.
The actuall function parameter is as follows:
void gluPerspective( float angle, // the viewable anlge infront of the camera/eye float aspect, // typically width/height of window or screen float near, // min distance from camera that is renderable float far, // max distance from camera that is renderable )
To do zooming the first parameter is the one u wnat to alter. The smaller the angle u specify the greater the zoom. Try experimenting and u'll see this in action.
The advantage of using this technique over the one above is that u won't get into a situation where u zoom past an object because u aren't actually repositioning any objects.
The disadvantage is that everytime u want to zoom or animate zooming and zooming out u have to recreate ur perspective viewing transformation. Well this isn't too bad. I found this on an other forum
|
|
|
|
|
9
|
Java Game APIs & Engines / JOGL Development / Re: Zoom In / Zoom Out
|
on: 2008-02-13 13:18:25
|
you can use glTranslate to zoom in and zoom out.  As you can see on this image, you see the x,y,z-axis using glTranslatef(0.0f, 0.0f, positionZ); you can "move" an object on the z-axis, thus making the object appear nearer or farther away. If you need more help on this, just tell me 
|
|
|
|
|
10
|
Java Game APIs & Engines / JOGL Development / Re: 3D Models and Animation
|
on: 2008-02-13 09:18:05
|
Well, i can't tell you about animators, but i just finished building my own JOGL loader for Obj and Blk file types today, that loads them into a JOGL scene in 3D where they can be animated. I've yet to actually translate animation data in terms of say morphing or camera data though. Dunno if that's the kind of thing you mean.
I can build my own OBJ Loader too, the actual problem is the animation. For example, with Collada, you can assign a skeleton to your model, and make an animated Collada model, and load it to JOGL and you have an animated 3d model in JOGL. Why not using JMonkey ? There is all you need to load animated model and it can work over jogl. I have already tried to use JMonkey, but i didn't understand how to use it. I couldn't find the source code or an API Description. Also they say that JMonkey doesn't work with JOGL, yet.
|
|
|
|
|
11
|
Java Game APIs & Engines / JOGL Development / Re: 3D Models and Animation
|
on: 2008-02-12 22:05:24
|
|
I am completely lost, not a little bit lost, no, i'm now completely lost.
I have done today research on COLLADA, MD5, MD3, MD2, MS3D, 3DS, OBJ, CAL3D, almost every 3d file format around.
I'm super confused. I cannot find a JOGL Loader for any _animated_ models.
I do not know what to do =(
What should i do, if i want to learn about 3d animated models in JOGL?
|
|
|
|
|
12
|
Java Game APIs & Engines / JOGL Development / [UNSOLVED] 3D Models and Animation
|
on: 2008-02-12 10:59:37
|
|
I have done some research about 3d models and how to animate them.
I have found out that Wavefront obj is rather easy to read and render and 3DS is a lot harder.
Making the models is not a huge problem, neither is rendering them.
But can anybody give me hints on how to animate Wavefront obj models? I don't completely understand how to use Wavefront obj, to make animated models. It seems that using Wavefront OBJ is the best way to create animated models in JOGL.
Any tips/suggestions are welcome.
Greetings, Cyrus
|
|
|
|
|
13
|
Java Game APIs & Engines / JOGL Development / [SOLVED] How to bind display() with the KeyBehaviour class?
|
on: 2008-02-10 23:28:45
|
|
Sorry, it's very late, sometimes i make simple mistakes.
You can ofc always access variables/methods from other files by calling filename.variable
somehow it totally slipped my mind.
------------------------------------------ I have two seperate classes for handeling GLEvents and KeyEvents.
I want to bind the classes so, that if i press "W" that,the boolean statement becomes true. now, nothing happens.
What should i do? Any tips are welcome!
(yeah ok, i'm new)
Greetings, Cyrus
///GfxFactory.java (GLEventListener) import javax.media.opengl.*; import javax.media.opengl.glu.*; import java.awt.event.*;
public class GfxFactory extends KeyBehaviour implements GLEventListener { private final GLU glu = new GLU(); ObjectLibrary ol = new ObjectLibrary(); KeyBehaviour kb = new KeyBehaviour(); float rot; public void display(GLAutoDrawable gld) { final GL gl = gld.getGL(); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); gl.glMatrixMode(GL.GL_MODELVIEW); gl.glLoadIdentity(); ol.camera(gl, kb.posx, kb.posy, kb.posz, kb.rotx, kb.roty, kb.rotz); gl.glTranslatef(0.0f, 0.0f, -5.0f); gl.glRotatef(rot, 1.0f, 0.0f, 0.0f); ol.cube(gl); rot += 4.0f; System.out.println(kb.FORWARD); } public void init(GLAutoDrawable gld) { final GL gl = gld.getGL(); gl.glShadeModel(GL.GL_SMOOTH); gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); gl.glClearDepth(1.0f); gl.glEnable(GL.GL_DEPTH_TEST); gl.glDepthFunc(GL.GL_LEQUAL); gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); } public void reshape(GLAutoDrawable gld, int x, int y, int width, int height) { final GL gl = gld.getGL(); if(height < 1) height = 1; float ratio = (float)width / (float)height; gl.glMatrixMode(GL.GL_PROJECTION); gl.glLoadIdentity(); glu.gluPerspective(50.0f, ratio, 1.0f, 1000.0f); gl.glMatrixMode(GL.GL_MODELVIEW); gl.glLoadIdentity(); } public void displayChanged(GLAutoDrawable gld, boolean modeChanged, boolean deviceChanged) { } }
///KeyBehaviour.java import java.awt.event.*; import java.awt.*; import javax.media.opengl.*;
public class KeyBehaviour implements KeyListener, MouseListener, MouseMotionListener { /***************************** GAME VARIABLES *****************************/ final float SPEED = 2.0f; final float ANGLESPEED = 1.0f; float posx, posy, posz; float rotx, roty, rotz; float angle; boolean FORWARD = false; boolean BACKWARD = false; boolean STRAFELEFT = false; boolean STRAFERIGHT = false; /***************************** INTERFACE METHODS *****************************/ GLCanvas glc; public void getGLCanvas(GLCanvas glc) { this.glc = glc; } /***************************** KEY PROCESSING *****************************/ /***************************** KEYBOARD EVENTS *****************************/ public void keyPressed(KeyEvent e) { switch(e.getKeyCode()) { case KeyEvent.VK_W: FORWARD = true; break; case KeyEvent.VK_S: BACKWARD = true; break; case KeyEvent.VK_A: STRAFELEFT = true; break; case KeyEvent.VK_D: STRAFERIGHT = true; break; case KeyEvent.VK_ESCAPE: case KeyEvent.VK_F10: System.exit(0); break; } glc.repaint(); } public void keyReleased(KeyEvent e) { switch(e.getKeyCode()) { case KeyEvent.VK_W: FORWARD = false; break; case KeyEvent.VK_S: BACKWARD = false; break; case KeyEvent.VK_A: STRAFELEFT = false; break; case KeyEvent.VK_D: STRAFERIGHT = false; break; } glc.repaint(); } public void keyTyped(KeyEvent e) { } /***************************** MOUSE EVENTS *****************************/ public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } public void mouseClicked(MouseEvent e) { } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } /***************************** MOUSE MOTION EVENTS *****************************/ public void mouseMoved(MouseEvent e) { } public void mouseDragged(MouseEvent e) { } }
|
|
|
|
|
15
|
Java Game APIs & Engines / JOGL Development / How to use gluLookAt as a camera
|
on: 2008-02-06 23:48:51
|
|
Hello everybody!
I've been programming some stuff in JOGL. But now i have stumbled upon a problem.
I want to build a camera, to view a couple of openGL rendered objects.
Well what does the camera do now?
If you push 'k' or 'l', the camera will rotate left or right. But if my angle hits -pi, or +pi, the camera is rotated!
Now i have read something about multiplying the view matrix with the matrix of the camera. This leaves me extremely baffeled. I cannot find a good tutorial about it, and i don't know how to invert it.
Could somebody please tell me how this works? I quite understand maths, but this confuses me a lot.
I have also added my source code (it might be messy), but maybe you can see what i have done wrong.
///////////////////////SOURCE CODE//////////////////////////////////////////////// import javax.media.opengl.*; import javax.media.opengl.glu.*; import com.sun.opengl.util.*; import javax.swing.*; import java.awt.event.*; import java.awt.*;
public class FirstPersonControl implements GLEventListener, KeyListener, MouseMotionListener { private static final GLU glu = new GLU(); //MOVEMENT public float posx = 0.0f, posz = 0.0f, angx = 0.0f, angz = 0.0f, angle = 0.0f; public float WALK = 0.01f, RUN = 0.03f, SPEED; public float ANGLE = 0.0f; public boolean UP = false, DOWN = false, LEFT = false, RIGHT = false, SHIFT = false; public boolean ROTL = false, ROTR = false; //END OF MOVEMENT GLCanvas glc; public void display(GLAutoDrawable gld) { final GL gl = gld.getGL(); //CONTROLS if(SHIFT == true) { SPEED = RUN; } else { SPEED = WALK; } if(UP == true) { posx += SPEED * (float)Math.sin(angle); posz += SPEED * (float)Math.cos(angle); } if(DOWN == true) { posx -= SPEED * (float)Math.sin(angle); posz -= SPEED * (float)Math.cos(angle); } if(LEFT == true) { //posx += SPEED; } if(RIGHT == true) { //posx -= SPEED; } if(ROTL == true) { angle += 0.005f; } if(ROTR == true) { angle -= 0.005f; } //END OF CONTROLS //ANGLE CONTROLS angx = 5.0f * (float)Math.sin(angle); angz = 5.0f * (float)Math.cos(angle); //END OF ANGLE CONTROLS gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); gl.glMatrixMode(GL.GL_MODELVIEW); gl.glLoadIdentity(); glu.gluLookAt(posx, 0, posz, posx + angx, 0, posz + angz + 5.0f, 0, 1, 0); gl.glPushMatrix(); gl.glTranslatef(0.0f, 0.0f, 5.0f); gl.glBegin(GL.GL_TRIANGLES); // Front gl.glColor3f(0.0f, 1.0f, 1.0f); gl.glVertex3f(0.0f, 1.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); gl.glVertex3f(1.0f, -1.0f, 1.0f); // Right Side Facing Front gl.glVertex3f(0.0f, 1.0f, 0.0f); gl.glVertex3f(1.0f, -1.0f, 1.0f); gl.glVertex3f(0.0f, -1.0f, -1.0f); // Left Side Facing Front gl.glVertex3f(0.0f, 1.0f, 0.0f); gl.glVertex3f(0.0f, -1.0f, -1.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); // Bottom gl.glVertex3f(-1.0f, -1.0f, 1.0f); gl.glVertex3f(1.0f, -1.0f, 1.0f); gl.glVertex3f(0.0f, -1.0f, -1.0f); gl.glEnd(); gl.glPopMatrix(); gl.glPushMatrix(); gl.glTranslatef(0.0f, 0.0f, -5.0f); gl.glBegin(GL.GL_TRIANGLES); // Front gl.glColor3f(0.0f, 0.0f, 1.0f); gl.glVertex3f(0.0f, 1.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); gl.glVertex3f(1.0f, -1.0f, 1.0f); // Right Side Facing Front gl.glVertex3f(0.0f, 1.0f, 0.0f); gl.glVertex3f(1.0f, -1.0f, 1.0f); gl.glVertex3f(0.0f, -1.0f, -1.0f); // Left Side Facing Front gl.glVertex3f(0.0f, 1.0f, 0.0f); gl.glVertex3f(0.0f, -1.0f, -1.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); // Bottom gl.glColor3f(0.5f, 0.0f, 0.5f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); gl.glVertex3f(1.0f, -1.0f, 1.0f); gl.glVertex3f(0.0f, -1.0f, -1.0f); gl.glEnd(); gl.glPopMatrix(); gl.glPushMatrix(); gl.glTranslatef(5.0f, 0.0f, 0.0f); gl.glBegin(GL.GL_TRIANGLES); // Front gl.glColor3f(0.0f, 1.0f, 0.0f); gl.glVertex3f(0.0f, 1.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); gl.glVertex3f(1.0f, -1.0f, 1.0f); // Right Side Facing Front gl.glVertex3f(0.0f, 1.0f, 0.0f); gl.glVertex3f(1.0f, -1.0f, 1.0f); gl.glVertex3f(0.0f, -1.0f, -1.0f); // Left Side Facing Front gl.glVertex3f(0.0f, 1.0f, 0.0f); gl.glVertex3f(0.0f, -1.0f, -1.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); // Bottom gl.glColor3f(0.5f, 0.0f, 0.5f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); gl.glVertex3f(1.0f, -1.0f, 1.0f); gl.glVertex3f(0.0f, -1.0f, -1.0f); gl.glEnd(); gl.glPopMatrix(); gl.glPushMatrix(); gl.glTranslatef(-5.0f, 0.0f, 0.0f); gl.glBegin(GL.GL_TRIANGLES); // Front gl.glColor3f(1.0f, 1.0f, 1.0f); gl.glVertex3f(0.0f, 1.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); gl.glVertex3f(1.0f, -1.0f, 1.0f); // Right Side Facing Front gl.glVertex3f(0.0f, 1.0f, 0.0f); gl.glVertex3f(1.0f, -1.0f, 1.0f); gl.glVertex3f(0.0f, -1.0f, -1.0f); // Left Side Facing Front gl.glVertex3f(0.0f, 1.0f, 0.0f); gl.glVertex3f(0.0f, -1.0f, -1.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); // Bottom gl.glColor3f(0.5f, 0.0f, 0.5f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); gl.glVertex3f(1.0f, -1.0f, 1.0f); gl.glVertex3f(0.0f, -1.0f, -1.0f); gl.glEnd(); gl.glPopMatrix(); } public void init(GLAutoDrawable gld) { final GL gl = gld.getGL(); gl.glShadeModel(GL.GL_SMOOTH); gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); gl.glClearDepth(1.0f); gl.glEnable(GL.GL_DEPTH_TEST); gl.glDepthFunc(GL.GL_LEQUAL); gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); } public void reshape(GLAutoDrawable gld, int x, int y, int width, int height) { final GL gl = gld.getGL(); if(height < 1) { height = 1; } final float ratio = (float)width / (float)height; gl.glMatrixMode(GL.GL_PROJECTION); gl.glLoadIdentity(); glu.gluPerspective(50.0f, ratio, 1.0f, 1000.0f); gl.glMatrixMode(GL.GL_MODELVIEW); gl.glLoadIdentity(); } public void displayChanged(GLAutoDrawable gld, boolean modeChanged, boolean deviceChanged) {} public void keyPressed(KeyEvent e) { switch(e.getKeyCode()) { case KeyEvent.VK_W: UP = true; break; case KeyEvent.VK_S: DOWN = true; break; case KeyEvent.VK_A: LEFT = true; break; case KeyEvent.VK_D: RIGHT = true; break; case KeyEvent.VK_SHIFT: SHIFT = true; break; case KeyEvent.VK_K: ROTL = true; break; case KeyEvent.VK_L: ROTR = true; break; case KeyEvent.VK_ESCAPE: case KeyEvent.VK_F10: System.exit(0); break; } glc.repaint(); } public void keyReleased(KeyEvent e) { switch(e.getKeyCode()) { case KeyEvent.VK_W: UP = false; break; case KeyEvent.VK_S: DOWN = false; break; case KeyEvent.VK_A: LEFT = false; break; case KeyEvent.VK_D: RIGHT = false; break; case KeyEvent.VK_SHIFT: SHIFT = false; break; case KeyEvent.VK_K: ROTL = false; System.out.println(angle); break; case KeyEvent.VK_L: ROTR = false; System.out.println(angle); break; } } public void keyTyped(KeyEvent e) { } public void mouseMoved(MouseEvent m) { } public void mouseDragged(MouseEvent m) { } public void getGLCanvas(GLCanvas glc) { this.glc = glc; } }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Anyway, thanks for reading!
I hope somebody can help me, because i'm not sure how to continue
|
|
|
|
|
17
|
Game Development / Newbie & Debugging Questions / [SOLVED] What is the best way to get Keyboard input?
|
on: 2008-02-06 13:57:59
|
|
Hi everybody!
I've started learning about JOGL and stuff, it is now all getting clear and such. But... i have been using the regular keylistener of the AWT class, for getting keyboard input.
I have now made a cube that can be controlled by W, A, S and D. The cube should rotate when you hit one of the keys. What is the best way to receive keyboard input, because when i press one of the keys it takes a while before the key 'repeats itself'. (The key repeat speed you have if you press a key to continue to get that key, for examples if you press "A", you get this: AAAAAAAAAAAAAAAA. You notice that between the first A and the rest of the A's there is some kind of pause, and i want to get rid of that pause.
I've read something about keybindings, but i'm left clueless now, cuz i can't find a decent tutorial about keybindings.
Thanks, Cyrus
|
|
|
|
|