Search in sources :

Example 11 with ReadOnlyTransform

use of com.ardor3d.math.type.ReadOnlyTransform in project energy3d by concord-consortium.

the class ParabolicTrough method updateEditShapes.

@Override
public void updateEditShapes() {
    final FloatBuffer buf = mesh.getMeshData().getVertexBuffer();
    final ReadOnlyTransform trans = mesh.getWorldTransform();
    final ReadOnlyVector3 n = normal == null ? Vector3.UNIT_Z : new Vector3(normal.getX(), 0, normal.getZ()).normalizeLocal();
    final double halfWidth = 0.5 * apertureWidth / Scene.getInstance().getAnnotationScale();
    final double dy = halfWidth * halfWidth / (2 * (semilatusRectum / Scene.getInstance().getAnnotationScale()));
    final Vector3 shift = new Vector3(n.getX() * dy, 0, n.getZ() * dy);
    final int j = buf.limit() / 6;
    final Vector3 v1 = new Vector3();
    final Vector3 v2 = new Vector3();
    BufferUtils.populateFromBuffer(v1, buf, 0);
    BufferUtils.populateFromBuffer(v2, buf, j);
    // along the direction of length
    final Vector3 p1 = trans.applyForward(v1).add(trans.applyForward(v2), null).multiplyLocal(0.5);
    BufferUtils.populateFromBuffer(v1, buf, 0);
    BufferUtils.populateFromBuffer(v2, buf, j - 1);
    // along the direction of width
    final Vector3 p2 = trans.applyForward(v1).add(trans.applyForward(v2), null).multiplyLocal(0.5).subtractLocal(shift);
    BufferUtils.populateFromBuffer(v1, buf, j - 1);
    BufferUtils.populateFromBuffer(v2, buf, 2 * j - 1);
    // along the direction of length
    final Vector3 p3 = trans.applyForward(v1).add(trans.applyForward(v2), null).multiplyLocal(0.5);
    BufferUtils.populateFromBuffer(v1, buf, j);
    BufferUtils.populateFromBuffer(v2, buf, 2 * j - 1);
    // along the direction of width
    final Vector3 p4 = trans.applyForward(v1).add(trans.applyForward(v2), null).multiplyLocal(0.5).subtractLocal(shift);
    int i = 1;
    getEditPointShape(i++).setTranslation(p1);
    getEditPointShape(i++).setTranslation(p2);
    getEditPointShape(i++).setTranslation(p3);
    getEditPointShape(i++).setTranslation(p4);
    final ReadOnlyColorRGBA c = Scene.getInstance().isGroundImageLightColored() ? ColorRGBA.DARK_GRAY : (lockEdit ? disabledColor : ColorRGBA.WHITE);
    for (i = 1; i < 5; i++) {
        getEditPointShape(i).setDefaultColor(c);
    }
    super.updateEditShapes();
    getEditPointShape(0).setTranslation(p1.addLocal(p3).multiplyLocal(0.5).addLocal(0, 0, 0.15));
}
Also used : ReadOnlyColorRGBA(com.ardor3d.math.type.ReadOnlyColorRGBA) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) ReadOnlyTransform(com.ardor3d.math.type.ReadOnlyTransform) FloatBuffer(java.nio.FloatBuffer) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) CullHint(com.ardor3d.scenegraph.hint.CullHint)

Example 12 with ReadOnlyTransform

use of com.ardor3d.math.type.ReadOnlyTransform in project energy3d by concord-consortium.

the class FresnelReflector method updateEditShapes.

@Override
public void updateEditShapes() {
    final FloatBuffer buf = mesh.getMeshData().getVertexBuffer();
    final ReadOnlyTransform trans = mesh.getWorldTransform();
    final Vector3 v1 = new Vector3();
    final Vector3 v2 = new Vector3();
    BufferUtils.populateFromBuffer(v1, buf, 0);
    BufferUtils.populateFromBuffer(v2, buf, 1);
    final Vector3 p1 = trans.applyForward(v1).add(trans.applyForward(v2), null).multiplyLocal(0.5);
    BufferUtils.populateFromBuffer(v1, buf, 1);
    BufferUtils.populateFromBuffer(v2, buf, 2);
    final Vector3 p2 = trans.applyForward(v1).add(trans.applyForward(v2), null).multiplyLocal(0.5);
    BufferUtils.populateFromBuffer(v1, buf, 2);
    BufferUtils.populateFromBuffer(v2, buf, 4);
    final Vector3 p3 = trans.applyForward(v1).add(trans.applyForward(v2), null).multiplyLocal(0.5);
    BufferUtils.populateFromBuffer(v1, buf, 4);
    BufferUtils.populateFromBuffer(v2, buf, 0);
    final Vector3 p4 = trans.applyForward(v1).add(trans.applyForward(v2), null).multiplyLocal(0.5);
    int i = 1;
    getEditPointShape(i++).setTranslation(p1);
    getEditPointShape(i++).setTranslation(p2);
    getEditPointShape(i++).setTranslation(p3);
    getEditPointShape(i++).setTranslation(p4);
    final ReadOnlyColorRGBA c = Scene.getInstance().isGroundImageLightColored() ? ColorRGBA.DARK_GRAY : (lockEdit ? disabledColor : ColorRGBA.WHITE);
    for (i = 1; i < 5; i++) {
        getEditPointShape(i).setDefaultColor(c);
    }
    super.updateEditShapes();
    getEditPointShape(0).setTranslation(p1.addLocal(p3).multiplyLocal(0.5).addLocal(0, 0, 0.15));
}
Also used : ReadOnlyColorRGBA(com.ardor3d.math.type.ReadOnlyColorRGBA) ReadOnlyTransform(com.ardor3d.math.type.ReadOnlyTransform) FloatBuffer(java.nio.FloatBuffer) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) CullHint(com.ardor3d.scenegraph.hint.CullHint)

Aggregations

Vector3 (com.ardor3d.math.Vector3)12 ReadOnlyTransform (com.ardor3d.math.type.ReadOnlyTransform)12 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)12 FloatBuffer (java.nio.FloatBuffer)10 CullHint (com.ardor3d.scenegraph.hint.CullHint)8 Matrix3 (com.ardor3d.math.Matrix3)3 ReadOnlyColorRGBA (com.ardor3d.math.type.ReadOnlyColorRGBA)3 BloomRenderPass (com.ardor3d.extension.effect.bloom.BloomRenderPass)2 ColladaImporter (com.ardor3d.extension.model.collada.jdom.ColladaImporter)1 ColladaStorage (com.ardor3d.extension.model.collada.jdom.data.ColladaStorage)1 Canvas (com.ardor3d.framework.Canvas)1 MouseState (com.ardor3d.input.MouseState)1 InputTrigger (com.ardor3d.input.logical.InputTrigger)1 KeyPressedCondition (com.ardor3d.input.logical.KeyPressedCondition)1 MouseButtonPressedCondition (com.ardor3d.input.logical.MouseButtonPressedCondition)1 MouseButtonReleasedCondition (com.ardor3d.input.logical.MouseButtonReleasedCondition)1 MouseMovedCondition (com.ardor3d.input.logical.MouseMovedCondition)1 TriggerAction (com.ardor3d.input.logical.TriggerAction)1 TwoInputStates (com.ardor3d.input.logical.TwoInputStates)1 IntersectionRecord (com.ardor3d.intersection.IntersectionRecord)1