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 ... 97 98 [99] 100 101 ... 108
Support / Re: Ship Lasers After Rotation
« on: 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).

Support / Ship Lasers After Rotation
« on: 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.

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

System.out.println("Laser to Ship Distance: "+calculateDistance(xWing, laser1));
firing = true;

Support / Re: Ship Rotation
« on: 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).

News / Re: LWJGL 2.0 is out!
« on: October 29, 2008, 12:09:20 am »
Or the lack of a check, or both, FYI.

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

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! :-)

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).

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();
xWing.rotateAxis(xWing.getXAxis(), rotationStored.x);
xWing.rotateAxis(xWing.getYAxis(), rotationStored.y);
xWing.rotateAxis(xWing.getZAxis(), rotationStored.z);
if (!cameraOnTie)
rotationStored.x = 0;
rotationStored.y = 0;
rotationStored.z = 0;

if (!openGL)
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 {
      catch (Exception e) {System.out.println("Keyboard failed: "+e.getMessage());}
      private static void glLoop(RogueSquadron instance) {
int keyCode;

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

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.

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?

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?

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.

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.

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.

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?

Pages: 1 ... 97 98 [99] 100 101 ... 108