Search in sources :

Example 41 with RenderObject

use of maspack.render.RenderObject in project artisynth_core by artisynth.

the class FemElement3dList method prerender.

public void prerender(RenderList list) {
    ComponentList<? extends FemNode> nodes = getNodeList();
    if (nodes == null) {
        // XXX what to do?
        return;
    }
    // will render first and be more visible.
    for (int i = 0; i < size(); i++) {
        FemElement3d elem = get(i);
        if (elem.isSelected() && elem.getRenderProps() != null) {
            list.addIfVisible(elem);
        }
    }
    for (int i = 0; i < size(); i++) {
        FemElement3d elem = get(i);
        if (!elem.isSelected() && elem.getRenderProps() != null) {
            list.addIfVisible(elem);
        }
    }
    int update = renderObjectsNeedUpdating();
    if (update != 0) {
        // for now just rebuild, even if only colors need changing
        buildRenderObjects();
    }
    if (myWidgetRob != null) {
        RenderObject r = myWidgetRob;
        int pidx = 0;
        for (int i = 0; i < size(); i++) {
            FemElement3d elem = get(i);
            byte flags = getRobFlags(elem);
            if ((flags & HAS_WIDGET) != 0) {
                double wsize = elem.getElementWidgetSize();
                pidx = FemElementRenderer.updateWidgetPositions(r, elem, wsize, pidx);
            }
        }
        FemElementRenderer.updateWidgetNormals(r, REG_GRP);
        FemElementRenderer.updateWidgetNormals(r, SEL_GRP);
        FemElementRenderer.updateWidgetNormals(r, INV_GRP);
        r.notifyPositionsModified();
    }
    if (myQuadEdges != null) {
        for (QuadEdgeDesc quad : myQuadEdges) {
            quad.updateCurve(myEdgeRob);
        }
    }
    myEdgeRob.notifyPositionsModified();
}
Also used : RenderObject(maspack.render.RenderObject)

Example 42 with RenderObject

use of maspack.render.RenderObject in project artisynth_core by artisynth.

the class FemElementRenderer method renderWidget.

public void renderWidget(Renderer renderer, FemElement3d elem, double size, RenderProps props) {
    RenderObject r = myRob;
    updateWidgetPositions(r, elem, size, myNumEdgePos);
    updateWidgetNormals(r, /*group=*/
    0);
    if (!renderer.isSelecting()) {
        float[] color = props.getFaceColorF();
        if (elem.isInverted()) {
            color = FemModel3d.myInvertedColor;
        }
        renderer.setFaceColoring(props, color, elem.isSelected());
    }
    renderer.drawTriangles(r, /*group=*/
    0);
}
Also used : RenderObject(maspack.render.RenderObject)

Example 43 with RenderObject

use of maspack.render.RenderObject in project artisynth_core by artisynth.

the class FemElementRenderer method renderRestWidget.

public void renderRestWidget(Renderer renderer, FemElement3d elem, double size, RenderProps props) {
    RenderObject r = myRob;
    updateWidgetRestPositions(r, elem, size, myNumEdgePos);
    updateWidgetNormals(r, /*group=*/
    0);
    if (!renderer.isSelecting()) {
        float[] color = props.getFaceColorF();
        if (elem.isInverted()) {
            color = FemModel3d.myInvertedColor;
        }
        renderer.setFaceColoring(props, color, elem.isSelected());
    }
    renderer.drawTriangles(r, /*group=*/
    0);
}
Also used : RenderObject(maspack.render.RenderObject)

Example 44 with RenderObject

use of maspack.render.RenderObject in project artisynth_core by artisynth.

the class FemElementRenderer method buildRenderObject.

void buildRenderObject(FemElement3d elem) {
    RenderObject r = new RenderObject();
    // dummy normal for lines
    r.addNormal(1, 0, 0);
    for (int i = 0; i < elem.numNodes(); i++) {
        r.vertex(0, 0, 0);
    }
    int[] eidxs = elem.getEdgeIndices();
    int numv = 0;
    for (int i = 0; i < eidxs.length; i += (numv + 1)) {
        numv = eidxs[i];
        if (numv == 2) {
            int vidx0 = eidxs[i + 1];
            int vidx1 = eidxs[i + 2];
            r.addLine(vidx0, vidx1);
        } else if (numv == 3) {
            int vidx0 = eidxs[i + 1];
            int vidxm = eidxs[i + 2];
            int vidx1 = eidxs[i + 3];
            // r.addLine (vidx0, vidxm);
            // r.addLine (vidxm, vidx1);
            QuadEdge quad = new QuadEdge(vidx0, vidxm, vidx1);
            quad.addCurve(r);
            myQuadEdges.add(quad);
        }
    }
    myNumEdgePos = r.numPositions();
    addWidgetFaces(r, elem);
    r.setTransient(true);
    myRob = r;
}
Also used : RenderObject(maspack.render.RenderObject)

Example 45 with RenderObject

use of maspack.render.RenderObject in project artisynth_core by artisynth.

the class FemElementRenderer method render.

public void render(Renderer renderer, FemElement3d elem, RenderProps props) {
    RenderObject r = myRob;
    updateEdgePositions(r, elem);
    Shading savedShading = renderer.setShading(Shading.NONE);
    renderer.setLineWidth(props.getLineWidth());
    renderer.setLineColoring(props, elem.isSelected());
    renderer.drawLines(r);
    renderer.setLineWidth(1);
    renderer.setShading(savedShading);
    double wsize = elem.getElementWidgetSize();
    if (wsize > 0) {
        renderWidget(renderer, elem, wsize, props);
    }
}
Also used : Shading(maspack.render.Renderer.Shading) RenderObject(maspack.render.RenderObject)

Aggregations

RenderObject (maspack.render.RenderObject)45 Vector3d (maspack.matrix.Vector3d)8 RenderProps (maspack.render.RenderProps)7 Point3d (maspack.matrix.Point3d)4 Shading (maspack.render.Renderer.Shading)4 Color (java.awt.Color)3 IntersectionPoint (maspack.collision.IntersectionPoint)3 PenetratingPoint (maspack.collision.PenetratingPoint)3 LineSegment (maspack.geometry.LineSegment)3 AffineTransform3d (maspack.matrix.AffineTransform3d)3 RigidTransform3d (maspack.matrix.RigidTransform3d)3 PointStyle (maspack.render.Renderer.PointStyle)3 PenetrationRegion (maspack.collision.PenetrationRegion)2 Face (maspack.geometry.Face)2 Vertex3d (maspack.geometry.Vertex3d)2 Point2d (maspack.matrix.Point2d)2 Renderer (maspack.render.Renderer)2 ColorInterpolation (maspack.render.Renderer.ColorInterpolation)2 LineStyle (maspack.render.Renderer.LineStyle)2 Group (artisynth.core.mechmodels.Collidable.Group)1