Creativ
December 9, 2009, 11:27pm
1
Hey,
i have a little Problem with my HUD.
Everything works well, except sometimes my HUD hides behind another Object, like in the Screenshot, although the HUD is rendered in Ortho-Mode.
Here is some Code how i create my HUD:
Quad dataBg = new Quad("hud", 236f, 100f);
dataBg.setRenderQueueMode(Renderer.QUEUE_ORTHO);
dataBg.setLocalTranslation(new Vector3f(118,50,0));
dataBg.setRenderState(TextureCache.getInstance().getTexture("hud/dataBg.png"));
dataBg.setRenderState(bs);
dataBg.setLightCombineMode(Spatial.LightCombineMode.Off);
dataBg.updateRenderState();
this.attachChild(dataBg);
bs is just some BlendState and this.attachChild(dataBg); attaches the quad to a node, that is attached to the rootNode. So it's not directly attached to the rootNode. Is this a mistake?
Do you have an Idea what I'm doing wrong?
normen
December 9, 2009, 11:33pm
2
This has to do with the minimum z-depth that the camera displays. I think you can avoid it by setting the setFrustumNear() value of the camera. I had this problem as well and dug into that a bit, its about camera settings, that much I can say for sure
Creativ
December 14, 2009, 9:20pm
3
Hi,
Thanks for your help.
I solved this Problem with replacing this line:
dataBg.setLocalTranslation(new Vector3f(118,50,0));
with this one:
dataBg.setLocalTranslation(new Vector3f(118,50,1));
But now I got another Problem.
I'm currently trying to add a Weapon to the HUD.
So i got this model:
As u can see, the model looks right, but if I add this to the HUD and set RenderQueue to Ortho it looks like this:
And here is the Code how i add the Weapon to the HUD:
URL ninjaUrl = new File("player/paintballGun.jme").toURI().toURL();
Node weapon = ModelCache.getInstance().getModel(ninjaUrl);
weapon.setLocalScale(5f);
weapon.setRenderQueueMode(Renderer.QUEUE_ORTHO);
weapon.setLightCombineMode(Spatial.LightCombineMode.Off);
Quaternion rot = new Quaternion();
rot.fromAngleAxis(FastMath.DEG_TO_RAD * 90, Vector3f.UNIT_Y);
weapon.setLocalRotation(rot);
weapon.setLocalTranslation(new Vector3f(
Game.getGame().getDisplay().getWidth()/2 + 250,
Game.getGame().getDisplay().getHeight()/2,
1));
weapon.updateRenderState();
this.attachChild(weapon);
ModelCache.getInstance().getModel(ninjaUrl); just returns a Node with the Model in it.
What am i doing wrong?
Dennis