Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (739)
Games in Android Showcase (224)
games submitted by our members
Games in WIP (820)
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 / JOGL Development / Re: Rendering java.awt.Graphics into a JOGL application example wanted on: 2009-11-20 18:49:26
wouldn't just overriding the paint() method in a canvas work?

I tried that before but i couldn't get it working, it also seems to crash the JVM.
2  Java Game APIs & Engines / JOGL Development / Rendering java.awt.Graphics into a JOGL application example wanted on: 2009-11-20 16:29:32
Basically, im writing a basic 3d game which features JOGL for rendering the actual game scene, i have all that stuff done, rendering of models etc, but now i need to create 2d graphics as a sort of "overlay" if you want;

For example, drawing a 2d picture onto the front of the application so it overlaps the scene, but so it's actually built in so if i was to use a lower alpha on the image it would appear semi-transparent.

Thanks for any help, i have googled for such examples but i cannot seem to find any.
3  Java Game APIs & Engines / JOGL Development / Re: jogl without a GLEventListener? on: 2009-11-20 16:27:05
thanks, i solved it before although this is basically what i had Smiley

but now for some reason java is throwing an exception:
1  
2  
3  
4  
5  
6  
7  
8  
9  
Exception in thread "Thread-3" java.lang.RuntimeException: Unable to initialize JAWT
   at com.sun.nativewindow.impl.jawt.JAWT$1.run(JAWT.java:100)
   at java.security.AccessController.doPrivileged(Native Method)
   at com.sun.nativewindow.impl.jawt.JAWT.getJAWT(JAWT.java:95)
   at com.sun.nativewindow.impl.jawt.windows.WindowsJAWTWindow.lockSurface(WindowsJAWTWindow.java:69)
   at com.sun.opengl.impl.GLDrawableImpl.lockSurface(GLDrawableImpl.java:130)
   at com.sun.opengl.impl.windows.wgl.WindowsWGLDrawable.setRealized(WindowsWGLDrawable.java:70)
   at org.peehpee.gl.ui.Canvas3D.run(Canvas3D.java:66)
   at java.lang.Thread.run(Unknown Source)

i've never had  this before, any ideas?

Gary i had the same problem, i think it's an actual JOGL bug, if you google it more people are having the problem and there are no answers.
4  Game Development / Game Play & Game Design / Re: Real Time Strategy handling sprite/character actions on: 2009-11-20 16:21:38
As you will be using alot of memory for holding the "units" you need to make sure that you only update WHEN required, especially if it is a server/client game so you send less data for quicker processing.

For example, the best way to do it for a server-client game would be like this, please note this is a quick example which could obviously be updated to make it more efficient.

1  
2  
3  
4  
5  
6  
7  
8  
9  
public void update()
{
   for (Unit unit : unitList)
   {
      if(unit.hasUpdate())
         unit.writeUpdate(BUFFER_CLASS);
      unit.writeOther(BUFFER_CLASS);
   }
}


Now, basically unit.writeUpdate() would have more flags, for example;

Animation updates;
Movement updates;
Graphic updates;

Each of which would change a flag byte and then write the data, then the unit.writeOther writes the information which is required, such as "unit index", for clientside entity finding,  etc.

Example of very basic writeUpdate() method;

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  
public void writeUpdate(ByteArrayOutputStream buffer)
{
   byte flag = 0;
   if(animationUpdateRequired)
      flag |= 0x1;
   if(graphicUpdateRequired)
      flag |= 0x2;
   if(movementUpdateRequired)
      flag |= 0x4;
   buffer.writeByte(flag);
   if(animationUpdateRequired)
   {
      buffer.writeByte(animationId);
      buffer.writeByte(animationSpeed);
   }
   if(graphicUpdateRequired)
   {
      buffer.writeByte(graphicId);
      buffer.writeShort(((graphicX << 8) + graphicY));
   }
   if(movementUpdateRequired)
   {
      buffer.writeByte(xPosition);
      buffer.writeByte(yPosition);
   }
}


This way you only send what the client needs, and you don't update anything that hasn't changed.

Obviously you have to reset the flags after each update and set them when the unit moves for example.

Hope it helps.
5  Java Game APIs & Engines / JOGL Development / Re: Drawing 2d shape in 3d scene? on: 2009-11-12 20:25:02
Seeing as you're using JOGL, look into the overlay functions, I think they are exactly what you want.

Mike

Ok, i just spent about 15 minutes on google trying to find a good example of using a 2d overlay in JOGL but i couldn't, the only site which looked promising you had to pay to see the answer lol.

Please could you try and put together a really really basic example, thanks for any help.
6  Java Game APIs & Engines / JOGL Development / Drawing 2d shape in 3d scene? on: 2009-11-12 19:57:26
I need help, i want to draw a rectangle in 2d over the 3d screen, it's for selecting stuff, basically the retangle shouls appear 2d at the front of the screen overlapping the whole part you select and then draw.

However, the 3d screen is rotated so it's not as easy as i thought.

I have the drag to make the size etc working, but now i need the actual drawing, thanks for any help.

For this help you could just supply a basic drawing of the rectangle with any dimensions and any coordinates.

Thanks.
7  Java Game APIs & Engines / JOGL Development / Nevermind on: 2009-11-10 15:26:46
Remove i fixed
8  Java Game APIs & Engines / JOGL Development / Re: Problem with JOGL picking after using glTranslate on: 2009-11-08 23:18:15
Ok i changed the question.
9  Java Game APIs & Engines / JOGL Development / Re: Colour problem on: 2009-11-08 14:51:26
I know but your dwarf warrior seems as the tiles a little colored too

Ok thanks i put that at the end and it worked.

Now, would you know how to draw the mesh, or outlines of the model but not actually colour it?

I was thinking about using gl.glDrawLine but it would be harder having to join vertex 1-2, 2-3, 3-4, 4-5, 5-1 or however many vertices there are in each polygon.
10  Java Game APIs & Engines / JOGL Development / Re: Colour problem on: 2009-11-08 14:05:33
no light is expected no ?

and the following will set vertex color painting no ?
1  
gl.glColor3f(t.getRed(), t.getGreen(), t.getBlue());


try to replace by:

1  
gl.glColor3f(1.0f,1.0f,1.0f);


That just colours the vertices of the floor tiles which can be rendered before or after and still cause the problem.
11  Java Game APIs & Engines / JOGL Development / Problem with JOGL picking after using glTranslate on: 2009-11-08 01:38:18
I decided to re-use my topic instead of spam the board since it's not really that active, so i just edited this.

The following posts were to do with my original problem so it hasn't been answered yet.

Anyway...

Im having a problem with Picking/Selecting whatever you want to call it, i had it working perfectly but if i want to move the drawing of the model then it dosn't work.

Here is the method to render the vertices of the model which IS VISIBLE, not the picking method;

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  
public void renderVertices(GL gl)
   {  
      gl.glPushMatrix();
      gl.glTranslatef(5f, 0.0f, 0f);
      //gl.glRotatef(-90.0f, 1.0f, 0.0f, 0.0f);
      gl.glDisable(GL.GL_LIGHTING);
      gl.glBegin(GL.GL_QUADS);  
      for (Vertex v : vertices)
      {
         gl.glColor3f(0.0f, 0.5f, 0.0f);
         float xMinus = v.x - 0.01f;
         float yMinus = v.y - 0.02f;
         float zMinus = v.z - 0.01f;
         float xPlus = v.x + 0.01f;
         float yPlus = v.y;
         float zPlus = v.z + 0.01f;
         gl.glVertex3f(xPlus, yPlus, zPlus);
         gl.glVertex3f(xPlus, yMinus, zPlus);
         gl.glVertex3f(xPlus, yMinus, zMinus);
         gl.glVertex3f(xPlus, yPlus, zMinus);
         gl.glVertex3f(xPlus, yPlus, zMinus);
         gl.glVertex3f(xPlus, yMinus, zMinus);
         gl.glVertex3f(xMinus, yMinus, zMinus);
         gl.glVertex3f(xMinus, yPlus, zMinus);
         gl.glVertex3f(xMinus, yPlus, zMinus);
         gl.glVertex3f(xMinus, yMinus, zMinus);
         gl.glVertex3f(xMinus, yMinus, zPlus);
         gl.glVertex3f(xMinus, yPlus, zPlus);
         gl.glVertex3f(xMinus, yPlus, zPlus);
         gl.glVertex3f(xMinus, yMinus, zPlus);
         gl.glVertex3f(xPlus, yMinus, zPlus);
         gl.glVertex3f(xPlus, yPlus, zPlus);
         gl.glVertex3f(xMinus, yPlus, zMinus);
         gl.glVertex3f(xMinus, yPlus, zPlus);
         gl.glVertex3f(xPlus, yPlus, zPlus);
         gl.glVertex3f(xPlus, yPlus, zMinus);
         gl.glVertex3f(xMinus, yMinus, zPlus);
         gl.glVertex3f(xMinus, yMinus, zMinus);
         gl.glVertex3f(xPlus, yMinus, zMinus);
         gl.glVertex3f(xPlus, yMinus, zPlus);
      }
      gl.glEnd();
      gl.glPopMatrix();
      gl.glEnable(GL.GL_LIGHTING);
   }


Picking works perfectly if i take out the translation and rotation parts.

Here is the method for rendering the vertices using picking, i have made it so that it performs a loop so i can set the "names" for each vertice by doing;

1  
2  
3  
gl.glPushName(index);
model.renderVertice(index, gl);
gl.glPopName();


index being the variable of the for statement.

So anyway, here is the picking rendering method;

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 renderVertex(int index, GL gl)
   {
      gl.glDisable(GL.GL_LIGHTING);
      gl.glPushMatrix();
      gl.glTranslatef(5f, 0.0f, 0f);
      //gl.glRotatef(-90.0f, 1.0f, 0.0f, 0.0f);
      Vertex v = vertices[index];
      gl.glBegin(GL.GL_QUADS);
      float xMinus = v.x - 0.01f;
      float yMinus = v.y - 0.02f;
      float zMinus = v.z - 0.01f;
      float xPlus = v.x + 0.01f;
      float yPlus = v.y;
      float zPlus = v.z + 0.01f;
      gl.glVertex3f(xPlus, yPlus, zPlus);
      gl.glVertex3f(xPlus, yMinus, zPlus);
      gl.glVertex3f(xPlus, yMinus, zMinus);
      gl.glVertex3f(xPlus, yPlus, zMinus);
      gl.glVertex3f(xPlus, yPlus, zMinus);
      gl.glVertex3f(xPlus, yMinus, zMinus);
      gl.glVertex3f(xMinus, yMinus, zMinus);
      gl.glVertex3f(xMinus, yPlus, zMinus);
      gl.glVertex3f(xMinus, yPlus, zMinus);
      gl.glVertex3f(xMinus, yMinus, zMinus);
      gl.glVertex3f(xMinus, yMinus, zPlus);
      gl.glVertex3f(xMinus, yPlus, zPlus);
      gl.glVertex3f(xMinus, yPlus, zPlus);
      gl.glVertex3f(xMinus, yMinus, zPlus);
      gl.glVertex3f(xPlus, yMinus, zPlus);
      gl.glVertex3f(xPlus, yPlus, zPlus);
      gl.glVertex3f(xMinus, yPlus, zMinus);
      gl.glVertex3f(xMinus, yPlus, zPlus);
      gl.glVertex3f(xPlus, yPlus, zPlus);
      gl.glVertex3f(xPlus, yPlus, zMinus);
      gl.glVertex3f(xMinus, yMinus, zPlus);
      gl.glVertex3f(xMinus, yMinus, zMinus);
      gl.glVertex3f(xPlus, yMinus, zMinus);
      gl.glVertex3f(xPlus, yMinus, zPlus);
      gl.glEnd();
      gl.glPopMatrix();
      gl.glEnable(GL.GL_LIGHTING);
   }


Like i said, if i don't add the translation part it works fine, but it's included in both methods so im not sure why it's not working.

Thanks for any help.
12  Java Game APIs & Engines / JOGL Development / Re: A few questions about JOGL on: 2009-11-02 23:54:44
As for Q1 - look up opengl 'selection' or 'picking' on Google.  There *is* support for that kind of thing, but there's a couple of different ways you can do it.



Ok thank you ill go and check.
13  Java Game APIs & Engines / JOGL Development / A few questions about JOGL on: 2009-11-02 20:37:13
I have a few questions i can't seem to find the answer to on the internet or in a book.

Question 1:

Does OpenGL offer any help towards mouse listening, for example, if you have rendered your "scene" and you have changed the rotations of stuff is there anything in OpenGL which will be able to relate to what is drawn and where you clicked?

For example;

Say i draw some "tiles" in JOGL using this;

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
public void renderTiles(GL gl)
{
   gl.glStart(GL.GL_QUADS);
   for (int tileX = 0; tileX < 10; tileX++)
   {
      for (int tileZ = 0; tileZ < 10; tileZ++)
      {
         gl.glVertex3f(tileX, 0, tileZ);
         gl.glVertex3f(tileX + 1, 0, tileZ);
         gl.glVertex3f(tileX + 1, 0, tileZ + 1);
         gl.glVertex3f(tileX, 0, tileZ + 1);
      }
   }
   gl.glEnd();
}


And then use this to set the view point;

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
public void setViewpoint(GL gl, GLU glu)
{
   double playerX = 5; //Middle, since we had 10 tiles
   double playerY = 1; //1 of the ground
   double playerZ = 5; //middle again
   double viewAngle = 0.0;
   double xStep = Math.cos( Math.toRadians(viewAngle));
      double zStep = Math.sin( Math.toRadians(viewAngle));
   double xLookAt = xPlayer + (100.0 * xStep);
       double yLookAt = 0.0;
       double zLookAt = zPlayer + (100.0 * zStep);
   float zAxis = 0.5f;
   glu.gluLookAt(xPlayer, yPlayer, zPlayer, xLookAt, yLookAt, zLookAt, 0, 1, 0);
   gl.glRotatef(zAxis, 0.0f, 0.0f, 1.0f);
}


Is there any methods in OpenGL to find out what one of those tiles was clicked?

Question 2:

For the following code sample, how would i apply a texture?

Ive tried all the examples, for instance getting a 2d image, loading it via TextureIO.read, setting gl.glEnable(GL.GL_TEXTURE_2D);

And then using the TextureCoords and gl.glTexCoords2f(tc details); but it still dosn't seem to work for me =s.

Question 3:

What is wrong with the following code?

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  
if(drawVerts)
      {
         gl.glBegin(GL.GL_QUADS);
         gl.glColor3f(0.0f, 0.0f, 0.5f);
         for (Tile t : tileMap)
         {
            TileVertex[] vertices = t.getVertices();
            for (int i = 0; i < 4; i++)
            {
               float xMinus = vertices[i].getX() - 0.05f;
               float yMinus = vertices[i].getY() - 0.1f; //Starts below
               float zMinus = vertices[i].getZ() - 0.05f;
               float xPlus = vertices[i].getX() + 0.05f;
               float yPlus = vertices[i].getY();
               float zPlus = vertices[i].getZ() + 0.05f;
               gl.glVertex3f(xPlus, yPlus, zPlus);
               gl.glVertex3f(xPlus, yMinus, zPlus);
               gl.glVertex3f(xPlus, yMinus, zMinus);
               gl.glVertex3f(xPlus, yPlus, zMinus);
               //
               gl.glVertex3f(xPlus, yPlus, zMinus);
               gl.glVertex3f(xPlus, yMinus, zMinus);
               gl.glVertex3f(xMinus, yMinus, zMinus);
               gl.glVertex3f(xMinus, yPlus, zMinus);
               //
               gl.glVertex3f(xMinus, yPlus, zMinus);
               gl.glVertex3f(xMinus, yMinus, zMinus);
               gl.glVertex3f(xMinus, yMinus, zPlus);
               gl.glVertex3f(xMinus, yPlus, yPlus);
               //
               gl.glVertex3f(xMinus, yPlus, zPlus);
               gl.glVertex3f(xMinus, yMinus, zPlus);
               gl.glVertex3f(xPlus, yMinus, zPlus);
               gl.glVertex3f(xPlus, yPlus, zPlus);
               //
               gl.glVertex3f(xMinus, yPlus, zMinus);
               gl.glVertex3f(xMinus, yPlus, zPlus);
               gl.glVertex3f(xPlus, yPlus, zPlus);
               gl.glVertex3f(xPlus, yPlus, zMinus);
               //
               gl.glVertex3f(xMinus, yMinus, zPlus);
               gl.glVertex3f(xMinus, yMinus, zMinus);
               gl.glVertex3f(xPlus, yMinus, zMinus);
               gl.glVertex3f(xPlus, yMinus, zPlus);
            }
         }
         gl.glEnd();
      }


Now, that code to me looks fine, it's ment to draw the vertices of a tile, which there are 4 for each tile, but on a straight grid like system i get this problem:

IMAGE LINK: http://i38.tinypic.com/ddm1x0.jpg

I have checked the code and can't see why it does it.

__

__

Thank you for any help i recieve, like i have already stated, i have an OpenGL book (it's for c++ because i couldn't find a java one) but i can't find anything to do with what i need, apart from the textures, but everything i try still dosn't work and ive been googling the problems for about an hour, i also put them on forums.sun.com but i havn't had a reply in a whole day.

Pages: [1]
 
Ecumene (57 views)
2017-09-30 02:57:34

theagentd (80 views)
2017-09-26 18:23:31

cybrmynd (187 views)
2017-08-02 12:28:51

cybrmynd (185 views)
2017-08-02 12:19:43

cybrmynd (192 views)
2017-08-02 12:18:09

Sralse (203 views)
2017-07-25 17:13:48

Archive (767 views)
2017-04-27 17:45:51

buddyBro (902 views)
2017-04-05 03:38:00

CopyableCougar4 (1452 views)
2017-03-24 15:39:42

theagentd (1327 views)
2017-03-24 15:32:08
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
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!