Search in sources :

Example 91 with RigidTransform3d

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);
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d)

Example 92 with RigidTransform3d

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);
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d)

Example 93 with RigidTransform3d

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");
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d)

Example 94 with RigidTransform3d

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);
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d) RevoluteJoint(artisynth.core.mechmodels.RevoluteJoint) RigidBody(artisynth.core.mechmodels.RigidBody)

Example 95 with RigidTransform3d

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);
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d) Renderable(maspack.render.Renderable) Vector3d(maspack.matrix.Vector3d) FixedMeshBody(artisynth.core.mechmodels.FixedMeshBody) PolygonalMesh(maspack.geometry.PolygonalMesh)

Aggregations

RigidTransform3d (maspack.matrix.RigidTransform3d)206 Vector3d (maspack.matrix.Vector3d)56 Point3d (maspack.matrix.Point3d)48 PolygonalMesh (maspack.geometry.PolygonalMesh)21 MechModel (artisynth.core.mechmodels.MechModel)19 RigidBody (artisynth.core.mechmodels.RigidBody)18 AxisAngle (maspack.matrix.AxisAngle)18 RotationMatrix3d (maspack.matrix.RotationMatrix3d)17 AffineTransform3d (maspack.matrix.AffineTransform3d)13 FemModel3d (artisynth.core.femmodels.FemModel3d)11 RenderProps (maspack.render.RenderProps)11 FemNode3d (artisynth.core.femmodels.FemNode3d)9 Color (java.awt.Color)7 Point (java.awt.Point)7 Matrix3d (maspack.matrix.Matrix3d)7 Shading (maspack.render.Renderer.Shading)7 LinearMaterial (artisynth.core.materials.LinearMaterial)6 Renderable (maspack.render.Renderable)6 ArrayList (java.util.ArrayList)5 Vector2d (maspack.matrix.Vector2d)5