コード例 #1
0
        /// <summary>
        /// Build vertices to represent an oriented box.
        /// </summary>
        /// <param name="hx">the half-width.</param>
        /// <param name="hy">the half-height.</param>
        /// <param name="center">the center of the box in local coordinates.</param>
        /// <param name="angle">the rotation of the box in local coordinates.</param>
        public void SetAsBox(float hx, float hy, Vec2 center, float angle)
        {
            VertexCount = 4;
            Vertices[0].Set(-hx, -hy);
            Vertices[1].Set(hx, -hy);
            Vertices[2].Set(hx, hy);
            Vertices[3].Set(-hx, hy);
            Normals[0].Set(0.0f, -1.0f);
            Normals[1].Set(1.0f, 0.0f);
            Normals[2].Set(0.0f, 1.0f);
            Normals[3].Set(-1.0f, 0.0f);
            Centroid.Set(center);

            Transform xf = poolt1;

            xf.P.Set(center);
            xf.Q.Set(angle);

            // Transform vertices and normals.
            for (int i = 0; i < VertexCount; ++i)
            {
                Transform.MulToOut(xf, Vertices[i], Vertices[i]);
                Rot.MulToOut(xf.Q, Normals[i], Normals[i]);
            }
        }
コード例 #2
0
ファイル: Body.cs プロジェクト: prepare/gerich_box2dnet
 public void GetWorldVectorToOut(Vec2 localVector, Vec2 result)
 {
     Rot.MulToOut(Xf.Q, localVector, result);
 }