Beispiel #1
0
        internal GearJoint(GearJointDef def)
            : base(def)
        {
            JointType type1 = def.joint1.JointType;
            JointType type2 = def.joint2.JointType;

            Debug.Assert(type1 == JointType.Revolute || type1 == JointType.Prismatic);
            Debug.Assert(type2 == JointType.Revolute || type2 == JointType.Prismatic);
            Debug.Assert(def.joint1.GetBodyA().GetType() == BodyType.Static);
            Debug.Assert(def.joint2.GetBodyA().GetType() == BodyType.Static);

            _revolute1 = null;
            _prismatic1 = null;
            _revolute2 = null;
            _prismatic2 = null;

            float coordinate1, coordinate2;

            _ground1 = def.joint1.GetBodyA();
            _bodyA = def.joint1.GetBodyB();
            if (type1 == JointType.Revolute)
            {
                _revolute1 = (RevoluteJoint)def.joint1;
                _groundAnchor1 = _revolute1._localAnchor1;
                _localAnchor1 = _revolute1._localAnchor2;
                coordinate1 = _revolute1.GetJointAngle();
            }
            else
            {
                _prismatic1 = (PrismaticJoint)def.joint1;
                _groundAnchor1 = _prismatic1._localAnchor1;
                _localAnchor1 = _prismatic1._localAnchor2;
                coordinate1 = _prismatic1.GetJointTranslation();
            }

            _ground2 = def.joint2.GetBodyA();
            _bodyB = def.joint2.GetBodyB();
            if (type2 == JointType.Revolute)
            {
                _revolute2 = (RevoluteJoint)def.joint2;
                _groundAnchor2 = _revolute2._localAnchor1;
                _localAnchor2 = _revolute2._localAnchor2;
                coordinate2 = _revolute2.GetJointAngle();
            }
            else
            {
                _prismatic2 = (PrismaticJoint)def.joint2;
                _groundAnchor2 = _prismatic2._localAnchor1;
                _localAnchor2 = _prismatic2._localAnchor2;
                coordinate2 = _prismatic2.GetJointTranslation();
            }

            _ratio = def.ratio;

            _ant = coordinate1 + _ratio * coordinate2;

            _impulse = 0.0f;
        }
Beispiel #2
0
        internal static Joint Create(JointDef def)
        {
            Joint joint = null;

            switch (def.type)
            {
            case JointType.Distance:
                {
                    joint = new DistanceJoint((DistanceJointDef)def);
                }
                break;

            case JointType.Mouse:
                {
                    joint = new MouseJoint((MouseJointDef)def);
                }
                break;

            case JointType.Prismatic:
                {
                    joint = new PrismaticJoint((PrismaticJointDef)def);
                }
                break;

            case JointType.Revolute:
                {
                    joint = new RevoluteJoint((RevoluteJointDef)def);
                }
                break;

            case JointType.Pulley:
                {
                    joint = new PulleyJoint((PulleyJointDef)def);
                }
                break;

            case JointType.Gear:
                {
                    joint = new GearJoint((GearJointDef)def);
                }
                break;

            case JointType.Line:
                {
                    joint = new LineJoint((LineJointDef)def);
                }
                break;

            case JointType.Weld:
                {
                    joint = new WeldJoint((WeldJointDef)def);
                }
                break;
            case JointType.Friction:
                {
                    joint = new FrictionJoint((FrictionJointDef)def);
                }
                break;
            case JointType.MaxDistance:
                {
                    joint = new MaxDistanceJoint((MaxDistanceJointDef)def);
                }
                break;

            default:
                Debug.Assert(false);
                break;
            }

            return joint;
        }
 public MotorTracker(AudioManager audio, PrismaticJoint pj, string soundName)
 {
     this.audio = audio;
     this.pj = pj;
     this.soundName = soundName;
 }
Beispiel #4
0
        internal static Joint Create(JointDef def)
        {
            Joint joint = null;

            switch (def.type)
            {
            case JointType.Distance:
            {
                joint = new DistanceJoint((DistanceJointDef)def);
            }
            break;

            case JointType.Mouse:
            {
                joint = new MouseJoint((MouseJointDef)def);
            }
            break;

            case JointType.Prismatic:
            {
                joint = new PrismaticJoint((PrismaticJointDef)def);
            }
            break;

            case JointType.Revolute:
            {
                joint = new RevoluteJoint((RevoluteJointDef)def);
            }
            break;

            case JointType.Pulley:
            {
                joint = new PulleyJoint((PulleyJointDef)def);
            }
            break;

            case JointType.Gear:
            {
                joint = new GearJoint((GearJointDef)def);
            }
            break;

            case JointType.Line:
            {
                joint = new LineJoint((LineJointDef)def);
            }
            break;

            case JointType.Weld:
            {
                joint = new WeldJoint((WeldJointDef)def);
            }
            break;

            case JointType.Friction:
            {
                joint = new FrictionJoint((FrictionJointDef)def);
            }
            break;

            case JointType.MaxDistance:
            {
                joint = new MaxDistanceJoint((MaxDistanceJointDef)def);
            }
            break;

            default:
                Debug.Assert(false);
                break;
            }

            return(joint);
        }