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

Pages: 1 ... 783 784 [785] 786 787 ... 823
11761
Support / Getting an object from a World
« on: September 10, 2005, 01:03:35 pm »
If you want to do it that way, you have to set the name yourself by using setName(<String>) for the objects in question, i.e. after loading your object, call obj.setName("Seleccionador"); before adding it to the world. But you have to make sure that the name is unique for the world the object belongs too. jPCT doesn't check this.
In Paradroidz, i'm using a subclass of World called Level that holds references to XXXManagers, which are in fact object pools. I.e. an EnemyManager manages all the enemies, an ExplosionManager manages all the explosion...that way, it's always possible to access your objects without retrieving them back from the world. But that's totally up to you, it's just one way of doing it that i wanted to share...it doesn't have to be the best one.

11762
Support / Videos
« on: September 10, 2005, 12:54:49 pm »
Have a look at the Java Media Framework (jmf). But as far as i've heard, it's quite complicated to use and doesn't work too well. But it's the only possibility that i know of. I've never used it myself.

11763
Support / Re: I did it
« on: September 06, 2005, 10:49:26 am »
Quote from: "Melssj5"
A suggestion is to do a method that only checks for a collision, it may be useful.
It is there. checkCollisionEllipsoid does exactly that. Again, the fps example should help to clarify this.

11764
Support / Using the mouse when using OpenGL
« on: September 06, 2005, 10:47:07 am »
Mouse is provided by LWJGL. It is "automagically" associated with the OpenGL frame. You simply create the OpenGL frame, then the Mouse and it should work fine.

11765
Support / Whats wrong with my collision detection
« on: September 06, 2005, 10:39:20 am »
Sorry for confusing you with the methods' naming.  In earlier versions, naming was different (something like moveCameraCollision IIRC, which was bogus too). But i agree that the naming is not that good. I just couldn't come up with anything better at that time and now...now i'll leave it this way... :wink:

11766
Bugs / 3ds models and mirrored objects
« on: September 06, 2005, 12:58:50 am »
Have you found a solution? This mirroring seems to be a *strange* feature. I've downloaded the 3ds you are using in your applets from your site and loaded it into DeepExploration (a mighty viewer/converter for all kinds of 3d and 2d files) and while it manages to mirror the parts in question, it "inverts" them, so that the back faces are visible while the front faces are not. So it's also wrong...just different...

11767
Support / Detecting OpneGL capability
« on: September 05, 2005, 06:14:23 pm »
To detect if OpenGL is possible, you may get the video modes by calling
FrameBuffer.getVideoModes(IRenderer.RENDERER_OPENGL);
If it returns a none empty array, OpenGL is supported. But that doesn't mean that your SIS651 correctly supports it. SIS is known for crappy drivers and the SIS651 is a joke of a graphics chipset. I also think some people reported problems with SIS and LWJGL but i'm not sure...

11768
Support / Using the mouse when using OpenGL
« on: September 05, 2005, 06:08:07 pm »
Here it is. It may contain some Paradroidz specific stuff, but it should help to get you started.

Code: [Select]
package naroth.util;

import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;

import org.lwjgl.input.*;
import com.threed.jpct.*;

import naroth.config.*;

public class MouseMapper extends MouseMotionAdapter implements MouseListener {

   public final static int BUTTON1=0;
   public final static int BUTTON2=1;

   private boolean lwjgl;
   private Frame frame=null;
   private java.awt.Cursor oldCursor=null;
   Robot robot=null;
   private int mouseX=0;
   private int mouseY=0;
   private boolean button1=false;
   private boolean button2=false;
   private boolean button3=false;
   private boolean hidden=false;


   public MouseMapper() {
      init(null);
   }

   public MouseMapper(Frame comp) {
      try {
         robot=new Robot();
      } catch (Exception e) {
          Logger.log("Error initializing awt.Robot: "+e.getMessage(), Logger.ERROR);
      }
      init(comp);
   }

   public void mouseMoved(MouseEvent e) {
     mouseX=e.getX()-frame.getInsets().left;
     mouseY=e.getY()-frame.getInsets().top;
   }

   public void mouseDragged(MouseEvent e) {
      mouseX=e.getX()-frame.getInsets().left;
      mouseY=e.getY()-frame.getInsets().top;
   }

   public void mouseClicked(MouseEvent e) {}

   public void mousePressed(MouseEvent e) {
      if (e.getButton()==MouseEvent.BUTTON1) {
         button1=true;
      }
      if (e.getButton()==MouseEvent.BUTTON2) {
         button2=true;
      }
      if (e.getButton()==MouseEvent.BUTTON3) {
         button3=true;
      }
   }

   public void mouseReleased(MouseEvent e) {
     if (e.getButton()==MouseEvent.BUTTON1) {
        button1=false;
     }
     if (e.getButton()==MouseEvent.BUTTON2) {
        button2=false;
     }
     if (e.getButton()==MouseEvent.BUTTON3) {
       button3=false;
    }

  }

  public void mouseEntered(MouseEvent e) {}

  public void mouseExited(MouseEvent e) {}



   public void center() {
      if (frame!=null) {
         int x=frame.getX();
         int y=frame.getY();
         int width=frame.getWidth();
         int height=frame.getHeight();
         width=width>>1;
         height=height>>1;
         x+=width;
         y+=height;
         robot.mouseMove(x,y);
      } else {
         // Tu nix...dies ist schon automatisch durch das Mouse.setGrabbed() erledigt.
      }
   }

   public void hide() {
     if (frame!=null) {
        oldCursor=frame.getCursor();
        int[] pixels=new int[16*16];
        Image image=Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(16, 16, pixels, 0, 16));
        java.awt.Cursor transparentCursor=Toolkit.getDefaultToolkit().createCustomCursor(image, new Point(0, 0),"hidden");
        frame.setCursor(transparentCursor);
      } else {
         Mouse.setGrabbed(true);
      }
      hidden=true;
   }

   public void show() {
      if (frame!=null) {
         if (oldCursor!=null) {
            frame.setCursor(oldCursor);
            oldCursor=null;
         }
      } else {
         Mouse.setGrabbed(false);
      }
      hidden=false;
   }

   public boolean isVisible() {
      return !hidden;
   }

   public void destroy() {
      if (frame!=null) {
         frame.removeMouseMotionListener(this);
         frame.removeMouseListener(this);
      } else {
         if (Mouse.isCreated()) {
            Mouse.destroy();
         }
      }
      show();
   }

   public boolean buttonDown(int button) {
      if (!lwjgl) {
         if (button==BUTTON1) return button1;
         if (button==BUTTON2) return button2|button3;
      }
      return Mouse.isButtonDown(button);
   }

   public int getMouseX() {
      if (!lwjgl) {
         return mouseX;
      } else {
         return Mouse.getX();
      }
   }

   public int getMouseY() {
      if (!lwjgl) {
         return mouseY;
      } else {
         return Configuration.height-Mouse.getY();
      }
   }

   public int getDeltaX() {
      if (!lwjgl) {
         int mouseXCenter=(frame.getWidth()>>1)-frame.getInsets().left; // Korrektur, da mouseMoved und mouseDragged dies auch abziehen
         return mouseX-mouseXCenter;
      } else {
         if (Mouse.isGrabbed()) {
            return Mouse.getDX();
         } else {
            return 0;
         }
      }
   }

   public int getDeltaY() {
      if (!lwjgl) {
         int mouseYCenter=(frame.getHeight()>>1)-frame.getInsets().top; // Korrektur, da mouseMoved und mouseDragged dies auch abziehen
         return mouseY-mouseYCenter;
      } else {
         if (Mouse.isGrabbed()) {
            return Mouse.getDY();
         } else {
            return 0;
         }
      }
   }

   private void init(Frame comp) {
      if (comp!=null) {
         this.frame=comp;
         comp.addMouseMotionListener(this);
         comp.addMouseListener(this);
         lwjgl=false;
         center();
      } else {
         lwjgl=true;
         try {
            if (!Mouse.isCreated()) {
               Mouse.create();
            }
         } catch (Exception e) {
            //e.printStackTrace();
            Logger.log("Couldn't create LWJGL-mouse - initialize the OpenGL renderer first!", Logger.WARNING);
         }
      }
   }
}

11769
Support / FeatureRequest: getLighting()
« on: September 05, 2005, 06:05:31 pm »
I agree. I'll add it.

11770
Bugs / 3ds models and mirrored objects
« on: September 04, 2005, 12:46:37 pm »
I wrote the importer based on a free, reverse engineered documentation from the net. I don't own 3ds, so i can't really verify this. It seems like 3ds doesn't really copy the geometry but stores the former (unmirrored one) with an additional mirror plane or matrix or whatever...i have no clue. Does it help to export the object into another format and reimport it as 3ds in 3ds?

11771
Support / Whats wrong with my collision detection
« on: September 04, 2005, 12:42:23 pm »
Don't use checkCameraCollision()...it's ancient stuff that doesn't work well in all cases. I strongly suggest to use checkCameraCollisionEllipsoid instead. Have a look at the fps example to see how to.

11772
Support / Re: Using the mouse when using OpenGL
« on: September 04, 2005, 12:40:07 pm »
Quote from: "Melssj5"

First is about using the openGL rendering, it opens a new Frame, how can I change the properties of that frame created when enabling the openGL render, for example, changing the title or things like that?

Second: KeyMapper is used to manage key events, but what about the mouse events?

Some properties (like the title) can be configured in Config. Have a look at glWindowName for example.
There is no MouseMapper in the package. I've written a very simple one for Paradroidz. I can post the code on monday, when i'm back home.

11773
Projects / Technopolies
« on: September 01, 2005, 02:52:10 pm »
I just started the client to see if something has changed during my holidays, but it downloads everthing each time i'm starting it (showing stuff like "lwjgl.dll 1576KB/0KB" which is a bit strange) and then hangs when trying to connect to the server (i.e. nothing happens anymore). Any ideas?

11774
News / "Away from keyboard" for 2.5 weeks
« on: September 01, 2005, 09:46:39 am »
Back from Bled/Slovenia...


11775
Support / Reusing Meshes and Colors
« on: August 11, 2005, 04:28:58 pm »
Quote from: "fendres"
i.e. have many properties of the original cloned, just to throw them away.
What do you mean by "throw them away"? You are using the objects, aren't you? As mentioned, the mesh is only a part of an Object3D. It doesn't contain texture coordinates, color information etc. There's no way to render a textured, lit object without them! If you worry about memory usage, you are save to set Config.saveMemory to true before creating Worlds and Object3Ds. It may help to reduce memory usage in some cases.

Pages: 1 ... 783 784 [785] 786 787 ... 823