public static void nextMode() { switch (_state) { case INSTANCE_MODE.NORMAL: _state = INSTANCE_MODE.DEBUG; break; case INSTANCE_MODE.DEBUG: _state = INSTANCE_MODE.NORMAL; break; } }
public void Draw(Camera pCamera) { if (_internalstate != _state) { _internalstate = _state; LoadParticleInstance(); } // Tell the GPU to read from both the model vertex buffer plus our instanceVertexBuffer. _graphicsDevice.SetVertexBuffers( new VertexBufferBinding(_vertexBuffer, 0, 0), new VertexBufferBinding(instanceVertexBuffer, 0, 1) ); _graphicsDevice.Indices = _indexBuffer; // Set up the instance rendering effect. _effect.CurrentTechnique = _effect.Techniques["InstancingBB"]; _effect.Parameters["world"].SetValue(Matrix.Identity); _effect.Parameters["view"].SetValue(pCamera.ViewMatrix); _effect.Parameters["projection"].SetValue(pCamera.ProjMatrix); _effect.Parameters["Texture"].SetValue(_billboardTexture); _effect.Parameters["positionMap"].SetValue(_sharedList.ParticlePositions); /*_effect.Parameters["alphaTestDirection"].SetValue(1.0f); * _effect.Parameters["alphaTestThreshold"].SetValue(0.3f);*/ _effect.Parameters["BBSize"].SetValue((_state == INSTANCE_MODE.DEBUG) ? _DebugBBSize : _BBSize); _effect.Parameters["debug"].SetValue((_state == INSTANCE_MODE.DEBUG) ? true : false); _graphicsDevice.BlendState = BlendState.AlphaBlend; _graphicsDevice.DepthStencilState = DepthStencilState.DepthRead; _graphicsDevice.RasterizerState = RasterizerState.CullNone; // Draw all the instance copies in a single call. foreach (EffectPass pass in _effect.CurrentTechnique.Passes) { pass.Apply(); _graphicsDevice.DrawInstancedPrimitives(PrimitiveType.TriangleList, 0, 0, _vertexBuffer.VertexCount, 0, _indexBuffer.IndexCount / 3, SharedList.SquareSize * SharedList.SquareSize); } }