Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (577)
games submitted by our members
Games in WIP (498)
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  Game Development / Newbie & Debugging Questions / Re: Rotation around Center on: 2010-04-12 13:18:18
I'm not really sure, no. How would I go and check this ?
2  Game Development / Newbie & Debugging Questions / Re: Rotation around Center on: 2010-04-12 11:13:50
Thank you very much for your answer DzzD.

The bounding box coordinates are around the same coordinates as the ones I calculated before with summing up each axis and dividing through number of points, so that seems to be okay.

1  
2  
getCenterVertex at : 119.68530292026117/62.29729093334656/239.88274836337095
Bounding box coordinates at : 116.318302/67.105699/248.7705065


I still don't get why it is not rotating around the centroid Sad

Did I set up my view wrong ?

3  Game Development / Newbie & Debugging Questions / Re: Rotation around Center on: 2010-04-12 08:54:53
hi DzzD

it might be a stupid question, but how can i find out the intended object center location coordinates ?
4  Game Development / Newbie & Debugging Questions / Re: Rotation around Center on: 2010-04-09 10:28:13
okay, i did what you said and it seems it's better now Smiley

instead of the object flying in circles around "my head", i can see it now in front of me and it's rotating. but still not around its center, it looks like it's attached to a point at its lower side and it's going around circles there Sad
5  Game Development / Newbie & Debugging Questions / Re: Rotation around Center on: 2010-04-09 08:50:54
If you plan on rotating the object from it's center a lot, you probably want to go ahead and center it's vertices around a 0,0,0 origin on import.

yes, the rotation will be only done around the objects center Smiley how would i center the vertices around the origin at import? with the method DzzD described below or is there a simpler way ?

what you probalby want to do is

1  
gl.glTranslated(-centerX, -centerY,-centerZ);


where centerX,centerY,centerZ is the center of your object vertices in local object space => sum all your vertices and divide each result by number of vertices (inded do it only once and apply same transform to it if you apply/modify vertices of your object (zoom for example...) like if it was another vertex)
1  
2  
3  
4  
5  
6  
7  
8  
9  
for(n=0;n<nbVertices;n++) 
{
centerX+=v[n].x;
centerY+=v[n].y;
etc....
}
centerX/=nbVertices;
centerY/=nbVertices;
etc...


thanks for your suggestion, i will try this and report back my results Smiley
6  Game Development / Newbie & Debugging Questions / Rotation around Center on: 2010-04-08 11:33:13
Hi guys,

I want to rotate a mesh around its center (kinda like in a arcball). The mesh is read in from a .obj file.
The way I have it now, the model is rotating around a point which is not its center (kinda like if you run around a house in circles).

I read that I would have to translate the object to 0,0,0 and then rotate, but I have no ideas which values I should take.

Oh, I am using JOGL btw.

Here's the code for rendering:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
   
public void display(GLAutoDrawable drawable) {
      final GL gl = drawable.getGL();      
      gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
      gl.glLoadIdentity();
     
      if(zoom)
         setProjectionMatrix(gl);
     
      drawBone(gl);

     
      gl.glFlush();


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
   
private void drawBone(GL gl){
      gl.glPushMatrix();
     
      gl.glTranslated(0, 0,0);      
           
      gl.glRotated(rotX, 1, 0, 0);
      gl.glRotated(rotY, 0, 1, 0);
     
      if(faces != null){
         for(Face f: faces){
            f.draw(gl);
         }
      }

      gl.glPopMatrix();
   }


reshape:

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  
   public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {
      GL gl = drawable.getGL();
      if(h<=0){
         this.height=1;
      }
      else{
         this.height = h;
      }
      this.width = w;
     
      aspect = (float)width/(float)height;
     
      // Set the viewport to be the entire window
     gl.glViewport(0, 0, width, height);
     
      // Reset the coordinate system before modifying
     gl.glMatrixMode(GL.GL_PROJECTION);
      gl.glLoadIdentity();
     
      // Set the correct perspective.
     glu.gluPerspective(DEFAULT_ZOOM*zoomFactor, aspect, 1.0, 1000.0f);
     
      gl.glMatrixMode(GL.GL_MODELVIEW);
      gl.glLoadIdentity();
     
      glu.gluLookAt(0.0, 0.0, 5.0,
      0.0, 0.0, 0.0,
      0.0, 1.0, 0.0);


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
   
public void setProjectionMatrix(GL gl){
      GLU glu = new GLU();
     
      gl.glMatrixMode(GL.GL_PROJECTION);
      gl.glLoadIdentity();
     
      glu.gluPerspective(DEFAULT_ZOOM*zoomFactor, aspect, 1f, 100.0f);
     
      gl.glMatrixMode(GL.GL_MODELVIEW);
      gl.glLoadIdentity();
   }


Any help is much appreciated. Thank you!
7  Game Development / Newbie & Debugging Questions / Geodesic distance on: 2009-12-09 10:45:11
Hi guys,

For a project I'm supposed to implement sth called the geodesic distance into my program. What I have until now is a model-loader which takes an .obj. file and displays it on screen. now i'm supposed to click and put 2 points on the mesh and calculate the shortest geodesic distance between those points. From what I understand, this can be done with the dijkstra-algorithm, but I am not too sure.

What I basically wanted to ask for is, if somebody could point me into the right direction to implement this functionality to compute the shortest geodesic distance between 2 points or even help me out with some tutorials / other helpful websites Smiley

Thank you in advance!
8  Game Development / Newbie & Debugging Questions / Re: Applet / HTML interaction ? on: 2009-10-09 16:05:38
Thanks mate, will look into it Smiley

Here are 2 links to get started
https://jdk6.dev.java.net/plugin2/liveconnect/
http://java.sun.com/javase/6/docs/technotes/guides/plugin/developer_guide/java_js.html
9  Game Development / Newbie & Debugging Questions / Applet / HTML interaction ? on: 2009-10-09 15:46:14
Hey guys, I wanna do a Model Viewer in JOGL (applet embedded into a webpage). The user can query for the data to display with different options and then it displays the selected model. I thought about having the Query Elements (like textfield, button, drop-down-menu) outside the applet as HTML elements.

So my question is, is itt even possible to interact with an applet (like pass certain parameters) from the HTML/JavaScript code ?

Thank you for your help.

Best regards
randy
10  Java Game APIs & Engines / JOGL Development / Re: glReadPixels, glDrawPixels / Overlay crash on: 2009-09-25 13:41:01
Hi zingbat,

thank you for your input. I tried it with GLJPanel aswell, but it still gives me that Exception  Cry
The reason I was using GLCanvas in the first place was because it gave me 10+fps more than a GLJPanel.

Could you please explain to me why a GLJPanel is better in my Swing Application?
11  Java Game APIs & Engines / JOGL Development / glReadPixels, glDrawPixels / Overlay crash on: 2009-09-25 11:46:15
Good morning Smiley

I try to create a zoom function that magnifies the content of the screensection where the mouse is being dragged over and draws it in a corner.

Since I am fairly new in the Jogl world, I tried to do sth basic. I get the content with

1  
         gl.glReadPixels(0, 0, this.width, this.height, GL.GL_BGRA, GL.GL_UNSIGNED_BYTE, buffer );


(where width/height are the current width and height of the canvas) and buffer is the ByteBuffer).

Then I draw the buffer content with

1  
2  
3  
         gl.glWindowPos2i(0,0);
         gl.glPixelZoom(0.25f, 0.25f);
         gl.glDrawPixels(this.width, this.height, GL.GL_BGRA, GL.GL_UNSIGNED_BYTE, buffer);


Okay, no problem until now and I have got a small screen which shows me the content of the canvas 1:1.

But here is my problem: The GLCanvas is embedded on a JFrame with a Menu/Toolbar.
The toolbar is dragable. When I place it over the Canvas I get a

1  
 java.lang.IndexOutOfBoundsException


So from what I have read, glReadPixels can only be called on a Canvas that is in the front.

What different approach can I use to reach the same result?


Take care
randy
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.

xsi3rr4x (24 views)
2014-04-15 18:08:23

BurntPizza (19 views)
2014-04-15 03:46:01

UprightPath (33 views)
2014-04-14 17:39:50

UprightPath (17 views)
2014-04-14 17:35:47

Porlus (33 views)
2014-04-14 15:48:38

tom_mai78101 (59 views)
2014-04-10 04:04:31

BurntPizza (117 views)
2014-04-08 23:06:04

tom_mai78101 (217 views)
2014-04-05 13:34:39

trollwarrior1 (184 views)
2014-04-04 12:06:45

CJLetsGame (191 views)
2014-04-01 02:16:10
List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:05:20
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!