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 ... 12 13 [14] 15 16
196
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.

197
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)?

198
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?

199
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);
}

200
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>

201
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?


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

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

204
Support / Performance Loss With Rendering 3D-2D-3D
« on: April 24, 2009, 04:23:40 am »
I'm writing a 2.5D RPG engine and sometimes a 2D object will have to be in front of some 3D ones, and behind others. I expect I'll draw the FrameBuffer, then get its graphics and draw the 2D object, then set all the behind 3D objects to invisible and draw the buffer again. Is that insanely slow? And Egon, a small request: World.setAllVisible(boolean), so that I need not know what's added to the world to set everything to invisible.

205
Support / Hardware jpct-lwjgl Applets
« on: April 23, 2009, 12:33:47 am »
I'm trying to make hardware jpct-lwjgl applets that use the joystick and 3D hardware. All three of the first ones have failed to render anything to the screen (except for when on the third one I was using jpct's software renderer). Check out the code of this incredibly simple applet and remember it worked on software rendering (without the canvas). As it is, I get a black screen (nothing renders). By the way, although I'm only using ambient light on this one, the other two had other lights positioned around the world.

Code: [Select]
import java.applet.*;
import java.awt.*;
import com.threed.jpct.*;
import com.threed.jpct.util.Light;
import org.lwjgl.opengl.*;
import org.lwjgl.input.*; //JOYSTICK AND OPENGL-MODE KEYBOARD

public class SimpleApplet3D extends Applet implements Runnable {
      private Object3D object;
      private World theWorld;
      private FrameBuffer buffer;
      private Camera theCamera;
      private boolean keepGoing;
      private Controller joystick;
      private Canvas theCanvas;

      public void init() {
object = Loader.load3DS("c:/MyPrograms/3D/SimpleApplet/Girl.3DS", 1f)[0];
buffer = new FrameBuffer(800, 600, FrameBuffer.SAMPLINGMODE_NORMAL);
buffer.enableRenderer(IRenderer.RENDERER_OPENGL);
buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
Config.maxPolysVisible *= 3;
theWorld = new World();
theCamera = theWorld.getCamera();
this.add(theCanvas = buffer.enableGLCanvasRenderer());
Controllers controllers = new Controllers();
try {
      controllers.create();
      if (controllers.getControllerCount() > 0) {
joystick = controllers.getController(0);
System.out.println("Got the joystick. Its name: "+joystick.getName());
      }
}
catch (org.lwjgl.LWJGLException e) {}
theWorld.addObject(object);
theWorld.setAmbientLight(65, 65, 65);
keepGoing = true;
      }
      public void start() {
Thread appletLoop = new Thread(this);
appletLoop.start();
      }
      private void draw() {
buffer.clear(Color.black);
theWorld.renderScene(buffer);
theWorld.draw(buffer);
buffer.display(theCanvas.getGraphics());
// buffer.displayGLOnly();
      }
      public void run() {
while (keepGoing) {
      if (joystick != null) {
theCamera.moveCamera(Camera.CAMERA_MOVEIN, joystick.getYAxisValue());
      }
      draw();
      try {
Thread.sleep(50);
      }
      catch (InterruptedException e) {}
}
      }
      public void stop() {
keepGoing = false;
      }
      public void destroy() {}
}

206
Support / lwjgl Joystick
« on: April 16, 2009, 08:20:45 pm »
I have two programs. One uses an AWT window and initializes the FrameBuffer like this:
Code: [Select]
buffer = new FrameBuffer(width, height, SAMPLINGMODE_NORMAL);
buffer.enableRenderer(IRenderer.MODE_OPENGL);
Then (after World.renderScene(buffer) and World.draw(buffer)) calls buffer.display(Graphics). The other, like this:
Code: [Select]
buffer = new FrameBuffer(width, height, SAMPLINGMODE_HARDWARE_ONLY);
buffer.enableRenderer(IRenderer.RENDERER_OPENGL);
then makes only buffer.displayGLOnly() calls. Oddly, the first program initializes and uses the lwjgl joystick succesfully whereas the second one can't get past controllers.create()! Why oh why?

207
Support / Midi Volume (Not jPCT But Java)
« on: February 03, 2009, 05:48:13 pm »
I've read everything on the subject that I could find by searching Google. Figured somebody here might know. I cannot, for the life of me, change the volume of the midi playback in my program. The following is my code. The last part (before the call to start()) is my attempt at discovering which Synthesizer is attached to the Sequencer. And the very last nested loop was an attempt to change everyone's volume. By the way, if my test for synthesizer.getDefaultSoundbank() == null is valid, I'm using the software synthesizer on my computer.

Code: [Select]
        private void playMidi(String fileName) {
try {
     midiPlayer = MidiSystem.getSequencer(true);
     Synthesizer synthesizer = MidiSystem.getSynthesizer();
     midiPlayer.open();
     synthesizer.open();
     Transmitter transmitter = midiPlayer.getTransmitter();

     if (synthesizer.getDefaultSoundbank() == null) {//MEANING "IF USING HARDWARE (NOT JRE) SYNTHESIZER"
transmitter.setReceiver(MidiSystem.getReceiver());//THIS IS RIGHT FOR HARDWARE
System.out.println("Hardware synthesizer!");
     }
     else {
transmitter.setReceiver(synthesizer.getReceiver());//SYNTHESIZER.GETRECEIVER() IS RIGHT FOR SOFTWARE

System.out.println("Software synthesizer in use!");
     }

     midiPlayer.setSequence(MidiSystem.getSequence(new File(fileName)));

     ShortMessage volumeMessage = new ShortMessage();
     int numberOfChannels = synthesizer.getChannels().length;
     for (int i = 0; i < numberOfChannels; i++) {
volumeMessage.setMessage(ShortMessage.CONTROL_CHANGE, i, 7, 5); //7 IS MASTER VOLUME CONTROLLER, 5 IS VOLUME BETWEEN 0-127
transmitter.getReceiver().send(volumeMessage, -1);
     }
System.out.println("Is the sequencer an instance of Synthesizer? "+(midiPlayer instanceof Synthesizer));

     MidiDevice device = MidiSystem.getMidiDevice(midiPlayer.getDeviceInfo());
     java.util.List<Transmitter> transmitters = device.getTransmitters();
     Transmitter[] transmitterArray = new Transmitter[transmitters.size()];
     transmitterArray = transmitters.toArray(transmitterArray);

for (int y = 0; y < transmitterArray.length; y++) {
for (int x = 0; x < 16; x++) {
volumeMessage.setMessage(ShortMessage.CONTROL_CHANGE, y, 7, 5); //7 IS MASTER VOLUME CONTROLLER, 5 IS VOLUME BETWEEN 0-127
transmitterArray[y].getReceiver().send(volumeMessage, -1);
}
}

     MidiChannel[] channels = synthesizer.getChannels();
     for (int i = 0; i < channels.length; i++){
channels[i].controlChange(7, 5);
System.out.println("Can we lower the volume? "+(channels[i].getController(7)!=0));}

     midiPlayer.start();
}
catch (Exception e) {System.out.println("Midi File Error: "+e.getMessage());}

208
Support / Okino Website Claims 3DS Exports Cameras
« on: January 08, 2009, 04:23:21 pm »
Which, come to think, I'm sure I've seen done. Can we PLEASE get that implemented? It would change my life on 3D/2D hybrids like the game on which I'm currently working.

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

210
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?

Pages: 1 ... 12 13 [14] 15 16