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));
}
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));
}
Aggregations