Search in sources :

Example 36 with Shading

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

the class PlanarConnector method render.

public void render(Renderer renderer, int flags) {
    Vector3d nrm = new Vector3d(0, 0, 1);
    RigidTransform3d TDW = getCurrentTDW();
    computeRenderVtxs(TDW);
    nrm.transform(TDW);
    RenderProps props = myRenderProps;
    Shading savedShading = renderer.setPropsShading(props);
    renderer.setFaceColoring(props, isSelected());
    renderer.setFaceStyle(props.getFaceStyle());
    renderer.beginDraw(DrawMode.TRIANGLE_STRIP);
    renderer.setNormal(nrm.x, nrm.y, nrm.z);
    renderer.addVertex(myRenderVtxs[3]);
    renderer.addVertex(myRenderVtxs[0]);
    renderer.addVertex(myRenderVtxs[2]);
    renderer.addVertex(myRenderVtxs[1]);
    renderer.endDraw();
    renderer.setShading(savedShading);
    // set default
    renderer.setFaceStyle(FaceStyle.FRONT);
    renderer.drawPoint(myRenderProps, myRenderCoords, isSelected());
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d) Vector3d(maspack.matrix.Vector3d) RenderProps(maspack.render.RenderProps) Shading(maspack.render.Renderer.Shading)

Example 37 with Shading

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

the class SoftPlaneCollider method render.

public void render(Renderer renderer, int flags) {
    Point3d renderCenter = new Point3d();
    myPlane.set(myNormal, myCenter);
    myPlane.project(renderCenter, myCenter);
    RigidTransform3d X = new RigidTransform3d();
    Vector3d nrml = myPlane.getNormal();
    X.R.setZDirection(nrml);
    X.p.set(renderCenter);
    renderer.pushModelMatrix();
    renderer.mulModelMatrix(X);
    Shading savedShading = renderer.setPropsShading(myRenderProps);
    renderer.setFaceColoring(myRenderProps, isSelected());
    renderer.setFaceStyle(myRenderProps.getFaceStyle());
    renderer.beginDraw(Renderer.DrawMode.TRIANGLE_STRIP);
    renderer.setNormal(nrml.x, nrml.y, nrml.z);
    renderer.addVertex(mySize, -mySize, 0);
    renderer.addVertex(mySize, mySize, 0);
    renderer.addVertex(-mySize, -mySize, 0);
    renderer.addVertex(-mySize, mySize, 0);
    renderer.endDraw();
    renderer.setShading(savedShading);
    // set default
    renderer.setFaceStyle(FaceStyle.FRONT);
    renderer.popModelMatrix();
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d) Vector3d(maspack.matrix.Vector3d) Point3d(maspack.matrix.Point3d) Shading(maspack.render.Renderer.Shading)

Example 38 with Shading

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

the class FreehandTool method render.

public void render(Renderer renderer, int flags) {
    if (!myVisibleP) {
        return;
    }
    renderer.pushModelMatrix();
    RigidTransform3d X = new RigidTransform3d();
    getToolToWorld(X);
    renderer.mulModelMatrix(X);
    Shading savedShading = renderer.setShading(Shading.NONE);
    float[] rgb = new float[4];
    myLineColor.getRGBColorComponents(rgb);
    renderer.setColor(rgb);
    renderer.setLineWidth(myLineWidth);
    if (myClosedP) {
        renderer.beginDraw(DrawMode.LINE_LOOP);
    } else {
        renderer.beginDraw(DrawMode.LINE_STRIP);
    }
    for (int i = 0; i < myPoints.size(); i++) {
        Point2d p = myPoints.get(i);
        renderer.addVertex(p.x, p.y, 0);
    }
    renderer.endDraw();
    renderer.setLineWidth(1);
    renderer.setShading(savedShading);
    renderer.popModelMatrix();
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d) Point2d(maspack.matrix.Point2d) Shading(maspack.render.Renderer.Shading)

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