本文整理汇总了C#中System.Windows.Media.Media3D.Matrix3D.ToXnaMatrix方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix3D.ToXnaMatrix方法的具体用法?C# Matrix3D.ToXnaMatrix怎么用?C# Matrix3D.ToXnaMatrix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Media3D.Matrix3D
的用法示例。
在下文中一共展示了Matrix3D.ToXnaMatrix方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Transform
private void Transform(AstroObject astroObject, Matrix3D baseTransformation, FrameworkElement txt)
{
// Transform Model
if (astroObject == null)
{
return;
}
var m = Matrix.Identity;
m *= Matrix.CreateTranslation(0, 60, 0);
m *= Matrix.CreateRotationX(Microsoft.Xna.Framework.MathHelper.ToRadians(90));
m *= baseTransformation.ToXnaMatrix();
astroObject.Transform = m;
astroObject.IsVisible = true;
// Transform FrameworkElement
// Center at origin of the TextBlock
var centerAtOrigin = Matrix3DFactory.CreateTranslation(-txt.ActualWidth * 0.5, -txt.ActualHeight * 0.5, 0);
// Swap the y-axis
var scale = Matrix3DFactory.CreateScale(1, -1, 1);
// Move a bit away from the center
var translation = Matrix3DFactory.CreateTranslation(0, 50, 0);
// Calculate the complete transformation matrix based on the first detection result
var world = centerAtOrigin * translation * scale * baseTransformation;
// Calculate the final transformation matrix by using the camera projection matrix
var vp = Matrix3DFactory.CreateViewportTransformation(Viewport.ActualWidth, Viewport.ActualHeight);
var mp = Matrix3DFactory.CreateViewportProjection(world, Matrix3D.Identity, arDetector.Projection, vp);
// Apply the final transformation matrix to the TextBox
txt.Projection = new Matrix3DProjection { ProjectionMatrix = mp };
txt.Visibility = Visibility.Visible;
}