重新导入obi
This commit is contained in:
34
Assets/Obi/Scripts/Common/DataStructures/AffineTransform.cs
Normal file
34
Assets/Obi/Scripts/Common/DataStructures/AffineTransform.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Obi
|
||||
{
|
||||
public struct AffineTransform
|
||||
{
|
||||
public Vector4 translation;
|
||||
public Vector4 scale;
|
||||
public Quaternion rotation;
|
||||
|
||||
public AffineTransform(Vector4 translation, Quaternion rotation, Vector4 scale)
|
||||
{
|
||||
// make sure there are good values in the 4th component:
|
||||
translation[3] = 0;
|
||||
scale[3] = 1;
|
||||
|
||||
this.translation = translation;
|
||||
this.rotation = rotation;
|
||||
this.scale = scale;
|
||||
}
|
||||
|
||||
public void FromTransform(Transform source, bool is2D = false)
|
||||
{
|
||||
translation = source.position;
|
||||
rotation = source.rotation;
|
||||
scale = source.lossyScale;
|
||||
|
||||
if (is2D)
|
||||
{
|
||||
translation[2] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user