Example #1
0
        public MotorJoint(IWorldPool pool, MotorJointDef def)
            : base(pool, def)
        {
            m_linearOffset.set(def.linearOffset);
            m_angularOffset = def.angularOffset;

            m_angularImpulse = 0.0f;

            m_maxForce = def.maxForce;
            m_maxTorque = def.maxTorque;
            m_correctionFactor = def.correctionFactor;
        }
Example #2
0
        public override void initTest(bool deserialized)
        {
            {
                EdgeShape shape = new EdgeShape();
                shape.set(new Vec2(-20.0f, 0.0f), new Vec2(20.0f, 0.0f));
                FixtureDef fd = new FixtureDef();
                fd.shape = shape;
                getGroundBody().createFixture(fd);
            }

            // Define motorized body
            {
                BodyDef bd = new BodyDef();
                bd.type = BodyType.DYNAMIC;
                bd.position.set(0.0f, 8.0f);
                Body body = getWorld().createBody(bd);

                PolygonShape shape = new PolygonShape();
                shape.setAsBox(2.0f, 0.5f);

                FixtureDef fd = new FixtureDef();
                fd.shape = shape;
                fd.friction = 0.6f;
                fd.density = 2.0f;
                body.createFixture(fd);

                MotorJointDef mjd = new MotorJointDef();
                mjd.initialize(getGroundBody(), body);
                mjd.maxForce = 1000.0f;
                mjd.maxTorque = 1000.0f;
                m_joint = (MotorJoint) m_world.createJoint(mjd);
            }

            m_go = false;
            m_time = 0.0f;
        }