use of maspack.util.InternalErrorException 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 maspack.util.InternalErrorException in project artisynth_core by artisynth.
the class SimpleCollide method removeObject.
private void removeObject(ModelComponent comp, ObjectType type) {
MechModel mechMod = (MechModel) models().get(0);
ComponentList<Probe> myProbes = getInputProbes();
for (Probe p : myProbes) {
System.out.println("type's name: " + type.name());
System.out.println("probe's name: " + p.getName());
if (type.name().equals(p.getName())) {
removeInputProbe(p);
}
}
switch(type) {
case FemEllipsoid:
case FemSphere:
case FemCube:
{
mechMod.removeModel((FemModel3d) comp);
break;
}
case Box:
case Molar:
case Bin:
case Paw:
case House:
{
mechMod.removeRigidBody((RigidBody) comp);
break;
}
default:
{
throw new InternalErrorException("Unimplemented type " + type);
}
}
}
use of maspack.util.InternalErrorException in project artisynth_core by artisynth.
the class RenderProps method clone.
public RenderProps clone() {
RenderProps props = null;
try {
props = (RenderProps) super.clone();
} catch (CloneNotSupportedException e) {
throw new InternalErrorException("cannot clone super in RenderProps");
}
props.myPropInfo = null;
props.myPropHost = null;
// create new objects
if (props.mySpecular != null) {
props.mySpecular = new float[3];
}
if (props.myBackColor != null) {
props.myBackColor = new float[3];
}
if (props.myEdgeColor != null) {
props.myEdgeColor = new float[3];
}
props.myFaceColor = new float[3];
props.myLineColor = new float[3];
props.myPointColor = new float[3];
props.set(this);
return props;
}
use of maspack.util.InternalErrorException in project artisynth_core by artisynth.
the class Jack3d method intersectRayAndFixture.
private void intersectRayAndFixture(Point3d p, Line ray) {
Line draggerRay = new Line(ray);
draggerRay.inverseTransform(myXDraggerToWorld);
switch(mySelectedComponent) {
case X_AXIS:
{
double l = xAxis.nearestPoint(p, draggerRay);
p.y = p.z = 0;
break;
}
case Y_AXIS:
{
yAxis.nearestPoint(p, draggerRay);
p.x = p.z = 0;
break;
}
case Z_AXIS:
{
zAxis.nearestPoint(p, draggerRay);
p.x = p.y = 0;
break;
}
case Z_ROTATE:
{
draggerRay.intersectPlane(p, xyPlane);
p.z = 0;
break;
}
case X_ROTATE:
{
draggerRay.intersectPlane(p, yzPlane);
p.x = 0;
break;
}
case Y_ROTATE:
{
draggerRay.intersectPlane(p, zxPlane);
p.y = 0;
break;
}
default:
{
throw new InternalErrorException("unexpected case");
}
}
}
use of maspack.util.InternalErrorException in project artisynth_core by artisynth.
the class HostList method getCommonRange.
public Range getCommonRange(PropTreeCell cell) {
int[] indexPath = cell.getIndexPath();
if (indexPath.length == 0) {
throw new InternalErrorException("getCommonRange cannot be called for top-level cell");
}
Range commonRange = null;
for (int i = 0; i < myHosts.size(); i++) {
PropTreeData data = myDataList[i];
HasProperties host = null;
for (int level = 0; level < indexPath.length; level++) {
host = data.myHost;
if (data.getSubData() == null) {
throw new InternalErrorException("data tree not initialized for " + cell.pathString());
}
// XXSystem.out.println ("25");
data = data.getSubData()[indexPath[level]];
}
Range range = PropertyUtils.getRange(data.myInfo, host);
if (range != null) {
if (commonRange == null) {
try {
commonRange = (Range) range.clone();
} catch (Exception e) {
throw new InternalErrorException("Can't clone " + range.getClass());
}
} else {
commonRange.intersect(range);
}
}
}
return commonRange;
}
Aggregations