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 ... 104 105 [106] 107 108 ... 116
1576
News / Re: Version 1.17 has been released!
« on: December 11, 2008, 07:27:56 pm »
Thanks a lot, buddy, I appreciate your efforts. Now, for that Math class... : )

1577
Support / Re: Ship Lasers After Rotation
« on: November 08, 2008, 10:50:43 pm »
Absolutely right. Sloppy (or stupid, you decide) me. Thanks for holding my hand a little bit on this one. I appreciate it.

1578
Support / Re: Ship Lasers After Rotation
« on: November 08, 2008, 05:45:23 pm »
No, what I meant was that my lasers stop mid-air at what looks like twice the distance between the laserDummy and the targetCone. For some reason, in your applet the laser keeps going, but my code is just like yours as far as I can tell:

Code: [Select]
if (instance.firing) {
      SimpleVector firingVector1 = instance.targetCone.getTransformedCenter().calcSub(instance.laserDummy1.getTransformedCenter());
      SimpleVector firingVector2 = instance.targetCone.getTransformedCenter().calcSub(instance.laserDummy2.getTransformedCenter());

      SimpleVector target1 = instance.targetCone.getTransformedCenter();
      target1.add(firingVector1);

      SimpleVector target2 = instance.targetCone.getTransformedCenter();
      target2.add(firingVector2);
System.out.println("Target2 vector length: "+target2.length());

      instance.moveTowards(instance.laser2, target1, .2f);
      instance.moveTowards(instance.laser1, target2, .2f);
}

1579
Support / Re: Ship Lasers After Rotation
« on: November 08, 2008, 05:13:50 pm »
Now how would you make it so that the lasers don't stop mid-air (just keep going until they're out of sight, assuming they don't hit anything)?

1580
Support / Re: Ship Lasers After Rotation
« on: November 08, 2008, 03:39:57 pm »
Paul, thank you very much. That direction vector will come in handy for the future. And I guess I missed re-reading the docs. I appreciate your time.

1581
Support / Re: Ship Lasers After Rotation
« on: November 08, 2008, 05:40:04 am »
If you notice, that line is more indented than the other ones: it was an attempted (and obviously failed) solution. But you make a good point: maybe neither the align method nor not aligning are working. Maybe I need to align differently. I'll try to answer your question and get right back to you.

1582
Support / Re: Ship Lasers After Rotation
« on: November 08, 2008, 01:03:42 am »
Test case #1: It's not happening. I already tested it without flipping firing to true. The second I rotate the ship I get weird locations for laserTarget. And again, what's odd is that the ship always flies towards targetCone (meaning it's not targetCone.getTransformedCenter()).

1583
Support / Re: Ship Lasers After Rotation
« on: November 07, 2008, 05:31:54 pm »
They show up in different places, like the sides of the ship. So the lasers, which again are aligned perfectly to the ship, fly sideways.

1584
Support / Re: Ship Lasers After Rotation
« on: November 07, 2008, 03:22:22 pm »
Egon, laserCone is the crosshair. In the fireLasers() method I posted, you see the lasers themselves are created at the location of laserDummy (sorry if some of it seems redundant or at least confusing). LaserCone is a visible crosshair, always in the right place, laserDummy are invisible dummy objects that are part of the ship (and are always in the right place). Laser targets (supposed to be invisible but for the purposes of debugging aren't) show up in the right places (directly in front of the lasers) ONLY until the ship is rotated.

Paulscode (is your name Paul?), unfortunately, there's not a lot to test. The game loop is VERY simple. If (firing) moveTowards(laser1, laserTarget1, .2f); kind of simple.

1585
Support / Re: Ship Lasers After Rotation
« on: November 07, 2008, 06:18:33 am »
1) TargetCone is ALWAYS visible. It's a crosshair.
2) In the posted code, the laserTargets are visible and showing up in weird places.
3) They remain stationary if I don't flip the firing variable. They're not supposed to be stationary otherwise.

I don't really think it's my code to be perfectly honest, but I appreciate you trying to help.

1586
Support / Re: Ship Lasers After Rotation
« on: November 07, 2008, 02:51:16 am »
Yes, laserDummy1 and 2 are a child of their wings, and targetCone is a child of the ship. All I really want is for the lasers to fly straight towards the target, but the lasers move much faster than the ship, obviously, and have to pass the targetCone. You have to keep in mind the fact that the ship rotates around any and all axis. And align works fine (the lasers are always aligned). What doesn't work is that the laserTargets show up in weird places.

1587
Support / Re: Ship Lasers After Rotation
« on: November 07, 2008, 12:43:44 am »
Voilá.

Code: [Select]
      private void align(Object3D from, Object3D to) {
// THIS IS EGON'S: As Javadocs state: The default align method doesn't take parent objects into
// account...This method takes parents into account.
float scale = from.getScale();
from.setScale(1);
Matrix matrix = to.getWorldTransformation();
float[] dm = matrix.getDump();
for (int i = 12; i < 15; i++) {
      dm[i] = 0;
}
dm[15]=1;
matrix.setDump(dm);
from.setRotationMatrix(matrix);
from.setScale(scale);
      }

      protected void moveTowards(Object3D toMove, SimpleVector direction, float amount) {
SimpleVector origin = toMove.getTransformedCenter();
float deltaX = (direction.x -origin.x)*amount;
float deltaY = (direction.y -origin.y)*amount;
float deltaZ = (direction.z -origin.z)*amount;

toMove.translate(deltaX, deltaY, deltaZ);
      }

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

1589
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
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;
      }

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

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