Search in sources :

Example 81 with ReadOnlyVector3

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;
}
Also used : ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) CullHint(com.ardor3d.scenegraph.hint.CullHint)

Example 82 with ReadOnlyVector3

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);
}
Also used : ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) FloatBuffer(java.nio.FloatBuffer) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) CullHint(com.ardor3d.scenegraph.hint.CullHint)

Example 83 with ReadOnlyVector3

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);
}
Also used : ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) ArrayList(java.util.ArrayList) FloatBuffer(java.nio.FloatBuffer) CullHint(com.ardor3d.scenegraph.hint.CullHint)

Example 84 with ReadOnlyVector3

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);
}
Also used : ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) FloatBuffer(java.nio.FloatBuffer) CullHint(com.ardor3d.scenegraph.hint.CullHint)

Example 85 with ReadOnlyVector3

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();
}
Also used : ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) FloatBuffer(java.nio.FloatBuffer) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3)

Aggregations

ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)125 Vector3 (com.ardor3d.math.Vector3)88 CullHint (com.ardor3d.scenegraph.hint.CullHint)60 FloatBuffer (java.nio.FloatBuffer)45 TPoint (org.poly2tri.triangulation.point.TPoint)44 Point (org.poly2tri.geometry.primitives.Point)34 PolygonPoint (org.poly2tri.geometry.polygon.PolygonPoint)32 Mesh (com.ardor3d.scenegraph.Mesh)25 Spatial (com.ardor3d.scenegraph.Spatial)25 ArrayList (java.util.ArrayList)23 Node (com.ardor3d.scenegraph.Node)18 PickingHint (com.ardor3d.scenegraph.hint.PickingHint)18 Ray3 (com.ardor3d.math.Ray3)16 PickResults (com.ardor3d.intersection.PickResults)15 PrimitivePickResults (com.ardor3d.intersection.PrimitivePickResults)15 ArdorVector3Point (org.poly2tri.triangulation.point.ardor3d.ArdorVector3Point)15 TriangulationPoint (org.poly2tri.triangulation.TriangulationPoint)13 Matrix3 (com.ardor3d.math.Matrix3)10 CancellationException (java.util.concurrent.CancellationException)10 Vector2 (com.ardor3d.math.Vector2)9