Пример #1
0
        public void UpdateInstanceBuffer(VertexBuffer buffer)
        {
            if (InstanceStride == 0 || buffer == null)
                return;

            mContext.Context.InputAssembler.SetVertexBuffers(1,
                new VertexBufferBinding(buffer.Native, InstanceStride, 0));
        }
Пример #2
0
 public Mesh(GxContext context)
 {
     mContext = context;
     VertexBuffer = new VertexBuffer(context);
     IndexBuffer = new IndexBuffer(context);
     DepthState = new DepthState(context);
     RasterizerState = new RasterState(context);
     BlendState = new BlendState(context);
 }
Пример #3
0
        public void OnFrame()
        {
            if (mAsyncLoaded == false)
                return;

            if (WorldFrame.Instance.ActiveCamera.Contains(ref mBoudingBox) == false)
                return;

            if(mSyncLoaded == false)
            {
                mVertexBuffer = new VertexBuffer(WorldFrame.Instance.GraphicsContext);
                mVertexBuffer.UpdateData(mVertexData);
                mSyncLoaded = true;
            }

            Mesh.UpdateVertexBuffer(mVertexBuffer);
            Mesh.Draw();
        }
Пример #4
0
        public void OnFrame()
        {
            if (mAsyncLoaded == false)
                return;

            if (AreaFile.IsValid == false)
                return;

            if(mSyncLoaded == false)
            {
                mVertexBuffer = new VertexBuffer(WorldFrame.Instance.GraphicsContext);
                mVertexBuffer.UpdateData(AreaFile.FullVertices);
                mSyncLoaded = true;
            }

            if(WorldFrame.Instance.MapManager.IsInitialLoad == false)
            {
                if (WorldFrame.Instance.ActiveCamera.Contains(ref mBoundingBox) == false)
                {
                    if (!M2Manager.IsViewDirty)
                        return;

                    if (!WorldFrame.Instance.ActiveCamera.Contains(ref mModelBox))
                        return;

                    foreach (var chunk in mChunks)
                        chunk.PushDoodadReferences();

                    return;
                }
            }

            if (mIsDirty)
            {
                AreaFile.UpdateNormals();
                mVertexBuffer.UpdateData(AreaFile.FullVertices);
                mIsDirty = false;
            }

            MapChunkRender.ChunkMesh.UpdateVertexBuffer(mVertexBuffer);

            foreach (var chunk in mChunks)
                chunk.OnFrame();
        }
Пример #5
0
 public void UpdateVertexBuffer(VertexBuffer vb)
 {
     mContext.Context.InputAssembler.SetVertexBuffers(0, new[] {vb.Native}, new[] {Stride}, new[] {0});
 }
Пример #6
0
        private void SyncLoad()
        {
            if (mVertices == null || mIndices == null || Groups == null)
                return;

            mVertexBuffer = new VertexBuffer(WorldFrame.Instance.GraphicsContext);
            mIndexBuffer = new IndexBuffer(WorldFrame.Instance.GraphicsContext)
            {
                IndexFormat = SharpDX.DXGI.Format.R32_UInt
            };

            if (mVertices.Length != 0 && mIndices.Length != 0)
            {
                mVertexBuffer.UpdateData(mVertices);
                mIndexBuffer.UpdateData(mIndices);
            }

            foreach (var group in Groups)
                group.SyncLoad();

            mSyncLoaded = true;
        }
Пример #7
0
        private void SyncLoad()
        {
            mIsSyncLoaded = true;

            if (mModel.Vertices.Length == 0 || mModel.Indices.Length == 0 || mModel.Passes.Count == 0)
            {
                mSkipRendering = true;
                return;
            }

            var ctx = WorldFrame.Instance.GraphicsContext;
            mVertexBuffer = new VertexBuffer(ctx);
            mIndexBuffer = new IndexBuffer(ctx);

            mVertexBuffer.UpdateData(mModel.Vertices);
            mIndexBuffer.UpdateData(mModel.Indices);

            mAnimBuffer = new ConstantBuffer(ctx);
            mAnimBuffer.UpdateData(mAnimationMatrices);

            mPerPassBuffer = new ConstantBuffer(ctx);
            mPerPassBuffer.UpdateData(new PerModelPassBuffer()
            {
                uvAnimMatrix = Matrix.Identity,
                modelPassParams = Vector4.Zero
            });
        }
Пример #8
0
 public void UpdateVertexBuffer(VertexBuffer vb)
 {
     mContext.Context.InputAssembler.SetVertexBuffers(0, new[] { vb.Native }, new[] { Stride }, new[] { 0 });
 }
Пример #9
0
        public void Dispose()
        {
            if(AreaFile != null)
                AreaFile.Dispose();
            AreaFile = null;

            mAsyncLoaded = false;
            var vertexBuffer = mVertexBuffer;
            mVertexBuffer = null;
            WorldFrame.Instance.Dispatcher.BeginInvoke(() => { if (vertexBuffer != null) vertexBuffer.Dispose(); });

            for(var i = 0; i < 256; ++i)
            {
                if (mChunks[i] == null) continue;

                mChunks[i].Dispose();
                mChunks[i] = null;
            }
        }