use of maspack.render.RenderObject in project artisynth_core by artisynth.
the class FemElement3dList method prerender.
public void prerender(RenderList list) {
ComponentList<? extends FemNode> nodes = getNodeList();
if (nodes == null) {
// XXX what to do?
return;
}
// will render first and be more visible.
for (int i = 0; i < size(); i++) {
FemElement3d elem = get(i);
if (elem.isSelected() && elem.getRenderProps() != null) {
list.addIfVisible(elem);
}
}
for (int i = 0; i < size(); i++) {
FemElement3d elem = get(i);
if (!elem.isSelected() && elem.getRenderProps() != null) {
list.addIfVisible(elem);
}
}
int update = renderObjectsNeedUpdating();
if (update != 0) {
// for now just rebuild, even if only colors need changing
buildRenderObjects();
}
if (myWidgetRob != null) {
RenderObject r = myWidgetRob;
int pidx = 0;
for (int i = 0; i < size(); i++) {
FemElement3d elem = get(i);
byte flags = getRobFlags(elem);
if ((flags & HAS_WIDGET) != 0) {
double wsize = elem.getElementWidgetSize();
pidx = FemElementRenderer.updateWidgetPositions(r, elem, wsize, pidx);
}
}
FemElementRenderer.updateWidgetNormals(r, REG_GRP);
FemElementRenderer.updateWidgetNormals(r, SEL_GRP);
FemElementRenderer.updateWidgetNormals(r, INV_GRP);
r.notifyPositionsModified();
}
if (myQuadEdges != null) {
for (QuadEdgeDesc quad : myQuadEdges) {
quad.updateCurve(myEdgeRob);
}
}
myEdgeRob.notifyPositionsModified();
}
use of maspack.render.RenderObject in project artisynth_core by artisynth.
the class FemElementRenderer method renderWidget.
public void renderWidget(Renderer renderer, FemElement3d elem, double size, RenderProps props) {
RenderObject r = myRob;
updateWidgetPositions(r, elem, size, myNumEdgePos);
updateWidgetNormals(r, /*group=*/
0);
if (!renderer.isSelecting()) {
float[] color = props.getFaceColorF();
if (elem.isInverted()) {
color = FemModel3d.myInvertedColor;
}
renderer.setFaceColoring(props, color, elem.isSelected());
}
renderer.drawTriangles(r, /*group=*/
0);
}
use of maspack.render.RenderObject in project artisynth_core by artisynth.
the class FemElementRenderer method renderRestWidget.
public void renderRestWidget(Renderer renderer, FemElement3d elem, double size, RenderProps props) {
RenderObject r = myRob;
updateWidgetRestPositions(r, elem, size, myNumEdgePos);
updateWidgetNormals(r, /*group=*/
0);
if (!renderer.isSelecting()) {
float[] color = props.getFaceColorF();
if (elem.isInverted()) {
color = FemModel3d.myInvertedColor;
}
renderer.setFaceColoring(props, color, elem.isSelected());
}
renderer.drawTriangles(r, /*group=*/
0);
}
use of maspack.render.RenderObject in project artisynth_core by artisynth.
the class FemElementRenderer method buildRenderObject.
void buildRenderObject(FemElement3d elem) {
RenderObject r = new RenderObject();
// dummy normal for lines
r.addNormal(1, 0, 0);
for (int i = 0; i < elem.numNodes(); i++) {
r.vertex(0, 0, 0);
}
int[] eidxs = elem.getEdgeIndices();
int numv = 0;
for (int i = 0; i < eidxs.length; i += (numv + 1)) {
numv = eidxs[i];
if (numv == 2) {
int vidx0 = eidxs[i + 1];
int vidx1 = eidxs[i + 2];
r.addLine(vidx0, vidx1);
} else if (numv == 3) {
int vidx0 = eidxs[i + 1];
int vidxm = eidxs[i + 2];
int vidx1 = eidxs[i + 3];
// r.addLine (vidx0, vidxm);
// r.addLine (vidxm, vidx1);
QuadEdge quad = new QuadEdge(vidx0, vidxm, vidx1);
quad.addCurve(r);
myQuadEdges.add(quad);
}
}
myNumEdgePos = r.numPositions();
addWidgetFaces(r, elem);
r.setTransient(true);
myRob = r;
}
use of maspack.render.RenderObject in project artisynth_core by artisynth.
the class FemElementRenderer method render.
public void render(Renderer renderer, FemElement3d elem, RenderProps props) {
RenderObject r = myRob;
updateEdgePositions(r, elem);
Shading savedShading = renderer.setShading(Shading.NONE);
renderer.setLineWidth(props.getLineWidth());
renderer.setLineColoring(props, elem.isSelected());
renderer.drawLines(r);
renderer.setLineWidth(1);
renderer.setShading(savedShading);
double wsize = elem.getElementWidgetSize();
if (wsize > 0) {
renderWidget(renderer, elem, wsize, props);
}
}
Aggregations