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;
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; private double currRotation;
private DecimalFormat df; public Sprite3DImpl()throws RemoteException { super(); t3d = new MySerTransform3D(); toMove = new MySerTransform3D(); toRot = new MySerTransform3D();
df = new DecimalFormat("0.###"); currRotation = 0.0; System.err.println("In remote constructor"); }
public void doMove(Vector3d theMove)throws RemoteException { toMove.setTranslation(theMove); t3d.mul(toMove); System.err.println("In remote doMove"); } public Point3d tryMove(Vector3d theMove)throws RemoteException { toMove.setTranslation(theMove); t3d.mul(toMove); Vector3d trans = new Vector3d(); t3d.get( trans ); System.err.println("In remote tryMove"); return new Point3d( trans.x, trans.y, trans.z);
} public void doRotateY(double radians)throws RemoteException { toRot.rotY(radians); t3d.mul(toRot); System.err.println("In remote doRotateY"); } public void setCR(double radians)throws RemoteException { currRotation += radians; } public Point3d getCurrLoc()throws RemoteException { Vector3d trans = new Vector3d(); t3d.get( trans ); System.err.println("In remote getCurrLoc"); 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"); }
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 { System.out.println(id + " x: " + df.format(t.x) + ", " + id + " y: " + df.format(t.y) + ", " + id + " z: " + df.format(t.z)); } } |
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[/code]