JAVA3D and RMI failing

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



this is remote class from where i m getting the transform3d:

 


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.

 

please help i would be really thankful

jibby lala

Hi!

I have a working example of (very limited) multiplayer 2D fighting game using RMI, maybe it could help you. Would you like to see the source code?

i m glad to have atleast some reply :slight_smile:
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 :frowning:

thanks
jibby lala

RMI is exactly the wrong technology to use for realtime client/server graphical applications. Use straight TCP/IP sockets, or UDP. I suggest TCP as you don’t seem to know what you’re doing anyway.

Cas :slight_smile:

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
thanks
J

TCPIP will be easier.

Cas :slight_smile:

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 :frowning:
thanks
:slight_smile:

The path to success doesn’t generally involve skipping fundamental steps. :slight_smile:

RMI will completely baffle you when it doesn’t work, and the reason you can’t and shouldn’t use it will become apparent with a more thorough understanding of TCP/IP, and then how RMI works on top of TCP/IP.

Cas :slight_smile:

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)?

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 :frowning: 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.

Hi!

That’s here:
http://membres.lycos.fr/javalution/download/fighting.zip

Princec is right, it would be better to use TCP/IP or JGN:
http://code.google.com/p/jgn/

if the fundamental steps can reach me to achieve this silly scenario:

i would really happy =)

You have to choose how you represent your balls at a very low level but why do you want to use NIO? Maybe some basic sockets would be enough for your needs, wouldn’t they?

LOL

finally, they would end up in an object or array of objects, how would i sent the array with IO socket or channels javaNIO?

To really mess up my next game I think I will use a mix of RMI, XML-RPC, and SOAP. Just to make even slower I might throw in some WSDL. WTH.

This could be a good starting point:
http://download.oracle.com/javase/tutorial/networking/sockets/readingWriting.html

What’s wrong with what I explained to him? RMI is quite slow, I don’t advise anyone to use it for games, I only did it for a blueprint.

That’s the funny thing about language barrier. Your statement could also be read like:

[quote]You need to choose how to illustrate your testicles at a very low level (…) maybe some basic bulb holders would be enough…
[/quote]
Something like that. Since I am german, I don’t know, what tberthel really read into this :wink:

ROFLMAO!!!