use of com.ardor3d.ui.text.BMText in project energy3d by concord-consortium.
the class HousePart method fetchBMText.
protected BMText fetchBMText(final String text, final int index) {
final BMText label;
if (labelsRoot.getChildren().size() > index) {
label = (BMText) labelsRoot.getChild(index);
label.setText(text);
label.getSceneHints().setCullHint(CullHint.Inherit);
} else {
label = new BMText("Label Text", text, FontManager.getInstance().getPartNumberFont(), Align.Center, Justify.Center);
Util.initHousePartLabel(label);
labelsRoot.attachChild(label);
}
return label;
}
use of com.ardor3d.ui.text.BMText in project energy3d by concord-consortium.
the class FresnelReflector method init.
@Override
protected void init() {
super.init();
if (Util.isZero(copyLayoutGap)) {
// FIXME: Why is a transient member evaluated to zero?
copyLayoutGap = 0.2;
}
if (Util.isZero(moduleLength)) {
moduleLength = 3;
}
if (Util.isZero(length)) {
length = 2 * moduleLength;
}
if (Util.isZero(moduleWidth)) {
moduleWidth = 2;
}
if (Util.isZero(reflectance)) {
reflectance = 0.9;
}
if (Util.isZero(opticalEfficiency)) {
opticalEfficiency = 0.99;
}
if (Util.isZero(nSectionLength)) {
nSectionLength = 16;
}
if (Util.isZero(nSectionWidth)) {
nSectionWidth = 4;
}
detailed = Scene.getInstance().countParts(this.getClass()) < 50;
if (absorber != null) {
// FIXME: Somehow the absorber foundation, when copied, doesn't point to the right object. This is not a prefect solution, but it fixes the problem.
absorber = (Foundation) Scene.getInstance().getPart(absorber.getId());
}
mesh = new Mesh("Fresnel Reflector Face");
mesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(6));
mesh.getMeshData().setTextureBuffer(BufferUtils.createVector2Buffer(6), 0);
mesh.setDefaultColor(SKY_BLUE);
mesh.setModelBound(new OrientedBoundingBox());
mesh.setUserData(new UserData(this));
root.attachChild(mesh);
reflector = new Box("Fresnel Reflector Box");
reflector.setModelBound(new OrientedBoundingBox());
final OffsetState offset = new OffsetState();
offset.setFactor(1);
offset.setUnits(1);
reflector.setRenderState(offset);
root.attachChild(reflector);
final int nModules = Math.max(1, getNumberOfModules());
outlines = new Line("Fresnel Reflector (Outline)");
outlines.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(8 + (nModules - 1) * 2));
outlines.setDefaultColor(ColorRGBA.BLACK);
outlines.setModelBound(new OrientedBoundingBox());
outlines.setLineWidth(1f);
outlines.setStipplePattern((short) 0xffff);
Util.disablePickShadowLight(outlines);
root.attachChild(outlines);
lightBeams = new Line("Light Beams");
lightBeams.setLineWidth(1f);
lightBeams.setStipplePattern((short) 0xffff);
lightBeams.setModelBound(null);
Util.disablePickShadowLight(lightBeams);
lightBeams.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(4));
lightBeams.setDefaultColor(new ColorRGBA(1f, 1f, 1f, 1f));
root.attachChild(lightBeams);
label = new BMText("Label", "#" + id, FontManager.getInstance().getPartNumberFont(), Align.Center, Justify.Center);
Util.initHousePartLabel(label);
label.setFontScale(0.5);
label.setVisible(false);
root.attachChild(label);
modulesRoot = new Node("Modules Root");
root.attachChild(modulesRoot);
updateTextureAndColor();
if (!points.isEmpty()) {
oldReflectorCenter = points.get(0).clone();
}
oldLength = length;
oldModuleWidth = moduleWidth;
}
use of com.ardor3d.ui.text.BMText in project energy3d by concord-consortium.
the class SceneManager method createCompass.
private Node createCompass() throws IOException {
final ResourceSource source = ResourceLocatorTool.locateResource(ResourceLocatorTool.TYPE_MODEL, "compass.dae");
final ColladaImporter colladaImporter = new ColladaImporter();
// Load the collada scene
Logger.getLogger(ColladaAnimUtils.class.getName()).setLevel(Level.SEVERE);
Logger.getLogger(ColladaMaterialUtils.class.getName()).setLevel(Level.SEVERE);
final ColladaStorage storage = colladaImporter.load(source);
final Node compass = storage.getScene();
BMText txt;
final double Z = 0.1;
txt = new BMText("N", "N", FontManager.getInstance().getAnnotationFont(), Align.South);
txt.setTextColor(ColorRGBA.BLACK);
txt.setAutoRotate(false);
txt.setTranslation(2, 0.0, Z);
txt.setRotation(new Matrix3().fromAngles(0.0, MathUtils.HALF_PI, -MathUtils.HALF_PI));
compass.attachChild(txt);
txt = new BMText("S", "S", FontManager.getInstance().getAnnotationFont(), Align.South);
txt.setTextColor(ColorRGBA.BLACK);
txt.setAutoRotate(false);
txt.setTranslation(-2, -0.0, Z);
txt.setRotation(new Matrix3().fromAngles(0.0, -MathUtils.HALF_PI, MathUtils.HALF_PI));
compass.attachChild(txt);
txt = new BMText("W", "W", FontManager.getInstance().getAnnotationFont(), Align.South);
txt.setAutoRotate(false);
txt.setTranslation(-0.0, 2, Z);
txt.setRotation(new Matrix3().fromAngles(-MathUtils.HALF_PI, 0.0, 0.0));
compass.attachChild(txt);
txt = new BMText("E", "E", FontManager.getInstance().getAnnotationFont(), Align.South);
txt.setAutoRotate(false);
txt.setTranslation(-0.0, -2, Z);
txt.setRotation(new Matrix3().fromAngles(MathUtils.HALF_PI, MathUtils.PI, 0.0));
compass.attachChild(txt);
final DirectionalLight light = new DirectionalLight();
light.setDirection(new Vector3(0, 0, -1));
light.setEnabled(true);
final LightState lightState = new LightState();
lightState.attach(light);
compass.setRenderState(lightState);
compass.getSceneHints().setLightCombineMode(LightCombineMode.Replace);
compass.updateWorldRenderStates(true);
final Node compassNode = new Node();
compassNode.setRotation(new Matrix3().fromAngles(-MathUtils.HALF_PI, 0.0, 0.0));
compassNode.attachChild(compass);
System.out.println("done");
compass.addController(new SpatialController<Spatial>() {
@Override
public void update(final double time, final Spatial caller) {
final Vector3 direction = getCamera().getDirection().normalize(null);
direction.setZ(0);
direction.normalizeLocal();
double angle = -direction.smallestAngleBetween(Vector3.UNIT_Y);
if (direction.dot(Vector3.UNIT_X) > 0) {
angle = -angle;
}
angle -= MathUtils.HALF_PI;
compass.setRotation(new Matrix3().fromAngles(0.0, 0.0, angle - 0.3));
}
});
return compassNode;
}
use of com.ardor3d.ui.text.BMText in project energy3d by concord-consortium.
the class Annotation method makeNewLabel.
public static BMText makeNewLabel(final double fontSize) {
final BMText label = new BMText("Annotation Label", "", FontManager.getInstance().getAnnotationFont(), BMText.Align.Center, BMText.Justify.Center);
label.setTextColor(ColorRGBA.BLACK);
label.setAutoScale(AutoScale.Off);
label.setFontScale(fontSize);
label.setAutoRotate(false);
label.setAutoFade(AutoFade.Off);
label.setModelBound(null);
label.updateWorldTransform(true);
label.getSceneHints().setRenderBucketType(RenderBucketType.PostBucket);
return label;
}
use of com.ardor3d.ui.text.BMText in project energy3d by concord-consortium.
the class Heliodon method createText.
private BMText createText(final String text) {
final BMText label = new BMText(text, text, FontManager.getInstance().getAnnotationFont(), Align.Center);
label.setAutoRotate(false);
label.setAutoScale(AutoScale.FixedScreenSize);
label.setAutoFade(AutoFade.Off);
label.setFontScale(0.75);
root.attachChild(label);
return label;
}
Aggregations