Main Menu
Menu

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.

Show posts Menu

Topics - AGP

#201
This error is produced by manager.addTexture("jaguarsk.jpg", new Texture(this.getClass().getResource("RacerModels/Textures"), "jaguarsk.jpg")); but not by 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?
#202
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:
else {//IF HARDWARE RENDERER
      Graphics canvasG = awtGlCanvas.getGraphics();
      buffer.display(canvasG);
      this.paint(this.getGraphics());
      awtGlCanvas.paint(canvasG);
}
#203
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.


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):
<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>
#204
Support / A Little Trigonometry
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?

#205
Support / Texture.setAlpha(int)
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.
#206
Support / World.setAllVisible(boolean)
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.
#207
Support / Performance Loss With Rendering 3D-2D-3D
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.
#208
Support / Hardware jpct-lwjgl Applets
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.

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() {}
}
#209
Support / lwjgl Joystick
April 16, 2009, 08:20:45 PM
I have two programs. One uses an AWT window and initializes the FrameBuffer like this:
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: 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?
#210
Support / Midi Volume (Not jPCT But Java)
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.

        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());}
#211
Support / Okino Website Claims 3DS Exports Cameras
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.
#212
Support / Ship Lasers After Rotation
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.

      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;
      }
#213
Support / Ship Rotation
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?
#214
Support / Why not add a math class?
September 06, 2008, 05:33:30 AM
And include methods like static float calculateAngle(SimpleVector origin, SimpleVector p1, SimpleVector p2)? Until then, if somebody would tell me the code for that I'd be grateful! : -)
#215
Support / Character Moves Towards Mouse Click
August 26, 2008, 09:17:15 PM
I'm trying to make an RPG with 2D backgrounds and a 3D hero. When the player clicks on the screen, the hero has to move that way. The following's what I did (for translation, rotation is something else). Is it wrong, because it's not working?
SimpleVector heroCenter = Interact2D.project3D2D(theCamera, buffer, hero.getTransformedCenter());
SimpleVector destination = Interact2D.reproject2D3D(theCamera, buffer, mousePoint.x-(int)heroCenter.x, mousePoint.y-(int)heroCenter.y, hero.getTransformedCenter().z);
destination.z = destination.y;
destination.y = 0;
hero.translate(destination);
#216
Does it return the number of subsequences in the animation, or does it return the number of frames? Because my MD2 file is supposed to have nearly (or exactly) 260 frames and 4 subsequences, and getSequenceCount() returns 16.0. How do I access the number of frames, and then how do I switch between subsequences? For that matter, how do I access the individual frame names?
#217
Support / Any Way to Speed Up an Animation?
August 18, 2008, 09:44:19 AM
There's not much in the Animation class itself, but is there some way of changing the timing of animations I'm missing?
#218
Support / Cyberkilla, In Case You'll Ever Read This
August 07, 2008, 06:13:01 PM
I found out the location where most of the NullPointerException problems are happening: the method getChild(String) addressed as   XMLElement geometryElement = submesh.getChild("geometry");
on private static OGREVertexBuffer loadGeometry(XMLElement) is returning null! Don't know how to fix it yet, but if you don't come back soon I may have to do it myself! : -(
#219
I understand why you didn't have one at first. And maybe don't even include as the main API. But couldn't you build your own skeletal extension, or else study Cyberkilla's and write a loader? Because his OgreXML loader is both limiting and broken. I could send you my models as proff, if you'd be willing to test them. You'll find they load on Max and Maya, but don't on Cyberkilla's API. And a skeletal structure is such a pivotal thing for most games.
#220
Support / Cyberkilla: About Your Skeletal API Again
July 23, 2008, 09:37:41 PM
Would you be kind enough to get a rigged model from me and send me an OgreXML file that works with your loader? PLEASE? I've tried everything, man. I got a Max 9 exporter, and it doesn't work with complex skeletons. I got a Maya Ogre binary exporter, then used the Ogre tools to get the XML and that didn't work. And I tried optimizing the meshes with OgreCommandLineTools. I used 5 different human models with similarly complex bone structures. All of them crash. PLEASE either convert one for me or send me a human model fully rigged that works with your loader.

By the way, just to clear things up: the exporters all work fine. What always crashes is your loader. And almost always it happens just after all the bones are read and as it's reading the very first mesh.

Or might I suggest a loadOgreXML(Object3D, InputStream, float)? That would help a lot in its own right.