Shrank the maximum I could and the problem is still here on my side.
Normally directly a copy/paste of this should be working:
import com.jme.bounding.BoundingBox;
import com.jme.input.FirstPersonHandler;
import com.jme.input.InputHandler;
import com.jme.input.KeyInput;
import com.jme.input.MouseInput;
import com.jme.light.DirectionalLight;
import com.jme.math.FastMath;
import com.jme.math.Quaternion;
import com.jme.math.Vector3f;
import com.jme.renderer.Camera;
import com.jme.renderer.ColorRGBA;
import com.jme.renderer.Renderer;
import com.jme.scene.Node;
import com.jme.scene.SceneElement;
import com.jme.scene.Text;
import com.jme.scene.shape.Box;
import com.jme.scene.shape.Quad;
import com.jme.scene.state.LightState;
import com.jme.scene.state.MaterialState;
import com.jme.scene.state.RenderState;
import com.jme.scene.state.TextureState;
import com.jme.scene.state.ZBufferState;
import com.jme.system.DisplaySystem;
import com.jme.util.TextureManager;
import com.jme.util.Timer;
import com.jmex.game.state.GameState;
public class TsGameState extends GameState
{
private Renderer renderer;
protected StringBuffer updateBuffer = new StringBuffer( 30 );
protected StringBuffer tempBuffer = new StringBuffer();
protected Timer timer;
protected long targetedFps;
protected Camera cam;
protected Node fpsNode;
protected Text fpsText;
protected Node gameInfoNode;
protected Text gameInfoText;
protected InputHandler input;
public static String fontLocation = Text.DEFAULT_FONT;
private static LightState mainLightState = null;
private Node rootNode = null;
private Node occluders = null;
private TsItemLoader tsItemLoader = null;
public TsGameState(String _name, long _targetedFps)
{
setName(_name);
timer = Timer.getTimer();
targetedFps = _targetedFps;
renderer = DisplaySystem.getDisplaySystem().getRenderer();
cam = renderer.getCamera();
gameInfoText = Text.createDefaultTextLabel( "InfoText label" );
gameInfoText.setCullMode( SceneElement.CULL_NEVER );
gameInfoText.setTextureCombineMode( TextureState.REPLACE );
gameInfoNode = new Node( "gameInfo node" );
gameInfoNode.setRenderState( gameInfoText.getRenderState( RenderState.RS_ALPHA ) );
gameInfoNode.setRenderState( gameInfoText.getRenderState( RenderState.RS_TEXTURE ) );
gameInfoNode.attachChild( gameInfoText );
gameInfoNode.setCullMode( SceneElement.CULL_NEVER );
gameInfoNode.setLocalTranslation(0,DisplaySystem.getDisplaySystem().getHeight()-20,0);
fpsText = Text.createDefaultTextLabel( "FPS label" );
fpsText.setCullMode( SceneElement.CULL_NEVER );
fpsText.setTextureCombineMode( TextureState.REPLACE );
fpsNode = new Node( "FPS node" );
fpsNode.setRenderState( fpsText.getRenderState( RenderState.RS_ALPHA ) );
fpsNode.setRenderState( fpsText.getRenderState( RenderState.RS_TEXTURE ) );
fpsNode.attachChild( fpsText );
fpsNode.setCullMode( SceneElement.CULL_NEVER );
rootNode = new Node("rootNode");
ZBufferState buf = renderer.createZBufferState();
buf.setEnabled( true );
buf.setFunction( ZBufferState.CF_LEQUAL );
rootNode.setRenderState( buf );
occluders = new Node();
rootNode.attachChild(occluders);
FirstPersonHandler firstPersonHandler = new FirstPersonHandler( cam, 50,1 );
input = firstPersonHandler;
loadWorld();
timer.reset();
rootNode.updateGeometricState( 0.0f, true );
rootNode.updateRenderState();
fpsNode.updateGeometricState( 0.0f, true );
fpsNode.updateRenderState();
gameInfoNode.updateGeometricState( 0.0f, true );
gameInfoNode.updateRenderState();
timer.reset();
renderer.enableStatistics( true );
}
public void loadWorld()
{
Node groundNode = new Node();
Quaternion roll90 = new Quaternion();
roll90.fromAngleAxis( FastMath.PI/2 , new Vector3f(1,0,0) );
Quad quad = new Quad("",32,32);
quad.setLocalRotation( roll90 );
quad.setModelBound(new BoundingBox());
quad.updateModelBound();
groundNode.attachChild(quad);
rootNode.attachChild(groundNode);
DirectionalLight dr1 = new DirectionalLight();
dr1.setDiffuse(ColorRGBA.white);
dr1.setAmbient(new ColorRGBA(0.2f, 0.2f, 0.2f, 0.4f));
dr1.setDirection(new Vector3f(-1f, -1f, 1f).normalizeLocal());
dr1.setShadowCaster(true);
dr1.setEnabled(true);
mainLightState = renderer.createLightState();
mainLightState.attach(dr1);
mainLightState.setEnabled(true);
mainLightState.setGlobalAmbient(new ColorRGBA(0.6f, 0.6f, 0.6f, 1.0f));
mainLightState.setSeparateSpecular(true);
rootNode.setRenderState(mainLightState);
MaterialState ms = DisplaySystem.getDisplaySystem().getRenderer().createMaterialState();
ms.setAmbient(new ColorRGBA(0.8f,0.1f,0.1f,0.5f));
ms.setEmissive(new ColorRGBA(1,0.0f,0,0.5f));
ms.setDiffuse(new ColorRGBA(1,0,0,0.5f));
ms.setSpecular(new ColorRGBA(1,0,0,0.5f));
ms.setShininess(50);
ms.setEnabled(true);
ms.setMaterialFace(MaterialState.MF_FRONT_AND_BACK);
groundNode.setRenderState(ms);
groundNode.updateRenderState();
Box box =new Box("my box",new Vector3f(1,1,1),new Vector3f(2,2,2));
box.setModelBound(new BoundingBox());
box.updateModelBound();
tsItemLoader = new TsItemLoader();
Node tankNode = tsItemLoader.loadTankItem();
tankNode.setLocalTranslation(10,0,10);
occluders.attachChild(tankNode);
}
//******DO NOT TOUCH BELOW*********************************
public Node getOccludersNode()
{
return occluders;
}
public Node getRootNode()
{
return rootNode;
}
public Node getFpsNode()
{
return fpsNode;
}
//
@Override
public void render(float tpf)
{
renderer.draw(rootNode);
renderer.draw(fpsNode);
renderer.draw(gameInfoNode);
}
@Override
public void update(float tpf)
{
timer.update();
tpf = timer.getTimePerFrame();
updateBuffer.setLength( 0 );
updateBuffer.append( "FPS: " ).append( (int) timer.getFrameRate() ).append(" - " );
updateBuffer.append( renderer.getStatistics( tempBuffer ) );
fpsText.print( updateBuffer );
fpsNode.updateGeometricState(tpf, true);
gameInfoNode.updateGeometricState(tpf, true);
rootNode.updateGeometricState(tpf, true);
input.update(tpf);
}
@Override
public void cleanup()
{
TextureManager.doTextureCleanup();
if (DisplaySystem.getDisplaySystem() != null && renderer != null) renderer.cleanup();
KeyInput.destroyIfInitalized();
MouseInput.destroyIfInitalized();
}
}
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URL;
import com.jme.bounding.BoundingSphere;
import com.jme.math.FastMath;
import com.jme.math.Quaternion;
import com.jme.math.Vector3f;
import com.jme.scene.Node;
import com.jme.scene.TriMesh;
import com.jme.util.export.binary.BinaryImporter;
import com.jmex.model.converters.ObjToJme;
public class TsItemLoader
{
public Node loadTankItem()
{
ObjToJme converter = new ObjToJme();
try
{
URL bodyObjFile = TsItemLoader.class.getClassLoader().getResource("resources/models/tank/body.obj");
converter.setProperty("mtllib", bodyObjFile);
converter.setProperty("texdir",bodyObjFile);
ByteArrayOutputStream BO = new ByteArrayOutputStream();
System.out.println("Starting to convert .obj to .jme");
converter.convert(bodyObjFile.openStream(),BO);
TriMesh bodyMesh = (TriMesh)BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
bodyMesh.setLocalScale(0.6f);
Quaternion roll180 = new Quaternion();
roll180.fromAngleAxis( FastMath.PI , new Vector3f(0,1,0) );
bodyMesh.setLocalRotation(roll180);
bodyMesh.setModelBound(new BoundingSphere());
bodyMesh.updateModelBound();
Node tankNode = new Node();
tankNode.attachChildAt(bodyMesh,0);
tankNode.setLocalScale(0.8f);
return tankNode;
}
catch (IOException e)
{
e.printStackTrace();
return null;
}
}
}
Main Class:
import com.jme.input.MouseInput;
import com.jme.system.DisplaySystem;
import com.jmex.game.StandardGame;
import com.jmex.game.state.GameStateManager;
public class TsStandardGame
{
public static void main(String[] args)
{
@SuppressWarnings("unused")
TsStandardGame sg = new TsStandardGame();
}
public TsStandardGame()
{
StandardGame game = new StandardGame("TankSport");
game.getSettings().setVerticalSync(false);
DisplaySystem.getDisplaySystem().setMinSamples(4);
game.getSettings().setStencilBits(4);
game.getSettings().setDepth( 16 );
game.getSettings().setAlphaBits( 0 );
game.getSettings().setSamples( 4 );
game.getSettings().setFramerate(-1);
game.start();
MouseInput.get().setCursorVisible(true);
TsGameState tsGameState = new TsGameState("tsGameState",60);
GameStateManager.getInstance().attachChild(tsGameState);
tsGameState.setActive(true);
}
}
And the simplified model (missing the turret but doesn't matter ;)):
http://www.mediafire.com/?f9wen0aydgr
Thanks a lot for your help Core-Dump !