本文整理汇总了C#中Location.CrossProduct方法的典型用法代码示例。如果您正苦于以下问题:C# Location.CrossProduct方法的具体用法?C# Location.CrossProduct怎么用?C# Location.CrossProduct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Location
的用法示例。
在下文中一共展示了Location.CrossProduct方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderPass_Setup
/// <summary>
/// Set up the rendering engine.
/// </summary>
public void RenderPass_Setup()
{
Location camup = CameraUp();
BEPUutilities.Quaternion cammod = CameraModifier();
Location camforward = ForwardVec;
camup = new Location(BEPUutilities.Quaternion.Transform(camup.ToBVector(), cammod));
camforward = new Location(BEPUutilities.Quaternion.Transform(camforward.ToBVector(), cammod));
CameraForward = camforward;
GL.BindFramebuffer(FramebufferTarget.Framebuffer, CurrentFBO);
GL.DrawBuffer(CurrentFBO == 0 ? DrawBufferMode.Back : DrawBufferMode.ColorAttachment0);
StandardBlend();
GL.Enable(EnableCap.DepthTest);
RenderTextures = true;
GL.ClearBuffer(ClearBuffer.Color, 0, ClearColor);
GL.ClearBuffer(ClearBuffer.Depth, 0, new float[] { 1.0f });
cameraBasePos = CameraPos;
cameraAdjust = -camforward.CrossProduct(camup) * 0.25;
RenderRelative = CameraPos;
SetViewport();
CameraTarget = CameraPos + camforward;
OffsetWorld = Matrix4d.CreateTranslation(ClientUtilities.ConvertD(-CameraPos));
Matrix4 proj = Matrix4.CreatePerspectiveFieldOfView(MathHelper.DegreesToRadians(TheClient.CVars.r_fov.ValueF),
(float)Width / (float)Height, TheClient.CVars.r_znear.ValueF, TheClient.CVars.r_zfar.ValueF); // TODO: View3D-level vars?
Location bx = TheClient.CVars.r_3d_enable.ValueB ? (cameraAdjust) : Location.Zero;
Matrix4 view = Matrix4.LookAt(ClientUtilities.Convert(bx), ClientUtilities.Convert(bx + camforward), ClientUtilities.Convert(camup));
PrimaryMatrix = view * proj;
if (TheClient.CVars.r_3d_enable.ValueB)
{
Matrix4 view2 = Matrix4.LookAt(ClientUtilities.Convert(-cameraAdjust), ClientUtilities.Convert(-cameraAdjust + camforward), ClientUtilities.Convert(camup));
PrimaryMatrix_OffsetFor3D = view2 * proj;
}
Matrix4d projd = Matrix4d.CreatePerspectiveFieldOfView(MathHelper.DegreesToRadians(TheClient.CVars.r_fov.ValueF),
(float)Width / (float)Height, TheClient.CVars.r_znear.ValueF, TheClient.CVars.r_zfar.ValueF); // TODO: View3D-level vars?
Location bxd = TheClient.CVars.r_3d_enable.ValueB ? (CameraPos + cameraAdjust) : CameraPos;
Matrix4d viewd = Matrix4d.LookAt(ClientUtilities.ConvertD(bxd), ClientUtilities.ConvertD(bxd + camforward), ClientUtilities.ConvertD(camup));
PrimaryMatrixd = viewd * projd;
Matrix4d PrimaryMatrix_OffsetFor3Dd = Matrix4d.Identity;
if (TheClient.CVars.r_3d_enable.ValueB)
{
Matrix4d view2d = Matrix4d.LookAt(ClientUtilities.ConvertD(CameraPos - cameraAdjust), ClientUtilities.ConvertD(CameraPos - cameraAdjust + camforward), ClientUtilities.ConvertD(camup));
PrimaryMatrix_OffsetFor3Dd = view2d * projd;
}
camFrust = new Frustum(PrimaryMatrixd);
cf2 = new Frustum(PrimaryMatrix_OffsetFor3Dd);
CFrust = camFrust;
CheckError("AfterSetup");
}
示例2: LookAtLH
public static Matrix LookAtLH(Location start, Location end, Location up)
{
Location zAxis = (end - start).Normalize();
Location xAxis = up.CrossProduct(zAxis).Normalize();
Location yAxis = zAxis.CrossProduct(xAxis);
return new Matrix((double)xAxis.X, (double)yAxis.X, (double)zAxis.X, 0, (double)xAxis.Y,
(double)yAxis.Y, (double)zAxis.Y, 0, (double)xAxis.Z, (double)yAxis.Z, (double)zAxis.Z, 0,
(double)-xAxis.Dot(start), (double)-yAxis.Dot(start), (double)-zAxis.Dot(start), 1);
}