Search in sources :

Example 21 with Shading

use of maspack.render.Renderer.Shading in project artisynth_core by artisynth.

the class Jack3d method render.

public void render(Renderer renderer, int flags) {
    if (!myVisibleP) {
        return;
    }
    renderer.pushModelMatrix();
    renderer.mulModelMatrix(myXDraggerToWorld);
    Shading savedShading = renderer.setShading(Shading.NONE);
    renderer.setLineWidth(myLineWidth);
    renderer.setPointSize(3);
    float[] coords = new float[3];
    renderer.setColor(1, 1, 0);
    myPnt0.get(coords);
    renderer.drawPoint(coords);
    renderer.scaleModelMatrix(mySize);
    if (renderObject == null) {
        renderObject = createJackRenderable();
    }
    // draw selected component first
    if (mySelectedComponent != 0) {
        renderer.drawLines(renderObject, mySelectedComponent);
    }
    renderer.drawLines(renderObject, 0);
    renderer.setLineWidth(1);
    renderer.setShading(savedShading);
    renderer.popModelMatrix();
}
Also used : Shading(maspack.render.Renderer.Shading)

Example 22 with Shading

use of maspack.render.Renderer.Shading in project artisynth_core by artisynth.

the class PrimitivesTest method addContent.

@Override
protected void addContent(MultiViewer mv) {
    SimpleSelectable renderable = new SimpleSelectable() {

        RenderProps props = new RenderProps();

        @Override
        public void updateBounds(Vector3d pmin, Vector3d pmax) {
            Point3d.X_UNIT.updateBounds(pmin, pmax);
            Point3d.Y_UNIT.updateBounds(pmin, pmax);
            Point3d.Z_UNIT.updateBounds(pmin, pmax);
            Point3d.NEG_X_UNIT.updateBounds(pmin, pmax);
            Point3d.NEG_Y_UNIT.updateBounds(pmin, pmax);
            Point3d.NEG_Z_UNIT.updateBounds(pmin, pmax);
        }

        @Override
        public void render(Renderer renderer, int flags) {
            props.setFaceColor(Color.CYAN);
            renderer.setFaceColoring(props, false);
            renderer.setColor(props.getFaceColorF());
            Shading savedShading = renderer.setShading(Shading.NONE);
            renderer.setPointSize(20f);
            renderer.drawPoint(new float[] { 0.1f, 0.2f, 0.3f });
            renderer.setLineWidth(20f);
            renderer.drawLine(new float[] { -0.1f, -0.2f, -0.3f }, new float[] { -0.3f, -0.2f, -0.1f });
            renderer.setShading(savedShading);
            renderer.drawTriangle(new float[] { 0.1f, 0.1f, -0.1f }, new float[] { 0.3f, 0.1f, -0.1f }, new float[] { 0.1f, 0.3f, -0.1f });
        }

        @Override
        public void prerender(RenderList list) {
        }

        @Override
        public int getRenderHints() {
            return 0;
        }

        @Override
        public int numSelectionQueriesNeeded() {
            return 0;
        }

        @Override
        public boolean isSelectable() {
            return false;
        }

        @Override
        public void getSelection(LinkedList<Object> list, int qid) {
        }

        @Override
        public void setSelected(boolean set) {
        }

        @Override
        public boolean isSelected() {
            // TODO Auto-generated method stub
            return false;
        }
    };
    mv.addRenderable(renderable);
}
Also used : SimpleSelectable(maspack.test.GL.MultiViewer.SimpleSelectable) Vector3d(maspack.matrix.Vector3d) RenderProps(maspack.render.RenderProps) Renderer(maspack.render.Renderer) Shading(maspack.render.Renderer.Shading) RenderList(maspack.render.RenderList) LinkedList(java.util.LinkedList)

Example 23 with Shading

use of maspack.render.Renderer.Shading in project artisynth_core by artisynth.

the class Transrotator3d method render.

public void render(Renderer renderer, int flags) {
    if (!myVisibleP) {
        return;
    }
    Shading savedShading = renderer.setShading(Shading.NONE);
    renderer.setLineWidth(myLineWidth);
    ColorMixing savedMixing = renderer.setVertexColorMixing(ColorMixing.REPLACE);
    renderer.pushModelMatrix();
    renderer.mulModelMatrix(myXDraggerToWorld);
    float[] coords = new float[3];
    if (myDragMode != DragMode.OFF && mySelectedComponent != NONE) {
        renderer.setColor(1, 1, 0);
        renderer.setPointSize(3);
        myPnt0.get(coords);
        renderer.drawPoint(coords);
        renderer.setPointSize(1);
    }
    renderer.scaleModelMatrix(mySize);
    if (renderObject == null) {
        renderObject = createTransrotatorRenderable();
    }
    // select appropriate color buffer
    if (mySelectedComponent != 0) {
        renderer.drawLines(renderObject, mySelectedComponent);
    }
    renderer.drawLines(renderObject, 0);
    renderer.popModelMatrix();
    if (myDragMode != DragMode.OFF && (mySelectedComponent == X_ROTATE || mySelectedComponent == Y_ROTATE || mySelectedComponent == Z_ROTATE)) {
        // Draw rotation lines using the orientation at the time the drag was
        // started
        RigidTransform3d X = new RigidTransform3d(myXDraggerToWorld0);
        X.p.set(myXDraggerToWorld.p);
        renderer.pushModelMatrix();
        renderer.mulModelMatrix(X);
        final float[] coords0 = new float[] { 0, 0, 0 };
        renderer.setColor(0.5f, 0.5f, 0.5f);
        myPnt0.get(coords);
        renderer.drawLine(coords0, coords);
        renderer.setColor(1, 1, 0);
        myRotPnt.get(coords);
        renderer.drawLine(coords0, coords);
        renderer.popModelMatrix();
    }
    renderer.setLineWidth(1);
    renderer.setShading(savedShading);
    renderer.setVertexColorMixing(savedMixing);
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d) ColorMixing(maspack.render.Renderer.ColorMixing) Shading(maspack.render.Renderer.Shading)

Example 24 with Shading

use of maspack.render.Renderer.Shading in project artisynth_core by artisynth.

the class AuxMaterialElementDescList method dorender.

private void dorender(Renderer renderer, int flags, boolean selected) {
    // This code is taken mostly verbatim from FemElement3dList.
    // Should find a way to avoid duplicate code ...
    double fractionRenderRadius = 0;
    FractionRenderType fractionRenderType = AuxMaterialBundle.DEFAULT_FRACTION_RENDER_TYPE;
    ModelComponent parent = getParent();
    if (parent instanceof AuxMaterialBundle) {
        fractionRenderRadius = ((AuxMaterialBundle) parent).getFractionRenderRadius();
        fractionRenderType = ((AuxMaterialBundle) parent).getFractionRenderType();
    }
    if (fractionRenderRadius > 0) {
        Shading savedShading = renderer.getShading();
        renderer.setShading(myRenderProps.getShading());
        renderer.setPointColoring(myRenderProps, /*highlight=*/
        false);
        renderFractions(renderer, fractionRenderRadius, fractionRenderType, false);
        renderer.setShading(savedShading);
    }
}
Also used : ModelComponent(artisynth.core.modelbase.ModelComponent) Shading(maspack.render.Renderer.Shading) FractionRenderType(artisynth.core.femmodels.AuxMaterialBundle.FractionRenderType)

Example 25 with Shading

use of maspack.render.Renderer.Shading in project artisynth_core by artisynth.

the class SDGridTest method render.

@Override
public void render(Renderer renderer, int flags) {
    if (sdgrid != null) {
        Shading savedShading = renderer.getShading();
        renderer.setShading(Shading.NONE);
        renderer.setPointSize(5);
        VectorTransformer3d TGL = sdgrid.getGridToLocalTransformer();
        Vector3i res = sdgrid.getResolution();
        // Draw 4 vertical lines.
        renderer.beginDraw(DrawMode.LINES);
        renderer.addVertex(gridToLocal(TGL, res.x, res.y, res.z));
        renderer.addVertex(gridToLocal(TGL, res.x, res.y, 0));
        renderer.addVertex(gridToLocal(TGL, 0, res.y, res.z));
        renderer.addVertex(gridToLocal(TGL, 0, res.y, 0));
        renderer.addVertex(gridToLocal(TGL, 0, 0, res.z));
        renderer.addVertex(gridToLocal(TGL, 0, 0, 0));
        renderer.addVertex(gridToLocal(TGL, res.x, 0, res.z));
        renderer.addVertex(gridToLocal(TGL, res.x, 0, 0));
        // Draw a diagonal line from max to min.
        renderer.addVertex(gridToLocal(TGL, 0, 0, 0));
        renderer.addVertex(gridToLocal(TGL, res.x, res.y, res.z));
        renderer.endDraw();
        double[] phi = sdgrid.getDistances();
        // Draw the vertices on the grid.
        Vector3d coords = new Vector3d();
        for (int i = 0; i < phi.length; i++) {
            Vector3i vxyz = new Vector3i();
            sdgrid.vertexToXyzIndices(vxyz, i);
            sdgrid.getLocalVertexCoords(coords, vxyz);
            if (phi[i] <= 0) {
                renderer.setColor(Color.BLUE);
                renderer.drawPoint(coords);
            } else {
                renderer.setColor(Color.RED);
                renderer.drawPoint(coords);
            }
        }
        renderer.setPointSize(1);
        renderer.setShading(savedShading);
    }
}
Also used : Vector3d(maspack.matrix.Vector3d) Vector3i(maspack.matrix.Vector3i) Shading(maspack.render.Renderer.Shading) VectorTransformer3d(maspack.matrix.VectorTransformer3d)

Aggregations

Shading (maspack.render.Renderer.Shading)38 RenderProps (maspack.render.RenderProps)10 RigidTransform3d (maspack.matrix.RigidTransform3d)7 Vector3d (maspack.matrix.Vector3d)7 FaceStyle (maspack.render.Renderer.FaceStyle)5 RenderObject (maspack.render.RenderObject)4 ColorInterpolation (maspack.render.Renderer.ColorInterpolation)4 PointStyle (maspack.render.Renderer.PointStyle)4 ModelComponent (artisynth.core.modelbase.ModelComponent)3 Point3d (maspack.matrix.Point3d)3 ColorMapProps (maspack.render.ColorMapProps)3 LineRenderProps (maspack.render.LineRenderProps)3 LineStyle (maspack.render.Renderer.LineStyle)3 FractionRenderType (artisynth.core.femmodels.AuxMaterialBundle.FractionRenderType)2 Rectangle2D (java.awt.geom.Rectangle2D)2 FaceRenderProps (maspack.render.FaceRenderProps)2 Renderer (maspack.render.Renderer)2 ColorMixing (maspack.render.Renderer.ColorMixing)2 DirectionRenderType (artisynth.core.femmodels.MuscleBundle.DirectionRenderType)1 LinkedList (java.util.LinkedList)1