Exemplo n.º 1
0
        private void UpdateMesh()
        {
            if (_dataSource == null)
            {
                return;
            }

            //Get the new model
            int modelId = Bridge4DS.UpdateModel(_dataSource.FDVUUID,
                                                _newVerticesHandle.AddrOfPinnedObject(),
                                                _newUVsHandle.AddrOfPinnedObject(),
                                                _newTrianglesHandle.AddrOfPinnedObject(),
                                                _newTextureDataHandle.AddrOfPinnedObject(),
                                                _newNormalsHandle.AddrOfPinnedObject(),
                                                _lastModelId,
                                                ref _nbVertices,
                                                ref _nbTriangles);

            //Check if there is model
            if (!_newMeshAvailable)
            {
                _newMeshAvailable = (modelId != -1 && modelId != _lastModelId);
            }

            if (modelId == -1)
            {
                modelId = _lastModelId;
            }
            else
            {
                _lastModelId = modelId;
            }

            if (_debugInfo)
            {
                double timeInMSeconds = System.DateTime.Now.Subtract(_lastDecodingTime).TotalMilliseconds;
                if (_lastDecodingId == 0 || timeInMSeconds > 500f)
                {
                    _decodingFPS      = (float)((double)(Mathf.Abs((float)(modelId - _lastDecodingId))) / timeInMSeconds) * 1000f;
                    _lastDecodingTime = System.DateTime.Now;
                    _lastDecodingId   = modelId;
                }
            }
        }
        private void UpdateMesh()
        {
            if (_dataSource == null)
            {
                return;
            }

            //Get the new model
#if USE_NATIVE_LIB
            System.IntPtr normalAddr = System.IntPtr.Zero;
            if (_computeNormals)
            {
                if (_newNormals == null)
                {
                    _newNormals       = new Vector3[_dataSource.MaxVertices];
                    _newNormalsHandle = GCHandle.Alloc(_newNormals, GCHandleType.Pinned);
                }
                normalAddr = _newNormalsHandle.AddrOfPinnedObject();
            }

            int modelId = Bridge4DS.UpdateModel(_dataSource.FDVUUID,
                                                _newVerticesHandle.AddrOfPinnedObject(),
                                                _newUVsHandle.AddrOfPinnedObject(),
                                                _newTrianglesHandle.AddrOfPinnedObject(),
                                                _newTextureDataHandle.AddrOfPinnedObject(),
                                                normalAddr,
                                                _lastModelId,
                                                ref _nbVertices,
                                                ref _nbTriangles);
#endif

            //look for end of range event
            if (Bridge4DS.OutOfRangeEvent(_dataSource.FDVUUID))
            {   //Send event
                if (onOutOfRange != null)
                {
                    onOutOfRange();
                }

                if (_outRangeMode == OUT_RANGE_MODE.Stop)
                {
                    Play(false);
                }

                if (_outRangeMode == OUT_RANGE_MODE.Hide)
                {
                    Play(false);
                    _meshComponent.sharedMesh.Clear();
                }
            }

            //Check if there is model
            if (!_newMeshAvailable)
            {
                _newMeshAvailable = (modelId != -1 && modelId != _lastModelId);
            }

            if (modelId == -1)
            {
                modelId = _lastModelId;
            }
            else
            {
                _lastModelId = modelId;
            }

            if (_debugInfo)
            {
                double timeInMSeconds = System.DateTime.Now.Subtract(_lastDecodingTime).TotalMilliseconds;
                if (_lastDecodingId == 0 || timeInMSeconds > 500f)
                {
                    _decodingFPS      = (float)((double)(Mathf.Abs((float)(modelId - _lastDecodingId))) / timeInMSeconds) * 1000f;
                    _lastDecodingTime = System.DateTime.Now;
                    _lastDecodingId   = modelId;
                }
            }
        }