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.


Topics - AGP

Pages: 1 ... 8 9 [10] 11 12 ... 16
136
Support / turnTo(SimpleVector)
« on: January 30, 2012, 07:37:05 pm »
I have a ship, and it follows a dummy object directly in front of it. When it reaches a certain distance from the center of the world, I would like to make it turn directly towards the player's ship. For that, I would like to calculate the degree between a direction vector composed of the ship's transformed center and its dummy's transformed center and the player's ship's transformed center. How would I go about doing that?

I've written two simple methods, a turnTo which simply calculates the number of iterations (in x degree segments) that the ship will turn on its Y axis, and a turnAround which turns the number of iterations that turnTo calculated (as follows). So how do I implement turnTo()?

Code: [Select]
      protected void turnAround() { //RUNS THE TURN-AROUND LOOP FOR THE ENEMY FIGHTER
if (!turning && i == numberOfTurnSegs) {
      turning = true;
      i = 0;
}
tieFighter.rotateAxis(enemyShip.getYAxis(), (float)Math.toRadians(10));
gameInstance.moveTowards(enemyShip, tieGuide.getTransformedCenter(), .1f); //THIS MOVES IT FORWARD
i++;

if (i == numberOfTurnSegs) {
      gameInstance.moveTowardsMinusY(enemyShip, tieGuide.getTransformedCenter(), 1f); //GET IT AWAY FROM SKY SO NO MORE COLLISION
      turning = false;
      lastTurn = System.currentTimeMillis();
}
      }

137
Support / Unknown Windows Version (Just a Nitpick)
« on: January 13, 2012, 06:35:18 pm »
Egon, you stubborn (occasionally likeable) man, do you think it's odd jpct still calls Windows 7 an "unknown Windows version?"

Also, is it possible to undo calling an enableCanvasRenderer() call? Does it take disabling the renderer and reenabling it (I'm trying to do the hardware fullscreen-only bit on my game)?

138
Support / Car Example's moveCamera() on X/Y Plane
« on: January 12, 2012, 12:11:34 am »
What's the equivalent of the following code (your car example's camera) for a game on the X/Y plane? I tried switching the Zs and Ys around, but I get weird results. For one thing, my game is of a ship with greater maneuverability than the car and the camera  sometimes ends on opposite sides of the ship (sometimes it's under it, sometimes over it).

Code: [Select]
   private void moveCamera() {
      SimpleVector oldCamPos=camera.getPosition();
      SimpleVector oldestCamPos=new SimpleVector(oldCamPos);
      oldCamPos.scalarMul(9f);

      SimpleVector carCenter=car.getTransformedCenter();
      SimpleVector camPos=new SimpleVector(carCenter);
      SimpleVector zOffset=car.getZAxis();
      SimpleVector yOffset=new SimpleVector(0, -100, 0);
      zOffset.scalarMul(-250f);

      camPos.add(zOffset);
      camPos.add(yOffset);

      camPos.add(oldCamPos);
      camPos.scalarMul(0.1f);

      SimpleVector delta=camPos.calcSub(oldestCamPos);
      float len=delta.length();

      if (len!=0) {
         /**
          * Do a collision detection between the camera and the ground to prevent the camera from
          * moving into the ground.
          */
         theWorld.checkCameraCollisionEllipsoid(delta.normalize(), new SimpleVector(20, 20, 20), len, 3);
      }

      /**
       * And finally: Look at the car
       */
      camera.lookAt(car.getTransformedCenter());
   }

139
I'm printing out FrameBuffer's list of compatible video modes, and using one of them. But the test device.isDisplayChangeSupported() comes back false every time. I'm confused, because display changes are supported (just about every game makes them).

Code: [Select]
      VideoMode[] videoModes = FrameBuffer.getVideoModes(IRenderer.RENDERER_OPENGL);
for (int i = 0; i < videoModes.length; i++)
System.out.println(videoModes[i]);
      buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
      if (engineData.fullScreen) {
GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
System.out.println("Width: "+engineData.width +" Height: "+engineData.height);//COMPATIBLE VALUES
if (!device.isDisplayChangeSupported()) {
     System.err.println("No support for current mode!");return;}//RETURNS EVERY TIME
this.setUndecorated(true);
this.setIgnoreRepaint(true);
device.setFullScreenWindow(this);
device.setDisplayMode(new java.awt.DisplayMode(engineData.width, engineData.height, 32, java.awt.DisplayMode.REFRESH_RATE_UNKNOWN));
      }

140
Support / What prints "Name in hierarchy found: Cylinde387?"
« on: January 07, 2012, 08:58:59 pm »
I'm trying to identify something wrong with my program and need to know what in jpct would print that message.

141
Support / Overlay Behind Nearly Everything With Software Renderer
« on: December 27, 2011, 06:50:21 am »
It's pretty much only in front of the skybox. I'm creating the Overlay as follows.

Code: [Select]
     public void createOverlay(World theWorld, FrameBuffer buffer) {
BufferedImage radarMap = new BufferedImage(targetWidth, targetHeight+5, BufferedImage.TYPE_INT_RGB);
radarMap.getGraphics().drawImage(borders, 0, 5, null);
radarMap.getGraphics().drawImage(logo, targetWidth/2-logo.getWidth(null)/2, 0, null);
Texture radarTexture = new Texture(radarMap);
TextureManager.getInstance().addTexture("SuperRadar", radarTexture);
Overlay over = new Overlay(theWorld, buffer, "SuperRadar");
over.setNewCoordinates(540, 40, 540+targetWidth, 40+targetHeight);
over.setDepth(Config.nearPlane);//THIS WASN'T HERE. I ADDED IT TO TEST WHETHER IT FIXED FOR SOFTWARE (IT DIDN'T)
over.setTransparency(100);
     }

142
Support / Billboarded Planes And Overlay Issues
« on: December 20, 2011, 07:38:10 pm »
I've noticed that on too many video cards, billboarded planes don't work (my animated GIFs come off as black and white for some reason), with both the software or hardware renderer. Also, most of those times the Overlay with TRANSPARENCY_MODE_DEFAULT doesn't work either. Has anybody else complained?

143
Support / Collision with Skybox
« on: December 16, 2011, 08:57:14 pm »
Egon, I have a game that uses a sky sphere object that I wrote years ago. Now I want to convert it to the util.Skybox, because it's so much easier to deal the textures (not to mention easier to find stuff for). Problem is that this game requires me to collide with the sky. I could keep the sphere just for the collision bit, but I'd much rather be able to collide straight with the skybox (for one thing, it would save a good deal of polygons and for another it would be better for future games!). The best way to do this, I think, would be to get a method like Skybox.getObject3D(). Would you be willing to do that?

144
Support / reproject2D3DWS for Walking with Mouse
« on: December 06, 2011, 05:10:01 pm »
What does this method look like with the now-existing reproject2D3DWS? I've been trying everything intuitive and it hasn't been working for me. I'm hoping, by the way, to no longer need the collision bit (so I won't need the 3D planes per screen). Thanks in advance.

Code: [Select]
     private void moveByMouse() {//WALKBYMOUSE; CALLED ONCE TO SETUP THE WALK DIRECTION
mouseWalk = true;
SimpleVector ray = Interact2D.reproject2D3D(theCamera, buffer, mouseX, mouseY);
currentRoom.plane.setVisibility(true);
if (ray != null) {
     SimpleVector norm = ray.normalize();
     Matrix mat = theCamera.getBack();
     mat = mat.invert3x3();
     norm.matMul(mat);

     SimpleVector ws = new SimpleVector(ray);
     ws.matMul(theCamera.getBack().invert3x3());
     ws.add(theCamera.getPosition());

     float f = theWorld.calcMinDistance(theCamera.getPosition(), norm, 1000);
     if (1==1/*f != Object3D.COLLISION_NONE*/) {
SimpleVector offset = new SimpleVector(norm);
norm.scalarMul(f);
norm = norm.calcSub(offset);
SimpleVector heroCenter = hero.getTransformedCenter();
SimpleVector destination = new SimpleVector(norm);
destination.x += theCamera.getPosition().x;
destination.z += theCamera.getPosition().z;
destination.y = heroCenter.y; // Make y the same as for the hero to avoid moving up/down.
hero.setRotationMatrix(destination.calcSub(heroCenter).getRotationMatrix());
target = new SimpleVector(destination);
     }
}
     }

145
Support / There Should be a util.Light.remove(World)
« on: November 30, 2011, 06:21:11 am »
One should be able to remove an added light in the same object-oriented fashion as it was created. Right? Disabling seems to be all one can do, as there seems to be no way (object-oriented or otherwise) to actually remove a light.

146
Support / KeyMapper isn't working with the software renderer...
« on: November 01, 2011, 09:09:57 pm »
...even after I added the premusably redundant line this.addKeyListener(keyMapper). My game loop prints "polling" just before I poll the KeyMapper, but then the state is always RELEASED (with key code 0). Very bizarre. It's worth noting that the pre-game parts of my game are handled on a canvas that I remove from the frame when the game starts. But this.addKeyListener(keyMapper) is being called AFTER the call to remove the canvas.

147
Support / Re: Ortho Rendering part 2
« on: October 28, 2011, 11:06:44 pm »
On a not completely unrelated note, cloneObject() is cloning the object just fine (I can add the new one without getting the "already added" message), but when I try to translate it, it doesn't move. The docs say both objects would share the same mesh data, but I don't think that would be a problem. The following code is printing non-zero values for x and y, but isn't moving the cloned plane:
Code: [Select]
SimpleVector buildingCenter = currentlyBuilding.unitPlane.getTransformedCenter();
SimpleVector center3d = workerStandsWalksDies.getTransformedCenter();
SimpleVector destination = new SimpleVector(center3d.x-buildingCenter.x, center3d.y-buildingCenter.y, 0);
currentlyBuilding.unitPlane.build();
System.out.println("Translated? "+destination);
currentlyBuilding.unitPlane.translate(destination);

148
Support / Picking and 2D Bounds
« on: October 23, 2011, 07:22:08 am »
I'm doing picking with the mouse on objects. I'm creating the textured plane like this:
Code: [Select]
     private Object3D createPlane(String textureName) {
Texture texture = TextureManager.getInstance().getTexture(textureName);
Object3D plane = Primitives.getPlane(1, texture.getWidth()/6);
plane.setTransparency(100);
plane.setTexture(textureName);
plane.setSelectable(Object3D.MOUSE_SELECTABLE);
plane.build();
return plane;
     }

Then I'm trying to get 2D bounds as follows:
Code: [Select]
     public Rectangle getBounds2D(Camera theCamera, FrameBuffer buffer) {
if (sourceMesh == null) {
     VertexController controller = new VertexController(this.unitPlane.getMesh());
     sourceMesh = controller.getSourceMesh();
}
SimpleVector p1 = new SimpleVector(sourceMesh[0]), p2 = new SimpleVector(sourceMesh[1]);
SimpleVector p3 = new SimpleVector(sourceMesh[2]), p4 = new SimpleVector(sourceMesh[3]);
p1.matMul(unitPlane.getWorldTransformation());p2.matMul(unitPlane.getWorldTransformation());
p3.matMul(unitPlane.getWorldTransformation());p4.matMul(unitPlane.getWorldTransformation());
p1 = Interact2D.project3D2D(theCamera, buffer, p1);
p2 = Interact2D.project3D2D(theCamera, buffer, p2);
p3 = Interact2D.project3D2D(theCamera, buffer, p3);
p4 = Interact2D.project3D2D(theCamera, buffer, p4);
float x1 = p1.x, x2, y1 = p1.y, y2;
if (x1 != p2.x)
     x2 = p2.x;
else x2 = p3.x;
if (y1 != p2.y)
     y2 = p2.y;
else y2 = p3.y;
System.out.println("X: "+x1 +" Y: "+y1 +" WIDTH : "+((int)Math.abs(x1-x2)) +" HEIGHT: "+(int)Math.abs(y1-y2));
return new Rectangle((int)x1, (int)y1, (int)Math.abs(x1-x2), (int)Math.abs(y1-y2));
     }

The trouble is that only the same two planes are selectable (the others aren't) and x1 is often negative (and it's always the right values for the same two).

I should add that I've rotated all the objects (but not the camera) by -90 degrees around the X axis so that I'm looking down on them from above (the world is on the X/Y plane).

149
Support / Where Should a Car's Pivot Point Be?
« on: October 15, 2011, 07:42:53 am »
Right in the middle? Between the front or the back wheels?

150
Support / Yet Another Request :- )
« on: October 08, 2011, 09:04:09 am »
A method on World or FrameBuffer or so which you could call before draw() (or maybe a drawWithAxis() or something of the sort) that drew this:


That would be REALLY helpful.

Pages: 1 ... 8 9 [10] 11 12 ... 16