Esempio n. 1
0
        /// <summary>
        /// Load the raw file at the path given
        /// </summary>
        /// <param name="path">Full path of the raw file</param>
        public void LoadRawFile(string path, GaiaConstants.RawByteOrder byteOrder, ref GaiaConstants.RawBitDepth bitDepth, ref int resolution)
        {
            if (string.IsNullOrEmpty(path))
            {
                Debug.LogError("Must supply a valid path. Raw load Aborted!");
            }

            //Clear out the old
            Reset();

            //Load up the new
            m_featureName = Path.GetFileNameWithoutExtension(path);
            m_scanMap     = new HeightMap();
            m_scanMap.LoadFromRawFile(path, byteOrder, ref bitDepth, ref resolution);
            if (m_scanMap.HasData() == false)
            {
                Debug.LogError("Unable to load raw file. Raw load aborted.");
                return;
            }

            m_scanWidth      = m_scanMap.Width();
            m_scanDepth      = m_scanMap.Depth();
            m_scanHeight     = m_scanWidth / 2;
            m_scanResolution = 0.1f;
            m_scanBounds     = new Bounds(transform.position, new Vector3(m_scanWidth * m_scanResolution, m_scanWidth * m_scanResolution * 0.4f, m_scanDepth * m_scanResolution));
            m_baseLevel      = m_scanMap.GetBaseLevel();

            MeshFilter mf = GetComponent <MeshFilter>();

            if (mf == null)
            {
                mf           = gameObject.AddComponent <MeshFilter>();
                mf.hideFlags = HideFlags.HideInInspector;
            }
            MeshRenderer mr = GetComponent <MeshRenderer>();

            if (mr == null)
            {
                mr           = gameObject.AddComponent <MeshRenderer>();
                mr.hideFlags = HideFlags.HideInInspector;
            }
            mf.mesh = Gaia.Utils.CreateMesh(m_scanMap.Heights(), m_scanBounds.size);
            if (m_previewMaterial != null)
            {
                m_previewMaterial.hideFlags = HideFlags.HideInInspector;
                mr.sharedMaterial           = m_previewMaterial;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Load the raw file at the path given
        /// </summary>
        /// <param name="path">Full path of the raw file</param>
        public void LoadRawFile(string path, GaiaConstants.RawByteOrder byteOrder, ref GaiaConstants.RawBitDepth bitDepth, ref int resolution)
        {
            if (string.IsNullOrEmpty(path))
            {
                Debug.LogError("Must supply a valid path. Raw load Aborted!");
            }

            //Clear out the old
            ResetData();

            //Load up the new
            m_scanMap = new HeightMap();
            m_scanMap.LoadFromRawFile(path, byteOrder, ref bitDepth, ref resolution);
            if (m_scanMap.HasData() == false)
            {
                Debug.LogError("Unable to load raw file. Raw load aborted.");
                return;
            }

            m_scanWidth      = m_scanMap.Width();
            m_scanDepth      = m_scanMap.Depth();
            m_scanHeight     = m_scanWidth / 2;
            m_scanResolution = 0.1f;
            m_scanBounds     = new Bounds(GetPosition(gameObject, null), new Vector3(m_scanWidth * m_scanResolution, m_scanWidth * m_scanResolution, m_scanDepth * m_scanResolution));
            //m_baseLevel = m_scanMap.GetBaseLevel();

            SetOrCreateMeshComponents();
            m_meshFilter.sharedMesh = GaiaUtils.CreateMesh(m_scanMap.Heights(), m_scanBounds.size);
            if (m_previewMaterial != null)
            {
                m_previewMaterial.hideFlags   = HideFlags.HideInInspector;
                m_meshRenderer.sharedMaterial = m_previewMaterial;
            }

            gameObject.transform.position = m_scanBounds.center;
            m_exportFileName = path.Substring(path.LastIndexOf('/'));
            m_boundsSet      = true;
        }