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 ... 10 11 [12] 13 14
166
Support / Object3D.getTransformedCenter() of Current Mesh
« on: September 10, 2009, 11:09:14 pm »
One of my models unfortunately moves forward on his own (as opposed to simply moving its legs) so that, obviously, it moves back when the animation loops. The following method doesn't work because the center is the same for both the start and end of the animation (I'm guessing it's right in the middle of the extremes). Is the answer along the lines of a VertexController or is there a simpler way to get different centers for both the first and last frames?

Code: [Select]
   private void advance() {//THEY WALK FORWARD BY THEMSELVES, THEN, WHEN ANIMATION LOOPS, GO BACK TO THEIR STARTING POINT...
model.calcCenter();
SimpleVector currentPosition = model.getTransformedCenter();
model.animate(animationPosition, currentAnimation);
model.calcCenter();
moveTowards(model, currentPosition, 1f);/**THIS WOULD WORK IF model.getTransformedCenter() DIDN'T RETURN THE SAME VALUE AS currentPosition*/
    }

167
Support / Is there a means by which to count the polygons in a world?
« on: September 07, 2009, 02:41:23 am »
By my count I shouldn't have passed my specified number, but jpct tells me I have. How could I get a count (without getting into the vertex controllers)? I've looked but couldn't find one such method. If none exists, perhaps just changing the error message to include current number of polygons would do.

168
Support / Why Can I Never Export (or Otherwise Import) 3ds Animations?
« on: August 22, 2009, 12:36:33 am »
Is there something different I should do when importing an animated 3ds model than when I import an MD2 (MD2 works for me but is bigger and uses more RAM)?

169
Support / Can't Rotate an Object By Its Center
« on: August 11, 2009, 12:05:01 am »
I tried everything both in MAX and in my program. The 3dsmax pivot is at the very center of the object and I get the desired effect on MAX, but Object3D.rotateAxis(Object3D.getZAxis(), float) simply won't rotate my model exactly in its center. I even tried writing a VertexController to get the objectspace center then apply to that the object's world transformation and set the object's new center, but that failed as well! Is it my code or is it jpct's?

Code: [Select]
currentMission.groundModel.build();
SimpleVector newCenter = new VertexController(currentMission.groundModel).getCenter();
newCenter.matMul(currentMission.groundModel.getWorldTransformation());
currentMission.groundModel.setCenter(newCenter);

// camera.setPosition(newCenter);
// camera.moveCamera(Camera.CAMERA_MOVEOUT, 10f);

while (currentMission.missionName.equals("Mission Briefing Room")) {
keyboardAndJoystick();
draw();
currentMission.groundModel.rotateAxis(currentMission.groundModel.getZAxis(), .02f);

//       currentMission.groundModel.rotateZ(.02f);
// awtGlCanvas.getGraphics().drawLine(this.getWidth()/2, 0, this.getWidth()/2, this.getHeight());
// awtGlCanvas.getGraphics().drawLine(0, this.getHeight()/2, this.getWidth(), this.getHeight()/2);
if (!paused) {}
try {
Thread.sleep(50);
}
catch (InterruptedException e) {System.err.println("Trouble sleeping: "+e.getMessage());}
}

170
Support / ship.align(plane) IN MULTIPLE ITERATIONS
« on: July 20, 2009, 07:23:03 pm »
I'm trying to achieve the equivalent of ship.align(plane) (leveling the ship) in multiple iterations. This is what I have. What I'm getting instead is the exact same thing as ship.align(plane): it aligns the ship to the plane in a single pass. Shouldn't lastRotation.interpolate(Matrix, Matrix, .1f) take care of only rotating 10%?

Code: [Select]
if (shipLeveling == 10) {
      lastRotation = plane.getRotationMatrix();
      shipLeveling = 0;
}

Matrix softMatrix = ship.getRotationMatrix();
lastRotation.interpolate(lastRotation, softMatrix, 0.1f);// interpolate between the matrices
Matrix matrix = new Matrix(lastRotation);
ship.setRotationMatrix(matrix);
shipLeveling++;

171
Support / Draw distance seems to shrink every time I draw an Overlay
« on: July 13, 2009, 08:59:45 pm »
And the Overlay itself doesn't show. The first lines are how I initialized the Overlay, the second are in my collision(CollisionEvent) method.

Code: [Select]
explosionPlane = new Overlay(theWorld, buffer, "explosion2.gif");
explosionPlane.setVisibility(false);

Code: [Select]
explosionPlane.setSourceCoordinates((int)point.x-explosion.getWidth()/2, (int)point.y-explosion.getHeight()/2, (int)(point.x+explosion.getWidth()/2), (int)(point.y+explosion.getHeight()/2));
explosionPlane.setVisibility(true);

172
Support / KeyMapper Class
« on: June 22, 2009, 11:44:50 pm »
Egon suggested I used the KeyMapper class to improve keyboard-input-reading for the racing game, and so it is that I am. Problem is, the input is at least as bad as it was before with the following code. The idea is that the car speeds up while you're holding down the UP key and slows down when you're holding DOWN, but in practice it only speeds up and slows down when I press, release, and press again. keyPressed at VK_UP sets speedingUp to true, and at VK_DOWN sets slowingDown to true. Shouldn't the car speed up with every loop iteration? It turns just fine. And I did remove the awt KeyListener, by the way, I'm just using its keyPressed because I'm being lazy.

Code: [Select]
      KeyState state = keyMapper.poll();
      if (state.getState() == KeyState.PRESSED || (speedingUp && state.getKeyCode() == KeyEvent.VK_UP) || (slowingDown && state.getKeyCode() == KeyEvent.VK_DOWN))
keyPressed(new KeyEvent(this, KeyEvent.KEY_PRESSED, System.currentTimeMillis(), 0, state.getKeyCode(), KeyEvent.CHAR_UNDEFINED));

173
Support / Very Very Simple C Question
« on: June 20, 2009, 07:27:27 pm »
I figure at the very least paulscode and Egon will know: what does the line "typedef struct animation Animation" do in a header file? I see no other defining reference to animation (lower or upper case) anywhere in this little assignment. I haven't done C programming in so long, I forgot more than I knew I had known. And to clarify, the assignment uses Animation* pointers a lot, I meant that this line is the only part that defines it.

174
Support / Using FrameBuffer's Graphics With AWTGLCanvas
« on: June 17, 2009, 11:27:18 pm »
I actually solved the ArrayIndexOutOfBoundsException. That little program I had written over a few years (it was the first one I built with jPCT) and it uses both the software and the hardware renderer (not at the same time obviously). And in changing it a million times I had introduced a stupid glitch in which I called run in one part of it (one attempt at getting the non-canvas OpenGL renderer to use the software loop), and started a separate thread that called it. So sometimes, draw() was being called twice at the same time (and before it draws it moves the objects). So that's that.

But now here's a question: what's the point of using AWTGLCanvas if the FrameBuffer's Graphics object will still be null (or useless, whichever it is)? I can no more use canvas.getGraphics()'s Graphics instance than I could a frame's (I can, but the screen will flicker). So is this a jPCT bug (I hope so)?

175
Support / java.security.AccessControlException: access denied
« on: June 16, 2009, 01:11:06 am »
This error is produced by
Code: [Select]
manager.addTexture("jaguarsk.jpg", new Texture(this.getClass().getResource("RacerModels/Textures"), "jaguarsk.jpg")); but not by
Code: [Select]
background = new javax.swing.ImageIcon(this.getClass().getResource("RacerModels/Textures/CLOUDS1.JPG")).getImage();
The same error is true for manager.add(String, new Texture(this.getClass().getResourceAsStream(...)). What gives?

176
Support / When does ArrayIndexOutOfBoundsException get thrown?
« on: June 11, 2009, 07:42:56 pm »
Since I went from the lwjgl window to the AWTGLCanvas (to get access to awt.Graphics) I've been getting this exception thrown at random times in my program a few seconds into it. I imagine it's some sort of thread synchronization issue, but I'm not quite sure how to solve it. The following are the lines that seem to cause it:
Code: [Select]
else {//IF HARDWARE RENDERER
      Graphics canvasG = awtGlCanvas.getGraphics();
      buffer.display(canvasG);
      this.paint(this.getGraphics());
      awtGlCanvas.paint(canvasG);
}

177
Support / Can't Get this Simple Appet to Work Online
« on: June 09, 2009, 08:16:33 pm »
Locally it runs fine (although it just occurred to me that the jaguar.3DS file is in the same folder as the jar). I've tried variations of the Loader.load3DS line and none of them work either.

Code: [Select]
import java.awt.*;
import java.applet.*;
import com.threed.jpct.*;

public class RacerMusic extends Applet {
      private FrameBuffer buffer;
      private World theWorld;
      private Object3D car;
      private Camera camera;
      private AudioClip music;
      private float cameraToObjectDistance, cameraDisplacement;

      public void init() {
try {
     music = Applet.newAudioClip(this.getClass().getResource("TheSign.wav"));
}
catch (Exception e) {}
buffer = new FrameBuffer(800, 600, FrameBuffer.SAMPLINGMODE_NORMAL);
buffer.enableRenderer(IRenderer.RENDERER_SOFTWARE);
Config.maxPolysVisible = 250000;
Config.collideOffset = 500;
Config.oldStyle3DSLoader = true;
theWorld = new World();
theWorld.setAmbientLight(100, 100, 100);
camera = theWorld.getCamera();
car = Object3D.mergeAll(Loader.load3DS(this.getClass().getResource("./jaguar.3DS"), "jaguar.3DS", 1f));
theWorld.addObject(car);
theWorld.buildAllObjects();
System.out.println("Got this far (past loading the model).");
follow();
System.out.println("Got this far. 2");
      }
      private void follow() {
Matrix matrix = car.getWorldTransformation().invert3x3();
camera.setBack(matrix);
camera.setPosition(car.getTransformedCenter());
camera.rotateCameraX((float)Math.toRadians(100+cameraDisplacement));
camera.moveCamera(Camera.CAMERA_MOVEOUT, cameraToObjectDistance);
      }

      public void paint(Graphics g) {
if (buffer == null || theWorld == null)
     return;
buffer.clear(Color.black);
theWorld.renderScene(buffer);
theWorld.draw(buffer);
buffer.display(g);
      }

      public void start() {
music.loop();
      }
      public void stop() {}
      public void destroy() {}
}

EDIT: The HTML file (I want it to run via AppletLoader):
Code: [Select]
<html>
  <applet code="org.lwjgl.util.applet.AppletLoader" archive="lwjgl_util_applet.jar, lzma.jar" codebase="."

width="800" height="600">
    <param name="java_arguments" value="-Xmx320m">
    <param name="al_title" value="Racer Music v. 0.1">
    <param name="al_main" value="RacerMusic">
    <!-- logo to paint while loading, will be centered -->
    <param name="al_logo" value="Car.gif">
    <!-- progressbar to paint while loading. Will be painted on top of logo, width clipped to percentage done -->
    <param name="al_progressbar" value="appletprogress.gif">
   
    <!-- signed windows natives jar in a jar -->
    <param name="al_windows" value="windows_natives.jar.lzma">

    <!-- List of Jars to add to classpath -->
    <param name="al_jars" value="RacerMusic.jar, Data.jar, jpct.jar, lwjgl_applet.jar.pack.lzma,

lwjgl.jar.pack.lzma, jinput.jar.pack.lzma, lwjgl_util.jar.pack.lzma, res.jar.lzma">
   
    <!-- signed linux natives jar in a jar -->
    <param name="al_linux" value="linux_natives.jar.lzma">
   
    <!-- signed mac osx natives jar in a jar -->
    <param name="al_mac" value="macosx_natives.jar.lzma">

    <!-- signed solaris natives jar in a jar -->
    <param name="al_solaris" value="solaris_natives.jar.lzma">
   
    <!-- Tags under here are optional -->
   
    <!-- Version of Applet, important otherwise applet won't be cached, version change will update applet, must be

int or float -->
    <!-- <param name="al_version" value="0.1"> -->
   
    <!-- background color to paint with, defaults to white -->
    <!-- <param name="al_bgcolor" value="000000"> -->
   
    <!-- foreground color to paint with, defaults to black -->
    <!-- <param name="al_fgcolor" value="ffffff"> -->
   
    <!-- error color to paint with, defaults to red -->
    <!-- <param name="al_errorcolor" value="ff0000"> -->
   
    <!-- whether to run in debug mode -->
    <!-- <param name="al_debug" value="false"> -->
   
    <!-- whether to prepend host to cache path - defaults to true -->
    <param name="al_prepend_host" value="false">

  </applet>

  <p>
    if <code>al_debug</code> is true the applet will load and extract resources with a delay, to be able to see the

loader process.
  </p>

  </body>
</html>

178
Support / A Little Trigonometry
« on: May 30, 2009, 06:32:34 pm »
I need to find the theta of the following triangle. The only trigonometry book I kept from school doesn't answer this very well. Can anyone help?


179
Support / Texture.setAlpha(int)
« on: May 28, 2009, 04:07:29 am »
I thought when I saw this method in the documentation that I would be able to select a texture then say texture.setAlpha(Color.blue.getRGB()), and that would make every blue area completely transparent. Since there's nothing in the docs to explain what it's supposed to do, what exactly is it supposed to do? And more importantly to me, how do I achieve the same result as the one I expected? Thanks in advance.

180
Support / World.setAllVisible(boolean)
« on: April 28, 2009, 01:17:06 am »
Not to rush you in any way, Egon, but I was wondering if you already have a beta of 1.18 with that in so that I don't have to do it differently on my code and have to change it later.

Pages: 1 ... 10 11 [12] 13 14