本文整理汇总了C#中ICamera.ComputeCameraMatrix方法的典型用法代码示例。如果您正苦于以下问题:C# ICamera.ComputeCameraMatrix方法的具体用法?C# ICamera.ComputeCameraMatrix怎么用?C# ICamera.ComputeCameraMatrix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICamera
的用法示例。
在下文中一共展示了ICamera.ComputeCameraMatrix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
public void Render(ICamera camera, ICamera lodCamera, Vector3d lightPosition)
{
var transformation = new Matrix4d(
new Vector4d(1, 0, 0, 0),
new Vector4d(0, 0, 1, 0),
new Vector4d(0, 1, 0, 1),
new Vector4d(0, 0, 0, 1));
var visibleChunks = _chunkedLod.Calculate(
_tree,
lodCamera.Width,
lodCamera.HorizontalFieldOfView,
Vector3d.Transform(lodCamera.Position, transformation),
30,
FrustumPlaneExtractor.ExtractRowMajor(transformation * lodCamera.ComputeCameraMatrix() * lodCamera.ComputeProjectionMatrix()));
GL.ClearColor(Color4.White);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
GL.Enable(EnableCap.DepthTest);
GL.CullFace(CullFaceMode.Back);
GL.Enable(EnableCap.CullFace);
GL.FrontFace(FrontFaceDirection.Cw);
_simpleMaterial.Bind();
_simpleMaterial.ProjectionMatrix.Set(camera.ComputeProjectionMatrix().ToMatrix4());
_simpleMaterial.ViewMatrix.Set(camera.ComputeCameraMatrix().ToMatrix4());
_simpleMaterial.LightDirection.Set(new Vector3(1, 1, 0).Normalized());
_simpleMaterial.Color.Set(new Vector4(0.9f, 0.9f, 0.9f, 1.0f));
foreach (var chunkedLodTreeNode in visibleChunks)
{
var renderableMesh = _cache.GetRenderable(chunkedLodTreeNode.Bounds);
if (renderableMesh == null)
continue;
renderableMesh.CreateVAO();
renderableMesh.VertexArrayObject.Bind();
var bounds = chunkedLodTreeNode.Bounds;
var translation = Matrix4.CreateTranslation((float)bounds.Center.X, 0, (float)bounds.Center.Y);
var delta = bounds.Max - bounds.Min;
var scale = Matrix4.CreateScale((float)delta.X, 1, (float)delta.Y);
var modelMatrix = scale * translation;
_simpleMaterial.ModelMatrix.Set(modelMatrix);
_simpleMaterial.NormalToWorld3x3.Set(new Matrix3(Matrix4.Transpose(modelMatrix.Inverted())));
_simpleMaterial.LightPosition.Set((Vector3)lightPosition);
GL.DrawElements(BeginMode.Triangles, renderableMesh.Faces * 3, DrawElementsType.UnsignedInt, 0);
renderableMesh.VertexArrayObject.Unbind();
}
_simpleMaterial.Unbind();
}
示例2: Render
public void Render(ICamera camera, Vector3d lightPosition)
{
_simpleMaterial.Bind();
_simpleMaterial.ProjectionMatrix.Set(camera.ComputeProjectionMatrix().ToMatrix4());
_simpleMaterial.ViewMatrix.Set(camera.ComputeCameraMatrix().ToMatrix4());
_simpleMaterial.Color.Set(new Vector4(0f, 1f, 0f, 1f));
_simpleMaterial.ModelMatrix.Set(Matrix4.CreateTranslation((Vector3)lightPosition));
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
GL.Disable(EnableCap.CullFace);
_renderable.VertexArrayObject.Bind();
GL.DrawElements(BeginMode.Triangles, _renderable.Faces * 3, DrawElementsType.UnsignedInt, 0);
_renderable.VertexArrayObject.Unbind();
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
GL.Enable(EnableCap.CullFace);
_simpleMaterial.Unbind();
}