use of artisynth.core.modelbase.TransformableGeometry in project artisynth_core by artisynth.
the class SimpleCollide method setBottomObject.
private void setBottomObject(Collidable comp, ObjectType type) {
Renderable rcomp = (Renderable) comp;
((TransformableGeometry) comp).transformGeometry(AffineTransform3d.createScaling(myBottomScale));
switch(type) {
case FemEllipsoid:
case FemSphere:
{
RenderProps.setPointColor(rcomp, Color.green);
// fix the lower nodes
Point3d min = new Point3d();
RenderableUtils.getBounds(rcomp, min, null);
FemModel3d fem = (FemModel3d) comp;
fem.getSurfaceMesh();
for (FemNode3d n : fem.getNodes()) {
if (fem.isSurfaceNode(n) && n.getPosition().z <= (min.z + mySize * 0.5)) {
n.setDynamic(false);
}
}
fem.resetRestPosition();
break;
}
case FemCube:
{
RenderProps.setPointColor(rcomp, Color.green);
// fix the lower nodes
Point3d min = new Point3d();
RenderableUtils.getBounds(rcomp, min, null);
FemModel3d fem = (FemModel3d) comp;
fem.getSurfaceMesh();
for (FemNode3d n : fem.getNodes()) {
if (fem.isSurfaceNode(n) && n.getPosition().z <= (min.z + mySize * 0.1)) {
n.setDynamic(false);
}
}
// RenderProps.setAlpha (rcomp, 0.3);
fem.resetRestPosition();
break;
}
case Box:
{
((RigidBody) comp).setDynamic(false);
((RigidBody) comp).setDistanceGridRes(new Vector3i(10, 5, 5));
break;
}
case Molar:
{
((RigidBody) comp).setPose(new RigidTransform3d(0, 0, 0, 0, -1, 0, Math.toRadians(172.09)));
((RigidBody) comp).setDynamic(false);
break;
}
case Bin:
{
((RigidBody) comp).setPose(new RigidTransform3d(0, 0, 0, 0, 0, 0, 0));
((RigidBody) comp).setDynamic(false);
break;
}
case Paw:
case House:
{
((RigidBody) comp).setDynamic(false);
break;
}
default:
{
throw new InternalErrorException("Unimplemented type " + type);
}
}
myBottomObject = comp;
myBottomType = type;
}
use of artisynth.core.modelbase.TransformableGeometry in project artisynth_core by artisynth.
the class Main method setDragger.
private void setDragger() {
translator3d.setVisible(false);
transrotator3d.setVisible(false);
scalar3d.setVisible(false);
rotator3d.setVisible(false);
constrainedTranslator3d.setVisible(false);
constrainedTranslator3d.setMesh(null);
currentDragger = null;
myDraggableComponents.clear();
if (mySelectionMode != SelectionMode.Select && mySelectionMode != SelectionMode.EllipticSelect && mySelectionMode != SelectionMode.Pull) {
Point3d pmin = new Point3d(inf, inf, inf);
Point3d pmax = new Point3d(-inf, -inf, -inf);
int n = 0;
for (ModelComponent sel : mySelectionManager.getCurrentSelection()) {
if (sel instanceof Renderable && sel instanceof TransformableGeometry && !ComponentUtils.isAncestorSelected(sel)) {
myDraggableComponents.add(sel);
((Renderable) sel).updateBounds(pmin, pmax);
n++;
}
}
if (n > 0) {
RigidTransform3d TDW = new RigidTransform3d();
double radius = computeDraggerToWorld(TDW, myDraggableComponents, null);
// set a minimum radius to about 1/6 of the viewer window width
radius = Math.max(radius, myViewer.distancePerPixel(myViewer.getCenter()) * myViewer.getScreenWidth() / 6);
if (mySelectionMode == SelectionMode.Translate) {
translator3d.setVisible(true);
translator3d.setDraggerToWorld(TDW);
translator3d.setSize(radius);
currentDragger = translator3d;
} else if (mySelectionMode == SelectionMode.Transrotate) {
transrotator3d.setVisible(true);
transrotator3d.setDraggerToWorld(TDW);
transrotator3d.setSize(radius);
currentDragger = transrotator3d;
} else if (mySelectionMode == SelectionMode.Scale) {
scalar3d.setVisible(true);
scalar3d.setDraggerToWorld(TDW);
scalar3d.setSize(radius);
currentDragger = scalar3d;
} else if (mySelectionMode == SelectionMode.Rotate) {
rotator3d.setVisible(true);
rotator3d.setDraggerToWorld(TDW);
rotator3d.setSize(radius);
currentDragger = rotator3d;
} else if (mySelectionMode == SelectionMode.ConstrainedTranslate) {
PolygonalMesh mesh = null;
for (Object sel : mySelectionManager.getCurrentSelection()) {
if (sel instanceof FrameMarker) {
FrameMarker frameMarker = (FrameMarker) sel;
Point3d p = new Point3d(frameMarker.getPosition());
constrainedTranslator3d.setLocation(p);
Frame frame = frameMarker.getFrame();
if (frame instanceof RigidBody) {
mesh = ((RigidBody) frame).getMesh();
}
break;
}
}
if (mesh != null) {
constrainedTranslator3d.setSize(radius);
constrainedTranslator3d.setMesh(mesh);
constrainedTranslator3d.setVisible(true);
currentDragger = constrainedTranslator3d;
}
}
}
}
}
use of artisynth.core.modelbase.TransformableGeometry in project artisynth_core by artisynth.
the class SimpleCollide method setTopObject.
private void setTopObject(Collidable comp, ObjectType type) {
Renderable rcomp = (Renderable) comp;
((TransformableGeometry) comp).transformGeometry(new RigidTransform3d(0, /*-0.3*/
0.0, mySeparation));
((TransformableGeometry) comp).transformGeometry(AffineTransform3d.createScaling(myTopScale));
RenderProps.setFaceColor(rcomp, Color.red);
switch(type) {
case FemEllipsoid:
case FemSphere:
case FemCube:
{
RenderProps.setPointColor(rcomp, Color.gray);
RenderProps.setAlpha(rcomp, 0.3);
RenderProps.setDrawEdges(rcomp, true);
RenderProps.setVisible(((FemModel3d) rcomp).getElements(), false);
break;
}
case House:
{
((TransformableGeometry) comp).transformGeometry(new RigidTransform3d(0, 0, 2 * mySeparation, 1, 1, 0, Math.toRadians(170)));
break;
}
case Box:
case Molar:
case Bin:
case Paw:
{
break;
}
default:
{
throw new InternalErrorException("Unimplemented type " + type);
}
}
myTopObject = comp;
myTopType = type;
}
Aggregations