Search in sources :

Example 6 with RenderProps

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

the class TextureEgyptianTest method addContent.

@Override
protected void addContent(MultiViewer mv) {
    JFrame frame = new JFrame();
    JPanel controls = new JPanel();
    frame.add(controls);
    PolygonalMesh plane = MeshFactory.createRectangle(4000, 400, 32, 8, /*texture=*/
    true);
    RenderProps rprops = plane.getRenderProps();
    if (rprops == null) {
        rprops = new RenderProps();
    }
    rprops.setShading(Shading.SMOOTH);
    rprops.setShininess(20);
    rprops.setFaceColor(new Color(155, 196, 30));
    rprops.setSpecular(new Color(255, 113, 0));
    rprops.setFaceStyle(FaceStyle.FRONT_AND_BACK);
    plane.transform(new RigidTransform3d(Vector3d.ZERO, AxisAngle.ROT_X_90));
    String srcDir = PathFinder.findSourceDir(this);
    ColorMapProps dprops = new ColorMapProps();
    dprops.setFileName(srcDir + "/data/specular_map.jpg");
    dprops.setColorMixing(ColorMixing.MODULATE);
    dprops.setEnabled(true);
    NormalMapProps normalProps = new NormalMapProps();
    normalProps.setFileName(srcDir + "/data/foil_normal_map2.png");
    normalProps.setScaling(0.3f);
    normalProps.setEnabled(true);
    BumpMapProps bumpProps = new BumpMapProps();
    bumpProps.setFileName(srcDir + "/data/egyptian_friz_2.png");
    bumpProps.setScaling(2.5f);
    bumpProps.setEnabled(true);
    rprops.setColorMap(dprops);
    rprops.setNormalMap(normalProps);
    rprops.setBumpMap(bumpProps);
    // FixedMeshBody fm = new FixedMeshBody(plane);
    // fm.setRenderProps(rprops);
    mv.addRenderable(plane);
    if (false) {
        mv.addRenderable(new IsRenderable() {

            @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) {
                renderer.setColor(Color.CYAN);
                renderer.setFaceStyle(FaceStyle.FRONT_AND_BACK);
                renderer.drawSphere(Point3d.ZERO, 1);
            }

            @Override
            public void prerender(RenderList list) {
            // TODO Auto-generated method stub
            }

            @Override
            public int getRenderHints() {
                // TODO Auto-generated method stub
                return 0;
            }
        });
    }
    mv.autoFitViewers();
    LabeledComponentBase base = PropertyWidget.create("Color texture", rprops.getColorMap(), "enabled");
    controls.add(base);
    base = PropertyWidget.create("Normal map", rprops.getNormalMap(), "enabled");
    controls.add(base);
    base = PropertyWidget.create("Bump map", rprops.getBumpMap(), "enabled");
    controls.add(base);
    base = PropertyWidget.create("Specular", rprops.getColorMap(), "specularColoring");
    controls.add(base);
    base = PropertyWidget.create("Bump map scale", rprops.getBumpMap(), "scaling");
    controls.add(base);
    base = PropertyWidget.create("Normal map scale", rprops.getNormalMap(), "scaling");
    controls.add(base);
    frame.pack();
    frame.setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) RigidTransform3d(maspack.matrix.RigidTransform3d) Color(java.awt.Color) ColorMapProps(maspack.render.ColorMapProps) RenderProps(maspack.render.RenderProps) PolygonalMesh(maspack.geometry.PolygonalMesh) RenderList(maspack.render.RenderList) BumpMapProps(maspack.render.BumpMapProps) IsRenderable(maspack.render.IsRenderable) JFrame(javax.swing.JFrame) Vector3d(maspack.matrix.Vector3d) Renderer(maspack.render.Renderer) LabeledComponentBase(maspack.widgets.LabeledComponentBase) NormalMapProps(maspack.render.NormalMapProps)

Example 7 with RenderProps

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

the class FemMuscleModel method render.

// public void setDrawFibers(boolean enable) {
// myDrawFibers = enable;
// }
public void render(Renderer renderer, int flags) {
    super.render(renderer, flags);
    // if (myFiberMesh != null) {
    // myFiberMesh.render(renderer, myRenderProps, /* flags= */0);
    // }
    // if (myDrawFibers) {
    RenderProps fiberRenderProps = myFiberRenderProps;
    if (fiberRenderProps == null) {
        fiberRenderProps = DEFAULT_FIBER_RENDER_PROPS;
    }
    double dirLen = getDirectionRenderLen();
    if (dirLen > 0) {
        Matrix3d F = new Matrix3d();
        Vector3d dir = new Vector3d();
        float[] coords0 = new float[3];
        float[] coords1 = new float[3];
        for (FemElement3d e : getElements()) {
            renderDirection(renderer, fiberRenderProps, e, coords0, coords1, F, dir, dirLen);
        }
    }
}
Also used : Matrix3d(maspack.matrix.Matrix3d) SymmetricMatrix3d(maspack.matrix.SymmetricMatrix3d) Vector3d(maspack.matrix.Vector3d) RenderProps(maspack.render.RenderProps)

Example 8 with RenderProps

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

the class FemMuscleModel method createDefaultFiberRenderProps.

private static RenderProps createDefaultFiberRenderProps() {
    if (DEFAULT_FIBER_RENDER_PROPS == null) {
        RenderProps props = new RenderProps();
        props.setLineColor(new Color(0f, 1f, 1f));
        props.setLineStyle(LineStyle.LINE);
        DEFAULT_FIBER_RENDER_PROPS = props;
    }
    return DEFAULT_FIBER_RENDER_PROPS;
}
Also used : Color(java.awt.Color) RenderProps(maspack.render.RenderProps)

Example 9 with RenderProps

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

the class MuscleElementDescList method render.

public void render(Renderer renderer, int flags) {
    RenderProps props = myRenderProps;
    if (renderer.isSelecting()) {
        for (int i = 0; i < size(); i++) {
            MuscleElementDesc desc = get(i);
            if (desc.getRenderProps() == null && renderer.isSelectable(desc)) {
                renderer.beginSelectionQuery(i);
                desc.render(renderer, myRenderProps, flags);
                renderer.endSelectionQuery();
            }
        }
    } else {
        dorender(renderer, flags, /*selected=*/
        true);
        dorender(renderer, flags, /*selected=*/
        false);
        RenderObject r = myWidgetRob;
        if (r != null) {
            drawWidgets(renderer, r, props, SEL_GRP);
            drawWidgets(renderer, r, props, REG_GRP);
        }
    }
}
Also used : RenderProps(maspack.render.RenderProps) RenderObject(maspack.render.RenderObject)

Example 10 with RenderProps

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

the class AuxMaterialElementDescList method render.

public void render(Renderer renderer, int flags) {
    RenderProps props = myRenderProps;
    if (renderer.isSelecting()) {
        for (int i = 0; i < size(); i++) {
            AuxMaterialElementDesc desc = get(i);
            if (desc.getRenderProps() == null && renderer.isSelectable(desc)) {
                renderer.beginSelectionQuery(i);
                desc.render(renderer, myRenderProps, flags);
                renderer.endSelectionQuery();
            }
        }
    } else {
        dorender(renderer, flags, /*selected=*/
        true);
        dorender(renderer, flags, /*selected=*/
        false);
        RenderObject r = myWidgetRob;
        if (r != null) {
            drawWidgets(renderer, r, props, SEL_GRP);
            drawWidgets(renderer, r, props, REG_GRP);
        }
    }
}
Also used : RenderProps(maspack.render.RenderProps) RenderObject(maspack.render.RenderObject)

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