use of com.ardor3d.math.type.ReadOnlyVector3 in project energy3d by concord-consortium.
the class Foundation method scanChildrenHeight.
private double scanChildrenHeight(final HousePart part) {
double maxHeight = height;
if (part instanceof Wall || part instanceof Roof || part instanceof Rack || part instanceof SolarPanel || part instanceof Mirror) {
for (int i = 0; i < part.points.size(); i++) {
final ReadOnlyVector3 p = part.getAbsPoint(i);
maxHeight = Math.max(maxHeight, p.getZ());
}
}
for (final HousePart child : part.children) {
maxHeight = Math.max(maxHeight, scanChildrenHeight(child));
}
return maxHeight;
}
use of com.ardor3d.math.type.ReadOnlyVector3 in project energy3d by concord-consortium.
the class Foundation method drawTopMesh.
public void drawTopMesh() {
mesh.setVisible(!Scene.getInstance().isGroundImageEnabled());
final FloatBuffer vertexBuffer = mesh.getMeshData().getVertexBuffer();
vertexBuffer.rewind();
ReadOnlyVector3 p;
final Vector3 p0 = getAbsPoint(0);
final Vector3 p1 = getAbsPoint(1);
final Vector3 p2 = getAbsPoint(2);
final Vector3 p3 = getAbsPoint(3);
p = p0;
vertexBuffer.put(p.getXf()).put(p.getYf()).put((float) height);
p = p2;
vertexBuffer.put(p.getXf()).put(p.getYf()).put((float) height);
p = p1;
vertexBuffer.put(p.getXf()).put(p.getYf()).put((float) height);
vertexBuffer.put(p.getXf()).put(p.getYf()).put((float) height);
p = p2;
vertexBuffer.put(p.getXf()).put(p.getYf()).put((float) height);
p = p3;
vertexBuffer.put(p.getXf()).put(p.getYf()).put((float) height);
final ReadOnlyVector3 normal = Vector3.UNIT_Z;
final FloatBuffer normalBuffer = mesh.getMeshData().getNormalBuffer();
normalBuffer.rewind();
for (int i = 0; i < 6; i++) {
normalBuffer.put(normal.getXf()).put(normal.getYf()).put(normal.getZf());
}
final FloatBuffer textureBuffer = mesh.getMeshData().getTextureBuffer(0);
textureBuffer.rewind();
textureBuffer.put(0).put(0);
textureBuffer.put(1).put(0);
textureBuffer.put(0).put(1);
textureBuffer.put(0).put(1);
textureBuffer.put(1).put(0);
textureBuffer.put(1).put(1);
mesh.updateModelBound();
CollisionTreeManager.INSTANCE.removeCollisionTree(mesh);
}
use of com.ardor3d.math.type.ReadOnlyVector3 in project energy3d by concord-consortium.
the class Foundation method drawLinePattern.
public void drawLinePattern() {
final ReadOnlyVector3 p0 = getAbsPoint(0);
final ReadOnlyVector3 p1 = getAbsPoint(1);
final ReadOnlyVector3 p2 = getAbsPoint(2);
final ReadOnlyVector3 width = p2.subtract(p0, null);
final ReadOnlyVector3 height = p1.subtract(p0, null);
final ArrayList<ReadOnlyVector3> points = new ArrayList<ReadOnlyVector3>();
final int count = 10;
if (width.length() < height.length()) {
final double step = width.length() / count;
for (int i = 0; i < count; i++) {
final ReadOnlyVector3 lineP1 = width.normalize(null).multiplyLocal(i * step).addLocal(p0);
points.add(lineP1);
final ReadOnlyVector3 lineP2 = lineP1.add(height, null);
points.add(lineP2);
}
} else {
final double step = height.length() / count;
for (int i = 0; i < count; i++) {
final ReadOnlyVector3 lineP1 = height.normalize(null).multiplyLocal(i * step).addLocal(p0);
points.add(lineP1);
final ReadOnlyVector3 lineP2 = lineP1.add(width, null);
points.add(lineP2);
}
}
if (points.size() < 2) {
return;
}
final FloatBuffer buf = BufferUtils.createVector3Buffer(points.size());
for (final ReadOnlyVector3 p : points) {
buf.put(p.getXf()).put(p.getYf()).put((float) this.height + 0.1f);
}
linePatternMesh.getMeshData().setVertexBuffer(buf);
}
use of com.ardor3d.math.type.ReadOnlyVector3 in project energy3d by concord-consortium.
the class Foundation method drawMeshSelection.
private void drawMeshSelection(final Mesh m) {
final List<ReadOnlyVector3> outlinePoints = MeshLib.computeOutline(m.getMeshData().getVertexBuffer());
if (outlinePoints == null || outlinePoints.isEmpty()) {
return;
}
final int n = outlinePoints.size();
FloatBuffer outlineVertexBuffer = selectedMeshOutline.getMeshData().getVertexBuffer();
if (outlineVertexBuffer.capacity() != n * 6) {
outlineVertexBuffer = BufferUtils.createFloatBuffer(n * 6);
selectedMeshOutline.getMeshData().setVertexBuffer(outlineVertexBuffer);
} else {
outlineVertexBuffer.rewind();
outlineVertexBuffer.limit(outlineVertexBuffer.capacity());
}
ReadOnlyVector3 p;
for (int i = 0; i < n; i++) {
p = outlinePoints.get(i);
outlineVertexBuffer.put(p.getXf()).put(p.getYf()).put(p.getZf());
p = outlinePoints.get((i + 1) % n);
outlineVertexBuffer.put(p.getXf()).put(p.getYf()).put(p.getZf());
}
selectedMeshOutline.setTransform(m.getWorldTransform());
selectedMeshOutline.updateModelBound();
selectedMeshOutline.setVisible(true);
// Util.drawBoundingBox(m.getParent(), selectedNodeBoundingBox);
}
use of com.ardor3d.math.type.ReadOnlyVector3 in project energy3d by concord-consortium.
the class SolarPanel method drawSupporFrame.
private void drawSupporFrame() {
supportFrame.setDefaultColor(getColor());
final FloatBuffer vertexBuffer = supportFrame.getMeshData().getVertexBuffer();
final FloatBuffer normalBuffer = supportFrame.getMeshData().getNormalBuffer();
vertexBuffer.rewind();
normalBuffer.rewind();
vertexBuffer.limit(vertexBuffer.capacity());
normalBuffer.limit(normalBuffer.capacity());
final ReadOnlyVector3 o = getAbsPoint(0);
Vector3 dir;
Vector3 p;
if (trackerType == NO_TRACKER && Util.isZero(tiltAngle)) {
dir = new Vector3(0.5, 0, 0);
p = o.add(0, 0, baseHeight, null);
} else {
// special case when normal is z-axis
dir = Util.isEqualFaster(normal, Vector3.UNIT_Z, 0.001) ? new Vector3(0, 1, 0) : normal.cross(Vector3.UNIT_Z, null);
dir = dir.multiplyLocal(0.5);
p = o.add(0, 0, baseHeight, null);
}
Util.addPointToQuad(normal, o, p, dir, vertexBuffer, normalBuffer);
final double w = (rotated ? panelHeight : panelWidth) / Scene.getInstance().getAnnotationScale();
dir.normalizeLocal().multiplyLocal(w * 0.5);
final Vector3 v1 = p.add(dir, null);
dir.negateLocal();
final Vector3 v2 = p.add(dir, null);
dir = new Vector3(normal).multiplyLocal(0.2);
Util.addPointToQuad(normal, v1, v2, dir, vertexBuffer, normalBuffer);
vertexBuffer.limit(vertexBuffer.position());
normalBuffer.limit(normalBuffer.position());
supportFrame.getMeshData().updateVertexCount();
supportFrame.updateModelBound();
}
Aggregations