Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (115)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 ... 4 5 [6] 7 8 ... 10
 51 
 on: 2014-09-21 19:39:29 
Started by JayManHall - Last post by Mike
I've been called Mike since I was born (well, the Swedish version anyway). I used to use a couple of internet names, but I don't mind everyone calling me by my real nickname Smiley

Mike

 52 
 on: 2014-09-21 19:14:04 
Started by P0jahn - Last post by CopyableCougar4
I know my code isn't as efficient, but it works and is easier to see how to get each point.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
 public Point2D.Float rotateAroundCenter(float x, float y, float angle, float cx, float cy) {
      float dx = x - cx;
      float dy = y - cy;
      float distance = (float) Math.sqrt(dx * dx + dy * dy);
      float originalAngle = getAngle(cx, cy, x, y);
      float newangle = originalAngle + angle;
      float ndx = distance * (float)Math.sin(newangle);
      float ndy = distance * (float)Math.cos(newangle);
      float nx = cx + ndx;
      float ny = cy + ndy;
      return new Point2D.Float(nx, ny);
   }


Returns the degree in radians.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
public static float getAngle(float mousex, float mousey, float playerx, float playery) {
      float deltax = mousex - playerx;
      float deltay = mousey - playery;
      double rawangle = Math.atan2(deltay, deltax);
      float degrees = (float) Math.toDegrees(rawangle);
      degrees += 90.0f; // add 90 so opengl can use it
     if (degrees < 0) {
         degrees += 360.0f; // fix all angles less than 0
     }
      if (degrees > 360.0f) {
         degrees -= 360.0f; // fix all angles more than 360
     }
      degrees %= 360.0f;
      if (degrees > 180.0f) {
         degrees -= 360.0f;
      }
      return (float) Math.toRadians(degrees);
   }


Smiley

CopyableCougar4

 53 
 on: 2014-09-21 19:11:37 
Started by tinfoilboy - Last post by Grunnt
Include a method in your entities to return the state of the entity at the time the method was called, call that method at the start of performing the render, and store all the returned values from the entities in an array.

Okay, I can see how that could work with some effort. However, this all sounds needlessly complicated and certainly not a performance gain: deep copying all entities each loop is not free, and rendering speed is mostly done on the GPU anyway.

If you don't want to create another array for all the entity states, try including a lock/unlock method in the entities, and call those methods at the start/end of the render loop.

So the update thread waits for the rendering thread and the rendering thread waits for the update thread. Which turns this into an extremely complicated way to do exactly the same thing as just a single thread performing update and render, or am I missing something here?

Also, neither solution solves the problem posed by the OP: how to make movement independent from framerate.

 54 
 on: 2014-09-21 19:09:03 
Started by trollwarrior1 - Last post by trollwarrior1
Just started working again on the parser, and I came up with a huge problem. I exported a single quad (triangulated) from Blender, however the position values are just plain wrong.

1  
2  
3  
4  
5  
6  
7  
8  
         <float_array id="Cube-mesh-positions-array" count="12">1 1 -1 -0.9999997 1 -1 1 0.9999995 1 -1 1 1</float_array>
          <technique_common>
            <accessor source="#Cube-mesh-positions-array" count="4" stride="3">
              <param name="X" type="float"/>
              <param name="Y" type="float"/>
              <param name="Z" type="float"/>
            </accessor>
          </technique_common>


This  is supposed to be a face looking directly at the camera, but as you can see, there are positions that are not on the Z -1. In blender, whole plane is displayed at z = -1.

Am I doing something wrong?

Edit----------
Coordinates are supposed to look something like this
1  
1 1 -1 -1 1 -1 1 -1 -1 -1 -1 -1

Basically all on the same Z plane making up a nice square.
I get a stupid looking quad with the exported coordinates.

 55 
 on: 2014-09-21 18:53:46 
Started by CopyableCougar4 - Last post by CopyableCougar4
I am trying to speed up rendering time by taking all text rendered, storing them in frame buffer objects, and then rendering those.

Problems:
  • I don't 100% know if that is even a possible solution
  • I have never used framebuffers before
  • I end up generally rendering everything with immediate mode, so I don't have any experience with modern OpenGL rendering

Here is the "FrameBuffer" class I have so far. It's very small and all it does (in theory) is bind something to the frame buffer 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  
public class FrameBuffer {

   private int framebuffer = -1;
   
   public FrameBuffer() {
      boolean FBOEnabled = GLContext.getCapabilities().GL_EXT_framebuffer_object;
      if (!FBOEnabled) {
         throw new RuntimeException("FrameBuffer objects must be enabled!");
      }
      framebuffer = GL30.glGenFramebuffers();
   }
   
   public void drawBuffer(Renderable renderable) {
      if (framebuffer == -1) {
         throw new RuntimeException("Invalid FrameBuffer object");
      }
               // Is this correct?
     GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, framebuffer);
      renderable.render();
      GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0);
   }
   
   public void renderBuffer() {
      if (framebuffer == -1) {
         throw new RuntimeException("Invalid FrameBuffer object");
      }
           // I don't even know how to approach rendering the frame buffer
  }
   
}

Renderable is just an interface with a method render().

Any help would be appreciated Smiley

CopyableCougar4

 56 
 on: 2014-09-21 18:44:50 
Started by P0jahn - Last post by P0jahn
That didnt work either. But I do not get it. What do you mean rotate around (0,0)?  How am I suppose to calculate the position of the rotated point if I rotate around 0,0 instead of the entity┬┤s position?

 57 
 on: 2014-09-21 18:38:44 
Started by P0jahn - Last post by nsigma
Well, the most obvious thing is that you've taken me slightly too literally  Wink - you need to translate your midY coordinates in the same way so that you're rotating around 0,0!

 58 
 on: 2014-09-21 18:38:35 
Started by JayManHall - Last post by matheus23
In school someone one day had the idea to give everyone a unique nickname. Mine was "matheus", because I was good at maths ("mathe" in german).

It was about that time that I first needed internet nicknames (~11 years of age), so that became my pseudonym Smiley

 59 
 on: 2014-09-21 18:32:32 
Started by JayManHall - Last post by kevglass
My real name is Kev(in)Glass.

Kev

 60 
 on: 2014-09-21 18:23:32 
Started by JayManHall - Last post by DarkCart
I just came up with my name in the middle of science class. I have no idea why or how.

Pages: 1 ... 4 5 [6] 7 8 ... 10
 

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

The first screenshot will be displayed as a thumbnail.

radar3301 (11 views)
2014-09-21 23:33:17

BurntPizza (29 views)
2014-09-21 02:42:18

BurntPizza (19 views)
2014-09-21 01:30:30

moogie (20 views)
2014-09-21 00:26:15

UprightPath (27 views)
2014-09-20 20:14:06

BurntPizza (30 views)
2014-09-19 03:14:18

Dwinin (47 views)
2014-09-12 09:08:26

Norakomi (74 views)
2014-09-10 13:57:51

TehJavaDev (102 views)
2014-09-10 06:39:09

Tekkerue (50 views)
2014-09-09 02:24:56
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!