Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - AGP

Pages: 1 ... 105 106 [107] 108 109 ... 116
1591
News / Re: LWJGL 2.0 is out!
« on: October 29, 2008, 12:09:20 am »
Or the lack of a Keyboard.next() check, or both, FYI.

1592
Support / Re: Ship Rotation
« on: October 29, 2008, 12:06:37 am »
FYI, it was the lack of a Keyboard.next() check that was crashing it. How annoying.

1593
News / Re: LWJGL 2.0 is out!
« on: October 28, 2008, 09:37:51 pm »
Then that's what's been crashing my program, damn you! :-)

1594
Support / Re: Ship Rotation
« on: October 11, 2008, 10:00:35 am »
The frame stops responding, but I'm not getting any command prompt messages. I always use the command prompt and a simple text editor, by the way. And you may add a instance.draw() inside the while (gameOn) loop (it doesn't really matter since it's never rendering it the second time around).

1595
Support / Re: Ship Rotation
« on: October 11, 2008, 08:38:15 am »
GL only. The latest hardware attempt was single-threaded. It still crashes. It's very weird because I've had a lot of success with the hardware renderer in the past, and I can't see anything wrong with this code. All ENTER is doing in this version is flipping gameOn.

Code: [Select]
      private void draw() {
// buffer.clearZBufferOnly();
buffer.clear(Color.black);
xWing.rotateAxis(xWing.getXAxis(), rotationStored.x);
xWing.rotateAxis(xWing.getYAxis(), rotationStored.y);
xWing.rotateAxis(xWing.getZAxis(), rotationStored.z);
if (!cameraOnTie)
    follow();
rotationStored.x = 0;
rotationStored.y = 0;
rotationStored.z = 0;
buffer.update();

theWorld.renderScene(buffer);
theWorld.draw(buffer);
drawAxisRep();
if (!openGL)
    buffer.display(this.getGraphics());
else buffer.displayGLOnly();
      }
      public static void main(String[] args) {
boolean hardware = false;
if (args != null && args.length > 0) {
      if (args[0].equalsIgnoreCase("OpenGL"))
hardware = true;
}
RogueSquadron instance = new RogueSquadron(hardware);
if (instance.openGL) {
      instance.buffer = new FrameBuffer(800, 600, FrameBuffer.SAMPLINGMODE_HARDWARE_ONLY);

      try {
Keyboard.create();
      }
      catch (Exception e) {System.out.println("Keyboard failed: "+e.getMessage());}
      glLoop(instance);
      Keyboard.destroy();
      instance.buffer.disableRenderer(IRenderer.RENDERER_OPENGL);
      instance.buffer.dispose();
}
      }
      private static void glLoop(RogueSquadron instance) {
int keyCode;
instance.buffer.enableRenderer(IRenderer.RENDERER_OPENGL);
instance.buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
instance.draw();

while (!Display.isCloseRequested()) {
      keyCode = Keyboard.getEventKey();
      instance.keyPressed(keyCode);
      if (instance.gameOn) {
instance.moveTowards(instance.xWing, instance.targetCone.getTransformedCenter(), .01f);
instance.follow();
if (instance.wingsHaveChanged)
      instance.changeWings();
try {
Thread.sleep(50);
}
catch (InterruptedException e) {}
      }
}
instance.gameOn = false;
      }

1596
Support / Re: Ship Rotation
« on: October 09, 2008, 08:12:31 pm »
The main thread (in static method main(String[]) calls draw() once, after which time all it does is check the keyboard. When you press ENTER a new thread, the game loop, starts. But in OpenGL mode, all I'm getting is a frozen window. I have to have Windows kill the process.

1597
Support / Re: Ship Rotation
« on: October 08, 2008, 09:43:32 pm »
Thanks a lot, that was simple!

Another question: I'm getting crashes with a second thread in hardware OpenGL mode. It doesn't happen in software mode. Is there anything about OpenGL or otherwise lwjgl that can't be multi-threaded?

1598
Support / Ship Rotation
« on: October 08, 2008, 03:31:01 am »
How do I make it so that a ship is rotated around its own axis? As I understand it, objects are rotated by the world axis, so that the moment I rotate a ship in any of its 3 axis, it's no longer aligned with the worls axis. Or am I far off here?

1599
Support / Re: Why not add a math class?
« on: September 10, 2008, 06:40:40 pm »
The hero doesn't rotate at all. And he sometimes rotates awkwardly.

1600
Support / Re: Why not add a math class?
« on: September 09, 2008, 06:17:19 am »
Oddly that works as often as it doesn't.

1601
Support / Re: Why not add a math class?
« on: September 08, 2008, 06:26:35 pm »
I need the hero to look in the direction of the mouse click. By the way, I could just use the original mouse coordinates which are already in 2D. So shouldn't converting the hero's center and the hero's direction vector (in front of him) to 2D and then calculate that angle make sense? And if you agree, tell me if my changes work and if not please make your own. Thanks a lot.

1602
Support / Re: Why not add a math class?
« on: September 07, 2008, 11:44:44 pm »
OK, now I'm confused. My s1 was the hero's transformed center, and my s2 was the mouse click's position.

The hero''s transformed center is the origin. I have a direction vector for the keyboard that's always directly ahead of the hero, and I have the direction vector of the mouse click. What exactly should I feed into the method and for that matter, what version of the method? Yours?

1603
Support / Re: Why not add a math class?
« on: September 07, 2008, 10:07:28 pm »
OK, but I still think that a Math class with all sorts of operations would be invaluable.

By the way, you know my problem and it didn't work for that one. I also tried the 2D variation that follows. Why doesn't it work?
Code: [Select]
      public float calculateAngle(SimpleVector s1, SimpleVector s2) {
s1=s1.normalize();//TRIED WITH AND WITHOUT THESE
s2=s2.normalize();
SimpleVector p13d = Interact2D.project3D2D(theCamera, buffer, s1);
Point p1 = new Point((int)p13d.x, (int)p13d.y);
SimpleVector p23d = Interact2D.project3D2D(theCamera, buffer, s2);
Point p2 = new Point((int)p23d.x, (int)p23d.y);

float pa=(float)p1.x*(float)p2.x+(float)p1.y*(float)p2.y;

// Inaccuracies may cause NaN...fix this:
if (pa<-1)
pa=-1;
else if (pa>1)
pa=1;
    return (float) Math.acos(pa);
      }

1604
Support / Re: Why not add a math class?
« on: September 06, 2008, 05:48:42 pm »
Thanks a lot. What about my suggestion of adding a Math class? Could be quite useful and wouldn't make jPCT cumbersome in any way.

1605
Support / Re: Why not add a math class?
« on: September 06, 2008, 06:19:21 am »
More specifically, I'm trying to calculate a 2D angle, so this method would only use the x and y components of the SimpleVector class. static float calculateAngle2D(SimpleVector origin, SimpleVector p1, SimpleVector p2) might be a better name!

Pages: 1 ... 105 106 [107] 108 109 ... 116