/// <summary>
        /// Helper function sets up the graphics device and
        /// effect ready for drawing instanced geometry.
        /// </summary>
        void SetRenderStates( InstancingTechnique instancingTechnique,
            Matrix view, Matrix projection, Vector3 eye)
        {
            // Set the graphics device to use our vertex data.
              graphicsDevice.VertexDeclaration = vertexDeclaration;
              graphicsDevice.Vertices[0].SetSource( vertexBuffer, 0, vertexStride );
              graphicsDevice.Indices = indexBuffer;

              // Make sure our effect is set to use the right technique.
              if ( techniqueChanged )
              {
            string techniqueName = instancingTechnique.ToString();
            effect.CurrentTechnique = effect.Techniques[techniqueName];
            techniqueChanged = false;
              }

              effectParameterView.SetValue( view );
              effectParameterProjection.SetValue( projection );
              effectParameterEye.SetValue( eye );

              effectParameterVertexCount.SetValue( vertexCount );
        }
Example #2
0
        void SetRenderStates(InstancingTechnique technique, Matrix view, Matrix projection)
        {
            device.VertexDeclaration = vertexDeclaration;
            device.Vertices[0].SetSource(vertexBuffer, 0, vertexStride);
            device.Indices = indexBuffer;

            if (techniqueChanged)
            {
                string techniqueName = technique.ToString();
                effect.CurrentTechnique = effect.Techniques[techniqueName];
                techniqueChanged = false;
            }

            effect.Parameters["View"].SetValue(view);
            effect.Parameters["Projection"].SetValue(projection);
        }