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

Messages - EgonOlsen

#12031
Support / project online? webstart?... how?
September 04, 2004, 07:11:47 PM
Yes, you have to sign them. Have a look at http://wiki.java.net/bin/view/Games/HowToUseWebstart to see how.
#12032
Support / Saving worlds
September 04, 2004, 07:10:32 PM
Yes, you can serialize a world. It has been done by someone here in the forums. Just do a search for it. About writing the world out to XML: Well, the code to do this is there. but it's not active at the moment. I can add it to the next release if this would help.
#12033
Looks like as if the Graphics-instance you are using is null. Check this before calling display(Graphics,....) to see if it's the case. There's not much more in display() that could be null.
#12034
Support / Two little questions
July 15, 2004, 08:24:08 PM
The first call to moveCamera() moves the camera down into the middle of the virtual ellipsoid...or in other words: The ellipsoid collision detection for the camera takes the camera as the ellipsoid's center. But in this case, the ellipsoid is virtually below the camera (i.e. the player looks through his eyes, not his belly). To correct this, the camera is moved half way down, then collision detection is performed, then it's moved up again. If you remove the line you mentioned, the camera will be moved down and down and down...half the radius every frame and the ellipsoid collision detection can only avoid collisions but it can't push you out of existing ones reliable. That's the reason why you fall through the floor.
The other problem may be related to model complexity. The visibility list has a fixed size. Try to adjust this size (http://www.jpct.net/doc/com/threed/jpct/Config.html#maxPolysVisible) and see if it helps. You have to do this before instantiating your world.

Hope this helps.
#12035
Projects / Re: Thanks
July 11, 2004, 05:40:35 PM
Quote from: "Crowley"As far as the engine is concerned, we aren't actually looking down from above, but from the side, along the Z-axis.
Shouldn't matter that much. The code may still work with some additional rotation magic applied to it. In fact, i wrote a little demo application for myself, where a MD2-model was moving towards the mouse. The camera was looking from somewhere between z and y axis down to the origin and it worked fine.
#12036
Support / Particle Systems.
July 05, 2004, 08:39:41 PM
There is no such thing like a built in particle system. If you want use one, you'll have to do it yourself, i'm afraid. However, that shouldn't be too difficult...for example, you can use billboarded Object3Ds to implement it.
#12037
Support / Retriving obj’s position value
July 05, 2004, 07:24:31 PM
checkForCollision is more or less a relic from the past of jPCT. It doesn't return a SimpleVector like the others do. It just returns an ObjectID. Anyway, i don't think that you'll get satisfying results with it, so don't bother with it too much. About the ellipsoid collision detection: That's hard to tell without knowing/seeing what you are actually doing. You may try to enable a different mode for ellipsoid collision detection by doing a call tosetEllipsoidMode(Object3D.ELLIPSOID_TRANSFORMED);
The default behaviour of ellipsoid collision detection is ELLIPSOID_ALLIGNED which may lead to unsatistfying results in your case.
#12038
Support / Retriving obj’s position value
July 02, 2004, 02:49:05 PM
Edit: Now i see...you are setting the collision mode wrong. You can't set SELF and OTHERS one after the other...you have to set them both at a time by doing a setCollisionMode(...SELF | ...OTHERS);

And my former posting:

It may also be a "problem" with the size of your objects. Try to set Config.collideOffset to higher values (try some very high value like 10000 first) and play around with the size of the sphere (the 10f in the example code that i gave you). The sphere is virtually positioned around the object's center. Maybe it just doesn't touch the obstacles with a radius of 10f from this position.
#12039
Projects / Project AuNG/zG
July 01, 2004, 10:07:33 PM
And by the way: Nice project... :D
#12040
Projects / Project AuNG/zG
July 01, 2004, 10:06:45 PM
Assuming that you are looking at your sprite from above (i.e. down the y-axis), this code may serve as a starting point (you just have to draw yourself an arrow-texture with the arrow pointing up to test it):

One last thing: Please use this code with the updated jPCT 1.02 from today. The version from yesterday had a bug in it that this code will suffer from).

import java.io.*;

import java.awt.*;
import java.awt.event.*;
import com.threed.jpct.*;
import com.threed.jpct.util.*;

class TargetDemo {
 
  private FrameBuffer buffer=null;
  private World theWorld=null;
  private TextureManager texMan=null;

  private int width=640;
  private int height=480;

  private Frame frame=null;
  private Graphics gFrame=null;
  private int titleBarHeight=0;
  private int leftBorderWidth=0;

  private boolean exit=false;
  private KeyMapper keyMapper=null;
 
  private int mouseX;
  private int mouseY;
  private Object3D arrow=null;

  public static void main(String[] args) {
     new TargetDemo();
  }

  private TargetDemo() {

     theWorld=new World();
     texMan=TextureManager.getInstance();

     Config.fadeoutLight=false;
     theWorld.setAmbientLight(255, 255, 255);

     texMan.addTexture("arrow", new Texture("textures"+File.separatorChar+"arrow.jpg"));

     arrow=Primitives.getPlane(1,10);
     arrow.setTexture("arrow");
     arrow.setTransparency(1);
     arrow.rotateX((float) (Math.PI/2d));
     arrow.rotateMesh();
     arrow.setRotationMatrix(new Matrix());
     arrow.build();
     theWorld.addObject(arrow);
     
     theWorld.getCamera().setPosition(0,-100,0);
     theWorld.getCamera().rotateCameraX((float) (Math.PI/2d));
         
     Config.tuneForOutdoor();
     initializeFrame();

     gameLoop();
  }

  private void initializeFrame() {
     frame=new Frame();
     frame.setTitle("jPCT "+Config.getVersion());
     frame.pack();
     Insets insets=frame.getInsets();
     titleBarHeight=insets.top;
     leftBorderWidth=insets.left;
     frame.setSize(width+leftBorderWidth+insets.right, height+titleBarHeight+insets.bottom);
     frame.setResizable(false);
     frame.show();
     gFrame=frame.getGraphics();
     keyMapper=new KeyMapper(frame);
     frame.addMouseMotionListener(new MouseMotionAdapter(){
        public void mouseMoved(MouseEvent e) {
           mouseX=e.getX()-frame.getInsets().left;
           mouseY=e.getY()-frame.getInsets().top;
        }
     });
  }

  private void display() {
     buffer.display(gFrame, leftBorderWidth, titleBarHeight);
  }

  private void gameLoop() {

     World.setDefaultThread(Thread.currentThread());
     Thread.currentThread().setPriority(Thread.NORM_PRIORITY);

     buffer=new FrameBuffer(width, height, FrameBuffer.SAMPLINGMODE_NORMAL);
     buffer.enableRenderer(IRenderer.RENDERER_SOFTWARE);
     buffer.setBoundingBoxMode(FrameBuffer.BOUNDINGBOX_USED);

     while (!exit) {
       
           poll();
           buffer.clear();

           theWorld.renderScene(buffer);
           theWorld.draw(buffer);

           buffer.update();
           display();
           
           // Rotation stuff
          SimpleVector arrowCenter=Interact2D.projectCenter3D2D(buffer, arrow);
          if (arrowCenter!=null) {
             arrowCenter.z=0;
             SimpleVector delta=arrowCenter.calcSub(new SimpleVector(mouseX, mouseY, 0));
 
             delta.z=delta.y;
             delta.x*=-1;
             delta.y=0;
 
             Matrix rotMat=delta.getRotationMatrix();
             arrow.setRotationMatrix(rotMat);
 
             if (delta.length()>5) {
                // Move the arrow slowly...
                SimpleVector t=arrow.getZAxis();
                t.scalarMul(0.1f);
                arrow.translate(t);
             }
          }
           
          Thread.yield();
     }

     keyMapper.destroy();
     System.exit(0);
  }

 
  private void poll() {
     KeyState state=null;
     do {
        state=keyMapper.poll();
        if (state!=KeyState.NONE) {
           keyAffected(state);
        }
     } while (state!=KeyState.NONE);
  }


  private void keyAffected(KeyState state) {
     int code=state.getKeyCode();
     boolean event=state.getState();

     switch (code) {
        case (KeyEvent.VK_ESCAPE): {
           exit=event;
           break;
        }
     }
  }
}
#12041
News / Version 1.02 has been released!
July 01, 2004, 09:42:03 PM
I've just uploaded a silent update that fixes two small bugs in Interact2D and various lookAt()-related stuff.
#12042
Support / Retriving obj’s position value
July 01, 2004, 06:17:28 PM
NEVER do this:

feritoID != "none"

This will always be true, because Strings are immutable in Java, so even if the text of the Strings is the same, these are two different instances and therefor, your != will always be true. Always check Strings for equality by using equals(). But that aside, i obviously wasn't clear enough on how translate() works.
translate() translates RELATIVE to the current position, i.e. if you want the object to travel 0.1 units in x-direction, you simply do translate(0.1,0,0). In your code, you are translating by the current position+, i.e. if your current position is (10,0,0) and you add 0.1 to x, you'll translate by (10.1,0,0). That explains the jumps your are experiencing.
And collision detection can only work if applied...it's not implicit when doing a translation.
In your case, this will somehow look like this (the 5f and 10f are wild guessing from me here):

if ((obj_up) && (!feritoID.equals("none"))){
                   
  Object3D oggetto=theWorld.getObjectByName(feritoID);
  SimpleVector trsl= new SimpleVector(5f,0f,0f);
  trsl=oggetto.checkForCollisionSpherical(trls, 10f);
  oggetto.translate(trsl);
                         
}


Have a look at the documentation and/or the manual for the different collision detection methods jPCT offers and see what's best suited for your application. Make sure that your Object3Ds are having the appropriate collision modes set.
And last but not least: Don't do this in timer(). It's a bad habbit i had in the past and it sadly made it into the bounce sources and earlier fps-sources. Have a look at the refactored source of fps or the new car-example to see how to do it in a better way.
#12043
News / Version 1.02 has been released!
June 30, 2004, 11:11:11 PM
Changes are documented here: http://www.jpct.net/changes.html

In addition to these API-modifications, the distribution has changed too. The terrain-example has been removed and a new, more complex example (the car-example) has been added. The jars of the examples are no longer containing the whole API...just their own classes. This reduces download size slightly.
The fps-example makes use of the new KeyMapper-class in util now.

Have fun!
#12044
Support / Retriving obj’s position value
June 30, 2004, 07:37:49 PM
You can get the position, i.e. the current translation from the object by calling getTranslation(). But thats the translation relative to the object's origin that can be set using setOrigin(). If you do so, you have to add your origin's coordinates to the value retrieved by getTranslation().
However, to move your object, this is not required at all. Just call translate() to move the object relative to it's current position.

Hope this helps.
#12045
News / Working on new example
June 30, 2004, 01:02:09 AM
It still exists...it will make it in jPCT 1.02...there are plants now that you can shoot for no particular reason and a radar showing their positions.