Example #1
0
        // public bool childIsTheOne;


        public SkeletalJoint(CustomRigidGroup parent, CustomRigidJoint rigidJoint)
        {
            if (rigidJoint.joints.Count != 1)
            {
                throw new Exception("Not a proper joint");
            }

            asmJoint           = rigidJoint.joints[0].Definition;
            asmJointOccurrence = rigidJoint.joints[0];
            childGroup         = null;
            parentGroup        = parent;
            this.rigidJoint    = rigidJoint;
            if (rigidJoint.groupOne.Equals(parent))
            {
                childGroup = rigidJoint.groupTwo;
            }
            else if (rigidJoint.groupTwo.Equals(parent))
            {
                childGroup = rigidJoint.groupOne;
            }
            else
            {
                throw new Exception("Couldn't match parent group");
            }
            if (childGroup == null)
            {
                throw new Exception("Not a proper joint: No child joint found");
            }

            /*childIsTheOne = childGroup.Contains(asmJointOccurrence.AffectedOccurrenceOne);
             * if (!childIsTheOne && !childGroup.Contains(asmJointOccurrence.AffectedOccurrenceTwo))
             * {
             * throw new Exception("Expected child not found inside assembly joint.");
             * }*/
        }
    //private FindPartMatches

    public RotationalJoint(CustomRigidGroup parent, CustomRigidJoint rigidJoint)
    {
        if (!(IsRotationalJoint(rigidJoint)))
        {
            throw new Exception("Not a rotational joint");
        }
        wrapped = new SkeletalJoint(parent, rigidJoint);

        try
        {
            axis      = Utilities.ToBXDVector(rigidJoint.geomOne.Normal);
            basePoint = Utilities.ToBXDVector(rigidJoint.geomOne.Center);
        }
        catch
        {
            axis      = Utilities.ToBXDVector(rigidJoint.geomOne.Direction);
            basePoint = Utilities.ToBXDVector(rigidJoint.geomOne.RootPoint);
        }


        hasAngularLimit = wrapped.asmJoint.HasAngularPositionLimits;
        if ((hasAngularLimit))
        {
            angularLimitLow  = (float)wrapped.asmJoint.AngularPositionStartLimit.Value;
            angularLimitHigh = (float)wrapped.asmJoint.AngularPositionEndLimit.Value;
        }
        currentAngularPosition = !((wrapped.asmJoint.AngularPosition == null)) ? (float)wrapped.asmJoint.AngularPosition.Value : 0;
    }
Example #3
0
    public LinearJoint(CustomRigidGroup parent, CustomRigidJoint rigidJoint)
    {
        Console.WriteLine(rigidJoint);
        if (!(IsLinearJoint(rigidJoint)))
        {
            throw new Exception("Not a linear joint");
        }
        wrapped = new SkeletalJoint(parent, rigidJoint);

        if (wrapped.childGroup == rigidJoint.groupOne)
        {
            axis      = Utilities.ToBXDVector(rigidJoint.geomTwo.Direction);
            basePoint = Utilities.ToBXDVector(rigidJoint.geomTwo.RootPoint);
        }
        else
        {
            axis      = Utilities.ToBXDVector(rigidJoint.geomOne.Direction);
            basePoint = Utilities.ToBXDVector(rigidJoint.geomOne.RootPoint);
        }

        if ((hasUpperLimit = wrapped.asmJoint.HasLinearPositionEndLimit) && (hasLowerLimit = wrapped.asmJoint.HasLinearPositionStartLimit))
        {
            linearLimitHigh = (float)wrapped.asmJoint.LinearPositionEndLimit.Value;
            linearLimitLow  = (float)wrapped.asmJoint.LinearPositionStartLimit.Value;
        }
        else
        {
            throw new Exception("Joints with linear motion need two limits.");
        }
        currentLinearPosition = !((wrapped.asmJoint.LinearPosition == null)) ? ((float)wrapped.asmJoint.LinearPosition.Value) : 0;
    }
 public static bool IsPlanarJoint(CustomRigidJoint jointI)
 {
     if (jointI.joints.Count == 1)
     {
         AssemblyJointDefinition joint = jointI.joints[0].Definition;
         return(joint.JointType == AssemblyJointTypeEnum.kPlanarJointType);
     }
     return(false);
 }
Example #5
0
    public CylindricalJoint(CustomRigidGroup parent, CustomRigidJoint rigidJoint)
    {
        if (!(IsCylindricalJoint(rigidJoint)))
        {
            throw new Exception("Not a Cylindrical joint");
        }
        wrapped = new SkeletalJoint(parent, rigidJoint);

        ReloadInventorJoint();
    }
Example #6
0
 public static bool IsCylindricalJoint(CustomRigidJoint jointI)
 {
     // kMateLineLineJoint
     if (jointI.joints.Count == 1)
     {
         AssemblyJointDefinition joint = jointI.joints[0].Definition;
         return(joint.JointType == AssemblyJointTypeEnum.kCylindricalJointType);
     }
     return(false);
 }
Example #7
0
    public PlanarJoint(CustomRigidGroup parent, CustomRigidJoint rigidJoint)
    {
        if (!(IsPlanarJoint(rigidJoint)))
        {
            throw new Exception("Not a planar joint");
        }
        wrapped = new SkeletalJoint(parent, rigidJoint);

        ReloadInventorJoint();
    }
Example #8
0
 public static bool IsBallJoint(CustomRigidJoint jointI)
 {
     if (jointI.joints.Count == 1)
     {
         AssemblyJointDefinition joint = jointI.joints[0].Definition;
         //Checks if there is no linear motion allowed.
         return(joint.JointType == AssemblyJointTypeEnum.kBallJointType);
     }
     return(false);
 }
Example #9
0
    public BallJoint(CustomRigidGroup parent, CustomRigidJoint rigidJoint)
    {
        if (!(IsBallJoint(rigidJoint)))
        {
            throw new Exception("Not a rotational joint");
        }
        wrapped = new SkeletalJoint(parent, rigidJoint);

        basePoint = Utilities.ToBXDVector(rigidJoint.geomOne);
    }
Example #10
0
    public LinearJoint(CustomRigidGroup parent, CustomRigidJoint rigidJoint)
    {
        Console.WriteLine(rigidJoint);
        if (!(IsLinearJoint(rigidJoint)))
        {
            throw new Exception("Not a linear joint");
        }
        wrapped = new SkeletalJoint(parent, rigidJoint);

        ReloadInventorJoint();
    }
Example #11
0
 public static bool IsLinearJoint(CustomRigidJoint jointI)
 {
     // kTranslationalJoint
     if (jointI.joints.Count == 1)
     {
         AssemblyJointDefinition joint = jointI.joints[0].Definition;
         //Cylindrical joints with no rotaion are effectively sliding joints.
         return(joint.JointType == AssemblyJointTypeEnum.kSlideJointType ||
                (joint.JointType == AssemblyJointTypeEnum.kCylindricalJointType &&
                 joint.HasAngularPositionLimits && joint.AngularPositionStartLimit.Value == joint.AngularPositionEndLimit.Value));
     }
     return(false);
 }
Example #12
0
 public static bool IsRotationalJoint(CustomRigidJoint jointI)
 {
     // RigidBodyJointType = kConcentricCircleCircleJoint
     if (jointI.jointBased && jointI.joints.Count == 1)
     {
         AssemblyJointDefinition joint = jointI.joints[0].Definition;
         //Checks if there is no linear motion allowed.
         return(joint.JointType == AssemblyJointTypeEnum.kRotationalJointType ||
                (joint.JointType == AssemblyJointTypeEnum.kCylindricalJointType &&
                 joint.HasLinearPositionStartLimit && joint.HasLinearPositionEndLimit &&
                 joint.LinearPositionStartLimit.Value == joint.LinearPositionEndLimit.Value));
     }
     return(false);
 }
Example #13
0
    public CylindricalJoint(CustomRigidGroup parent, CustomRigidJoint rigidJoint)
    {
        if (!(IsCylindricalJoint(rigidJoint)))
        {
            throw new Exception("Not a Cylindrical joint");
        }
        wrapped = new SkeletalJoint(parent, rigidJoint);

        if (wrapped.childGroup == rigidJoint.groupOne)
        {
            axis      = Utilities.ToBXDVector(rigidJoint.geomTwo.Direction);
            basePoint = Utilities.ToBXDVector(rigidJoint.geomTwo.RootPoint);
        }
        else
        {
            axis      = Utilities.ToBXDVector(rigidJoint.geomOne.Direction);
            basePoint = Utilities.ToBXDVector(rigidJoint.geomOne.RootPoint);
        }

        currentLinearPosition = wrapped.asmJoint.LinearPosition != null ? (float)wrapped.asmJoint.LinearPosition.Value : 0;

        hasAngularLimit = wrapped.asmJoint.HasAngularPositionLimits;
        if (hasAngularLimit)
        {
            angularLimitLow  = (float)wrapped.asmJoint.AngularPositionStartLimit.Value;
            angularLimitHigh = (float)wrapped.asmJoint.AngularPositionEndLimit.Value;
        }
        currentAngularPosition = wrapped.asmJoint.AngularPosition != null ? (float)wrapped.asmJoint.AngularPosition.Value : 0;

        hasLinearStartLimit = wrapped.asmJoint.HasLinearPositionStartLimit;
        hasLinearEndLimit   = wrapped.asmJoint.HasLinearPositionEndLimit;

        if (hasLinearStartLimit && hasLinearEndLimit)
        {
            linearLimitStart = (float)wrapped.asmJoint.LinearPositionStartLimit.Value;
            linearLimitEnd   = (float)wrapped.asmJoint.LinearPositionEndLimit.Value;
        }
        else
        {
            throw new Exception("Joints with linear motion need two limits.");
        }
        wrapped.asmJoint.LinearPosition = wrapped.asmJoint.LinearPosition;
    }
    public PlanarJoint(CustomRigidGroup parent, CustomRigidJoint rigidJoint)
    {
        if (!(IsPlanarJoint(rigidJoint)))
        {
            throw new Exception("Not a planar joint");
        }
        wrapped = new SkeletalJoint(parent, rigidJoint);


        if (wrapped.childGroup == rigidJoint.groupOne)
        {
            normal    = Utilities.ToBXDVector(rigidJoint.geomTwo.Normal);
            basePoint = Utilities.ToBXDVector(rigidJoint.geomTwo.RootPoint);
        }
        else
        {
            normal    = Utilities.ToBXDVector(rigidJoint.geomOne.Normal);
            basePoint = Utilities.ToBXDVector(rigidJoint.geomOne.RootPoint);
        }
    }
Example #15
0
 public static SkeletalJoint_Base Create(CustomRigidJoint rigidJoint, CustomRigidGroup parent)
 {
     if (RotationalJoint.IsRotationalJoint(rigidJoint))
     {
         return(new RotationalJoint(parent, rigidJoint));
     }
     if (LinearJoint.IsLinearJoint(rigidJoint))
     {
         return(new LinearJoint(parent, rigidJoint));
     }
     if (CylindricalJoint.IsCylindricalJoint(rigidJoint))
     {
         return(new CylindricalJoint(parent, rigidJoint));
     }
     if (PlanarJoint.IsPlanarJoint(rigidJoint))
     {
         return(new PlanarJoint(parent, rigidJoint));
     }
     if (BallJoint.IsBallJoint(rigidJoint))
     {
         return(new BallJoint(parent, rigidJoint));
     }
     return(null);
 }