Search in sources :

Example 6 with MutableCompositeComponent

use of artisynth.core.modelbase.MutableCompositeComponent in project artisynth_core by artisynth.

the class RigidBodyConnectorList method createAndAddConnector.

private void createAndAddConnector(Point3d origin) {
    BodyConnector connector;
    RigidTransform3d TCW = new RigidTransform3d();
    TCW.R.set(myBodyA.getPose().R);
    TCW.p.set(origin);
    RigidTransform3d TCA = new RigidTransform3d();
    TCA.mulInverseLeft(myBodyA.getPose(), TCW);
    if (myComponentType == RevoluteJoint.class) {
        RevoluteJoint joint;
        if (myBodyB == null) {
            joint = new RevoluteJoint(myBodyA, TCA, TCW);
        } else {
            RigidTransform3d TCB = new RigidTransform3d();
            TCB.mulInverseLeft(myBodyB.getPose(), TCW);
            joint = new RevoluteJoint(myBodyA, TCA, myBodyB, TCB);
        }
        connector = joint;
    } else if (myComponentType == SphericalJoint.class) {
        SphericalJoint joint;
        if (myBodyB == null) {
            joint = new SphericalJoint(myBodyA, TCA, TCW);
        } else {
            RigidTransform3d TCB = new RigidTransform3d();
            TCB.mulInverseLeft(myBodyB.getPose(), TCW);
            joint = new SphericalJoint(myBodyA, TCA, myBodyB, TCB);
        }
        connector = joint;
    } else {
        throw new InternalErrorException("Unimplemented connector type " + myComponentType);
    }
    connector.setName(getNameFieldValue());
    setProperties(connector, getPrototypeComponent(myComponentType));
    // update properties in the prototype as well ...
    setProperties(myPrototype, myPrototype);
    addComponent(new AddComponentsCommand("add BodyConnector", connector, (MutableCompositeComponent<?>) myModel.bodyConnectors()));
    setState(State.Complete);
    myMain.setSelectionMode(Main.SelectionMode.Translate);
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d) MutableCompositeComponent(artisynth.core.modelbase.MutableCompositeComponent) SphericalJoint(artisynth.core.mechmodels.SphericalJoint) RevoluteJoint(artisynth.core.mechmodels.RevoluteJoint) InternalErrorException(maspack.util.InternalErrorException) BodyConnector(artisynth.core.mechmodels.BodyConnector)

Aggregations

MutableCompositeComponent (artisynth.core.modelbase.MutableCompositeComponent)6 InternalErrorException (maspack.util.InternalErrorException)2 ViewerManager (artisynth.core.driver.ViewerManager)1 AddComponentsCommand (artisynth.core.gui.editorManager.AddComponentsCommand)1 DuplicateAgent (artisynth.core.gui.editorManager.DuplicateAgent)1 RemoveComponentsCommand (artisynth.core.gui.editorManager.RemoveComponentsCommand)1 SelectionManager (artisynth.core.gui.selectionManager.SelectionManager)1 BodyConnector (artisynth.core.mechmodels.BodyConnector)1 MechModel (artisynth.core.mechmodels.MechModel)1 RevoluteJoint (artisynth.core.mechmodels.RevoluteJoint)1 SphericalJoint (artisynth.core.mechmodels.SphericalJoint)1 ModelComponent (artisynth.core.modelbase.ModelComponent)1 NumericInputProbe (artisynth.core.probes.NumericInputProbe)1 NumericOutputProbe (artisynth.core.probes.NumericOutputProbe)1 Probe (artisynth.core.probes.Probe)1 WayPointProbe (artisynth.core.probes.WayPointProbe)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 RigidTransform3d (maspack.matrix.RigidTransform3d)1