public override void ReadFrom(object obj)
        {
            base.ReadFrom(obj);
            if (obj == null)
            {
                return;
            }

            TerrainData o = (TerrainData)obj;

            m_detailResolution         = o.detailResolution;
            m_detailResolutionPerPatch = o.detailResolutionPerPatch;
            m_heightmapResolution      = o.heightmapResolution;
            m_heightMapWidth           = o.heightmapResolution;
            m_heightMapHeight          = o.heightmapResolution;

            m_size = o.size;

            detailPrototypes = Assign(o.detailPrototypes, v_ => (PersistentDetailPrototype)v_);
            treeInstances    = Assign(o.treeInstances, v_ => (PersistentTreeInstance)v_);
            treePrototypes   = Assign(o.treePrototypes, v_ => (PersistentTreePrototype)v_);

            float[,] data = o.GetHeights(0, 0, m_heightMapWidth, m_heightMapHeight);
            m_data        = new float[data.GetLength(0) * data.GetLength(1)];
            Buffer.BlockCopy(data, 0, m_data, 0, m_data.Length * sizeof(float));

            m_alphamapWidth       = o.alphamapWidth;
            m_alphamapHeight      = o.alphamapHeight;
            m_terrainLayersLength = o.terrainLayers.Length;

            float[,,] alphamaps = o.GetAlphamaps(0, 0, m_alphamapWidth, m_alphamapHeight);
            m_alphamaps         = new float[alphamaps.GetLength(0) * alphamaps.GetLength(1) * alphamaps.GetLength(2)];
            Buffer.BlockCopy(alphamaps, 0, m_alphamaps, 0, m_alphamaps.Length * sizeof(float));
        }
Пример #2
0
        public override void ReadFrom(object obj)
        {
            base.ReadFrom(obj);
            if (obj == null)
            {
                return;
            }
            Mesh o = (Mesh)obj;

            indexFormat  = o.indexFormat;
            subMeshCount = o.subMeshCount;
            if (o.vertices != null)
            {
                vertices = new PersistentVector3[o.vertices.Length];
                for (int i = 0; i < o.vertices.Length; ++i)
                {
                    PersistentVector3 v = new PersistentVector3();
                    v.ReadFrom(o.vertices[i]);
                    vertices[i] = v;
                }
            }

            m_tris = new IntArray[subMeshCount];
            for (int i = 0; i < subMeshCount; ++i)
            {
                m_tris[i]       = new IntArray();
                m_tris[i].Array = o.GetTriangles(i);
            }
        }