use of maspack.render.RenderProps in project artisynth_core by artisynth.
the class VertexList method render.
public void render(Renderer renderer, int flags) {
RenderProps props = myRenderProps;
if (renderer.isSelecting()) {
PointStyle style = props.getPointStyle();
if (style == PointStyle.POINT) {
int size = props.getPointSize();
if (size > 0) {
renderer.setPointSize(size);
} else {
return;
}
}
for (int i = 0; i < size(); i++) {
VertexComponent pnt = get(i);
if (pnt.getRenderProps() == null && renderer.isSelectable(pnt)) {
float[] v0 = pnt.myRenderCoords;
renderer.beginSelectionQuery(i);
switch(style) {
case POINT:
{
renderer.drawPoint(v0);
break;
}
case CUBE:
{
renderer.drawCube(v0, 2 * props.getPointRadius());
}
case SPHERE:
{
renderer.drawSphere(v0, props.getPointRadius());
break;
}
}
renderer.endSelectionQuery();
}
}
if (style == PointStyle.POINT) {
renderer.setPointSize(1);
}
} else if (myRob != null) {
int numReg = myRob.numPoints(REG_GRP);
int numSel = myRob.numPoints(SEL_GRP);
// draw selected first
if (numSel > 0) {
drawPoints(renderer, SEL_GRP, props, /*selected=*/
true);
}
if (numReg > 0) {
drawPoints(renderer, REG_GRP, props, /*selected=*/
false);
}
}
}
use of maspack.render.RenderProps 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);
}
use of maspack.render.RenderProps in project artisynth_core by artisynth.
the class GridPlane method render.
@Override
public void render(Renderer renderer, int flags) {
boolean highlight = ((flags & Renderer.HIGHLIGHT) != 0);
RenderProps props = getRenderProps();
renderer.pushModelMatrix();
renderer.mulModelMatrix(XGridToWorld);
float[] coords0 = new float[3];
float[] coords1 = new float[3];
// draw grid lines
// draw lines parallel to y axis
coords0[1] = -(float) (mySize.y / 2);
coords1[1] = (float) (mySize.y / 2);
double dx = mySize.x / myResolution.x;
for (int i = 0; i <= (int) (myResolution.x); i++) {
coords0[0] = (float) (-mySize.x / 2 + i * dx);
coords1[0] = coords0[0];
renderer.drawLine(props, coords0, coords1, highlight);
}
// draw lines parallel to x axis
coords0[0] = -(float) (mySize.x / 2);
coords1[0] = (float) (mySize.x / 2);
double dy = mySize.y / myResolution.y;
for (int i = 0; i <= (int) (myResolution.y); i++) {
coords0[1] = (float) (-mySize.y / 2 + i * dy);
coords1[1] = coords0[1];
renderer.drawLine(props, coords0, coords1, highlight);
}
renderer.popModelMatrix();
}
use of maspack.render.RenderProps in project artisynth_core by artisynth.
the class IsRenderableHolder method init.
private void init(IsRenderable renderable) {
if (renderable == null) {
throw new IllegalArgumentException("Cannot hold a null object");
}
myRenderable = renderable;
myProps = new PropertyList(IsRenderableHolder.class, RenderableComponentBase.class);
myProps.add("renderProps * *", "render properties", null);
if (myRenderable instanceof HasProperties) {
myProps.addReadOnly("renderable", "the held renderable object");
}
if (myRenderable instanceof HasRenderProps) {
myHasRenderProps = (HasRenderProps) myRenderable;
getRenderPropsMethod = null;
setRenderPropsMethod = null;
createRenderPropsMethod = null;
} else {
myHasRenderProps = null;
// try to find methods
Class<?> clazz = myRenderable.getClass();
getRenderPropsMethod = getMethod(clazz, "getRenderProps");
setRenderPropsMethod = getMethod(clazz, "setRenderProps", RenderProps.class);
createRenderPropsMethod = getMethod(clazz, "createRenderProps");
}
if (myRenderable instanceof Scannable) {
myScannable = (Scannable) myRenderable;
writeMethod = null;
scanMethod = null;
} else {
myScannable = null;
Class<?> clazz = myRenderable.getClass();
writeMethod = getMethod(clazz, "write", PrintWriter.class, NumberFormat.class, Object.class);
scanMethod = getMethod(clazz, "scan", ReaderTokenizer.class, CompositeComponent.class);
}
}
use of maspack.render.RenderProps in project artisynth_core by artisynth.
the class TextComponentBase method createRenderProps.
@Override
public RenderProps createRenderProps() {
RenderProps rprops = createDefaultRenderProps();
PropertyUtils.updateInheritedProperties(rprops, this, "renderProps");
return rprops;
}
Aggregations