Creating the SceneWrapMover3D is like previous Wrap classes: it creates a 3D scene inside a JPanel, made up of a checkerboard floor, blue sky, lighting, and an OrbitBehavior node to allow the user to adjust the viewpoint. Much of this is done in the createSceneGraph( ) method: private void createSceneGraph( ) { sceneBG = new BranchGroup( ); bounds = new BoundingSphere(new Point3d(0,0,0), BOUNDSIZE); lightScene( ); // add the lights addBackground( ); // add the sky sceneBG.addChild( new CheckerFloor( ).getBG( ) ); // add the floor addFigure( ); sceneBG.compile( ); // fix the scene } The code that distinguishes WrapMover3D from earlier Wrap classes is mostly contained in addFigure( ): // global: the multilimbed figure private Figure figure; private void addFigure( ) // add the figure and its behavior to the scene { figure = new Figure( ); sceneBG.addChild( figure.getFigureTG( ) ); // add figure's TG // add behavior LocationBeh locBeh = new LocationBeh( figure ); locBeh.setSchedulingBounds(bounds); sceneBG.addChild(locBeh); } The Figure object constructs the articulated figure, and its top-level transformGroup is added to the scene. The LocationBeh object converts user key presses into figure commands. Mover3D uses the getFigure( ) method to obtain a reference to the Figure object, which it passes to the CommandsPanel: public Figure getFigure( ) { return figure; } |