ComputeBoundingVolume() public method

public ComputeBoundingVolume ( ) : void
return void
Beispiel #1
0
        //------------------------------------------------------------------------------------------
        //------------------------------------------------------------------------------------------
        public ResourceItem Convert(object input, String collection)
        {
            if (input == null)
                return null;

            MeshObject obj = (MeshObject) input;
            MeshItem ret = new MeshItem(this._graphics);

            if (obj.Indexes == null) obj.Indexes = SystemCore.Environment.CreateUInt16Array(0);
            if (obj.Vertices == null) obj.Vertices = SystemCore.Environment.CreateFloat32Array(0);
            if (obj.Normals == null) obj.Normals = SystemCore.Environment.CreateFloat32Array(0);
            if (obj.UVs == null) obj.UVs = SystemCore.Environment.CreateFloat32Array(0);

            ret.Indexes = SystemCore.Environment.CreateUInt16ArrayFromArray(obj.Indexes);
            ret.Mesh = SystemCore.Environment.CreateFloat32Array((ulong) (obj.Vertices.Length + obj.Normals.Length + obj.UVs.Length));
            ret.OffsetPosition = 0;
            ret.OffsetNormal = obj.Vertices.Length;
            ret.OffsetUv = obj.Vertices.Length + obj.Normals.Length;

            /*mesh data*/
            for (int i = 0; i < obj.Vertices.Length; i++) ret.Mesh[i] = obj.Vertices[i];
            for (int i = 0; i < obj.Normals.Length; i++)  ret.Mesh[i + ret.OffsetNormal] = obj.Normals[i];
            for (int i = 0; i < obj.UVs.Length; i++)      ret.Mesh[i + ret.OffsetUv] = obj.UVs[i];
            /*bounding volume*/
            ret.ComputeBoundingVolume();

            return ret;
        }