Exemplo n.º 1
0
        /// <summary>
        /// Set the position and angle of the body manually.
        /// </summary>
        /// <param name="pos">global position</param>
        /// <param name="angleInRadians">global angle</param>
        public virtual void setPositionAngle(Vector2 pos, float angleInRadians, Vector2 scale)
        {
            mBaseShape.transformVertices(ref pos, angleInRadians, ref scale, ref mGlobalShape);
            for (int i = 0; i < mPointMasses.Count; i++)
            {
                mPointMasses [i].Position = mGlobalShape [i];
            }


            DerivedPos   = pos;
            DerivedAngle = angleInRadians;
        }
Exemplo n.º 2
0
        /// <summary>
        /// set the shape of this body to a new ClosedShape object.  This function
        /// will remove any existing PointMass objects, and replace them with new ones IF
        /// the new shape has a different vertex count than the previous one.  In this case
        /// the mass for each newly added point mass will be set zero.  Otherwise the shape is just
        /// updated, not affecting the existing PointMasses.
        /// </summary>
        /// <param name="shape">new closed shape</param>
        public void setShape(ClosedShape shape)
        {
            mBaseShape = shape;

            if (mBaseShape.Vertices.Count != mPointMasses.Count)
            {
                mPointMasses.Clear();
                mGlobalShape = new Vector2[mBaseShape.Vertices.Count];

                Vector2 p = DerivedPos;
                mBaseShape.transformVertices(ref p, DerivedAngle, ref mScale, ref mGlobalShape);
                DerivedPos = p;

                for (int i = 0; i < mBaseShape.Vertices.Count; i++)
                {
                    mPointMasses.Add(new PointMass(0.0f, mGlobalShape [i]));
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// set the shape of this body to a new ClosedShape object.  This function 
        /// will remove any existing PointMass objects, and replace them with new ones IF
        /// the new shape has a different vertex count than the previous one.  In this case
        /// the mass for each newly added point mass will be set zero.  Otherwise the shape is just
        /// updated, not affecting the existing PointMasses.
        /// </summary>
        /// <param name="shape">new closed shape</param>
        public void setShape(ClosedShape shape)
        {
            mBaseShape = shape;

            if (mBaseShape.Vertices.Count != mPointMasses.Count)
            {
                mPointMasses.Clear();
                mGlobalShape = new Vector2[mBaseShape.Vertices.Count];

                Vector2 p = DerivedPos;
                mBaseShape.transformVertices(ref p, DerivedAngle, ref mScale, ref mGlobalShape);
                DerivedPos = p;

                for (int i = 0; i < mBaseShape.Vertices.Count; i++)
                    mPointMasses.Add(new PointMass(0.0f, mGlobalShape [i]));
            }
        }