Search in sources :

Example 31 with RenderObject

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

the class PolygonalMeshRenderer method renderEdges.

public void renderEdges(Renderer renderer, RenderProps props, boolean highlight, FeatureIndexArray edges, boolean featureSelection) {
    PolygonalMesh mesh = getMesh();
    RenderObject rob = getRenderObject();
    if (mesh.numVertices() == 0) {
        return;
    }
    renderer.pushModelMatrix();
    if (mesh.isRenderBuffered()) {
        renderer.mulModelMatrix(mesh.getXMeshToWorldRender());
    } else {
        renderer.mulModelMatrix(mesh.XMeshToWorld);
    }
    drawEdges(renderer, props, highlight, false, rob, edges, featureSelection);
    renderer.popModelMatrix();
}
Also used : RenderObject(maspack.render.RenderObject)

Example 32 with RenderObject

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

the class PolygonalMeshRenderer method render.

public void render(Renderer renderer, RenderProps props, boolean highlight, FeatureIndexArray faces, FeatureIndexArray edges, boolean featureSelection) {
    PolygonalMesh mesh = getMesh();
    if (mesh.numVertices() == 0) {
        return;
    }
    RenderObject rob = getRenderObject();
    renderer.pushModelMatrix();
    if (mesh.isRenderBuffered()) {
        renderer.mulModelMatrix(mesh.getXMeshToWorldRender());
    } else {
        renderer.mulModelMatrix(mesh.XMeshToWorld);
    }
    boolean drawFaces = (props.getFaceStyle() != Renderer.FaceStyle.NONE);
    ColorMixing savedColorMixing = null;
    if (mesh.hasColors()) {
        savedColorMixing = renderer.setVertexColorMixing(mesh.getVertexColorMixing());
    }
    if (props.getDrawEdges()) {
        drawEdges(renderer, props, highlight, drawFaces, rob, edges, featureSelection);
    }
    if (drawFaces) {
        drawFaces(renderer, props, highlight, rob, faces, featureSelection);
    }
    if (mesh.hasColors()) {
        renderer.setVertexColorMixing(savedColorMixing);
    }
    renderer.popModelMatrix();
}
Also used : ColorMixing(maspack.render.Renderer.ColorMixing) RenderObject(maspack.render.RenderObject)

Example 33 with RenderObject

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

the class PointMeshRenderer method render.

@Override
public void render(Renderer renderer, RenderProps props, int flags) {
    PointMesh mesh = getMesh();
    RenderObject rob = getRenderObject();
    if (mesh.numVertices() == 0) {
        return;
    }
    boolean highlight = ((flags & Renderer.HIGHLIGHT) != 0);
    renderer.pushModelMatrix();
    if (mesh.isRenderBuffered()) {
        renderer.mulModelMatrix(mesh.getXMeshToWorldRender());
    } else {
        renderer.mulModelMatrix(mesh.XMeshToWorld);
    }
    float savedLineWidth = renderer.getLineWidth();
    Shading savedShadeModel = renderer.getShading();
    // if (renderer.isSelecting()) {
    // shading = Shading.NONE;
    // }
    PointStyle pointStyle = props.getPointStyle();
    if (pointStyle == PointStyle.POINT && !mesh.hasNormals()) {
        renderer.setShading(Shading.NONE);
    } else {
        renderer.setShading(props.getShading());
    }
    ColorInterpolation savedColorInterp = null;
    if (usingHSV(mesh)) {
        savedColorInterp = renderer.setColorInterpolation(ColorInterpolation.HSV);
    }
    renderer.setPointColoring(props, highlight);
    switch(pointStyle) {
        case POINT:
            {
                int size = props.getPointSize();
                if (size > 0) {
                    renderer.drawPoints(rob, PointStyle.POINT, size);
                }
                break;
            }
        case CUBE:
        case SPHERE:
            {
                double rad = props.getPointRadius();
                if (rad > 0) {
                    renderer.drawPoints(rob, pointStyle, rad);
                }
                break;
            }
    }
    if (savedColorInterp != null) {
        renderer.setColorInterpolation(savedColorInterp);
    }
    if (mesh.getNormalRenderLen() > 0) {
        renderer.setLineWidth(props.getLineWidth());
        renderer.setLineColoring(props, highlight);
        renderer.drawLines(rob);
    }
    renderer.setLineWidth(savedLineWidth);
    renderer.setShading(savedShadeModel);
    renderer.popModelMatrix();
}
Also used : PointStyle(maspack.render.Renderer.PointStyle) Shading(maspack.render.Renderer.Shading) ColorInterpolation(maspack.render.Renderer.ColorInterpolation) RenderObject(maspack.render.RenderObject)

Example 34 with RenderObject

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

the class PolylineMeshRenderer method render.

@Override
public void render(Renderer renderer, RenderProps props, int flags) {
    PolylineMesh mesh = getMesh();
    RenderObject rob = getRenderObject();
    if (mesh.numVertices() == 0) {
        return;
    }
    boolean highlight = ((flags & Renderer.HIGHLIGHT) != 0);
    renderer.pushModelMatrix();
    if (mesh.isRenderBuffered()) {
        renderer.mulModelMatrix(mesh.getXMeshToWorldRender());
    } else {
        renderer.mulModelMatrix(mesh.XMeshToWorld);
    }
    float savedLineWidth = renderer.getLineWidth();
    Shading savedShadeModel = renderer.getShading();
    // Shading shading = props.getShading();
    // if (renderer.isSelecting()) {
    // shading = Shading.NONE;
    // }
    LineStyle lineStyle = props.getLineStyle();
    Shading savedShading = renderer.getShading();
    if (lineStyle == LineStyle.LINE && !mesh.hasNormals()) {
        renderer.setShading(Shading.NONE);
    } else {
        renderer.setShading(props.getShading());
    }
    ColorInterpolation savedColorInterp = null;
    if (usingHSV(mesh)) {
        savedColorInterp = renderer.setColorInterpolation(ColorInterpolation.HSV);
    }
    renderer.setLineColoring(props, highlight);
    switch(lineStyle) {
        case LINE:
            {
                int width = props.getLineWidth();
                if (width > 0) {
                    renderer.drawLines(rob, LineStyle.LINE, width);
                }
                break;
            }
        case SPINDLE:
        case SOLID_ARROW:
        case CYLINDER:
            {
                double rad = props.getLineRadius();
                if (rad > 0) {
                    renderer.drawLines(rob, props.getLineStyle(), rad);
                }
                break;
            }
    }
    if (savedColorInterp != null) {
        renderer.setColorInterpolation(savedColorInterp);
    }
    renderer.setShading(savedShading);
    renderer.setLineWidth(savedLineWidth);
    renderer.setShading(savedShadeModel);
    renderer.popModelMatrix();
}
Also used : LineStyle(maspack.render.Renderer.LineStyle) Shading(maspack.render.Renderer.Shading) ColorInterpolation(maspack.render.Renderer.ColorInterpolation) RenderObject(maspack.render.RenderObject)

Example 35 with RenderObject

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

the class MeshRendererBase method prerender.

/**
 * Updates rendering information
 * @param props render properties
 */
public void prerender(RenderProps props) {
    RobSignature sig = createSignature(myMesh, props);
    if (myRob == null || renderObjectNeedsBuilding(myMesh, props, sig, mySignature)) {
        RenderObject robj = buildRenderObject(myMesh, props);
        myRob = robj;
        mySignature = sig;
    } else {
        updateRenderObject(myMesh, props, myRob);
    }
}
Also used : 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