BaseGame in JME 2.0[Fixed]

How do I alter the display settings for this JME 1.0 class that extends BaseGame to be compatible with JME 2.0?



I'm new to all this and am a bit lost as to how to implement changes…


import com.jme.app.BaseGame;
import com.jme.math.Matrix3f;
import com.jme.math.Quaternion;
import com.jme.math.Vector3f;
import com.jme.renderer.Camera;
import com.jme.renderer.ColorRGBA;
import com.jme.scene.CameraNode;
import com.jme.scene.Node;
import com.jme.scene.state.WireframeState;
import com.jme.scene.state.ZBufferState;
import com.jme.system.DisplaySystem;
import com.jme.system.JmeException;
import com.jme.util.Timer;
import com.sun.sgs.client.ClientChannel;
import com.sun.sgs.client.ClientChannelListener;
import com.sun.sgs.client.simple.SimpleClientListener;
import java.net.PasswordAuthentication;
import java.nio.ByteBuffer;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Jeffrey Kesselman
 */
public class WW3DGame extends BaseGame implements SimpleClientListener {

    static final Logger logger = Logger.getLogger(WW3DGame.class.getName());
    private Camera cam;
    private Timer timer;
    private long ticksPerSecond;
    private Node rootNode;
    private CameraNode cameraNode;
    private Node cameraRotNode;
    private Node cameraXlateNode;
    private WireframeState wireState;
    private WW3DGameState currentState = null;
    private WW3DGameState nextState=null;
   
    public WW3DGame(){
        super();
     
    }

    @Override
    protected void initSystem() {
        logger.info(getVersion());
        try {
            /**
             * Get a DisplaySystem acording to the renderer selected in the
             * startup box.
             */
            display = DisplaySystem.getDisplaySystem(properties.getRenderer());

            /*
            display.setMinDepthBits( depthBits );
            display.setMinStencilBits( stencilBits );
            display.setMinAlphaBits( alphaBits );
            display.setMinSamples( samples );
             * */


            /** It's the properties variable round here that isn't recognized.

            /** Create a window with the startup box's information. */
            display.createWindow(properties.getWidth(), properties.getHeight(),
                    properties.getDepth(), properties.getFreq(),
                    properties.getFullscreen());
            logger.info("Running on: " + display.getAdapter() +
                    "nDriver version: " + display.getDriverVersion() + "n" +
                    display.getDisplayVendor() + " - " +
                    display.getDisplayRenderer() + " - " +
                    display.getDisplayAPIVersion());


            /**
             * Create a camera specific to the DisplaySystem that works with the
             * display's width and height
             */
            cam = display.getRenderer().createCamera(display.getWidth(),
                    display.getHeight());


        } catch (JmeException e) {
            /**
             * If the displaysystem can't be initialized correctly, exit
             * instantly.
             */
            logger.log(Level.SEVERE, "Could not create displaySystem", e);
            System.exit(1);
        }

        /** Set a black background. */
        display.getRenderer().setBackgroundColor(ColorRGBA.black.clone());

        /*** set up camera ***/
        initializeCamera();


        /** Sets the title of our display. */
        String className = getClass().getName();
        if (className.lastIndexOf('.') > 0) {
            className = className.substring(className.lastIndexOf('.') + 1);
        }
        display.setTitle(className);
        /**
         * Signal to the renderer that it should keep track of rendering
         * information.
         */
       // display.getRenderer().;
        timer = Timer.getTimer();
        ticksPerSecond = timer.getResolution();
    }

    private void initializeCamera() {
        /** Set up how our camera sees. */
        cam.setFrustumPerspective(45.0f,
                (float) display.getWidth() / (float) display.getHeight(), 1,
                1000);
        cam.setParallelProjection(false);

        Vector3f loc = new Vector3f(0.0f, 0.0f, 25.0f);
        Vector3f left = new Vector3f(-1.0f, 0.0f, 0.0f);
        Vector3f up = new Vector3f(0.0f, 1.0f, 0.0f);
        Vector3f dir = new Vector3f(0.0f, 0f, -1.0f);
        /** Move our camera to a correct place and orientation. */
        cam.setFrame(loc, left, up, dir);
        /** Signal that we've changed our camera's location/frustum. */
        cam.update();
        /** Assign the camera to this renderer. */
        display.getRenderer().setCamera(cam);
    }

    @Override
    protected void initGame() {
         /** Create rootNode */
        rootNode = new Node("rootNode");
        /** create camera nodes **/
        cameraNode = new CameraNode();
        cameraNode.setCamera(cam);
        cameraRotNode = new Node();
        cameraXlateNode = new Node();
        cameraRotNode.attachChild(cameraXlateNode);
        cameraXlateNode.attachChild(cameraNode);
        Vector3f left = new Vector3f(-1.0f, 0.0f, 0.0f);
        Vector3f up = new Vector3f(0.0f, 1.0f, 0.0f);
        Vector3f dir = new Vector3f(0.0f, 0f, -1.0f);
        Matrix3f camMatrix = new Matrix3f(left.x, left.y, left.z,
                up.x, up.y, up.z, dir.x, dir.y, dir.z);
        cameraNode.setLocalRotation(camMatrix);
        cameraXlateNode.setLocalTranslation(0f, 0f, 25f);
        Quaternion startingCameraRot = new Quaternion();
        startingCameraRot.fromAngles((float) Math.PI / 4, 0f, 0f);
        cameraRotNode.setLocalRotation(startingCameraRot);
        rootNode.attachChild(cameraRotNode);

        /**
         * Create a wirestate to toggle on and off. Starts disabled with default
         * width of 1 pixel.
         */
        wireState = display.getRenderer().createWireframeState();
        wireState.setEnabled(false);
        rootNode.setRenderState(wireState);

        /**
         * Create a ZBuffer to display pixels closest to the camera above
         * farther ones.
         */
        ZBufferState buf = display.getRenderer().createZBufferState();
        buf.setEnabled(true);
        buf.setFunction(ZBufferState.TestFunction.EqualTo);
        rootNode.setRenderState(buf);
       
       

        /**
         * Update geometric and rendering information for both the rootNode and
         * fpsNode.
         */
        rootNode.updateGeometricState(0.0f, true);
        rootNode.updateRenderState();
     
    }

    @Override
    protected void update(float arg0) {
        if (nextState != null){
            if (currentState!=null) {
                currentState.deactivate();
            }
            currentState = nextState;
            currentState.activate(this);
        }
        timer.update();
        float deltaTime = timer.getTimePerFrame() / ticksPerSecond * 1000;
        if (currentState!=null){
            currentState.update(deltaTime);
        }
    }

    @Override
    protected void render(float arg0) {
         if (currentState!=null){
            currentState.render(display.getRenderer());
        }
    }

    @Override
    protected void reinit() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    protected void cleanup() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public PasswordAuthentication getPasswordAuthentication() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void loggedIn() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void loginFailed(String arg0) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public ClientChannelListener joinedChannel(ClientChannel arg0) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void receivedMessage(ByteBuffer arg0) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void reconnecting() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void reconnected() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void disconnected(boolean arg0, String arg1) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
   
    // acessors
    public void setState(WW3DGameState newState){
        nextState = newState;
    }
}



Edit: Had a dig round and sorted it :)