Main Menu
Menu

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.

Show posts Menu

Messages - AGP

#1606
Support / Re: Ship Lasers After Rotation
November 06, 2008, 09:21:12 PM
Oh, the rotation matrix thing wasn't supposed to be there. That was a stupid shot in the dark. The code wasn't working long before that. The target cone is like the crosshair of a gun. It is by following it that the ship flies. If you look around your mailbox you'll find an old screenshot of this. But all it is is a crosshair.

And laserTarget is just that: the direction at which the laser flies. It's just an object meant to be chased by the laser. The game loop calls moveTowards(laser1, laserTarget1, .2f), which moves the laser1 cylinder 20% of the way towards laserTarget1 (but since laserTarget1 is added as its child, laserTarget1 moves away by the same amount).
#1607
Support / Ship Lasers After Rotation
November 06, 2008, 05:40:52 PM
The way the ship flies forward is it's always chasing targetCone. After the following method flips firing to true, the game loop makes the lasers chase after the laserTarget variables using the very same method that always works for the ship. What's weird is that the following code only works before the ship is rotated. Then, for some bizarre reason, the laserTargets start showing up in the wrong place. It's worth mentioning that the laser cylinders are ALWAYS aligned to the ship, but they end up flying sideways after the first rotation.

      private void fireLasers() {//SETS IT UP, THEN FLIPS firing TO TRUE SO THAT THE GAME LOOP TAKES IT FROM THERE
targetCone.calcCenter();
laser1 = Primitives.getCylinder(16, 4f, 20f);
laser1.build();
laser1.translate(laserDummy1.getTransformedCenter());
align(laser1, wing1);
// laserTarget1 = Object3D.createDummyObj();
laserTarget1 = Primitives.getBox(10, 1);
align(laserTarget1, targetCone);
moveTowards(laserTarget1, targetCone.getTransformedCenter(), 1f);
theWorld.addObject(laser1);
laser2 = Primitives.getCylinder(16, 4f, 20f);
laser2.build();
laser2.translate(laserDummy2.getTransformedCenter());
align(laser2, wing2);
theWorld.addObject(laser2);
// laserTarget2 = Object3D.createDummyObj();
laserTarget2 = Primitives.getBox(10, 1);
laserTarget2.build();
moveTowards(laserTarget2, targetCone.getTransformedCenter(), 1f);

laser1.addChild(laserTarget2);
laser2.addChild(laserTarget1);
theWorld.addObject(laserTarget1);
theWorld.addObject(laserTarget2);
laser1.setAdditionalColor(Color.red);
laser2.setAdditionalColor(Color.red);
System.out.println("Laser to Ship Distance: "+calculateDistance(xWing, laser1));
firing = true;
      }
#1608
Support / Re: Ship Rotation
October 29, 2008, 03:53:38 PM
No, I meant it was missing from my code. And I do think the class changed a little, because I don't remember the getKeyEventState() method, but I like it. I'll have to change every program that uses it (lest I get two events, key down and key up, for every key press).
#1609
News / Re: LWJGL 2.0 is out!
October 29, 2008, 12:09:20 AM
Or the lack of a Keyboard.next() check, or both, FYI.
#1610
Support / Re: Ship Rotation
October 29, 2008, 12:06:37 AM
FYI, it was the lack of a Keyboard.next() check that was crashing it. How annoying.
#1611
News / Re: LWJGL 2.0 is out!
October 28, 2008, 09:37:51 PM
Then that's what's been crashing my program, damn you! :-)
#1612
Support / Re: Ship Rotation
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).
#1613
Support / Re: Ship Rotation
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.


      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;
      }
#1614
Support / Re: Ship Rotation
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.
#1615
Support / Re: Ship Rotation
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?
#1616
Support / Ship Rotation
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?
#1617
Support / Re: Why not add a math class?
September 10, 2008, 06:40:40 PM
The hero doesn't rotate at all. And he sometimes rotates awkwardly.
#1618
Support / Re: Why not add a math class?
September 09, 2008, 06:17:19 AM
Oddly that works as often as it doesn't.
#1619
Support / Re: Why not add a math class?
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.
#1620
Support / Re: Why not add a math class?
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?