Java-Gaming.org Hi !
 Featured games (91) games approved by the League of Dukes Games in Showcase (756) Games in Android Showcase (229) games submitted by our members Games in WIP (842) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
 Show Posts Pages: [1]
 1 Game Development / Newbie & Debugging Questions / Re: Shifting from Java 2D to Java3D Physics on: 2011-05-20 20:55:47 No,it's not the code is working perfect with in java 2D.
2  Game Development / Newbie & Debugging Questions / Re: Shifting from Java 2D to Java3D Physics on: 2011-05-20 00:48:03

as far as my poor knowledge about Java3d, the values should be 1 and 20 or less for Xs and Ys, but the values are like 300 and 400 and above than these...
and trouble means

some time the balls are drawing but not moving

some time going out of the panel

some time moving on little area

some time just stick at one place...

these all happening on my hit and tries to decrease the values but  still i m not getting the normal results.

for me these values are causing all problems as these are set with respect to 2D , but i m unable to fix these:

 1  2  3  4  5  6  7  8 private static final float BOX_WIDTH = 640;        private static final float BOX_HEIGHT = 480;  // Get the ball's bounds, offset by the radius of the ball       float minX = 0.0f + radius;       float minY = 0.0f + radius;       float maxX = 0.0f + BOX_WIDTH - 1.0f - radius;       float maxY = 0.0f + BOX_HEIGHT - 1.0f - radius;
3  Game Development / Newbie & Debugging Questions / Shifting from Java 2D to Java3D Physics on: 2011-05-18 22:17:57
Hi Experts,

I am new to  game physics and really bad in physics and mathematical calculations, i am trying to adapt a simple 2d balls Simulation code for the 3d simulation with java3D library, but i have this problem:

Two things i noted down the values generated by engine,

for
X/Y are too high and minX / minY/ maxY /maxX values are causing troubles and i m unable to select/define/set the default correct/suitable values considering the 3D graphics scaling/resolution while they are set with respect to 2d screen coordinates,

that is my only problem.

this is code :

here how i m drawing the balls:

 1  2  3  4  5  6 for (int i = 0; i < currentNumBalls; i++) {             printTG(objTrans[i], "SteerTG");             trans[i]                   .setTranslation(new Vector3f(ball[i].getX(), ball[i].getY(), 0.0f));             objTrans[i].setTransform(trans[i]);          }
 4 Java Game APIs & Engines / Java 3D / Re: Collision Detection - different object types, or multiple Shape3D objects on: 2011-05-16 22:44:51
5  Game Development / Networking & Multiplayer / The Simplest and Easiest Game Network layer with KRYONET on: 2011-05-02 16:41:54
Hi all,
Hope u all are fine =), I created a simple network layer with kryonet, this can work as a sample application for kryonet.

Game state:

 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38 package org.multiuser.simulation.ballPhysics;/** *  * @author Jibbylala */public class BallState {   /**    *     */   private float X;   private float Y;   public BallState() {         }      public BallState(int x, int y) {      this.X = x;      this.Y = y;   }      public void setX(float f)   {      this.X = f;   }      public void setY(float y)   {      this.Y = y;   }        @Override       public String toString() {                          return "Ball X (" + X + ")"+ ", Y(" + Y + ")";                 }}

The Client:
 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60  61  62  63  64  65  66  67 package org.physics.balls;import java.io.IOException;import org.multiuser.simulation.ballPhysics.BallState;import com.esotericsoftware.kryo.Kryo;import com.esotericsoftware.kryonet.Client;import com.esotericsoftware.kryonet.Connection;import com.esotericsoftware.kryonet.Listener;/** *  * @author Jibbylala */public class SimulationClient {   private Client simulationClient;   private boolean connected = false;   public SimulationClient() {      try {         simulationClient = new Client();         simulationClient.start();         Kryo kryo = simulationClient.getKryo();         kryo.register(BallState.class);         simulationClient.addListener(new Listener() {            public void received(Connection connection, Object object) {               if (object instanceof BallState) {                  BallState ball = (BallState) object;                  System.out                        .println("Received Ball : " + ball.toString());               }            }         });      } catch (Exception e) {         e.printStackTrace();      }      new Thread("Connect") {         public void run() {            try {               simulationClient.connect(5000, Common.DEFAULT_IP,                     Common.DEFAULT_PORT_TCP);            } catch (IOException ex) {               ex.printStackTrace();               System.exit(1);            }         }      }.start();   }   public static void main(String[] argv) {      try {         new SimulationClient();      } catch (Exception e) {         e.printStackTrace();      }   }}

The Server:
 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95  96  97  98  99  100  101  102  103 package org.physics.balls;import java.awt.Color;import java.io.IOException;import java.util.Random;import com.esotericsoftware.kryo.Kryo;import com.esotericsoftware.kryonet.Connection;import com.esotericsoftware.kryonet.Listener;import com.esotericsoftware.kryonet.Server;import org.multiuser.simulation.ballPhysics.BallState;/** *  * @author Jibbylala */public class SimulationServer implements Runnable {           public static final int BOX_WIDTH = 640;   public static final int BOX_HEIGHT = 480;           public static final int BALLS = 1;        private static BallState BS = new BallState(10, 5);        public boolean running = true;   private volatile boolean Play = true;   private long mFrameDelay = 564;   private Box box; // The container box   private Ball[] balls = new Ball[BALLS];   private int port = 54555;   private Server server;   public SimulationServer() throws Exception {      server = new Server();      Thread gameThread = new Thread(this);      Kryo kryo = server.getKryo();      server.addListener(new Listener() {         public void received(Connection c, Object object) {         }         public void disconnected(Connection c) {         }      });      server.bind(port);      server.start();      gameThread.start();      // keep server running      while (running) {         Thread.sleep(100);      }      System.out.println("server started");   }   @Override   public void run() {      while (Play == true) {         System.out.println("Sending game state process start");         int radius = 40;         Random rand = new Random();         int angleInDegree = rand.nextInt(360);         box = new Box(0, 0, BOX_WIDTH, BOX_HEIGHT);         balls[0] = new Ball(BS, "ball" + 0, 0, 50, 40, 14, angleInDegree,               Color.yellow);         for (int i = 0; i < BALLS; i++) {            balls[i].move();            try {               balls[i].collideWith(box);               System.out.println("Sending object state : " + BS);               server.sendToAllTCP(BS);            } catch (IOException e) {               e.printStackTrace();            }         }         try {            Thread.sleep(mFrameDelay);         } catch (InterruptedException ie) {         }      }   }       public static void main(String[] args) {      try {         new SimulationServer();      } catch (Exception e) {         e.printStackTrace();      }   }}

enjoy!

P.S: I m sending this time single object, I will update this for sending the multiple objects (array of objects) and some complex objects, which exploit KRYO Serialization capabilities.
 6 Game Development / Networking & Multiplayer / Re: JAVA3D and RMI (Moving sprites with RMI not working) on: 2011-04-29 16:40:43 finally, they would end up in an object or array of objects, how would i sent the array with IO socket or channels javaNIO?
 7 Game Development / Networking & Multiplayer / Re: JAVA3D and RMI (Moving sprites with RMI not working) on: 2011-04-28 14:31:58 Quote from: Nate on 2010-11-18 23:50:35The path to success doesn't generally involve skipping fundamental steps. if the fundamental steps can reach me to achieve this silly scenario:http://stackoverflow.com/questions/5370279/sending-receiving-object-references-or-part-of-object-with-javanioi would really happy =)
 8 Game Development / Newbie & Debugging Questions / Re: IndexoutofBoundException[kryonet] on: 2011-04-28 11:19:09 what do you mean by not using java RMI, i m already using kryonet instead of javaRMI, so what u wanna convey.P.S : about there suggestion to create a simple case is quite trivial, but going far from them is not that much trivial and achieving the robust solutions, u can see my this post, is it kryonet  able to give me the solution for this scenario :http://stackoverflow.com/questions/5370279/sending-receiving-object-references-or-part-of-object-with-javanioand more importantly what would the complexity level  as far as implementation is concerned, i tried that with javaNIO but find that way harder to go further. if kryonet will gave me such solution for that with moderate implementation efforts, i would be glad but till now i m not seeing.
9  Game Development / Newbie & Debugging Questions / IndexoutofBoundException[kryonet] on: 2011-04-27 22:00:26
Hi all,
inspite of my best efforts i m unable to run to move a ball with
kryo ,i m beginner java programmer can somebody please pointing me
where i m wrong in adapting kryonet as i did lot of efforts and tries
but this code is not working and everytime coming with some
exception,am i doing so much obvious mistake as i m exhausted with
trying different ways and started hit and try approach will this kind
of project will be complicated with kryonet,

java.lang.IndexOutOfBoundsException: Index: 482, Size: 482
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at com.esotericsoftware.kryonet.rmi.ObjectSpace\$RemoteInvocationHandler.waitForResponse(ObjectSpace.java:344)
at com.esotericsoftware.kryonet.rmi.ObjectSpace\$RemoteInvocationHandler.invoke(ObjectSpace.java:329)
at \$Proxy0.location(Unknown Source)
at com.esotericsoftware.kryonet.BallWorldClient.runball(BallWorldClient.java:135)
at com.esotericsoftware.kryonet.BallWorldClient.run(BallWorldClient.java:123)
java.lang.IndexOutOfBoundsException: Index: 483, Size: 483
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at com.esotericsoftware.kryonet.rmi.ObjectSpace\$RemoteInvocationHandler.waitForResponse(ObjectSpace.java:344)
at com.esotericsoftware.kryonet.rmi.ObjectSpace\$RemoteInvocationHandler.invoke(ObjectSpace.java:329)
at \$Proxy0.getColor(Unknown Source)
at com.esotericsoftware.kryonet.BallWorldClient.drawworld(BallWorldClient.java:153)
at com.esotericsoftware.kryonet.BallWorldClient\$MyKeyListener.paintComponent(BallWorldClient.java:192)
at javax.swing.JComponent.paint(JComponent.java:1029)
at javax.swing.JComponent.paintChildren(JComponent.java:862)
at javax.swing.JComponent.paint(JComponent.java:1038)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:567)
at javax.swing.JComponent.paintChildren(JComponent.java:862)
at javax.swing.JComponent.paintToOffscreen(JComponent.java:5131)
at javax.swing.RepaintManager\$PaintManager.paintDoubleBuffered(RepaintManager.java:1479)
at javax.swing.RepaintManager\$PaintManager.paint(RepaintManager.java:1410)
at javax.swing.RepaintManager.paint(RepaintManager.java:1224)
at javax.swing.JComponent.paint(JComponent.java:1015)
at java.awt.GraphicsCallback\$PaintCallback.run(GraphicsCallback.java:21)
at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:60)
at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:97)
at java.awt.Container.paint(Container.java:1780)
at java.awt.Window.paint(Window.java:3375)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:796)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713)
at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693)
at javax.swing.SystemEventQueueUtilities\$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)

lot of thanks in advance  ,
wishes,
jibbylala
10  Java Game APIs & Engines / Java 3D / losing initial value for Y axis value on setting X and Z on: 2010-12-22 16:57:06
hello all,

i have a beginner question :

i have a robot

which i m setting on (0,1.45,0)  and then i m moving it like this:
 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16 public  boolean moveBy(double x, double z)    /* Move the sprite by offsets x and z, but only if within the floor     and there is no obstacle nearby. */    {        if (isActive()) {            Point3d nextLoc = tryMove(new Vector3d(x, 0, z));            if (obs.nearObstacle(nextLoc, radius*OBS_FACTOR))                return false;            else {                doMove( new Vector3d(x, 0, z) );   // inefficient recalc                return true;            }        }        else    // not active            return false;    }  // end of moveBy()

Accessing TG for that robot,  return me always 0 at y axis (x,0,y)

 1  2  3  4 public TransformGroup getTG()    {         return objectTG; }

but i want the same value,  when i get that TG after applying movement on this robot as shown

like(x,1.45,y)

so what i can do before return TG or where that y value which i set as initial for y why it's returning y=0.

i want "y" the always same return which i set initially; irrespective of the x and z of TG.

thanks,
Jibbylala
11  Game Development / Networking & Multiplayer / Why in this design ;CHANNEL is null in some cases and NOT null in some cases? on: 2010-12-13 03:27:06
Dear experts,

i have  strange problem atleast for me :

 1  2  3  4  5  6  7  8  9  10  11  12 private void makeContact()throws IOException, InterruptedException      /* Contact the server, and set up a TourWatcher to monitor the         server. */      {        try {           TP.start();        }        catch(Exception e)        { System.out.println("No contact with server"+e);          System.exit(0);        }        }  // end of makeContact()

here it's not working when i m sending message from here, channel is null:

 1  2  3  4  5  6  7  8  9  10  11  12 sceneBG.addChild( new CheckerFloor().getBG() );  // add the floor            makeScenery(tourFnm);      // add scenery and obstacles                       TP = new TourProxy("localhost",this,obs);        makeContact();     // contact server (after Obstacles object created)        ***TP.sendMessage("create " + userName + " " + xPosn + " " + zPosn);*** //not working        addTourist(userName, xPosn, zPosn);                      sceneBG.compile();   // fix the scene      } // end of createSceneGraph()

here from this class constrcutor it is working:

 1  2  3  4  5  6  7  8  9 public TourSprite(String userName, String fnm, Obstacles obs,           double xPosn, double zPosn, TourProxy tp) throws IOException      { super(userName, fnm, obs);        setPosition(xPosn, zPosn);       // out = o;        this.tp1 = tp;        ***tp1.sendMessage("create " + userName + " " + xPosn + " " + zPosn);***//working from here       // out.println("create " + userName + " " + xPosn + " " + zPosn);      }  // end of TourSprite()

when i m calling message as i shown from then "channel" in my TourProxy class is "NULL" and the message is not going to server
but when i m passing this TP to the class TourSprite which i don't need but i m using that just for this purpose the send message is working and there is no problem the channel is NOT null, why it is like that and what is the solution.

PS:i feel that this problem is because of  some thread suspension while 3d GUI rendering is also happening and networking stuff is also going on...

Code Reference: The killer game programming, Chapter 32.   Networked Tour3D here:http://fivedots.coe.psu.ac.th/~ad/jg/ch21/index.html.

thanks in advance for any reviews

jibbylala

its cross link : http://www.java-gaming.org/index.php/topic,23495.0.html considering the problem  particularly related to  Rendering with java3d.
 12 Game Development / Networking & Multiplayer / Re: JAVA3D and RMI (Moving sprites with RMI not working) on: 2010-11-19 00:44:48 and actually it's not that much hard problem its raising, my problem is not related to RMI i thought , i m calling remote methods and getting back the objects(Transform3d)  i thought it's not matter of  technology u used when the application would have more features and the design will get complicated; these problems will definitely come.i need some reviews on design i heard about callbacks and i wanted to know whether that is what i need or i need to implement observer pattern for client site as only one class on client site is getting updates and i m feeling others don't have those updates so they are not updating their selves.but i just need some expert eyes on this  as testing all of these possibilities are taking time and i m also new to java3D library also and its also bothering me to implement what i have written.
 13 Game Development / Networking & Multiplayer / Re: JAVA3D and RMI (Moving sprites with RMI not working) on: 2010-11-19 00:26:44 OK lets say  i consider your advice,  can i have some generic network layer  based on TCP/IP which can be valid for different real time MP games(because i heard there are constraints also in TCP/IP than other people will say why not UDP)  and if how much complex that would be  and how much time will it take to develop (yaw its subjective question)?
 14 Game Development / Networking & Multiplayer / Re: JAVA3D and RMI (Moving sprites with RMI not working) on: 2010-11-18 21:49:27 and secondly the aim is to have a "generic network layer" for variety of games , and this will going to be really long journey if now i start with TCPIP...and heard that are lot of low level concepts involve which really need time to understand and grasp thanks
 15 Game Development / Networking & Multiplayer / Re: JAVA3D and RMI (Moving sprites with RMI not working) on: 2010-11-18 21:28:16 yes you are right but now i m on the way and i m totally unaware of other technologies for networking and have no time to start from scratch thanksJ
 16 Game Development / Networking & Multiplayer / Re: JAVA3D and RMI (Moving sprites with RMI not working) on: 2010-11-18 20:47:03 i m glad to have atleast some reply  actually my aim is to create the multiuser game/environment leveraging JAVA3D and all its all capabilities that'S why i approach that application from book but ok i can have a look how u r using RMI.     but i m disappointed that nobody is interested in my question thanks jibby lala
17  Game Development / Networking & Multiplayer / JAVA3D and RMI failing on: 2010-11-17 04:58:57
Dear experts,

My intention was to create RMI version of  Networked Tour3D

example in the 3d book here:http://fivedots.coe.psu.ac.th/~ad/jg/ch21/index.html.

which is about moving sprites on multiple client and navigate together through virtual world simultaneously but i  m failing.

i refactor the  class Sprite3d  to get the Transform3d from remote object on server so when all clients get the same transform 3d all change their position hence "Network tour of sprites in virtual worlds' can be achieved .

i m  beginner programmer  and i dived into these advanced things and now i have no idea, why it is not working may be i m doing some  silly mistake. I don't know what to do  and  now  the code is much i can't paste all on some forum.

this is code in which the methods are calling remote but sprites are NOT moving simulataneously :

this is class which is getting the tranform3d from server other class on client site are calling this class for getting the objectgroup or transformgroup

 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95  96  97  98  99  100  101  102  103  104  105  106  107  108  109  110  111  112  113  114  115  116  117  118  119  120  121  122  123  124  125  126  127  128  129  130  131  132  133  134  135  136  137  138  139  140  141  142  143  144  145  146  147  148 this is remote class from where i m getting the transform3d: [code]package ServerSite;// Sprite3D.java// Andrew Davison, April 2005, ad@fivedots.coe.psu.ac.th/* Sprite3D loads a 3D image, placing it at (0,0,0).   We assume that the object's actual position is (0,0) in the XZ plane.   The Y position will vary but probably the base of the object is   touching the XZ plane.   Movements are restricted to the XZ plane and rotations   around the Y-axis.   An object cannot move off the floor, or travel through obstacles   (as defined in the Obstacles object).   Very sinmilar to Sprite3D in Tour3D.   New net-related code:     - a userName above the sprite that stays oriented along +z axis;     - return a detachable branchgroup for the scene;     - store the current rotation around the y-axis, and methods to return       and set it. */import java.rmi.RemoteException;import java.rmi.server.UnicastRemoteObject;import java.text.DecimalFormat;import java.util.Enumeration;import java.util.Vector;import javax.media.j3d.*;import javax.vecmath.*;public class Sprite3DImpl extends UnicastRemoteObject implements  Sprite3D{    private static final long serialVersionUID = 1L;    private MySerTransform3D t3d, toMove, toRot;    // for manipulating objectTG's transform    private double currRotation;    private DecimalFormat df;   // for simpler output during debugging    public Sprite3DImpl()throws RemoteException {        super();        t3d = new MySerTransform3D();        toMove = new MySerTransform3D();        toRot = new MySerTransform3D();        df = new DecimalFormat("0.###");  // 3 dp        currRotation = 0.0;        System.err.println("In remote constructor");    }    public void doMove(Vector3d theMove)throws RemoteException    //  // Move the sprite by the amount in theMove    {        toMove.setTranslation(theMove);    // overwrite previous trans        t3d.mul(toMove);        System.err.println("In remote doMove");    }  // end of doMove()    public Point3d tryMove(Vector3d theMove)throws RemoteException    /* Calculate the effect of the given translation but     do not update the sprite's position until it's been     tested.     */    {        toMove.setTranslation(theMove);        t3d.mul(toMove);        Vector3d trans = new Vector3d();        t3d.get( trans );        // printTuple(trans, "nextLoc");        System.err.println("In remote tryMove");        return new Point3d( trans.x, trans.y, trans.z);    }  // end of tryMove()    public void doRotateY(double radians)throws RemoteException    // Rotate the sprite by radians amount around its y-axis    {        toRot.rotY(radians);   // overwrite previous rotation        t3d.mul(toRot);        System.err.println("In remote doRotateY");    } // end of doRotateY()    public void setCR(double radians)throws RemoteException    {        currRotation += radians;    } // end of setCurrRotation()    public Point3d getCurrLoc()throws RemoteException    {           Vector3d trans = new Vector3d();        t3d.get( trans );        System.err.println("In remote getCurrLoc");        // printTuple(trans, "currLoc");        return new Point3d( trans.x, trans.y, trans.z);    }    public void setCurrRotation(double rot)throws RemoteException    {        double rotChange = rot - currRotation;        doRotateY(rotChange);        System.err.println("In remote setCurrRotation");    } // end of setCurrRotation()    public double getCurrRotation()throws RemoteException    {  System.err.println("In remote getCurrRotation");    return currRotation;  }    private void setT3d(MySerTransform3D t3d)throws RemoteException {        this.t3d = t3d;    }    public MySerTransform3D getT3d() throws RemoteException{        if(t3d!=null){            return t3d;}        else            System.err.println("t3d is null");        return t3d;    }    private void setToMove(MySerTransform3D toMove) throws RemoteException{        this.toMove = toMove;    }    public MySerTransform3D getToMove()throws RemoteException {        return toMove;    }    private void setToRot(MySerTransform3D toRot)throws RemoteException {        this.toRot = toRot;    }    public MySerTransform3D getToRot()throws RemoteException {        return  toRot;    }       private void printTuple(Tuple3d t, String id)throws RemoteException    // used for debugging    {        System.out.println(id + " x: " + df.format(t.x) +                ", " + id + " y: " + df.format(t.y) +                ", " + id + " z: " + df.format(t.z));    }  // end of printTuple()}  // end of Sprite3D class

Other classes include behavior class and WrapNetTour3D according to changed design because of RMI may be there is some issue in those but first i would like to confirm and have some review on these main classes  and why it is not working and how it can be implemented with RMI.(other files and code everything you can look at the link)

If somebody need i can send the whole project because i just wanted that working and i thought i did the major changes and spent lot of time on it.