} // RenderableMesh(setVertexBuffer, setIndexBuffer, setMaterial) #endregion #region Render //float lastAlpha = 1.0f; /// <summary> /// Render this renderable mesh, MUST be called inside of the /// render method of ShaderEffect.normalMapping! /// </summary> /// <param name="worldMatrix">World matrix</param> public void RenderMesh(MatrixAndAlpha worldMatrixAndAlpha) { // Update world matrix BaseGame.ParallaxShader.WorldMatrix = worldMatrixAndAlpha.matrix; BaseGame.ParallaxShader.AlphaValue = worldMatrixAndAlpha.alpha; BaseGame.ParallaxShader.Effect.CommitChanges(); // Set vertex buffer and index buffer if (lastVertexBufferSet != vertexBuffer || lastIndexBufferSet != indexBuffer) { //tst: BaseGame.Device.VertexDeclaration = vertexDeclaration; lastVertexBufferSet = vertexBuffer; lastIndexBufferSet = indexBuffer; BaseGame.Device.Vertices[0].SetSource( vertexBuffer, streamOffset, vertexStride); BaseGame.Device.Indices = indexBuffer; } // if (vertexBuffer) // And render (this call takes the longest, we can't optimize // it any further because the vertexBuffer and indexBuffer are // WriteOnly, we can't combine it or optimize it any more). BaseGame.Device.DrawIndexedPrimitives( PrimitiveType.TriangleList, baseVertex, 0, numVertices, startIndex, primitiveCount); } // RenderMesh(worldMatrix)
//float lastAlpha = 1.0f; /// <summary> /// Render this renderable mesh, MUST be called inside of the /// render method of ShaderEffect.normalMapping! /// </summary> /// <param name="worldMatrix">World matrix</param> public void RenderMesh(MatrixAndAlpha worldMatrixAndAlpha) { // Update world matrix BaseGame.ParallaxShader.WorldMatrix = worldMatrixAndAlpha.matrix; BaseGame.ParallaxShader.AlphaValue = worldMatrixAndAlpha.alpha; BaseGame.ParallaxShader.Effect.CommitChanges(); // Set vertex buffer and index buffer if (lastVertexBufferSet != vertexBuffer || lastIndexBufferSet != indexBuffer) { //tst: BaseGame.Device.VertexDeclaration = vertexDeclaration; lastVertexBufferSet = vertexBuffer; lastIndexBufferSet = indexBuffer; BaseGame.Device.Vertices[0].SetSource( vertexBuffer, streamOffset, vertexStride); BaseGame.Device.Indices = indexBuffer; } // if (vertexBuffer) // And render (this call takes the longest, we can't optimize // it any further because the vertexBuffer and indexBuffer are // WriteOnly, we can't combine it or optimize it any more). BaseGame.Device.DrawIndexedPrimitives( PrimitiveType.TriangleList, baseVertex, 0, numVertices, startIndex, primitiveCount); }