Search in sources :

Example 1 with RenderProps

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

the class NURBSViewer method addCollidable.

void addCollidable() {
    colmesh = MeshFactory.createQuadSphere(colRad, 32, colCenter.x, colCenter.y, colCenter.z);
    RenderProps props = colmesh.getRenderProps();
    props.setFaceColor(new Color(0.5f, 0.5f, 0.5f));
    props.setAlpha(0.5);
    viewer.addRenderable(colmesh);
}
Also used : Color(java.awt.Color) RenderProps(maspack.render.RenderProps)

Example 2 with RenderProps

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

the class NagataDistanceTest method createRenderProps.

public RenderProps createRenderProps() {
    RenderProps props = new RenderProps();
    props.setPointColor(Color.BLUE);
    props.setLineColor(Color.GREEN);
    props.setPointSize(2);
    return props;
}
Also used : HasRenderProps(maspack.render.HasRenderProps) RenderProps(maspack.render.RenderProps)

Example 3 with RenderProps

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

the class Test method setMeshRenderProps.

static void setMeshRenderProps(PolygonalMesh mesh, GLViewerFrame frame, Color col) {
    RenderProps rp = mesh.getRenderProps();
    rp.setDrawEdges(true);
    rp.setFaceStyle(Renderer.FaceStyle.NONE);
    rp.setLineColor(col);
    mesh.setRenderProps(rp);
    frame.getViewer().addRenderable(mesh);
    frame.getViewer().addRenderable(mesh.getBVTree());
}
Also used : RenderProps(maspack.render.RenderProps)

Example 4 with RenderProps

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

the class WavefrontReader method parseMaterialFile.

private void parseMaterialFile(String matFileName) throws IOException {
    File parentFile = new File(currPath);
    File matFile = new File(parentFile, matFileName);
    if (!matFile.canRead() && verbose) {
        System.out.println("WavefrontReader warning: can't read material file '" + matFile + "'; ignoring");
    }
    ReaderTokenizer rtok = new ReaderTokenizer(new BufferedReader(new FileReader(matFile)));
    myCurrentProps = null;
    rtok.commentChar('#');
    rtok.eolIsSignificant(true);
    // fast-forward to first definition
    nextToken(rtok);
    RenderProps newProps = null;
    String matName = null;
    while (rtok.ttype != ReaderTokenizer.TT_EOF) {
        if (rtok.ttype == ReaderTokenizer.TT_WORD) {
            if (rtok.sval.equals("newmtl")) {
                break;
            }
        }
        toNextLine(rtok);
    }
    while (rtok.ttype != ReaderTokenizer.TT_EOF) {
        if (rtok.ttype == ReaderTokenizer.TT_WORD) {
            if (rtok.sval.equals("newmtl")) {
                // save old
                if (newProps != null) {
                    // this doesn't work
                    myMaterialMap.put(matName, newProps);
                }
                matName = scanName(rtok);
                newProps = new RenderProps();
            // System.out.println ("found new material '"+matName+"'");
            } else {
                processMaterialLine(rtok, newProps);
            }
            toNextLine(rtok);
        } else {
            if (rtok.ttype != ReaderTokenizer.TT_EOL) {
                throw new IOException("unexpected token " + rtok.ttype + " in material file " + matFile + ", line " + rtok.lineno());
            } else {
                // move to next token
                nextToken(rtok);
            }
        }
    }
    if (newProps != null) {
        // add final render props
        myMaterialMap.put(matName, newProps);
    }
    rtok.close();
}
Also used : ReaderTokenizer(maspack.util.ReaderTokenizer) BufferedReader(java.io.BufferedReader) RenderProps(maspack.render.RenderProps) FileReader(java.io.FileReader) IOException(java.io.IOException) File(java.io.File)

Example 5 with RenderProps

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

the class MultiViewerTesterBase method addCube.

protected static void addCube(MultiViewer tester) {
    RenderObject cube = new RenderObject();
    // positions                                 // normals
    int[] pIdxs = new int[8];
    int[] nIdxs = new int[6];
    pIdxs[0] = cube.addPosition(-1f, -1f, -1f);
    nIdxs[0] = cube.addNormal(0f, 0f, -1f);
    pIdxs[1] = cube.addPosition(1f, -1f, -1f);
    nIdxs[1] = cube.addNormal(0f, 0f, 1f);
    pIdxs[2] = cube.addPosition(1f, 1f, -1f);
    nIdxs[2] = cube.addNormal(0f, -1f, 0f);
    pIdxs[3] = cube.addPosition(-1f, 1f, -1f);
    nIdxs[3] = cube.addNormal(0f, 1f, 0f);
    pIdxs[4] = cube.addPosition(-1f, -1f, 1f);
    nIdxs[4] = cube.addNormal(-1f, 0f, 0f);
    pIdxs[5] = cube.addPosition(1f, -1f, 1f);
    nIdxs[5] = cube.addNormal(1f, 0f, 0f);
    pIdxs[6] = cube.addPosition(1f, 1f, 1f);
    pIdxs[7] = cube.addPosition(-1f, 1f, 1f);
    // vertices
    int[] vIdxs = new int[24];
    // bottom    indices:(position, normal, color, texture)
    vIdxs[0] = cube.addVertex(0, 0, -1, -1);
    vIdxs[1] = cube.addVertex(1, 0, -1, -1);
    vIdxs[2] = cube.addVertex(2, 0, -1, -1);
    vIdxs[3] = cube.addVertex(3, 0, -1, -1);
    // top
    vIdxs[4] = cube.addVertex(4, 1, -1, -1);
    vIdxs[5] = cube.addVertex(5, 1, -1, -1);
    vIdxs[6] = cube.addVertex(6, 1, -1, -1);
    vIdxs[7] = cube.addVertex(7, 1, -1, -1);
    // left
    vIdxs[8] = cube.addVertex(0, 2, -1, -1);
    vIdxs[9] = cube.addVertex(1, 2, -1, -1);
    vIdxs[10] = cube.addVertex(4, 2, -1, -1);
    vIdxs[11] = cube.addVertex(5, 2, -1, -1);
    // right
    vIdxs[12] = cube.addVertex(2, 3, -1, -1);
    vIdxs[13] = cube.addVertex(3, 3, -1, -1);
    vIdxs[14] = cube.addVertex(6, 3, -1, -1);
    vIdxs[15] = cube.addVertex(7, 3, -1, -1);
    // front
    vIdxs[16] = cube.addVertex(3, 4, -1, -1);
    vIdxs[17] = cube.addVertex(0, 4, -1, -1);
    vIdxs[18] = cube.addVertex(7, 4, -1, -1);
    vIdxs[19] = cube.addVertex(4, 4, -1, -1);
    // back
    vIdxs[20] = cube.addVertex(1, 5, -1, -1);
    vIdxs[21] = cube.addVertex(2, 5, -1, -1);
    vIdxs[22] = cube.addVertex(5, 5, -1, -1);
    vIdxs[23] = cube.addVertex(6, 5, -1, -1);
    // triangular faces
    // bottom
    cube.addTriangle(2, 1, 0);
    // bottom
    cube.addTriangle(3, 2, 0);
    // top
    cube.addTriangle(4, 5, 6);
    // top
    cube.addTriangle(7, 4, 6);
    // left
    cube.addTriangle(8, 9, 10);
    // left
    cube.addTriangle(9, 11, 10);
    // right
    cube.addTriangle(12, 13, 14);
    // right
    cube.addTriangle(13, 15, 14);
    // front
    cube.addTriangle(16, 17, 18);
    // front
    cube.addTriangle(17, 19, 18);
    // back
    cube.addTriangle(20, 21, 22);
    // back
    cube.addTriangle(21, 23, 22);
    // add to renderer
    RenderObjectWrapper cuber = new RenderObjectWrapper(cube);
    AffineTransform3d trans = new AffineTransform3d();
    trans.setTranslation(0.5, 0.5, 0.5);
    trans.applyScaling(0.2, 0.2, 0.2);
    cuber.setTransform(trans);
    RenderProps props = cuber.getRenderProps();
    props.setFaceColor(Color.ORANGE.darker());
    tester.addRenderable(cuber);
}
Also used : RenderProps(maspack.render.RenderProps) RenderObject(maspack.render.RenderObject) AffineTransform3d(maspack.matrix.AffineTransform3d)

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