本文整理匯總了C#中Microsoft.Xna.Framework.BoundingBox.Center方法的典型用法代碼示例。如果您正苦於以下問題:C# BoundingBox.Center方法的具體用法?C# BoundingBox.Center怎麽用?C# BoundingBox.Center使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Microsoft.Xna.Framework.BoundingBox
的用法示例。
在下文中一共展示了BoundingBox.Center方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: SetupViewProj
public void SetupViewProj(BoundingBox worldBBox)
{
Vector3 lightPos = worldBBox.Center() - LightDir;
Vector3 up = Vector3.Up;
LightView = Matrix.CreateLookAt(lightPos, worldBBox.Center(), up);
Vector3[] corners = worldBBox.GetCorners();
Vector3[] transformedCorners = new Vector3[8];
for(int i = 0; i < 8; i++)
{
transformedCorners[i] = Vector3.Transform(corners[i], LightView);
}
BoundingBox transformedBBox = new BoundingBox { Min = MathFunctions.Min(transformedCorners), Max = MathFunctions.Max(transformedCorners) };
float width = transformedBBox.Max.X - transformedBBox.Min.X;
float height = transformedBBox.Max.Y - transformedBBox.Min.Y;
float near = transformedBBox.Min.Z - 10;
float far = transformedBBox.Max.Z + 10;
LightProj = Matrix.CreateOrthographic(width, height, near, far);
//LightProj = Matrix.CreatePerspective(ShadowWith, ShadowHeight, 0.1f, 10000);
//LightProj = Matrix.CreatePerspectiveFieldOfView(MathHelper.Pi - 0.5f, 1f, 1f, 1000f);
}