public CustomRigidJoint(RigidBodyJoint joint, CustomRigidGroup groupOnez, CustomRigidGroup groupTwoz)
 {
     foreach (AssemblyJoint aj in joint.Joints)
     {
         joints.Add(aj);
     }
     foreach (AssemblyConstraint cj in joint.Constraints)
     {
         constraints.Add(cj);
     }
     groupOne = groupOnez;
     groupTwo = groupTwoz;
     type     = joint.JointType;
     joint.GetJointData(out geomOne, out geomTwo, out options);
     try
     {
         jointBased = options.get_Value("FromJoint");
     }
     catch
     {
         jointBased = false;
     }
 }
Пример #2
0
        private byte[] ProcessRotationalJoint(RigidBodyJoint linearJoint, JointData jointDataObject)
        {
            try {
                ArrayList rotationalJointBytes = new ArrayList();

                //Adds ID to signify that it's a rotational joint
                ushort ID = 0;
                byte[] rotationalJointID = BitConverter.GetBytes(ID);
                rotationalJointBytes.Add(rotationalJointID);

                foreach (AssemblyJoint joint in linearJoint.Joints)
                {
                    //Adds the ID of the parent STL to the output array
                    STLData parentSTL = new STLData();
                    STLDictionary.TryGetValue(NameFilter(joint.OccurrenceOne.Name), out parentSTL);
                    byte[] parentIDBytes = BitConverter.GetBytes((uint)(parentSTL.getID()));
                    rotationalJointBytes.Add(parentIDBytes);
                    //Adds the ID of the child STL to the output array
                    STLData childSTL = new STLData();
                    STLDictionary.TryGetValue(NameFilter(joint.OccurrenceTwo.Name), out childSTL);
                    byte[] childIDBytes = BitConverter.GetBytes((uint)(childSTL.getID()));
                    rotationalJointBytes.Add(childIDBytes);
                    //Adds the vector parallel to the movement onto the array of bytes
                    object       GeometryOne, GeometryTwo;
                    NameValueMap nameMap;
                    linearJoint.GetJointData(out GeometryOne, out GeometryTwo, out nameMap);
                    Circle vectorCircle    = (Circle)GeometryTwo;
                    byte[] vectorJointData = new byte[12];
                    BitConverter.GetBytes(vectorCircle.Center.X).CopyTo(vectorJointData, 0);
                    BitConverter.GetBytes(vectorCircle.Center.Y).CopyTo(vectorJointData, 4);
                    BitConverter.GetBytes(vectorCircle.Center.Z).CopyTo(vectorJointData, 8);
                    rotationalJointBytes.Add(vectorJointData);
                    //Adds the point of connection relative to the parent part
                    byte[] transJointData             = new byte[12];
                    AssemblyJointDefinition jointData = joint.Definition;
                    BitConverter.GetBytes(jointData.OriginTwo.Point.X).CopyTo(transJointData, 0);
                    BitConverter.GetBytes(jointData.OriginTwo.Point.Y).CopyTo(transJointData, 4);
                    BitConverter.GetBytes(jointData.OriginTwo.Point.Z).CopyTo(transJointData, 8);
                    rotationalJointBytes.Add(transJointData);
                    //Adds the degrees of freedom
                    byte[]         freedomData       = new byte[8];
                    ModelParameter positionData      = (ModelParameter)jointData.AngularPosition;
                    double         relataivePosition = positionData._Value;
                    positionData = (ModelParameter)jointData.AngularPositionEndLimit;
                    BitConverter.GetBytes((float)(Math.Abs(relataivePosition) - Math.Abs(positionData._Value))).CopyTo(freedomData, 0);
                    positionData = (ModelParameter)jointData.AngularPositionStartLimit;
                    BitConverter.GetBytes((float)(Math.Abs(relataivePosition) - Math.Abs(positionData._Value))).CopyTo(freedomData, 4);
                    rotationalJointBytes.Add(freedomData);
                    rotationalJointBytes.Add(processJointAttributes(jointDataObject));
                }
                object[] tempArray     = rotationalJointBytes.ToArray();
                byte[]   returnedArray = new byte[tempArray.Length];
                tempArray.CopyTo(returnedArray, 0);
                return(returnedArray);
            }
            catch (Exception e) {
                //catches problems
                MessageBox.Show(e.Message + "\n\n\n" + e.StackTrace);
                return(null);
            }
        }