コード例 #1
0
ファイル: c2Mesh.cs プロジェクト: DevilboxGames/ToxicRagers
        public void ProcessMesh()
        {
            Vector3 min, max;
            min = new Vector3(Single.MaxValue, Single.MaxValue, Single.MaxValue);
            max = new Vector3(Single.MinValue, Single.MinValue, Single.MinValue);

            for (int i = 0; i < Verts.Count; i++)
            {
                if (min.X > Verts[i].X) { min.X = Verts[i].X; }
                if (min.Y > Verts[i].Y) { min.Y = Verts[i].Y; }
                if (min.Z > Verts[i].Z) { min.Z = Verts[i].Z; }

                if (max.X < Verts[i].X) { max.X = Verts[i].X; }
                if (max.Y < Verts[i].Y) { max.Y = Verts[i].Y; }
                if (max.Z < Verts[i].Z) { max.Z = Verts[i].Z; }
            }

            Extents = new MeshExtents(min, max);

            AssignUVs();
        }
コード例 #2
0
ファイル: c2Mesh.cs プロジェクト: DevilboxGames/ToxicRagers
        // =========================================
        // ============= Build by Shape ============
        public void BuildFromExtents(MeshExtents box)
        {
            Verts.Add(new Vector3(box.Min.X, box.Min.Y, box.Max.Z));
            Verts.Add(new Vector3(box.Max.X, box.Min.Y, box.Max.Z));
            Verts.Add(new Vector3(box.Max.X, box.Max.Y, box.Max.Z));
            Verts.Add(new Vector3(box.Min.X, box.Max.Y, box.Max.Z));
            Verts.Add(new Vector3(box.Min.X, box.Min.Y, box.Min.Z));
            Verts.Add(new Vector3(box.Max.X, box.Min.Y, box.Min.Z));
            Verts.Add(new Vector3(box.Max.X, box.Max.Y, box.Min.Z));
            Verts.Add(new Vector3(box.Min.X, box.Max.Y, box.Min.Z));

            UVs.Add(new Vector2(0.0001f, 0.9999f));
            UVs.Add(new Vector2(0.9999f, 0.9999f));
            UVs.Add(new Vector2(0.9999f, 0.9999f));
            UVs.Add(new Vector2(0.0001f, 0.9999f));
            UVs.Add(new Vector2(0.0001f, 0.0001f));
            UVs.Add(new Vector2(0.9999f, 0.0001f));
            UVs.Add(new Vector2(0.9999f, 0.0001f));
            UVs.Add(new Vector2(0.0001f, 0.0001f));

            AddFace(3, 4, 0);
            AddFace(0, 2, 3);
            AddFace(0, 1, 2);
            AddFace(1, 5, 6);
            AddFace(1, 6, 2);
            AddFace(3, 7, 4);
            AddFace(2, 7, 3);
            AddFace(2, 6, 7);
            AddFace(0, 5, 1);
            AddFace(4, 7, 6);
            AddFace(0, 4, 5);
            AddFace(4, 6, 5);
        }