Vector3d scale = scale(entity);
// TODO: use this as fallback, but load real 3D models if available
if (true) {
Shape3D sh = tilesetManager.getModel(entity);
Transform3D t = new Transform3D();
t.rotX(pitch(entity));
t.setScale(scale);
mech = new TransformGroup(t);
mech.addChild(sh);
}
mech.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
Transform3D ftrans = new Transform3D();
ftrans.rotZ(facing(dir));
ftrans.setTranslation(location(hex, c, elevation, height(entity)));
facing = new TransformGroup(ftrans);
facing.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
facing.addChild(mech);
if (entity.getECMRange() != Entity.NONE) {
int range = entity.getECMRange();
Appearance eapp = new Appearance();
eapp.setColoringAttributes(new ColoringAttributes(c50, ColoringAttributes.SHADE_FLAT));
TransparencyAttributes ta = new TransparencyAttributes(TransparencyAttributes.BLENDED, 0.90f);
ta.setCapability(TransparencyAttributes.ALLOW_VALUE_WRITE);
eapp.setTransparencyAttributes(ta);
TransparencyInterpolator ti = new TransparencyInterpolator(C.halfAlpha, ta, .90f, .97f);
ti.setSchedulingBounds(BoardModel.bounds);
addChild(ti);
eapp.setPolygonAttributes(C.noCull);
Shape3D ecm = makeECMArea(range);
ecm.setAppearance(eapp);
ecm.setPickable(false);
facing.addChild(ecm);
ecm = makeECMBorder(range);
ecm.setAppearance(eapp);
ecm.setPickable(false);
facing.addChild(ecm);
eapp = new Appearance();
eapp.setColoringAttributes(new ColoringAttributes(c50, ColoringAttributes.SHADE_FLAT));
eapp.setLineAttributes(C.defLine);
ecm = makeECMOutline(range);
ecm.setAppearance(eapp);
ecm.setPickable(false);
facing.addChild(ecm);
}
Appearance sapp = new Appearance();
sapp.setMaterial(new Material(new Color3f(tint), C.black, c50, C.white, 64.0f));
Cone co = new Cone();
co.setAppearance(sapp);
if (dir != sdir) {
TransformGroup fscale = new TransformGroup();
fscale.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
ScaleInterpolator si = new ScaleInterpolator(C.dblAlpha, fscale);
si.setSchedulingBounds(BoardModel.bounds);
si.setMinimumScale(.8f);
si.setMaximumScale(1.25f);
fscale.addChild(co);
Transform3D sftrans = new Transform3D();
sftrans.rotZ(facing(sdir-dir));
Vector3d sv = new Vector3d(0.0, 5*BoardModel.HEX_DIAMETER/12, 0.0);
sftrans.transform(sv);
sftrans.setTranslation(sv);
TransformGroup sfacing = new TransformGroup(sftrans);
sfacing.addChild(fscale);
sfacing.addChild(si);
facing.addChild(sfacing);
}
label = new TransformGroup(new Transform3D(C.nullRot, labelLocation(hex, c, elevation), 1.0));
label.addChild(view.makeViewRelative(new LabelModel(entity.getShortName(), C.white, c50, LabelModel.BOLD), BoardModel.HEX_DIAMETER*.45));
label.setPickable(false);
label.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
addChild(facing);