Hey guys,
Getting some weird behavior – for debugging purposes, I set everyone to have targets. I am generally using werulez’s suggestion of a quad pointed at the player.
http://i.imgur.com/hM0Ap.png
Using the translucent bucket (as shown above), it seems only 1 target shows the correct texture – everyone else is solid green. If someone else appears with a target, the previously correct target guy turns solid green and the correct target goes to the newest character. If I use the transparent bucket, I sometimes see multiple correctly textured targets, but they flicker in and out, and often disappear completely.
Here is the code I use to set the targets (FastGeometry is just a Geometry with a custom, faster SetLocalTranslation etc.):
[java]
private FastGeometry Target;
private static Texture targetTex = mainGame.getAssetManager().loadTexture(“Textures/target.png”);
private Material targetMaterial;
public boolean usingTarget;
private ColorRGBA lastTargetColor;
public void SetTargetColor(ColorRGBA clr) {
if( clr == null ) {
if( usingTarget ) Main.myApp.getRootNode().detachChild(Target);
usingTarget = false;
return;
}
if( Target == null ) {
Target = new FastGeometry(World.unitCenterQuad);
targetMaterial = new Material(mainGame.getAssetManager(), “Common/MatDefs/Misc/Unshaded.j3md”);
targetMaterial.getAdditionalRenderState().setDepthTest(false);
targetMaterial.setTexture(“ColorMap”, targetTex);
targetMaterial.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
Target.setQueueBucket(Bucket.Transparent);
targetMaterial.getAdditionalRenderState().setDepthWrite(false);
Target.setLocalScale((float)SizeX
2, (float)SizeY1.33f, (float)SizeZ*2);
Target.setMaterial(targetMaterial);
}
if( usingTarget == false ) {
Target.setCullHint(CullHint.Always);
Main.myApp.getRootNode().attachChild(Target);
usingTarget = true;
}
if( lastTargetColor == null ||
clr.r != lastTargetColor.r ||
clr.g != lastTargetColor.g ||
clr.b != lastTargetColor.b ||
clr.a != lastTargetColor.a ) {
targetMaterial.setColor(“Color”, clr);
lastTargetColor = clr;
}
}
[/java]
I call this function like SetTargetColor(ColorRGBA.Green);
I position and rotate the target like this:
[java] if( usingTarget ) {
Vector3f myTrans = myNode.getLocalTranslation();
Target.setLocalTranslation(myTrans);
Vector3f pdiff = myTrans.subtract(Main.myWorld.Player.holdNode.getWorldTranslation());
Helpers.FastLookAt(rotator, pdiff);
Target.setLocalRotation(rotator);
Target.setCullHint(CullHint.Dynamic);
}[/java]
(Helpers.FastLookAt is just a faster Quaternion.lookAt)
Any suggestions?