Hey guys, i've tried using TestCameraMan as the base to build a camera zoomed out above my terrain - as a 'minimap' - i can't even get the camera node to show up over the 'game' state though (it's part of a third person adventure game)
Can anyone please help by shedding light on the situation???
I'm of course adding it to gamestatemanager and setting to active after the main level state has been loaded
Thanks,
HC
import com.jme.light.DirectionalLight;
import com.jme.light.LightNode;
import com.jme.light.SpotLight;
import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;
import com.jme.renderer.TextureRenderer;
import com.jme.scene.CameraNode;
import com.jme.scene.Node;
import com.jme.scene.Spatial;
import com.jme.scene.state.AlphaState;
import com.jme.scene.state.CullState;
import com.jme.scene.state.LightState;
import com.jme.system.DisplaySystem;
import com.jmex.game.state.BasicGameState;
public class MiniMap extends BasicGameState
{
// Camera Node (Minimap Stuff)
CameraNode camNode;
TextureRenderer tRenderer;
public MiniMap(String name)
{
super(name);
this.init();
}
public void init()
{
ColorRGBA color = new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f);
AlphaState alphaState = DisplaySystem.getDisplaySystem().getRenderer().createAlphaState();
alphaState.setBlendEnabled(true);
alphaState.setSrcFunction(AlphaState.SB_SRC_ALPHA);
alphaState.setDstFunction(AlphaState.DB_ONE_MINUS_SRC_ALPHA);
alphaState.setTestEnabled(true);
alphaState.setTestFunction(AlphaState.TF_GREATER);
alphaState.setEnabled(true);
rootNode = this.getRootNode();
rootNode.setCullMode(Spatial.CULL_NEVER);
rootNode.setLightCombineMode(LightState.OFF);
/* Add the minimap camera */
tRenderer = DisplaySystem.getDisplaySystem().createTextureRenderer(256, 256, TextureRenderer.RENDER_TEXTURE_2D);
camNode = new CameraNode("Camera Node", tRenderer.getCamera());
camNode.setLocalTranslation(new Vector3f(0.0f, 50.0f, -50.0f));
camNode.updateGeometricState(0, true);
DirectionalLight am = new DirectionalLight();
am.setDiffuse(new ColorRGBA(0.0f, 1.0f, 0.0f, 1.0f));
am.setAmbient(new ColorRGBA(0.5f, 0.5f, 0.5f, 1.0f));
am.setDirection(new Vector3f(1.0f, 0.0f, 0.0f));
LightState state = DisplaySystem.getDisplaySystem().getRenderer().createLightState();
state.setEnabled(true);
LightNode cameraLight = new LightNode("Camera Light", state);
camNode.attachChild(cameraLight);
CullState cs = DisplaySystem.getDisplaySystem().getRenderer().createCullState();
cs.setCullMode(CullState.CS_BACK);
cs.setEnabled(true);
rootNode.setRenderState(cs);
rootNode.attachChild(camNode);
}
public void update(float f)
{
super.update(f);
this.getRootNode().updateGeometricState(f, true);
}
public void render(float f)
{
super.render(f);
DisplaySystem.getDisplaySystem().getRenderer().draw(this.getRootNode());
}
}