jPCT - a 3d engine for Java > Projects

Project AuNG/zG

(1/2) > >>

Crowley:
AuNG/zG is a codename for a project that has been brewing in my mind for about seven years and now jpct has given me the opportunity to move ahead with it. I've spent the last four days working on creating the basic graphical framework so that I have something to show others, and here it is now, at http://www.zaren.net/the_project

The screeshots don't really show much, but it will show you the direction where I am headed with this game. Any feedback would, of course, be welcome :)

Anonymous:
Reminds me of "Into the eagle's nest" on the CBM64. It looks much better than that of course.:wink:  It's just that it reminds me of it. Is the headless player a 3d model or a sprite?

Anonymous:
Here's a pic of "Into the eagle's nest":

Crowley:
A sprite. Actually, the characters will be made of three sprites - the legs, the torso and the head. This will allow you to aim to one direction and move in another as all the parts can rotate independently. I'm still trying to figure out a way to make the torso turn towards the mouse cursor so that you could use the mouse to aim. (I know, trigonometry is propably the way to go, but I haven't quite figured it out)  :oops:

Basically I am going for the feel of the first two GTA games but with a couple of improvements, such as the aiming. Those who have played the first GTA will remember that aiming was really not that easy at times.

Btw, I'm not able to view the pic at this time as my net connection is acting weird. I can access some servers and some I cant. I'll have to check "Into the eagle's nest" out later.  :)

EgonOlsen:
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).


--- Code: ---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;
         }
      }
   }
}

--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version