コード例 #1
0
ファイル: Biped.cs プロジェクト: RubisetCie/box2c
        public Biped(Player ownedPlayer, World world, Vector2 position, float xScale, float yScale)
        {
            _ownedPlayer = ownedPlayer;
            m_world = world;

            BipedDef def = new BipedDef(world, xScale, yScale);

            for (int i = 0; i < def.Bodies.Length; ++i)
            {
                def.Bodies[i].Position += position;
                def.Bodies[i].UserData = new BipedBodyDescriptor((BipedFixtureIndex)i, this);
            }

            Bodies = def.Bodies;
            Joints = def.Joints;

            // link body parts
            def.Joints[(int)BipedJointIndex.LAnkle].BodyA = def.Bodies[(int)BipedFixtureIndex.LFoot];
            def.Joints[(int)BipedJointIndex.LAnkle].BodyB = def.Bodies[(int)BipedFixtureIndex.LCalf];
            def.Joints[(int)BipedJointIndex.RAnkle].BodyA = def.Bodies[(int)BipedFixtureIndex.RFoot];
            def.Joints[(int)BipedJointIndex.RAnkle].BodyB = def.Bodies[(int)BipedFixtureIndex.RCalf];
            def.Joints[(int)BipedJointIndex.LKnee].BodyA = def.Bodies[(int)BipedFixtureIndex.LCalf];
            def.Joints[(int)BipedJointIndex.LKnee].BodyB = def.Bodies[(int)BipedFixtureIndex.LThigh];
            def.Joints[(int)BipedJointIndex.RKnee].BodyA = def.Bodies[(int)BipedFixtureIndex.RCalf];
            def.Joints[(int)BipedJointIndex.RKnee].BodyB = def.Bodies[(int)BipedFixtureIndex.RThigh];
            def.Joints[(int)BipedJointIndex.LHip].BodyA = def.Bodies[(int)BipedFixtureIndex.LThigh];
            def.Joints[(int)BipedJointIndex.LHip].BodyB = def.Bodies[(int)BipedFixtureIndex.Pelvis];
            def.Joints[(int)BipedJointIndex.RHip].BodyA = def.Bodies[(int)BipedFixtureIndex.RThigh];
            def.Joints[(int)BipedJointIndex.RHip].BodyB = def.Bodies[(int)BipedFixtureIndex.Pelvis];
            def.Joints[(int)BipedJointIndex.LowerAbs].BodyA = def.Bodies[(int)BipedFixtureIndex.Pelvis];
            def.Joints[(int)BipedJointIndex.LowerAbs].BodyB = def.Bodies[(int)BipedFixtureIndex.Stomach];
            def.Joints[(int)BipedJointIndex.UpperAbs].BodyA = def.Bodies[(int)BipedFixtureIndex.Stomach];
            def.Joints[(int)BipedJointIndex.UpperAbs].BodyB = def.Bodies[(int)BipedFixtureIndex.Chest];
            def.Joints[(int)BipedJointIndex.LowerNeck].BodyA = def.Bodies[(int)BipedFixtureIndex.Chest];
            def.Joints[(int)BipedJointIndex.LowerNeck].BodyB = def.Bodies[(int)BipedFixtureIndex.Neck];
            def.Joints[(int)BipedJointIndex.UpperNeck].BodyA = def.Bodies[(int)BipedFixtureIndex.Chest];
            def.Joints[(int)BipedJointIndex.UpperNeck].BodyB = def.Bodies[(int)BipedFixtureIndex.Head];
            def.Joints[(int)BipedJointIndex.LShoulder].BodyA = def.Bodies[(int)BipedFixtureIndex.Chest];
            def.Joints[(int)BipedJointIndex.LShoulder].BodyB = def.Bodies[(int)BipedFixtureIndex.LUpperArm];
            def.Joints[(int)BipedJointIndex.RShoulder].BodyA = def.Bodies[(int)BipedFixtureIndex.Chest];
            def.Joints[(int)BipedJointIndex.RShoulder].BodyB = def.Bodies[(int)BipedFixtureIndex.RUpperArm];
            def.Joints[(int)BipedJointIndex.LElbow].BodyA = def.Bodies[(int)BipedFixtureIndex.LForearm];
            def.Joints[(int)BipedJointIndex.LElbow].BodyB = def.Bodies[(int)BipedFixtureIndex.LUpperArm];
            def.Joints[(int)BipedJointIndex.RElbow].BodyA = def.Bodies[(int)BipedFixtureIndex.RForearm];
            def.Joints[(int)BipedJointIndex.RElbow].BodyB = def.Bodies[(int)BipedFixtureIndex.RUpperArm];
            def.Joints[(int)BipedJointIndex.LWrist].BodyA = def.Bodies[(int)BipedFixtureIndex.LHand];
            def.Joints[(int)BipedJointIndex.LWrist].BodyB = def.Bodies[(int)BipedFixtureIndex.LForearm];
            def.Joints[(int)BipedJointIndex.RWrist].BodyA = def.Bodies[(int)BipedFixtureIndex.RHand];
            def.Joints[(int)BipedJointIndex.RWrist].BodyB = def.Bodies[(int)BipedFixtureIndex.RForearm];

            // create joints
            world.AddJoint(def.Joints[(int)BipedJointIndex.LAnkle]);
            world.AddJoint(def.Joints[(int)BipedJointIndex.RAnkle]);
            world.AddJoint(def.Joints[(int)BipedJointIndex.LKnee]);
            world.AddJoint(def.Joints[(int)BipedJointIndex.RKnee]);
            world.AddJoint(def.Joints[(int)BipedJointIndex.LHip]);
            world.AddJoint(def.Joints[(int)BipedJointIndex.RHip]);
            world.AddJoint(def.Joints[(int)BipedJointIndex.LowerAbs]);
            world.AddJoint(def.Joints[(int)BipedJointIndex.UpperAbs]);
            world.AddJoint(def.Joints[(int)BipedJointIndex.LowerNeck]);
            world.AddJoint(def.Joints[(int)BipedJointIndex.UpperNeck]);
            world.AddJoint(def.Joints[(int)BipedJointIndex.LShoulder]);
            world.AddJoint(def.Joints[(int)BipedJointIndex.RShoulder]);
            world.AddJoint(def.Joints[(int)BipedJointIndex.LElbow]);
            world.AddJoint(def.Joints[(int)BipedJointIndex.RElbow]);
            world.AddJoint(def.Joints[(int)BipedJointIndex.LWrist]);
            world.AddJoint(def.Joints[(int)BipedJointIndex.RWrist]);
        }
コード例 #2
0
ファイル: Biped.cs プロジェクト: prepare/box2c
        public Biped(Player ownedPlayer, World world, Vector2 position, float xScale, float yScale)
        {
            _ownedPlayer = ownedPlayer;
            m_world      = world;

            BipedDef def = new BipedDef(world, xScale, yScale);

            for (int i = 0; i < def.Bodies.Length; ++i)
            {
                def.Bodies[i].Position += position;
                def.Bodies[i].UserData  = new BipedBodyDescriptor((BipedFixtureIndex)i, this);
            }

            Bodies = def.Bodies;
            Joints = def.Joints;

            // link body parts
            def.Joints[(int)BipedJointIndex.LAnkle].BodyA    = def.Bodies[(int)BipedFixtureIndex.LFoot];
            def.Joints[(int)BipedJointIndex.LAnkle].BodyB    = def.Bodies[(int)BipedFixtureIndex.LCalf];
            def.Joints[(int)BipedJointIndex.RAnkle].BodyA    = def.Bodies[(int)BipedFixtureIndex.RFoot];
            def.Joints[(int)BipedJointIndex.RAnkle].BodyB    = def.Bodies[(int)BipedFixtureIndex.RCalf];
            def.Joints[(int)BipedJointIndex.LKnee].BodyA     = def.Bodies[(int)BipedFixtureIndex.LCalf];
            def.Joints[(int)BipedJointIndex.LKnee].BodyB     = def.Bodies[(int)BipedFixtureIndex.LThigh];
            def.Joints[(int)BipedJointIndex.RKnee].BodyA     = def.Bodies[(int)BipedFixtureIndex.RCalf];
            def.Joints[(int)BipedJointIndex.RKnee].BodyB     = def.Bodies[(int)BipedFixtureIndex.RThigh];
            def.Joints[(int)BipedJointIndex.LHip].BodyA      = def.Bodies[(int)BipedFixtureIndex.LThigh];
            def.Joints[(int)BipedJointIndex.LHip].BodyB      = def.Bodies[(int)BipedFixtureIndex.Pelvis];
            def.Joints[(int)BipedJointIndex.RHip].BodyA      = def.Bodies[(int)BipedFixtureIndex.RThigh];
            def.Joints[(int)BipedJointIndex.RHip].BodyB      = def.Bodies[(int)BipedFixtureIndex.Pelvis];
            def.Joints[(int)BipedJointIndex.LowerAbs].BodyA  = def.Bodies[(int)BipedFixtureIndex.Pelvis];
            def.Joints[(int)BipedJointIndex.LowerAbs].BodyB  = def.Bodies[(int)BipedFixtureIndex.Stomach];
            def.Joints[(int)BipedJointIndex.UpperAbs].BodyA  = def.Bodies[(int)BipedFixtureIndex.Stomach];
            def.Joints[(int)BipedJointIndex.UpperAbs].BodyB  = def.Bodies[(int)BipedFixtureIndex.Chest];
            def.Joints[(int)BipedJointIndex.LowerNeck].BodyA = def.Bodies[(int)BipedFixtureIndex.Chest];
            def.Joints[(int)BipedJointIndex.LowerNeck].BodyB = def.Bodies[(int)BipedFixtureIndex.Neck];
            def.Joints[(int)BipedJointIndex.UpperNeck].BodyA = def.Bodies[(int)BipedFixtureIndex.Chest];
            def.Joints[(int)BipedJointIndex.UpperNeck].BodyB = def.Bodies[(int)BipedFixtureIndex.Head];
            def.Joints[(int)BipedJointIndex.LShoulder].BodyA = def.Bodies[(int)BipedFixtureIndex.Chest];
            def.Joints[(int)BipedJointIndex.LShoulder].BodyB = def.Bodies[(int)BipedFixtureIndex.LUpperArm];
            def.Joints[(int)BipedJointIndex.RShoulder].BodyA = def.Bodies[(int)BipedFixtureIndex.Chest];
            def.Joints[(int)BipedJointIndex.RShoulder].BodyB = def.Bodies[(int)BipedFixtureIndex.RUpperArm];
            def.Joints[(int)BipedJointIndex.LElbow].BodyA    = def.Bodies[(int)BipedFixtureIndex.LForearm];
            def.Joints[(int)BipedJointIndex.LElbow].BodyB    = def.Bodies[(int)BipedFixtureIndex.LUpperArm];
            def.Joints[(int)BipedJointIndex.RElbow].BodyA    = def.Bodies[(int)BipedFixtureIndex.RForearm];
            def.Joints[(int)BipedJointIndex.RElbow].BodyB    = def.Bodies[(int)BipedFixtureIndex.RUpperArm];
            def.Joints[(int)BipedJointIndex.LWrist].BodyA    = def.Bodies[(int)BipedFixtureIndex.LHand];
            def.Joints[(int)BipedJointIndex.LWrist].BodyB    = def.Bodies[(int)BipedFixtureIndex.LForearm];
            def.Joints[(int)BipedJointIndex.RWrist].BodyA    = def.Bodies[(int)BipedFixtureIndex.RHand];
            def.Joints[(int)BipedJointIndex.RWrist].BodyB    = def.Bodies[(int)BipedFixtureIndex.RForearm];

            // create joints
            world.AddJoint(def.Joints[(int)BipedJointIndex.LAnkle]);
            world.AddJoint(def.Joints[(int)BipedJointIndex.RAnkle]);
            world.AddJoint(def.Joints[(int)BipedJointIndex.LKnee]);
            world.AddJoint(def.Joints[(int)BipedJointIndex.RKnee]);
            world.AddJoint(def.Joints[(int)BipedJointIndex.LHip]);
            world.AddJoint(def.Joints[(int)BipedJointIndex.RHip]);
            world.AddJoint(def.Joints[(int)BipedJointIndex.LowerAbs]);
            world.AddJoint(def.Joints[(int)BipedJointIndex.UpperAbs]);
            world.AddJoint(def.Joints[(int)BipedJointIndex.LowerNeck]);
            world.AddJoint(def.Joints[(int)BipedJointIndex.UpperNeck]);
            world.AddJoint(def.Joints[(int)BipedJointIndex.LShoulder]);
            world.AddJoint(def.Joints[(int)BipedJointIndex.RShoulder]);
            world.AddJoint(def.Joints[(int)BipedJointIndex.LElbow]);
            world.AddJoint(def.Joints[(int)BipedJointIndex.RElbow]);
            world.AddJoint(def.Joints[(int)BipedJointIndex.LWrist]);
            world.AddJoint(def.Joints[(int)BipedJointIndex.RWrist]);
        }
コード例 #3
0
ファイル: BipedDef.cs プロジェクト: prepare/box2c
        public BipedModel(float xScale, float yScale)
        {
            _shapes = new Shape[(int)BipedFixtureIndex.RHand + 1];

            _shapes[(int)BipedFixtureIndex.RFoot] = BipedDef.ReverseShape
                                                    (
                new Vector2(xScale, yScale) * new Vector2(.033f, .143f),
                new Vector2(xScale, yScale) * new Vector2(.023f, .033f),
                new Vector2(xScale, yScale) * new Vector2(.267f, .035f),
                new Vector2(xScale, yScale) * new Vector2(.265f, .065f),
                new Vector2(xScale, yScale) * new Vector2(.117f, .143f)
                                                    );

            _shapes[(int)BipedFixtureIndex.RCalf] = BipedDef.ReverseShape
                                                    (
                new Vector2(xScale, yScale) * new Vector2(.089f, .016f),
                new Vector2(xScale, yScale) * new Vector2(.178f, .016f),
                new Vector2(xScale, yScale) * new Vector2(.205f, .417f),
                new Vector2(xScale, yScale) * new Vector2(.095f, .417f)
                                                    );

            _shapes[(int)BipedFixtureIndex.RThigh] = BipedDef.ReverseShape
                                                     (
                new Vector2(xScale, yScale) * new Vector2(.137f, .032f),
                new Vector2(xScale, yScale) * new Vector2(.243f, .032f),
                new Vector2(xScale, yScale) * new Vector2(.318f, .343f),
                new Vector2(xScale, yScale) * new Vector2(.142f, .343f)
                                                     );

            _shapes[(int)BipedFixtureIndex.Pelvis] = BipedDef.ReverseShape
                                                     (
                new Vector2(xScale, yScale) * new Vector2(.105f, .051f),
                new Vector2(xScale, yScale) * new Vector2(.277f, .053f),
                new Vector2(xScale, yScale) * new Vector2(.320f, .233f),
                new Vector2(xScale, yScale) * new Vector2(.112f, .233f),
                new Vector2(xScale, yScale) * new Vector2(.067f, .152f)
                                                     );

            _shapes[(int)BipedFixtureIndex.Stomach] = BipedDef.ReverseShape
                                                      (
                new Vector2(xScale, yScale) * new Vector2(.088f, .043f),
                new Vector2(xScale, yScale) * new Vector2(.284f, .043f),
                new Vector2(xScale, yScale) * new Vector2(.295f, .231f),
                new Vector2(xScale, yScale) * new Vector2(.100f, .231f)
                                                      );

            _shapes[(int)BipedFixtureIndex.Chest] = BipedDef.ReverseShape
                                                    (
                new Vector2(xScale, yScale) * new Vector2(.091f, .042f),
                new Vector2(xScale, yScale) * new Vector2(.283f, .042f),
                new Vector2(xScale, yScale) * new Vector2(.177f, .289f),
                new Vector2(xScale, yScale) * new Vector2(.065f, .289f)
                                                    );

            _shapes[(int)BipedFixtureIndex.Neck] = BipedDef.ReverseShape
                                                   (
                new Vector2(xScale, yScale) * new Vector2(.038f, .054f),
                new Vector2(xScale, yScale) * new Vector2(.149f, .054f),
                new Vector2(xScale, yScale) * new Vector2(.154f, .102f),
                new Vector2(xScale, yScale) * new Vector2(.054f, .113f)
                                                   );

            _shapes[(int)BipedFixtureIndex.Head] = new CircleShape(yScale * .115f, 4.0f);

            _shapes[(int)BipedFixtureIndex.RUpperArm] = BipedDef.ReverseShape
                                                        (
                new Vector2(xScale, yScale) * new Vector2(.092f, .059f),
                new Vector2(xScale, yScale) * new Vector2(.159f, .059f),
                new Vector2(xScale, yScale) * new Vector2(.169f, .335f),
                new Vector2(xScale, yScale) * new Vector2(.078f, .335f),
                new Vector2(xScale, yScale) * new Vector2(.064f, .248f)
                                                        );

            _shapes[(int)BipedFixtureIndex.RForearm] = BipedDef.ReverseShape
                                                       (
                new Vector2(xScale, yScale) * new Vector2(.082f, .054f),
                new Vector2(xScale, yScale) * new Vector2(.138f, .054f),
                new Vector2(xScale, yScale) * new Vector2(.149f, .296f),
                new Vector2(xScale, yScale) * new Vector2(.088f, .296f)
                                                       );

            _shapes[(int)BipedFixtureIndex.RHand] = BipedDef.ReverseShape
                                                    (
                new Vector2(xScale, yScale) * new Vector2(.066f, .031f),
                new Vector2(xScale, yScale) * new Vector2(.123f, .020f),
                new Vector2(xScale, yScale) * new Vector2(.160f, .127f),
                new Vector2(xScale, yScale) * new Vector2(.127f, .178f),
                new Vector2(xScale, yScale) * new Vector2(.074f, .178f)
                                                    );
        }