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

#11671
Projects / Technopolies
December 15, 2005, 05:51:07 PM
Great news! :D  Now you just have to move away from JGF with the webstart version. That site was a nice idea but blah^3 completely ran it into the ground with his "use a sledgehammer to crack a nut and blame others if it doesn't work out"-behaviour...  :cry:
#11672
Support / Object3D not displayed
December 14, 2005, 11:36:27 PM
Loading is fine IMHO. Try
camera_.lookAt(obj.getTransformedCenter()); to see, if this brings the object into view. I think you are somehow looking into the wrong direction. Or maybe just printing out obj.getTransformedCenter() would help to see, if the object is really located where it's supposed to be.
Doing the game logic in another thread is fine as long as you are not manipulating jPCT entities directly in that thread (i.e. don't do translations, rotations, collision detection etc) without synchronizing that with your rendering thread. Doing a rotation in the game logic thread while the render thread is using the matrix for rendering will most likely hurt you sooner or later. Anyway, that shouldn't be the cause of your problem.
#11673
Support / Object3D not displayed
December 14, 2005, 10:09:22 PM
When looking down the z-axis (default, if you don't rotate the view), your model (-480) is behind the camera (-400). Maybe that's the problem?
#11674
Support / small collision detection problem
December 14, 2005, 08:52:21 PM
Yes, midnight...but that's not a problem. I'm only sleeping around 5-6 hours during the week anyway... :wink:

To your problem: I can't spot anything wrong in the code you've posted (that doesn't mean that there isn't, of course). So i did a quick and dirty modification of another example to mimic this behaviour and it works fine for me. Here is the code (maybe it's helpful to find out what's wrong with your code):

import com.threed.jpct.*;
import org.lwjgl.opengl.*;
import java.awt.event.*;
import com.threed.jpct.util.*;

public class MoveTest {

 public static void main(String[] args) throws Exception {
   MoveTest mt = new MoveTest();
   mt.doIt();
 }

 private void doIt() throws Exception {
   FrameBuffer fb = new FrameBuffer(640, 480,
                                    FrameBuffer.SAMPLINGMODE_HARDWARE_ONLY);
   fb.disableRenderer(IRenderer.RENDERER_SOFTWARE);
   fb.enableRenderer(IRenderer.RENDERER_OPENGL);

   World w = new World();
   w.setAmbientLight(255, 255, 255);

   TextureManager tm = TextureManager.getInstance();
   Texture base = new Texture("base.jpg");
   Texture decal = new Texture("decal.jpg");

   tm.addTexture("base", base);
   tm.addTexture("decal", decal);

   int bid = tm.getTextureID("base");
   int did = tm.getTextureID("decal");

   Object3D plane = new Object3D(9);
   plane.setCulling(Object3D.CULLING_DISABLED);

   int bs = 0;

   // Base texture only
   TextureInfo tInf1 = new TextureInfo(bid, -1, -1, 2, -1, -1, 2);
   TextureInfo tInf2 = new TextureInfo(bid, 2, -1, 2, 2, -1, 2);
   plane.addTriangle(new SimpleVector( -10, -10, 30),
                     new SimpleVector( -10, 0, 30),
                     new SimpleVector(0, -10, 30), tInf1);
   plane.addTriangle(new SimpleVector( -10, 0, 30), new SimpleVector(0, 0, 25),
                     new SimpleVector(0, -10, 30), tInf2);

   // 2nd stage used, modulate
   tInf1 = new TextureInfo(bid, 0, 0, 1, 0, 0, 1);
   tInf1.add(did, 0, 0, 1, 0, 0, 1, TextureInfo.MODE_MODULATE);
   tInf2 = new TextureInfo(bid, 1, 0, 1, 1, 0, 1);
   tInf2.add(did, 1, 0, 1, 1, 0, 1, TextureInfo.MODE_MODULATE);
   plane.addTriangle(new SimpleVector(0, -10, 30), new SimpleVector(0, 0, 25),
                     new SimpleVector(10, -10, 30), tInf1);
   plane.addTriangle(new SimpleVector(0, 0, 25), new SimpleVector(10, 0, 30),
                     new SimpleVector(10, -10, 30), tInf2);

   // 2nd stage used, add
   tInf1 = new TextureInfo(bid, 0, 0, 1, 0, 0, 1);
   tInf1.add(did, 0, 0, 1, 0, 0, 1, TextureInfo.MODE_ADD);
   tInf2 = new TextureInfo(bid, 1, 0, 1, 1, 0, 1);
   tInf2.add(did, 1, 0, 1, 1, 0, 1, TextureInfo.MODE_ADD);
   plane.addTriangle(new SimpleVector( -10, 0, 30),
                     new SimpleVector( -10, 10, 30), new SimpleVector(0, 0, 25),
                     tInf1);
   plane.addTriangle(new SimpleVector( -10, 10, 30),
                     new SimpleVector(0, 10, 30), new SimpleVector(0, 0, 25),
                     tInf2);

   // 2nd stage used, blend
   tInf1 = new TextureInfo(bid, 0, 0, 1, 0, 0, 1);
   tInf1.add(did, 0, 0, 1, 0, 0, 1, TextureInfo.MODE_BLEND);
   tInf2 = new TextureInfo(bid, 1, 0, 1, 1, 0, 1);
   tInf2.add(did, 1, 0, 1, 1, 0, 1, TextureInfo.MODE_BLEND);
   plane.addTriangle(new SimpleVector(0, 0, 25), new SimpleVector(0, 10, 30),
                     new SimpleVector(10, 0, 30), tInf1);
   plane.addTriangle(new SimpleVector(0, 10, 30), new SimpleVector(10, 10, 30),
                     new SimpleVector(10, 0, 30), tInf2);

   plane.rotateX( (float) Math.PI / 2f);
   plane.rotateMesh();
   plane.setRotationMatrix(new Matrix());
   w.addObject(plane);
   plane.build();

   Object3D o2 = Primitives.getCone(0.25f);
   o2.rotateX( (float) Math.PI / 2f);
   o2.rotateMesh();
   o2.setRotationMatrix(new Matrix());

   w.addObject(o2);
   o2.setOrigin(plane.getTransformedCenter());
   o2.translate(0, -10, 0);
   o2.build();

   plane.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
   o2.setCollisionMode(Object3D.COLLISION_CHECK_SELF);

   w.getCamera().moveCamera(Camera.CAMERA_MOVEOUT, 10);
   w.getCamera().moveCamera(Camera.CAMERA_MOVEDOWN, 10);
   w.getCamera().lookAt(o2.getOrigin());

   KeyMapper km = new KeyMapper();
   float yRot = 0;
   SimpleVector elr = new SimpleVector(0.25f, 0.25f, 0.25f);

   while (!Display.isCloseRequested()) {
     int key = 0;
     KeyState keys = null;

     // place
     SimpleVector dd = new SimpleVector(0, 1, 0);
     float dist = plane.calcMinDistance(o2.getTransformedCenter(), dd, 40);
     if (dist != Object3D.COLLISION_NONE) {
       dd.scalarMul(dist - 0.5f);
       o2.translate(dd);
     }

     // rotateY
     o2.getRotationMatrix().setIdentity();
     o2.rotateY(yRot);

     if ( (bs & 1) == 1) {
       yRot += 0.1f;
     }
     if ( (bs & 2) == 2) {
       yRot -= 0.1f;
     }

     //move
     if ( (bs & 4) == 4) {
       SimpleVector a = o2.getZAxis();
       a.scalarMul(0.25f);
       a = o2.checkForCollisionEllipsoid(a, elr, 5);
       o2.translate(a);
     }

     if ( (bs & 8) == 8) {
       SimpleVector a = o2.getZAxis();
       a.scalarMul( -0.25f);
       a = o2.checkForCollisionEllipsoid(a, elr, 5);
       o2.translate(a);
     }

     do {
       keys = km.poll();
       if (keys != KeyState.NONE) {
         key = keys.getKeyCode();
         if (key == KeyEvent.VK_W) {
           bs ^= 4;
         }
         if (key == KeyEvent.VK_S) {
           bs ^= 8;
         }
         if (key == KeyEvent.VK_A) {
           bs ^= 2;
         }
         if (key == KeyEvent.VK_D) {
           bs ^= 1;
         }
       }
     }
     while (keys != KeyState.NONE);

     fb.clear();
     w.renderScene(fb);
     w.draw(fb);
     fb.displayGLOnly();

     Thread.sleep(10);
   }

   km.destroy();
   fb.disableRenderer(IRenderer.RENDERER_OPENGL);
   System.exit(0);
 }
}
#11675
Support / Re: small collision detection problem
December 14, 2005, 01:04:48 AM
Quote from: "manumoi"i.e. whether i push forward or backward,  i always go in the same direction
Which direction is that? I can't see something obviously wrong in your code ATM.
#11676
Support / SWT and JPCT?
December 12, 2005, 05:58:02 PM
For OpenGL support, jPCT uses LWJGL, which can either render into a native window of its own or into an awt canvas. There is no support for SWT in LWJGL as far as i know. And i do know nothing about SWT, so i don't know if it's possible to use that awt canvas inside of SWT by using a kind of hack or whatever.
#11677
Support / Streaming algorithm
December 09, 2005, 12:47:46 AM
Quote from: "radvani7"I'll just manually call the GC whenever I get new polygons.
You don't have to. The VM will do it for you before giving an out of memory error. If it still occurs, there must be a reference somewhere to the objects that should be collected.
#11678
Projects / Raven's projects
December 09, 2005, 12:34:06 AM
Loading them from the jar should definitely work. Can you provide me with a simple test case that doesn't work for you? I could upload it to my webspace and see if that works.
#11679
Support / Re: Streaming algorithm
December 09, 2005, 12:30:36 AM
Quote from: "radvani7"At last, here is my question: Using the GeneralVertexController, am I allowed to change the number of vertices in a Mesh (i.e. replace the whole SimpleVector array)? Or am I only allowed to change the vertex coordinates? Thanks! And any other suggestions would be appreciated. The JPCT framework is great, very fast and easy to use.
No, you can't change the number, but you can initialize it with a number "high enough" and simply set unused vertices to coords out of view. That what i'm doing for the fog of war in Paradroidz. However, i'm not sure that the VertexController is a good idea, because you would have to calculate normales yourself and can't modify the texture coords. Why don't you simply create new Object3Ds from your data stream and discard old ones? If you are not referencing them yourself somewhere, the garbage collector will clean them up after you've removed them from your world. Or did i get you wrong?
#11680
Projects / Raven's projects
December 08, 2005, 12:09:11 AM
Looks like you are not using the correct method to load them. To load them from a server, use the URL-version of the loading methods, to load them from a jar-file, use the InputStream variants. You can get the InputStream like so: this.getClass().getClassLoader().getResourceAsStream(<your file>);
#11681
Projects / Raven's projects
December 07, 2005, 11:42:27 PM
Quote from: "Raven"
1) The scans are placed on a thin slice as a texture, the slices (object3D's) are then made transparent(0), however -- it's still very hard to see "inside" the brain without moving the slices further apart.
0 is the lowest possible setting for transparency in the software renderer, so there's no way to make them more transparent when not using hardware. Maybe picking a slice with the mouse is an option. If it's picked, you could temporary remove all slices above or make the picked slice slide out somehow.

Quote from: "Raven"
In the actual applet you can swirl the scans around using the arrow buttons, but unfortunately my service provider doesn't allow applets to read files (textures) from the server itself. So I only have images to show.
How it that done and why? It should be quite transparent for the server if a browser is reading the files or an applet is. However, how about putting the files in the applet's jar and load them from there.

Oh, and...nice brain... :wink:
#11682
Feedback / AN ask for Egon
December 07, 2005, 07:18:02 PM
Quote from: "EgonOlsen"Yes. It's not forgotten, just delayed. I should be able to upload it next week.
DONE.
#11683
Projects / Imperio - Galaxy-wide strategy
December 07, 2005, 05:17:10 PM
Quote from: "raft"i once thought of a object or polygonRendered method to add to paintListener interface but Egon said it wont do the trick since rendering is done from front to back for optimization purposes (Egon please correct me if i remember it wrong)
No, you are remembering that correctly. That's one reason why it doesn't work, but there are others too. The one and correct way to do it, would be to write into the zBuffer when  doing 2d blitting in these cases but that's not a good idea for other reasons.
#11684
Projects / Ripples - 4k game
December 07, 2005, 01:00:20 AM
This is not exactly jPCT related but anyway (read: It's my forum...i can post whatever i want to... :wink: ). It's a crazy shoot 'em up that i've written for a 4k competition. It started out as a kind of tetris with water. See what it is now: http://www.jpct.net/4k/ripples

Note: It's slow on Macs for whatever reason. I don't know why and i don't really care for now.
#11685
Feedback / AN ask for Egon
December 03, 2005, 01:03:45 PM
Yes. It's not forgotten, just delayed. I should be able to upload it next week.