本文整理汇总了C#中ICamera.GetMatrices方法的典型用法代码示例。如果您正苦于以下问题:C# ICamera.GetMatrices方法的具体用法?C# ICamera.GetMatrices怎么用?C# ICamera.GetMatrices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICamera
的用法示例。
在下文中一共展示了ICamera.GetMatrices方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
public void Render(GameTime gameTime, ICamera camera)
{
if (_basicEffect != null)
{
// Set the effect's parameters.
Matrix projectionMatrix, viewMatrix;
camera.GetMatrices(out projectionMatrix, out viewMatrix);
_basicEffect.Projection = projectionMatrix;
_basicEffect.View = viewMatrix;
_basicEffect.World = SceneNode.Transformation;
// Set the rasterizer state.
_graphics.DepthStencilState = DepthStencilState.Default;
_graphics.BlendState = BlendState.AlphaBlend;
_graphics.RasterizerState = _rasterizerState;
// Draw the vertex buffer.
foreach (var effectPass in _basicEffect.CurrentTechnique.Passes)
{
effectPass.Apply();
_graphics.DrawUserPrimitives(PrimitiveType.TriangleList, _particleVertices, 0, _particles.Length, VertexPositionColor.VertexDeclaration);
}
}
}
示例2: Draw
/// <summary>
/// This method draws the terrain.
/// </summary>
/// <param name="gameTime">The game time.</param>
/// <param name="camera">The camera.</param>
public void Draw(GameTime gameTime, ICamera camera)
{
_graphics.RasterizerState = _rasterizerState;
_graphics.DepthStencilState = DepthStencilState.Default;
// Set the debug effect's parameters.
Matrix projectionMatrix, viewMatrix;
camera.GetMatrices(out projectionMatrix, out viewMatrix);
// Draw the enabled quads.
foreach (var quadTree in _blockGrid)
{
_effect.Projection = projectionMatrix;
_effect.View = viewMatrix;
_effect.World = quadTree.SceneNode.Transformation;
foreach (var effectPass in _effect.CurrentTechnique.Passes)
{
effectPass.Apply();
quadTree.Draw(true);
}
}
if (DebugEnabled)
{
_graphics.RasterizerState = _debugRasterizerState;
// Draw the enabled quads.
_debugEffect.DiffuseColor = new Vector3(0.0f, 0.0f, 1.0f);
foreach (var quadTree in _blockGrid)
{
_debugEffect.Projection = projectionMatrix;
_debugEffect.View = viewMatrix;
_debugEffect.World = quadTree.SceneNode.Transformation;
foreach (var effectPass in _debugEffect.CurrentTechnique.Passes)
{
effectPass.Apply();
quadTree.Draw(true);
}
}
// Draw the disabled quads.
_debugEffect.DiffuseColor = new Vector3(1.0f, 0.0f, 0.0f);
foreach (var quadTree in _blockGrid)
{
_debugEffect.Projection = projectionMatrix;
_debugEffect.View = viewMatrix;
_debugEffect.World = quadTree.SceneNode.Transformation;
foreach (var effectPass in _debugEffect.CurrentTechnique.Passes)
{
effectPass.Apply();
quadTree.Draw(false);
}
}
}
}
示例3: Render
public void Render(GameTime gameTime, ICamera camera)
{
if (_basicEffect != null)
{
// Generate the vertices and indices.
var screenSize = camera.ScreenSize;
var halfWidth = (screenSize.X / 2.0f) * 1.01f;
var halfHeight = (screenSize.Y / 2.0f) * 1.01f;
var uv = screenSize / Scale;
var vertices = new[]
{
new VertexPositionColorTexture
{
Position = new Vector3(-halfWidth, -halfHeight, 0.0f),
TextureCoordinate = new Vector2(0.0f, 0.0f),
Color = Color.White
},
new VertexPositionColorTexture
{
Position = new Vector3(halfWidth, -halfHeight, 0.0f),
TextureCoordinate = new Vector2(uv.X, 0.0f),
Color = Color.White
},
new VertexPositionColorTexture
{
Position = new Vector3(halfWidth, halfHeight, 0.0f),
TextureCoordinate = new Vector2(uv.X, uv.Y),
Color = Color.White
},
new VertexPositionColorTexture
{
Position = new Vector3(-halfWidth, halfHeight, 0.0f),
TextureCoordinate = new Vector2(0.0f, uv.Y),
Color = Color.White
}
};
var indices = new short[] { 0, 3, 1, 1, 3, 2 };
// Set the effect's parameters.
Matrix projectionMatrix, viewMatrix;
camera.GetMatrices(out projectionMatrix, out viewMatrix);
_basicEffect.Projection = projectionMatrix;
_basicEffect.View = Matrix.Identity;
_basicEffect.World = Matrix.Identity;
// Set the device states.
_graphics.BlendState = BlendState.Opaque;
_graphics.RasterizerState = _rasterizerState;
_graphics.SamplerStates[0] = SamplerState.LinearWrap;
// Draw.
foreach (var effectPass in _basicEffect.CurrentTechnique.Passes)
{
effectPass.Apply();
_graphics.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, vertices, 0, vertices.Length, indices, 0,
indices.Length / 3);
}
}
}
示例4: Render
public void Render(GameTime gameTime, ICamera camera)
{
if (m_vertexBuffer != null && m_indexBuffer != null && m_basicEffect != null)
{
// Set the effect's parameters.
Matrix projectionMatrix, viewMatrix;
camera.GetMatrices(out projectionMatrix, out viewMatrix);
m_basicEffect.Projection = projectionMatrix;
m_basicEffect.View = viewMatrix;
m_basicEffect.World =
Matrix.CreateRotationZ(MathHelper.ToRadians(this.SceneNode.Rotation)) *
Matrix.CreateTranslation(new Vector3(this.SceneNode.Position, this.SceneNode.Depth)) *
Matrix.CreateScale(new Vector3(this.SceneNode.Scale, 1.0f));
// Set the rasterizer state.
m_graphics.BlendState = BlendState.AlphaBlend;
m_graphics.RasterizerState = m_rasterizerState;
// Draw the vertex buffer.
m_graphics.SetVertexBuffer(m_vertexBuffer);
m_graphics.Indices = m_indexBuffer;
foreach (var effectPass in m_basicEffect.CurrentTechnique.Passes)
{
effectPass.Apply();
m_graphics.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, m_vertexBuffer.VertexCount, 0, m_indexBuffer.IndexCount / 3);
}
}
}
示例5: Render
public void Render(GameTime gameTime, ICamera camera)
{
if (_vertexBuffer != null)
{
// Set the effect's parameters.
Matrix projectionMatrix, viewMatrix;
camera.GetMatrices(out projectionMatrix, out viewMatrix);
_basicEffect.Projection = projectionMatrix;
_basicEffect.View = viewMatrix;
_basicEffect.World = SceneNode.Transformation;
_basicEffect.DiffuseColor = this.Color;
// Set the rasterizer state.
_graphics.RasterizerState = _rasterizerState;
// Draw the vertex buffer.
foreach (var effectPass in _basicEffect.CurrentTechnique.Passes)
{
effectPass.Apply();
_graphics.SetVertexBuffer(_vertexBuffer);
_graphics.DrawPrimitives(PrimitiveType.LineStrip, 0, _vertexBuffer.VertexCount - 1);
}
}
}
示例6: Render
public void Render(GameTime gameTime, ICamera camera)
{
if (_vertexBuffer != null && _indexBuffer != null && _basicEffect != null)
{
// Set the effect's parameters.
Matrix projectionMatrix, viewMatrix;
camera.GetMatrices(out projectionMatrix, out viewMatrix);
_basicEffect.Projection = projectionMatrix;
_basicEffect.View = viewMatrix;
_basicEffect.World = SceneNode.Transformation;
// Set the rasterizer state.
_graphics.DepthStencilState = DepthStencilState.Default;
_graphics.BlendState = BlendState;
_graphics.RasterizerState = RasterizerState;
_graphics.SamplerStates[0] = SamplerState;
// Draw the vertex buffer.
foreach (var effectPass in _basicEffect.CurrentTechnique.Passes)
{
effectPass.Apply();
_graphics.SetVertexBuffer(_vertexBuffer);
_graphics.Indices = _indexBuffer;
_graphics.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, _vertexBuffer.VertexCount, 0,
_indexBuffer.IndexCount / 3);
}
}
}