Search in sources :

Example 1 with BMText

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;
}
Also used : BMText(com.ardor3d.ui.text.BMText)

Example 2 with BMText

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;
}
Also used : Line(com.ardor3d.scenegraph.Line) OrientedBoundingBox(com.ardor3d.bounding.OrientedBoundingBox) ReadOnlyColorRGBA(com.ardor3d.math.type.ReadOnlyColorRGBA) ColorRGBA(com.ardor3d.math.ColorRGBA) Node(com.ardor3d.scenegraph.Node) Mesh(com.ardor3d.scenegraph.Mesh) BoundingBox(com.ardor3d.bounding.BoundingBox) Box(com.ardor3d.scenegraph.shape.Box) OrientedBoundingBox(com.ardor3d.bounding.OrientedBoundingBox) BMText(com.ardor3d.ui.text.BMText) OffsetState(com.ardor3d.renderer.state.OffsetState) CullHint(com.ardor3d.scenegraph.hint.CullHint)

Example 3 with BMText

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;
}
Also used : LightState(com.ardor3d.renderer.state.LightState) ColladaImporter(com.ardor3d.extension.model.collada.jdom.ColladaImporter) Node(com.ardor3d.scenegraph.Node) CameraNode(com.ardor3d.scenegraph.extension.CameraNode) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) Matrix3(com.ardor3d.math.Matrix3) ResourceSource(com.ardor3d.util.resource.ResourceSource) Spatial(com.ardor3d.scenegraph.Spatial) DirectionalLight(com.ardor3d.light.DirectionalLight) ColladaStorage(com.ardor3d.extension.model.collada.jdom.data.ColladaStorage) BMText(com.ardor3d.ui.text.BMText)

Example 4 with BMText

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;
}
Also used : BMText(com.ardor3d.ui.text.BMText)

Example 5 with BMText

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;
}
Also used : BMText(com.ardor3d.ui.text.BMText)

Aggregations

BMText (com.ardor3d.ui.text.BMText)17 OrientedBoundingBox (com.ardor3d.bounding.OrientedBoundingBox)10 Line (com.ardor3d.scenegraph.Line)9 BoundingBox (com.ardor3d.bounding.BoundingBox)8 ColorRGBA (com.ardor3d.math.ColorRGBA)7 Mesh (com.ardor3d.scenegraph.Mesh)7 Node (com.ardor3d.scenegraph.Node)7 Box (com.ardor3d.scenegraph.shape.Box)6 Vector3 (com.ardor3d.math.Vector3)5 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)5 OffsetState (com.ardor3d.renderer.state.OffsetState)5 CullHint (com.ardor3d.scenegraph.hint.CullHint)5 ReadOnlyColorRGBA (com.ardor3d.math.type.ReadOnlyColorRGBA)4 Spatial (com.ardor3d.scenegraph.Spatial)4 Cylinder (com.ardor3d.scenegraph.shape.Cylinder)4 BlendState (com.ardor3d.renderer.state.BlendState)2 CullState (com.ardor3d.renderer.state.CullState)2 AngleAnnotation (org.concord.energy3d.shapes.AngleAnnotation)2 PvModuleSpecs (org.concord.energy3d.simulation.PvModuleSpecs)2 ColladaImporter (com.ardor3d.extension.model.collada.jdom.ColladaImporter)1