csharp SlimDX_Transform.cs
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp SlimDX_Transform.cs相关的知识,希望对你有一定的参考价值。
using SlimDX;
public class Transform
{
public Vector3 Position
{
get
{
return LocalPosition + (_parent != null ? _parent.Position : new Vector3(0, 0, 0));
}
set
{
LocalPosition = value - (_parent != null ? _parent.Position : new Vector3(0, 0, 0));
}
}
public Vector3 LocalPosition { get; set; }
public Vector3 EulerAngles
{
get
{
return LocalEulerAngles + (_parent != null ? _parent.EulerAngles : new Vector3(0, 0, 0));
}
set
{
LocalEulerAngles = value - (_parent != null ? _parent.EulerAngles : new Vector3(0, 0, 0));
}
}
public Vector3 LocalEulerAngles { get; set; }
public Vector3 LocalScale { get; set; } = new Vector3(1f, 1f, 1f);
private Transform _parent;
internal Matrix MMatrix =>
(LocalScaleMatrix * LocalRotateMatrix * LocalPositionMatrix)
* (_parent != null ? _parent.MMatrix : Matrix.Identity);
private Matrix LocalScaleMatrix => Matrix.Scaling(LocalScale);
private Matrix LocalRotateMatrix
{
get
{
// X軸回転行列
var localRotateXMatrix = Matrix.RotationQuaternion(
Quaternion.RotationAxis(new Vector3(1, 0, 0), LocalEulerAngles.X)
);
// Y軸回転行列
var localRotateYMatrix = Matrix.RotationQuaternion(
Quaternion.RotationAxis(new Vector3(0, 1, 0), LocalEulerAngles.Y)
);
// Z軸回転行列
var localRotateZMatrix = Matrix.RotationQuaternion(
Quaternion.RotationAxis(new Vector3(0, 0, 1), LocalEulerAngles.Z)
);
// ZXYの順で計算
return localRotateZMatrix * localRotateXMatrix * localRotateYMatrix;
}
}
private Matrix LocalPositionMatrix
{
get
{
var localPositionMatrix = Matrix.Identity;
localPositionMatrix.set_Rows(3, new Vector4(
LocalPosition.X,
LocalPosition.Y,
LocalPosition.Z, 1f));
return localPositionMatrix;
}
}
public Matrix MVPMatrix => MMatrix * _vpMatrix;
Matrix _vpMatrix;
public Transform SetVPMatrix(Matrix vpMatrix)
{
_vpMatrix = vpMatrix;
return this;
}
public Transform SetParent(DrawableObject parent)
{
_parent = parent;
return this;
}
}
以上是关于csharp SlimDX_Transform.cs的主要内容,如果未能解决你的问题,请参考以下文章
csharp 例如-CSHARP-GroupDocs.Conversion.Examples.CSharp渲染,RenderPSDImageAsPath.cs
csharp 实例-CSHARP-GroupDocs.Conversion.Examples.CSharp变频-ConvertTopresentationAsPath.cs
csharp 实例-CSHARP-GroupDocs.Conversion.Examples.CSharp变频-ConvertTopresentationAsPath.cs
csharp 实例-CSHARP-GroupDocs.Conversion.Examples.CSharp变频-ConvertTopresentationAsPath.cs
csharp 例如-CSHARP-GroupDocs.Search.Examples.CSharp索引,AddDocumentToIndex.cs
csharp 例如-CSHARP-GroupDocs.Search.Examples.CSharp索引,AddDocumentToIndexAsynchronously.cs