use of maspack.matrix.RigidTransform3d in project artisynth_core by artisynth.
the class GridPlane method setPosition.
/**
* Sets the 3D position of the centre of the display
*/
public void setPosition(Point3d pos) {
RigidTransform3d X = new RigidTransform3d(XGridToWorld);
X.p.set(pos);
setGridToWorld(X);
}
use of maspack.matrix.RigidTransform3d in project artisynth_core by artisynth.
the class TextComponent3d method transformGeometry.
public void transformGeometry(GeometryTransformer gtr, TransformGeometryContext context, int flags) {
RigidTransform3d Xpose = new RigidTransform3d();
// read rotation off myTransform to account for viewer rotation
Xpose.setRotation(myOrientation);
if (followEye) {
Xpose.R.mul(rEye, Xpose.R);
}
Xpose.setTranslation(myPos);
gtr.transform(Xpose);
myTransform.set(Xpose);
if (followEye) {
myTransform.R.mulInverseLeft(rEye, Xpose.R);
}
myOrientation.set(myTransform.R);
myPos.set(Xpose.p);
}
use of maspack.matrix.RigidTransform3d in project artisynth_core by artisynth.
the class SkinDemo method addRigidBodies.
public void addRigidBodies() {
RigidTransform3d X;
X = new RigidTransform3d();
X.p.z = len / 2;
myUpper = addBody("upper", X, "barm.obj");
X = new RigidTransform3d();
double angle = Math.toRadians(225);
X.R.setAxisAngle(0, 1, 0, angle);
X.p.set(len / 2 * Math.sin(angle), 0.0, len / 2 * Math.cos(angle));
myLower = addBody("lower", X, "barm.obj");
}
use of maspack.matrix.RigidTransform3d in project artisynth_core by artisynth.
the class SkinDemo method addJoint.
public void addJoint() {
RigidBody upperArm = model.rigidBodies().get("upper");
RigidBody lowerArm = model.rigidBodies().get("lower");
if (upperArm == null || lowerArm == null) {
return;
}
RevoluteJoint j = new RevoluteJoint();
j.setName("elbow");
RigidTransform3d TCA = new RigidTransform3d();
TCA.p.z = -len / 2;
TCA.R.setAxisAngle(1, 0, 0, Math.PI / 2);
RigidTransform3d TCW = new RigidTransform3d();
TCW.R.setAxisAngle(1, 0, 0, Math.PI / 2);
j.setBodies(lowerArm, TCA, null, TCW);
j.setAxisLength(len / 3);
model.addBodyConnector(j);
upperArm.setDynamic(false);
}
use of maspack.matrix.RigidTransform3d in project artisynth_core by artisynth.
the class CSGCubeTest method build.
@Override
public void build(String[] args) throws IOException {
super.build(args);
PolygonalMesh cube1 = MeshFactory.createBox(1, 1, 1);
PolygonalMesh cube2 = MeshFactory.createBox(0.5, 0.5, 0.5);
cube2.transform(new RigidTransform3d(new Vector3d(0.25, 0.25, 0.25), AxisAngle.IDENTITY));
cube1.setHardEdgesFromFaceNormals(0.707);
cube2.setHardEdgesFromFaceNormals(0.707);
PolygonalMesh isect = MeshFactory.getIntersection(cube1, cube2);
isect.setHardEdgesFromFaceNormals(0.707);
PolygonalMesh sub = MeshFactory.getSubtraction(cube1, cube2);
sub.setHardEdgesFromFaceNormals(0.707);
PolygonalMesh union = MeshFactory.getUnion(cube1, cube2);
union.setHardEdgesFromFaceNormals(0.707);
addRenderable(new FixedMeshBody("cube1", cube1));
addRenderable(new FixedMeshBody("cube2", cube2));
addRenderable(new FixedMeshBody("intersection", isect));
addRenderable(new FixedMeshBody("subtraction", sub));
addRenderable(new FixedMeshBody("union", union));
for (Renderable r : renderables()) {
if (r instanceof FixedMeshBody) {
FixedMeshBody fmesh = (FixedMeshBody) r;
PolygonalMesh mesh = (PolygonalMesh) (fmesh.getMesh());
System.out.println("Mesh: " + fmesh.getName());
System.out.println(" # verts: " + mesh.numVertices());
System.out.println(" # faces: " + mesh.numFaces());
System.out.println(" closed: " + mesh.isClosed());
System.out.println(" manifo: " + mesh.isManifold());
System.out.println(" area: " + mesh.computeArea());
System.out.println(" volume: " + mesh.computeVolume());
}
}
// PolygonalMesh cube3 = new PolygonalMesh(cube1);
// cube3 = MeshFactory.subdivide(cube3);
// cube3.mergeCoplanarFaces(0.99);
// for (Face f : cube3.getFaces()) {
// System.out.println(f.getIndex() + ", " + f.numEdges());
// }
//
// int[] nrmIdxs = cube3.getNormalIndices();
// int[] offsets = cube3.getFeatureIndexOffsets();
// for (int i=0; i<offsets.length-1; ++i) {
// System.out.println("Face " + i + ": ");
// for (int j = offsets[i]; j<offsets[i+1]; ++j) {
// Vector3d nrm = cube3.getNormal(nrmIdxs[j]);
// System.out.println(nrm.toString());
// }
// }
// FixedMeshBody fm = new FixedMeshBody("cube3", cube3);
// addRenderable(fm);
// RenderProps.setFaceStyle(fm, FaceStyle.FRONT_AND_BACK);
// RenderProps.setFaceColor(fm, Color.BLUE);
// RenderProps.setBackColor(fm, Color.YELLOW);
RenderProps.setDrawEdges(this, true);
}
Aggregations