use of maspack.render.RenderProps in project artisynth_core by artisynth.
the class RigidBodyAgent method createPreviewBody.
private void createPreviewBody() {
resetScaling();
body = new RigidBody();
setProperties(body, getPrototypeComponent(myComponentType));
setProperties(myPrototype, myPrototype);
body.setMesh(myGeometryPanel.getMesh(), myGeometryPanel.getMeshFileName(), myGeometryPanel.getMeshTransform());
RigidTransform3d X = new RigidTransform3d();
X.p.set(positionField.getVectorValue());
X.R.setAxisAngle(orientationField.getAxisAngleValue());
body.setPose(X);
RenderProps props = body.createRenderProps();
props.setFaceStyle(Renderer.FaceStyle.NONE);
props.setDrawEdges(true);
props.setLineColor(Color.LIGHT_GRAY);
body.setRenderProps(props);
myMain.getWorkspace().getViewerManager().addRenderable(body);
rotator = new Transrotator3d();
GLViewer viewer = myMain.getMain().getViewer();
rotator.setDraggerToWorld(X);
rotator.setSize(viewer.distancePerPixel(viewer.getCenter()) * viewer.getScreenWidth() / 6);
rotator.addListener(new RigidBodyDraggerListener());
myMain.getWorkspace().getViewerManager().addDragger(rotator);
myGeometryPanel.setAttachedBody(body);
myMain.rerender();
}
use of maspack.render.RenderProps in project artisynth_core by artisynth.
the class ConnectorBoundsRenderer method drawTriangle.
public void drawTriangle(Renderer renderer, TriInfo tri) {
RenderProps props = tri.props;
Shading savedShading = renderer.setPropsShading(props);
renderer.setFaceColoring(props, isSelected());
renderer.setFaceStyle(props.getFaceStyle());
renderer.beginDraw(DrawMode.TRIANGLES);
renderer.setNormal(tri.nrm);
for (int i = 0; i < tri.pts.length; i++) {
renderer.addVertex(tri.pts[i]);
}
renderer.endDraw();
renderer.setShading(savedShading);
renderer.setFaceStyle(FaceStyle.FRONT);
}
use of maspack.render.RenderProps in project artisynth_core by artisynth.
the class SelectionPopup method isVisible.
private boolean isVisible(RenderableComponent rcomp) {
RenderProps props = rcomp.getRenderProps();
if (props != null) {
return props.isVisible();
}
CompositeComponent parent = rcomp.getParent();
if (parent instanceof RenderableComponentList) {
return ((RenderableComponentList<?>) parent).rendersSubComponents();
}
return false;
}
use of maspack.render.RenderProps in project artisynth_core by artisynth.
the class MeshComponent method setMesh.
public void setMesh(MeshBase mesh, String fileName, AffineTransform3dBase X) {
doSetMesh(mesh, fileName, X);
RenderProps meshProps = mesh.getRenderProps();
if (meshProps != null) {
setRenderProps(meshProps);
}
}
use of maspack.render.RenderProps in project artisynth_core by artisynth.
the class MFreeMeshComp method updateVertexColors.
protected void updateVertexColors() {
if (mySurfaceRendering != SurfaceRender.Stress && mySurfaceRendering != SurfaceRender.Strain) {
return;
}
if (myStressPlotRanging == Ranging.Auto) {
myStressPlotRange.merge(myModel.getNodalPlotRange(mySurfaceRendering));
}
RenderProps rprops = getRenderProps();
float alpha = (float) rprops.getAlpha();
MeshBase mesh = getMesh();
double sval = 0;
for (int i = 0; i < myVertexAttachments.size(); i++) {
PointAttachment attacher = myVertexAttachments.get(i);
sval = 0;
if (attacher instanceof PointFem3dAttachment) {
PointFem3dAttachment pfa = (PointFem3dAttachment) attacher;
FemNode[] nodes = pfa.getNodes();
VectorNd weights = pfa.getCoordinates();
for (int j = 0; j < nodes.length; j++) {
if (nodes[j] instanceof MFreeNode3d) {
// paranoid!
MFreeNode3d node = (MFreeNode3d) nodes[j];
double w = weights.get(j);
if (mySurfaceRendering == SurfaceRender.Strain) {
sval += w * node.getVonMisesStrain();
} else if (mySurfaceRendering == SurfaceRender.Stress) {
sval += w * node.getVonMisesStress();
}
}
}
} else if (attacher instanceof PointParticleAttachment) {
PointParticleAttachment ppa = (PointParticleAttachment) attacher;
MFreeNode3d node = (MFreeNode3d) ppa.getParticle();
if (mySurfaceRendering == SurfaceRender.Strain) {
sval = node.getVonMisesStrain();
} else if (mySurfaceRendering == SurfaceRender.Stress) {
sval = node.getVonMisesStress();
}
}
double smin = myStressPlotRange.getLowerBound();
double srng = myStressPlotRange.getRange();
double c = (sval - smin) / srng;
c = Math.max(0, Math.min(c, 1.0));
myColorMap.getRGB(c, colorArray);
mesh.setColor(i, colorArray[0], colorArray[1], colorArray[2], alpha);
}
}
Aggregations