Skip to main content

Problem having java3D Behavior class as an Observable.

Please note these forums are being decommissioned and use the new and improved forums at
No replies
Joined: 2010-11-16

Dear Experts,

I m using observer pattern

in which i wanted to send the tranform group or branchgroup from one class main GUI to Touristcontrol for responding to user inputs and getting back to update the each gui rendered :

first this is class which is sending viewerTG to touristcontrol:

// --------------------- tourists ---------------------------

private void addTourist(String userName, double xPosn, double zPosn) throws RemoteException

// create sprite for this client


SC = new Sprite3DClient(userName, "Coolrobo.3ds", obs);

if (SC !=null )


bob = new TourSprite( SC, userName, "Coolrobo.3ds", obs, xPosn, zPosn); // sprite

sceneBG.addChild( this.SC.getBG());

//sceneBG.addChild( this.SC.getTG());

ViewingPlatform vp = su.getViewingPlatform();

TransformGroup viewerTG = vp.getViewPlatformTransform(); // view point TG

TouristControls tcs = new TouristControls(this , bob, SC, viewerTG); // sprite's controls

tcs.setSchedulingBounds( bounds );

sceneBG.addChild( tcs );



System.err.println("SC is null");

} // end of addTourist()

and touristcontrol after perorming its action :

private void setViewer() throws RemoteException

/* Position the viewpoint so it is offset by ZOFFSET from the

sprite along the z-axis, and is at height HEIGHT.



bobPosn = bob.getCurrLoc(); // start location for bob

viewerTG.getTransform( getT3d() );

// args are: viewer posn, where looking, up direction

getT3d().lookAt( new Point3d(bobPosn.x, HEIGHT, bobPosn.z + ZOFFSET),

new Point3d(bobPosn.x, HEIGHT, bobPosn.z),

new Vector3d(0,1,0));




if (mysubject !=null){



// mysubject.notifyObservers(this);



System.err.println("subject is null");

} // end of setViewer()

and back to observer means main class:


public void update(Observable o, Object arg1) {

if (arg1 instanceof BranchGroup ){
BranchGroup sBG = (BranchGroup) arg1;
sBG.compile(); // generally a good idea

try {

Thread.sleep(200); // delay a little, so world has been finished


catch(InterruptedException e) {}

sceneBG.addChild( sBG );

System.out.println("i m in observer update()");


but every time i m getting one or the other exception and i am unable to accomplish my goal.

please tell me how can i achieved that ; when some changes occur in tourist control class all clients get the same updates

thanks a lot,

jibby lala