Search in sources :

Example 1 with FeatureIndexArray

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

the class PolygonalMeshRenderer method prerender.

// private Material getEffectiveEdgeMaterial (RenderProps props) {
// Material mat = props.getEdgeMaterial();
// if (mat == null) {
// mat = props.getLineMaterial();
// }
// return mat;
// }
@Override
public void prerender(RenderProps props) {
    super.prerender(props);
    PolygonalMesh mesh = getMesh();
    if (myFaceTriangles == null || mesh.getVersion() != myFacePrimitivesVersion) {
        int[] faceOrder = new int[mesh.numFaces()];
        for (int i = 0; i < faceOrder.length; ++i) {
            faceOrder[i] = i;
        }
        myFaceTriangles = new FeatureIndexArray(faceOrder.length, 3 * faceOrder.length);
        myFaceLines = new FeatureIndexArray(faceOrder.length, 6 * faceOrder.length);
        updateFaceTriangles(faceOrder, myFaceTriangles);
        updateFaceLines(faceOrder, myFaceLines);
        myFacePrimitivesVersion = mesh.getVersion();
    }
}
Also used : FeatureIndexArray(maspack.render.FeatureIndexArray)

Example 2 with FeatureIndexArray

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

the class PolygonalMeshRenderer method getFaceLines.

public FeatureIndexArray getFaceLines(int[] faceIdxs) {
    FeatureIndexArray fia = new FeatureIndexArray(faceIdxs.length, 6 * faceIdxs.length);
    updateFaceLines(faceIdxs, fia);
    return fia;
}
Also used : FeatureIndexArray(maspack.render.FeatureIndexArray)

Example 3 with FeatureIndexArray

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

the class PolygonalMeshRenderer method getFaceTriangles.

public FeatureIndexArray getFaceTriangles(int[] faceIdxs) {
    FeatureIndexArray fia = new FeatureIndexArray(faceIdxs.length, 3 * faceIdxs.length);
    updateFaceTriangles(faceIdxs, fia);
    return fia;
}
Also used : FeatureIndexArray(maspack.render.FeatureIndexArray)

Example 4 with FeatureIndexArray

use of maspack.render.FeatureIndexArray 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 5 with FeatureIndexArray

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

the class FemElement3dList method buildRenderObjects.

protected void buildRenderObjects() {
    RenderObject r = new RenderObject();
    r.createLineGroup();
    r.createLineGroup();
    // r.createTriangleGroup();
    // r.createTriangleGroup();
    // r.createTriangleGroup();
    myQuadEdges = null;
    ComponentList<? extends FemNode> nodes = getNodeList();
    if (nodes == null) {
        // XXX what to do?
        return;
    }
    // create positions and vertices for rendering lines
    for (int i = 0; i < nodes.size(); i++) {
        FemNode node = nodes.get(i);
        r.addVertex(r.addPosition(node.myRenderCoords));
    }
    // allocate per-element flag storage that will be used to determine when
    // the render object needs to be rebuilt
    myRobFlags = new byte[size()];
    boolean hasWidgets = false;
    // for each element, add edge lines, plus widget triangles if the element
    // has a non-zero widget size. Place these additions in the appropriate
    // group (REG_GRP, SEL_GRP,INV_GRP), each of which will be rendered with
    // a different color.
    // two groups for edges
    myEdgeFeatures = new FeatureIndexArray[2];
    myEdgeFeatures[0] = new FeatureIndexArray();
    myEdgeFeatures[1] = new FeatureIndexArray();
    HashSet<EdgeDesc> edges = new HashSet<EdgeDesc>();
    r.lineGroup(SEL_GRP);
    for (int i = 0; i < size(); i++) {
        FemElement3d elem = get(i);
        if (elem.getRenderProps() == null) {
            if (elem.isSelected()) {
                myEdgeFeatures[SEL_GRP].beginFeature(i);
                addEdgeLines(r, myEdgeFeatures[SEL_GRP], elem, nodes, edges);
                myEdgeFeatures[SEL_GRP].endFeature();
            }
        }
    }
    r.lineGroup(REG_GRP);
    for (int i = 0; i < size(); i++) {
        FemElement3d elem = get(i);
        if (elem.getRenderProps() == null) {
            if (!elem.isSelected()) {
                myEdgeFeatures[REG_GRP].beginFeature(i);
                addEdgeLines(r, myEdgeFeatures[REG_GRP], elem, nodes, edges);
                myEdgeFeatures[REG_GRP].endFeature();
            }
            byte flags = getRobFlags(elem);
            if ((flags & HAS_WIDGET) != 0) {
                hasWidgets = true;
            }
            myRobFlags[i] = flags;
        }
    }
    myEdgeRob = r;
    if (hasWidgets) {
        r = new RenderObject();
        r.createTriangleGroup();
        r.createTriangleGroup();
        r.createTriangleGroup();
        myWidgetFeatures = new FeatureIndexArray[3];
        for (int i = 0; i < myWidgetFeatures.length; ++i) {
            myWidgetFeatures[i] = new FeatureIndexArray();
        }
        for (int i = 0; i < size(); i++) {
            FemElement3d elem = get(i);
            if (elem.getRenderProps() == null) {
                byte flags = getRobFlags(elem);
                if ((flags & HAS_WIDGET) != 0) {
                    int gidx = flags & GRP_MASK;
                    r.triangleGroup(gidx);
                    myWidgetFeatures[gidx].beginFeature(i);
                    FemElementRenderer.addWidgetFaces(r, myWidgetFeatures[gidx], elem);
                    myWidgetFeatures[gidx].endFeature();
                }
            }
        }
        myWidgetRob = r;
    } else {
        myWidgetRob = null;
    }
}
Also used : FeatureIndexArray(maspack.render.FeatureIndexArray) RenderObject(maspack.render.RenderObject) HashSet(java.util.HashSet)

Aggregations

FeatureIndexArray (maspack.render.FeatureIndexArray)5 HashSet (java.util.HashSet)1 Vector3d (maspack.matrix.Vector3d)1 PointRenderProps (maspack.render.PointRenderProps)1 RenderObject (maspack.render.RenderObject)1 RenderProps (maspack.render.RenderProps)1