Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
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: LWJGL Object Coordinates on: 2012-04-24 08:39:23
I think I might've figured it out...

=)
* lethalwire puts away the coffee.
2  Java Game APIs & Engines / OpenGL Development / LWJGL Object Coordinates on: 2012-04-24 05:09:02
I'm trying to get the object coordinates of objects I'm drawing in 3D space.
I've read that the GL_MODELVIEW_MATRIX is the comprised of the GL_PROJECTION_MATRIX and the transformation_matrix(which isn't defined for lwjgl).

So, are the object coordinates simply in the matrix:
transformation_matrix = GL_PROJECTION_MATRIX * inverse(GL_MODELVIEW_MATRIX);

Also...
If I'm letting the user move the camera around freely in the 3D space, do I have to add anything to the computation when I'm solving for the transformation_matrix?

I've already read that this ISN'T the way it should be done, and that I should be keeping track of any x,y and z coordinates myself. (As this isn't what OpenGL was meant for)
In that case, what method would I use to keep track of x,y and z coordinates if I'm consistently doing something similar to:

glTranslatef(x, y, z);
glRotatef(degree, 0, 1, 0); //Where there could, or could NOT be a rotation
glRotatef(degree, 1, 0, 0);//Where there could, or could NOT be a rotation
glTranslatef(x, y, z);
...
etc.
3  Java Game APIs & Engines / OpenGL Development / Re: TWL or Slick2D Development on: 2012-04-23 07:38:35
I went ahead and used a JFrame to show the buttons I need. In the end, I realized I really didn't need to integrate the buttons into the lwjgl display.

Thanks for your help on the issue though.
4  Java Game APIs & Engines / OpenGL Development / Re: TWL or Slick2D Development on: 2012-04-23 03:41:10
That's what I originally said.

I have everything drawn.
I just need a library to throw some 2D buttons on top of what I have. (I'm assuming it's possible w/o having to create my own buttons, but I could be wrong.)

That is the reason I am wanting to use TWL or SLick2D. Just for the buttons/text.

The hard part for me is figuring out how put the buttons/text on the UI.
5  Java Game APIs & Engines / OpenGL Development / Re: TWL or Slick2D Development on: 2012-04-23 03:12:09
Slick2D was designed to hide the low-level GL calls from the user, so generally speaking you should be using Slick's utilities instead of calling GL11/Display directly.

If you just need text, buttons and a text field, then use Slick2D's Font/UI classes, as they will suffice.

If you want a more professional interface, with tables, combo boxes, text areas, etc. use TWL. It has a much steeper learning curve, requires you to design your own themes (although you could use an existing theme), and takes a little bit of work setting up with Slick2D.

Hmm... The points I'm drawing are in 3D space though. I can't seem to find anything with the Slick API that allows me to draw anything in depth.
How would I mimick something similar to :
glVertex3f( ... ) in slick2D?
6  Java Game APIs & Engines / OpenGL Development / Re: TWL or Slick2D Development on: 2012-04-23 02:28:11
Thanks for your fast reply.

At this point, I'm not worried about the aesthetics. I just want results! =)

I'll look into slick and see what I can conjure up.
7  Java Game APIs & Engines / OpenGL Development / TWL or Slick2D Development on: 2012-04-23 02:17:35
I've developed a small program that parses a Biovision Hierarchy file (.bvh) and I currently have a very basic canvas that displays the animation.
See attachment for canvas example.

I'm not sure if this is old-fashioned or not, but I've got everything rendered to org.lwjgl.opengl.Display
I'm also using the org.lwjgl.opengl.GL11.* methods.

Now, I've come across a problem. I want my UI to have a few buttons and some text around the UI displaying information like filename, etc.
What I need help with is choosing a library for such a thing.
I can't see how to just "lay" TWL  or Slick2D objects on top of the code I have to add a few buttons and some text.

So it brings me to ask, should I be using TWL or Slick2D or neither? Or, if I am to use either of these 2 libraries, will I have to extend Widgets (for TWL) or extend BasicGame( SLick2D) and THEN integrate what I have into either of these libraries?

I'm also on a short timeframe so another question I will ask is: Which of these libraries is quicker to learn/pickup and get my hands dirty?

8  Java Game APIs & Engines / OpenGL Development / Bitmap & Font Help on: 2011-12-26 20:48:28
I'm reading the red book and I'm in the section about bitmaps and fonts.
What I'm trying to do is setup a bitmap for each letter (uppercase/lowercase) and number and store the data into an inner-class I call RasterFontInfo.

The class RasterFont contains RasterFontInfo and sets up the Map.
A bitmap for each char can be called from a Map that is setup like:
Map<Character, RasterFontInfo> map;

RasterFontInfo contains width, height, x0, y0, and a ByteBuffer which holds the bitmap data.

So far, I've been pretty successful but I'm now blocked with the following problem:


Uploaded with ImageShack.us

All of the letters are showing up correctly except for m, G, J, M, O, Q, and 1. I've tried looking for patterns between these but I can't see any.
I'm hoping someone can give insight as to why the letters show up like this.
If you need the code I have the following:

The code I'm using to draw each letter looks like:
1  
2  
3  
4  
5  
6  
7  
8  
glTranslatef(0.0f, 0.0f, zTranslation);
      glRasterPos2f(-3.2f, 0f);
      char[] phrase = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toCharArray();
     
      for(char c : phrase) {
         RasterFontInfo rfi = characterMap.get(c);
         glBitmap(rfi.getWidth(), rfi.getHeight(), (float)rfi.getX0(), (float)rfi.getY0(), (float)rfi.getWidth()+2, 0, rfi.getBuffer());
      }


Code for deriving a RasterFontInfo object:
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  
   private RasterFontInfo deriveRasterFontInfo(char c) {
      /* keeps track of width and height of font raster */
      int width = 0, height = 0;
     
      String stringValueOfC = String.valueOf(c);

      /* Temporary drawing area for c */
      BufferedImage temporaryBufferedImage = new BufferedImage(1024, 1024,
            BufferedImage.TYPE_INT_RGB);
     
      /* Acquire graphics object to draw char to drawing area */
      Graphics2D g2d = (Graphics2D) temporaryBufferedImage.getGraphics();
      g2d.setFont(getFont());
     
      /* Acquire FontMetrics object to get geometrical data from font */
      FontMetrics fontMetrics = g2d.getFontMetrics();
     
      /* Acquire geometrical font data */
      int charHeight = fontMetrics.getHeight();
      int charWidth = fontMetrics.stringWidth(stringValueOfC);
      int charDescent = fontMetrics.getDescent();
      Dimension charDimension = new Dimension(charWidth, charHeight+charDescent);
     
      g2d.drawString(stringValueOfC, 0, charHeight);
     
      /* Acquire a sub-image that only contains the drawing area of the char */
      BufferedImage bi = temporaryBufferedImage.getSubimage(0, 0, (int)charDimension.getWidth(), (int)charDimension.getHeight());


      char[][] bitmapArray = new char[bi.getHeight()][multipleOfEight(bi.getWidth())];
      for(char[] ch : bitmapArray)
         java.util.Arrays.fill(ch, '0');
     
      /* setup bitmap array based on values read from the subimage's RGB coordinates */
      /* the result is a 2D-array filled with 0's and 1's */
      for(int i = bi.getHeight()-1; i >= 0; --i) {
         for(int j = bi.getWidth()-1; j >= 0; --j) {
            if(bi.getRGB(j,i) == -16777216)
               bitmapArray[i][j] = '0';
            else if (bi.getRGB(j,i) == -1)
               bitmapArray[i][j] = '1';
         }
      }
     
     
      /* Clear unused bits from bitmapArray */
      bitmapArray = clearUnusedBits(bitmapArray);
     
      /* Temporary list to hold chunks of translated data from bitmap */
      ArrayList<Byte> chunkList = new ArrayList<Byte>();
      int numChunks = bitmapArray[0].length / 8;
     
      /* loop through each array of bitmapArray beginning from the end */
      for(int lineNumber = bitmapArray.length - 1; lineNumber >= 0; --lineNumber) {
         /* sets up data to insert into chunk list */
         String currentLine = new String(bitmapArray[lineNumber]);
         String[] chunks = new String[numChunks];
         getChunks(chunks, currentLine);
         
         int[] binaryChunks = new int[numChunks];
         getBinaryChunks(binaryChunks, chunks);
         
         for(int binaryChunk : binaryChunks)
            chunkList.add((byte) binaryChunk);
         
         /* computes height and width of font raster */
         height = bitmapArray.length;
         int x1 = -1, x2 = -1;
         if( currentLine.contains("1") ) {
            /* count the distance from the first 1 to the last 1 */
            /* the greatest distance found instantiates the width of the raster of the font */
            x1 = currentLine.indexOf('1');
            x2 = currentLine.lastIndexOf('1');
            int leadingZeros = currentLine.substring(0, x1).length();
            int distance = x2 - x1 + 1 + leadingZeros;
            width = Math.max(width, distance);
         }
      }
     
      /* Prints each bitmap */
      System.out.println("---");
      for(char[] ch : bitmapArray) {
         System.out.println(new String(ch));
      }
      System.out.println("---");
     
     
      /* determine x0 and y0, used for glBitmap */
      int x0 = 0;
      int y0 = 0;
     
      /* add chunkList elements to ByteBuffer */
      ByteBuffer buffer = BufferUtils.createByteBuffer(chunkList.size());
      for(Byte b : chunkList)
         buffer.put(b);
      buffer.flip();
     
      /* Setup and return RasterFontInfo used for Map */
      RasterFontInfo rfi = new RasterFontInfo(buffer, width, height, x0, y0);
      return rfi;
   }


And if you need all of the files, they're located here: (2 .java files)
https://skydrive.live.com/?cid=f6516fcd92fde78e#cid=F6516FCD92FDE78E&id=F6516FCD92FDE78E!130
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.

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

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

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

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

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

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

danieldean (36 views)
2014-07-17 23:41:23

MustardPeter (39 views)
2014-07-16 23:30:00

Cero (54 views)
2014-07-16 00:42:17

Riven (54 views)
2014-07-14 18:02:53
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!