Converting to BaseGame framework from SimplePassGame.. nothing renders

Here's a HUGE mass of code, nothing renders but the Tile-Loader reports creating everything and I see the skybox created in the output, as well.


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package fyrestonev01;

import com.jme.app.BaseGame;
import com.jme.input.ChaseCamera;
import com.jme.input.KeyBindingManager;
import com.jme.input.KeyInput;
import com.jme.light.DirectionalLight;
import com.jme.math.Plane;
import com.jme.math.Vector3f;
import com.jme.renderer.Camera;
import com.jme.renderer.ColorRGBA;
import com.jme.renderer.pass.BasicPassManager;
import com.jme.renderer.pass.RenderPass;
import com.jme.scene.Node;
import com.jme.scene.PassNode;
import com.jme.scene.Skybox;
import com.jme.scene.shape.Quad;
import com.jme.scene.state.FogState;
import com.jme.scene.state.LightState;
import com.jme.system.DisplaySystem;
import com.jme.util.GameTaskQueue;
import com.jme.util.GameTaskQueueManager;
import com.jme.util.Timer;
import com.jmex.effects.water.WaterRenderPass;
import java.nio.FloatBuffer;
import java.util.ArrayList;




/**
 *
 * @author Tyler Trussell
 * Copyright 2009 Tyler Trussell
 * All Rights Reserved.
 * It is illegal to possess this source code unless you have express written consent from Tyler Trussell.
 * Any dissemenation, use, transcription, or translation of this source code is forbidden unless express written consent from Tyler Trussell has been provided.
 *
 */


public class FyrestoneClient extends BaseGame
{
   
    //DISPLAY SETTINGS
    private int width, height, freq, depth;
    private boolean fullscreen;
    //END DISPLAY SETTINGS
   
    //Camera Setup
    Camera cam;
    ChaseCamera chaser;
    //End Camera Setup
   
    //FPS Setup
    Timer timer;
    Node fpsNode;
    float tpf;
    //End FPS Node;
   
    //Terrain Setup
    Node terrainNode;
    Skybox skybox;
    FogState fog;
    TileSpace[] loadedTiles = new TileSpace[9];
    PassNode[] textures = new PassNode[9];
    //End Terrain Setup
   
    //Water setup
    BasicPassManager pManager;
    Node waterNode;
    WaterRenderPass water;
    Quad myWater;
    //End water setup
   
    //Lighting setup
    LightState lightState;
    //End lighting setup
   
    //Rendering setup
    RenderPass terrainPass;
    //End rendering setup
   
    public static void main(String args[])
    {
        FyrestoneClient app = new FyrestoneClient();
        app.setDialogBehaviour(app.ALWAYS_SHOW_PROPS_DIALOG);
        app.start();
    }
   
   
    @Override
    protected void initSystem()
    {
        setupWindow();
        makeCamera();
        timer = Timer.getTimer();
    }
   
    @Override
    protected void initGame()
    {
        terrainNode = new Node("terrain");
        waterNode = new Node("water");
        terrainPass = new RenderPass();
       
        pManager = new BasicPassManager();
        TileSpaceManager.startup();
        createLighting();
        skybox = EnvironmentalManager.makeSkybox();
        fog = EnvironmentalManager.makeFog();
        terrainNode.attachChild(skybox);
        terrainNode.setRenderState(fog);
        terrainPass.add(terrainNode);
        pManager.add(terrainPass);
       
        createStartTile();
        makeWater();
    }
   
    @Override
    protected void reinit()
    {
        display.recreateWindow(width, height, depth, freq, fullscreen);
    }

    @Override
    protected void update(float interpolation)
    {
        timer.update();
        tpf = timer.getTimePerFrame();
        interpolation = timer.getTimePerFrame();
       
        updateSkybox();
        updateTiles();
       
        checkForInput();
       
        terrainNode.updateGeometricState(tpf, true);
        waterNode.updateGeometricState(tpf, true);
    }

    @Override
    protected void render(float interpolation)
    {
        terrainNode.updateGeometricState(tpf, false);
        waterNode.updateGeometricState(tpf, false);
        pManager.updatePasses(tpf);
        display.getRenderer().clearStatistics();
        display.getRenderer().clearBuffers();
        pManager.renderPasses(display.getRenderer());
    }
   
    @Override
    protected void cleanup()
    {
       
    }

    private void checkForInput()
    {
        if(KeyBindingManager.getKeyBindingManager().isValidCommand("exit"))
            finished = true;
    }
   
    private void updateTiles()
    {
        Vector3f myLoc = cam.getLocation();
        int tile_x = (int)myLoc.x / (TileSpaceManager.TERRAINSCALE * TileSpaceManager.MAPSIZE);
        int tile_y = (int)myLoc.z / (TileSpaceManager.TERRAINSCALE * TileSpaceManager.MAPSIZE);
        ArrayList<TileSpace> mustStayLoaded = TileSpaceManager.getTileSpace(tile_x, tile_y).getNeighbors();
        mustStayLoaded.add(TileSpaceManager.getTileSpace(tile_x, tile_y));
       
        for(int i=0; i<loadedTiles.length; i++)
        {
            if(loadedTiles[i] != null)
            {
                boolean kill = true;
                for(TileSpace ts : mustStayLoaded)
                {
                    if(loadedTiles[i].x == ts.x && loadedTiles[i].y == ts.y)
                        kill = false;
                }
               
                if(kill)
                {
                    System.out.println("************************* Killing page at " + loadedTiles[i].x + " " + loadedTiles[i].y + " *************************");
                    loadedTiles[i] = null;
                    textures[i].removeFromParent();
                    textures[i] = null;
                }
            }
        }
       
        for(TileSpace ts : mustStayLoaded)
        {
            boolean present = false;
            for(int i=0; i<loadedTiles.length; i++)
            {
                if(loadedTiles[i] != null)
                {
                    if(loadedTiles[i].x == ts.x && loadedTiles[i].y == ts.y)
                        present = true;
                }
            }
            if(!present)
            {
                int x = getFirstNullPage();
                loadedTiles[x] = TileSpaceManager.getTileSpace(ts.x, ts.y);
                textures[x] = TileSpaceManager.makePassNode(TileSpaceManager.makeTerrainPage(ts.x, ts.y), ts.x, ts.y);
                terrainNode.attachChild(textures[x]);
                terrainNode.updateRenderState();
            }
        }
    }
   
    private WaterRenderPass makeWater()
    {
        water = new WaterRenderPass(cam, 6, false, true);
        water.setWaterPlane(new Plane(new Vector3f(0f, 1f, 0f), 1f));
        water.setClipBias(-1f);
        water.setReflectionThrottle(0f);
        water.setRefractionThrottle(0f);
       
        myWater = new Quad("myWater", 1, 1);
        FloatBuffer normBuf = myWater.getNormalBuffer(0);
        normBuf.clear();
        normBuf.put(0).put(1).put(0);
        normBuf.put(0).put(1).put(0);
        normBuf.put(0).put(1).put(0);
        normBuf.put(0).put(1).put(0);
       
        water.setWaterEffectOnSpatial(myWater);
       
        waterNode.attachChild(myWater);
       
        water.setReflectedScene(terrainNode);
        water.setReflectedScene(skybox);
        water.setSkybox(skybox);
       
        pManager.add(water);
       
        return water;
    }
   
    private int getFirstNullPage()
    {
        for(int i=0; i<loadedTiles.length; i++)
        {
            if(loadedTiles[i] == null)
                return i;
        }
        return 0;
    }
   
    private void createStartTile()
    {
        Vector3f myLoc = cam.getLocation();
        int tile_x = (int)myLoc.x / (TileSpaceManager.TERRAINSCALE * TileSpaceManager.MAPSIZE);
        int tile_y = (int)myLoc.z / (TileSpaceManager.TERRAINSCALE * TileSpaceManager.MAPSIZE);
        loadedTiles[0] = TileSpaceManager.getTileSpace(tile_x, tile_y);
        textures[0] = TileSpaceManager.makePassNode(TileSpaceManager.makeTerrainPage(tile_x, tile_y), tile_x, tile_y);
        terrainNode.attachChild(textures[0]);
    }
   
    private void makeCamera()
    {
        cam = display.getRenderer().createCamera(width, height);
        Vector3f location = new Vector3f(SystemManager.CAMSTARTX, SystemManager.CAMSTARTY, SystemManager.CAMSTARTZ);
        Vector3f left = new Vector3f(-1f, 0f, 0f);
        Vector3f up = new Vector3f(0f, 1f, 0f);
        Vector3f dir = new Vector3f(0f, 0f, -1f);
        cam.setFrame(location, left, up, dir);
        cam.update();
       
        display.getRenderer().setCamera(cam);
    }
   
    private void setupWindow()
    {
        width = properties.getWidth();
        height = properties.getHeight();
        freq = properties.getFreq();
        depth = properties.getDepth();
        fullscreen = properties.getFullscreen();
       
        display = DisplaySystem.getDisplaySystem(properties.getRenderer());
        display.createWindow(width, height, depth, freq, fullscreen);
        display.setTitle("Fyrestone: Development Edition v. 0.1");
        display.getRenderer().setBackgroundColor(ColorRGBA.pink);
    }
   
    private void setupKeyBindings()
    {
        KeyBindingManager.getKeyBindingManager().set("exit", KeyInput.KEY_ESCAPE);
    }
   
    private void setTextureCoords(int buffer, float x, float y, float textureScale)
    {
        x *= textureScale * 0.5f;
        y *= textureScale * 0.5f;
        textureScale = EnvironmentalManager.fogEnd * textureScale;
        FloatBuffer texBuf;
        texBuf = myWater.getTextureBuffer(0, buffer);
        texBuf.clear();
        texBuf.put(x).put(textureScale + y);
        texBuf.put(x).put(y);
        texBuf.put(textureScale + x).put(y);
        texBuf.put(textureScale + x).put(textureScale + y);
    }
   
    private void updateSkybox()
    {
        Vector3f camLoc = cam.getLocation();
        skybox.setLocalTranslation(camLoc);
    }
   
    private void updateWater()
    {
        Vector3f transVec = new Vector3f(cam.getLocation().x, water.getWaterHeight(), cam.getLocation().z);
        setTextureCoords(0, transVec.y, -transVec.z, .07f);
        setVertexCoords(transVec.x, transVec.y, transVec.z);
    }
   
    private void createLighting()
    {
        lightState = display.getRenderer().createLightState();
        DirectionalLight sun = EnvironmentalManager.makeSun();
        lightState.attach(sun);
        lightState.setEnabled(true);
    }
   
    private void setVertexCoords(float x, float y, float z)
    {
        FloatBuffer vertBuf = myWater.getVertexBuffer(0);
        vertBuf.clear();

        vertBuf.put(x - EnvironmentalManager.fogEnd).put(y).put(z - EnvironmentalManager.fogEnd);
        vertBuf.put(x - EnvironmentalManager.fogEnd).put(y).put(z + EnvironmentalManager.fogEnd);
        vertBuf.put(x + EnvironmentalManager.fogEnd).put(y).put(z + EnvironmentalManager.fogEnd);
        vertBuf.put(x + EnvironmentalManager.fogEnd).put(y).put(z - EnvironmentalManager.fogEnd);
    }
}

Don't take this the wrong way, but this forum is not really meant as a personal debugging tool.  :slight_smile:

renanse said:

Don't take this the wrong way, but this forum is not really meant as a personal debugging tool.  :)


As I understand, this forum is here to allow the jME community to collaborate and for more experienced coders to help less experienced coders. If we don't help each other, we'll never learn. If people are discouraged by the fact that nobody is helping them, they won't stick around to be a part of the jME community. (For instance this thread)

While I understand it's not just a debugging tool, when I see a forum that I can help on, I gladly post solutions to problems, so I see nothing wrong with requesting that help from others.

Isn't there supposed to be an update at the end of your init method… or am I missing something?

Trussell said:

Here's a HUGE mess of code,


You're right, it is  :wink:

first of all:


        terrainNode.updateGeometricState(tpf, false);
        waterNode.updateGeometricState(tpf, false);
        pManager.updatePasses(tpf);



is meant to happen in update(), not in render().

You might want to take a look at the test classes in the jme source  :)

so long,
Andy
dhdd said:

You might want to take a look at the test classes in the jme source  :)


Last night I printed out the source for BaseGame, BaseSimpleGame, and SimplePassGame to see what they are rendering and updating that I may have missed.

But because it was so late I fell asleep at my desk! :D
Trussell said:

Last night I printed out the source for BaseGame, BaseSimpleGame, and SimplePassGame to see what they are rendering and updating that I may have missed.


I meant the classes TestBaseGame, TestSimplePassGame, and such. They show you how the classes you mentioned should be used  ;)
Trussell said:

renanse said:

Don't take this the wrong way, but this forum is not really meant as a personal debugging tool.  :)


As I understand, this forum is here to allow the jME community to collaborate and for more experienced coders to help less experienced coders. If we don't help each other, we'll never learn. If people are discouraged by the fact that nobody is helping them, they won't stick around to be a part of the jME community. (For instance this thread)

While I understand it's not just a debugging tool, when I see a forum that I can help on, I gladly post solutions to problems, so I see nothing wrong with requesting that help from others.


Sure, but if you don't understand your own code enough to narrow it down to some smaller chunk of code then you probably need to take a step back.  Posting a whole class and saying "what's wrong with this" is a bit much, imho.

agree with renanse…

I totally agree with renanse and MrCoder.



Trussell, please remember that when you started your very ambitious project everybody kept telling you to take that step back and start with simpler things. You rejected that advice, and sometimes even in an almost aggressive manner.



That advice was the best, and sometimes the only answer to many of the questions you have asked here since then.  You could have answered a lot of those questions yourself if you had started at a reasonable level and pace.



Sorry if this sounds like I'm bashing you, I really don't mean to.

But you have to understand that it is pretty inappropriate to refuse learning jME at a reasonable pace and then come back with two or three questions a day about some really basic things.



Again, if this sounds overly harsh in your ears, I apologize. A lot. You have answered some questions on the forum, and in a nice and informed way too, which must be recognized. But that's not the point here. I hope you understand :slight_smile:



(EDIT: just removed a litte redundant jabbering. nothing important.)

Well, I didn't pay much attention to it at the time because I haven't become very familiar with Renanse, so I thought it may be him just being annoyed with me. The large (or what I would consider to be sufficient) group of people that agreed with him made me think.



I went back and took a look at all of my posts, and I find that in my excitement to make progress with my game I posted many problems that I solved immediately after posting.



I would like to apologize for my voracious posting habits. I will try my best to keep my posts more relevant and not so  obvious. I understand that this can be annoying for you. Once more, I am sorry.