Trouble with ImposterNode

Hi All,



I am looking at using DLOD and have the model switch to an imposterNode at a distance.

Using the example from the 2.0.1 package I have got a sample working using BaseGame, But when I tried to intergrate it with my main project that uses game states I get a Null Pointer Exception at the first line of creating the imposter Node



[java]tRenderer = DisplaySystem.getDisplaySystem().createTextureRenderer(

twidth, theight, TextureRenderer.Target.Texture2D);[/java]



Seems that there may be a problem with obtaining the DisplaySystem?



[java]

DistanceSwitchModel DLODMod = new DistanceSwitchModel(2);

private DiscreteLodNode dlod;

private ImposterNode iNode;

BillboardNode bnode;



public void setModel(Node model) {

CreateDLOD();

this.model = model;

this.model.setModelBound(new BoundingBox());

this.model.updateModelBound();

this.model.updateWorldBound();

this.model.updateRenderState();

this.model.updateGeometricState(0, true);

dlod.attachChild(this.model);

ImposterScene = new Node(“Imposter”);

ImposterScene.attachChild(this.model);

ImposterScene.updateRenderState();

ImposterScene.updateGeometricState(0, true);

iNode = new ImposterNode(“model imposter”, 10, 256, 256);

iNode.attachChild(ImposterScene);

iNode.setRedrawRate(.05f); // .05 = update texture 20 times a second on average

bnode = new BillboardNode(“imposter bbnode”);

bnode.setAlignment(BillboardNode.SCREEN_ALIGNED);

bnode.attachChild(iNode);

dlod.attachChild(bnode);

this.attachChild(dlod);

}



public void CreateDLOD() {

DLODMod.setModelDistance(0, 0, 20);

DLODMod.setModelDistance(1, 20, 500);

dlod = new DiscreteLodNode(“DLOD”, DLODMod);

}

[/java]

I think BaseGame does not support GameStates, BasicGame does.

Sorry my main project uses BasicGameState which works fine for everything else that I have tried to do so far, just wont let me use the imposterNode



Not sure if its how Im trying to do it



I have a Loading Game state that loads my models and a game state which is the main part of my game.

I have a unitManager class that looks after the unit side of things and the code posted above is part of the unit class which is based on the vehicle class from the flag run tutorial

Also to Note here is the trace:

Exception in thread “playerThread” java.lang.NullPointerException

at com.jme.renderer.lwjgl.LWJGLTextureRenderer.(LWJGLTextureRenderer.java:104)

at com.jme.system.lwjgl.LWJGLDisplaySystem.createTextureRenderer(LWJGLDisplaySystem.java:327)

at com.jme.scene.ImposterNode.(ImposterNode.java:101)

at MOTD.units.Unit.setModel(Unit.java:442)

at MOTD.units.UnitManager.CreateUnit(UnitManager.java:430)

at MOTD.units.UnitManager.CreatePerson(UnitManager.java:480)

at MOTD.gamestates.MainGameState.buildPlayer(MainGameState.java:599)

at MOTD.gamestates.LoadingState.run(LoadingState.java:84)



the line in LWJGLTextureRenderer is

[java]

isSupported = GLContext.getCapabilities().GL_EXT_framebuffer_object;

[/java]



Only happens from my Unit manger class not my basic game test code, was just wondering what may be the cause of the problem?



Thanks



EDIT:

OK think I may have found the problem but not sure if that may mean what I’m trying to do it just not done like that

In my test case i was actual loading 2 models, one as the actual model to display and the other as the imposter that gets switched at a distance with dlod, That doesnt really suite my needs because then for each unit I will have 2 models loading



Ok so what Im trying to do is when the camera is far from an object it will make a sprite version of it to reduce load on the computer, say if I have 100 odd units visable the more distant ones will be just a simple sprite instead of trying to render the full model, i did try clod but didnt seem to work with my animated person model, I cant really remeber how I tried to get that going perhaps I may need to have another look



Edit2:

Ok have made a check compare and added a bit of a switch class, few issues though.

Issue 1) I lose my vertex colour from my model after making it an imposter and changing it back, also seems that the colour doesnt show up on the imposter either



Issue 2) The Imposter nodes dont render in the same spot as the original model and appear to be leaning to the side a bit should I not be using a billboard node to display the imposter?



Thanks