Search in sources :

Example 56 with RenderProps

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

the class VertexList method render.

public void render(Renderer renderer, int flags) {
    RenderProps props = myRenderProps;
    if (renderer.isSelecting()) {
        PointStyle style = props.getPointStyle();
        if (style == PointStyle.POINT) {
            int size = props.getPointSize();
            if (size > 0) {
                renderer.setPointSize(size);
            } else {
                return;
            }
        }
        for (int i = 0; i < size(); i++) {
            VertexComponent pnt = get(i);
            if (pnt.getRenderProps() == null && renderer.isSelectable(pnt)) {
                float[] v0 = pnt.myRenderCoords;
                renderer.beginSelectionQuery(i);
                switch(style) {
                    case POINT:
                        {
                            renderer.drawPoint(v0);
                            break;
                        }
                    case CUBE:
                        {
                            renderer.drawCube(v0, 2 * props.getPointRadius());
                        }
                    case SPHERE:
                        {
                            renderer.drawSphere(v0, props.getPointRadius());
                            break;
                        }
                }
                renderer.endSelectionQuery();
            }
        }
        if (style == PointStyle.POINT) {
            renderer.setPointSize(1);
        }
    } else if (myRob != null) {
        int numReg = myRob.numPoints(REG_GRP);
        int numSel = myRob.numPoints(SEL_GRP);
        // draw selected first
        if (numSel > 0) {
            drawPoints(renderer, SEL_GRP, props, /*selected=*/
            true);
        }
        if (numReg > 0) {
            drawPoints(renderer, REG_GRP, props, /*selected=*/
            false);
        }
    }
}
Also used : PointStyle(maspack.render.Renderer.PointStyle) PointRenderProps(maspack.render.PointRenderProps) RenderProps(maspack.render.RenderProps)

Example 57 with RenderProps

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

the class FaceList method render.

public void render(Renderer renderer, int flags) {
    RenderProps props = getRenderProps();
    if (myFaces == null) {
        myFaces = new FeatureIndexArray[2];
        myEdges = new FeatureIndexArray[2];
        for (int i = 0; i < 2; ++i) {
            int size = myFaceIdxs[i].size();
            myFaces[i] = new FeatureIndexArray(size, 3 * size);
            myEdges[i] = new FeatureIndexArray(size, 6 * size);
        }
    }
    if ((flags & Renderer.SORT_FACES) != 0) {
        Vector3d zdir = renderer.getEyeZDirection();
        myMeshRenderer.sortFaces(myFaceIdxs[REG_GRP].getArray(), 0, myFaceIdxs[REG_GRP].size(), zdir);
        myMeshRenderer.sortFaces(myFaceIdxs[SEL_GRP].getArray(), 0, myFaceIdxs[SEL_GRP].size(), zdir);
        myFaceIdxs[REG_GRP].notifyModified();
        myFaceIdxs[SEL_GRP].notifyModified();
    }
    for (int i = 0; i < 2; ++i) {
        if (myFaceIdxsVersions[i] != myFaceIdxs[i].getVersion()) {
            int[] faceIdxs = myFaceIdxs[i].getArray();
            int len = myFaceIdxs[i].size();
            myMeshRenderer.updateFaceTriangles(faceIdxs, 0, len, myFaces[i]);
            myMeshRenderer.updateFaceLines(faceIdxs, 0, len, myEdges[i]);
            myFaceIdxsVersions[i] = myFaceIdxs[i].getVersion();
        }
    }
    // first draw selected
    boolean highlight = false;
    if (renderer.getHighlightStyle() == HighlightStyle.COLOR) {
        highlight = true;
    }
    myMeshRenderer.render(renderer, props, highlight, myFaces[SEL_GRP], myEdges[SEL_GRP], true);
    myMeshRenderer.render(renderer, props, false, myFaces[REG_GRP], myEdges[REG_GRP], true);
}
Also used : FeatureIndexArray(maspack.render.FeatureIndexArray) Vector3d(maspack.matrix.Vector3d) PointRenderProps(maspack.render.PointRenderProps) RenderProps(maspack.render.RenderProps)

Example 58 with RenderProps

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

the class GridPlane method render.

@Override
public void render(Renderer renderer, int flags) {
    boolean highlight = ((flags & Renderer.HIGHLIGHT) != 0);
    RenderProps props = getRenderProps();
    renderer.pushModelMatrix();
    renderer.mulModelMatrix(XGridToWorld);
    float[] coords0 = new float[3];
    float[] coords1 = new float[3];
    // draw grid lines
    // draw lines parallel to y axis
    coords0[1] = -(float) (mySize.y / 2);
    coords1[1] = (float) (mySize.y / 2);
    double dx = mySize.x / myResolution.x;
    for (int i = 0; i <= (int) (myResolution.x); i++) {
        coords0[0] = (float) (-mySize.x / 2 + i * dx);
        coords1[0] = coords0[0];
        renderer.drawLine(props, coords0, coords1, highlight);
    }
    // draw lines parallel to x axis
    coords0[0] = -(float) (mySize.x / 2);
    coords1[0] = (float) (mySize.x / 2);
    double dy = mySize.y / myResolution.y;
    for (int i = 0; i <= (int) (myResolution.y); i++) {
        coords0[1] = (float) (-mySize.y / 2 + i * dy);
        coords1[1] = coords0[1];
        renderer.drawLine(props, coords0, coords1, highlight);
    }
    renderer.popModelMatrix();
}
Also used : RenderProps(maspack.render.RenderProps)

Example 59 with RenderProps

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

the class IsRenderableHolder method init.

private void init(IsRenderable renderable) {
    if (renderable == null) {
        throw new IllegalArgumentException("Cannot hold a null object");
    }
    myRenderable = renderable;
    myProps = new PropertyList(IsRenderableHolder.class, RenderableComponentBase.class);
    myProps.add("renderProps * *", "render properties", null);
    if (myRenderable instanceof HasProperties) {
        myProps.addReadOnly("renderable", "the held renderable object");
    }
    if (myRenderable instanceof HasRenderProps) {
        myHasRenderProps = (HasRenderProps) myRenderable;
        getRenderPropsMethod = null;
        setRenderPropsMethod = null;
        createRenderPropsMethod = null;
    } else {
        myHasRenderProps = null;
        // try to find methods
        Class<?> clazz = myRenderable.getClass();
        getRenderPropsMethod = getMethod(clazz, "getRenderProps");
        setRenderPropsMethod = getMethod(clazz, "setRenderProps", RenderProps.class);
        createRenderPropsMethod = getMethod(clazz, "createRenderProps");
    }
    if (myRenderable instanceof Scannable) {
        myScannable = (Scannable) myRenderable;
        writeMethod = null;
        scanMethod = null;
    } else {
        myScannable = null;
        Class<?> clazz = myRenderable.getClass();
        writeMethod = getMethod(clazz, "write", PrintWriter.class, NumberFormat.class, Object.class);
        scanMethod = getMethod(clazz, "scan", ReaderTokenizer.class, CompositeComponent.class);
    }
}
Also used : HasRenderProps(maspack.render.HasRenderProps) HasProperties(maspack.properties.HasProperties) HasRenderProps(maspack.render.HasRenderProps) RenderProps(maspack.render.RenderProps) PropertyList(maspack.properties.PropertyList) ReaderTokenizer(maspack.util.ReaderTokenizer) Scannable(maspack.util.Scannable) PrintWriter(java.io.PrintWriter) NumberFormat(maspack.util.NumberFormat)

Example 60 with RenderProps

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

the class TextComponentBase method createRenderProps.

@Override
public RenderProps createRenderProps() {
    RenderProps rprops = createDefaultRenderProps();
    PropertyUtils.updateInheritedProperties(rprops, this, "renderProps");
    return rprops;
}
Also used : FaceRenderProps(maspack.render.FaceRenderProps) RenderProps(maspack.render.RenderProps)

Aggregations

RenderProps (maspack.render.RenderProps)86 Color (java.awt.Color)17 Vector3d (maspack.matrix.Vector3d)17 RigidBody (artisynth.core.mechmodels.RigidBody)11 RigidTransform3d (maspack.matrix.RigidTransform3d)11 Shading (maspack.render.Renderer.Shading)10 PolygonalMesh (maspack.geometry.PolygonalMesh)8 Point3d (maspack.matrix.Point3d)8 RenderObject (maspack.render.RenderObject)7 FrameMarker (artisynth.core.mechmodels.FrameMarker)6 File (java.io.File)6 IOException (java.io.IOException)6 Vertex3d (maspack.geometry.Vertex3d)6 AffineTransform3d (maspack.matrix.AffineTransform3d)4 ColorMapProps (maspack.render.ColorMapProps)4 HasRenderProps (maspack.render.HasRenderProps)4 LineRenderProps (maspack.render.LineRenderProps)4 AxialSpring (artisynth.core.mechmodels.AxialSpring)3 Muscle (artisynth.core.mechmodels.Muscle)3 LinkedList (java.util.LinkedList)3