1. 축(Axis)

X축은 빨간색(좌/우), Y축은 녹색(위/아래) 그리고 Z축은 파란색(앞/뒤)

 

2. 오일러각(Euler Angles)

Gimbal lock 문제가 있슴.

 

3. Transform

Local 변환 : transform

World 변환 : global_transform

 

4. Basis

transform.basis = Vector3(transform.basis.x, transform.basis.y, transform.basis.z)

var basis = Basis()
# Contains the following default values:
basis.x = Vector3(1, 0, 0) # Vector pointing along the X axis
basis.y = Vector3(0, 1, 0) # Vector pointing along the Y axis
basis.z = Vector3(0, 0, 1) # Vector pointing along the Z axis

 

5. 변환하기

x축 기준으로 180(PI)도 회전

# Rotate the transform about the X axis
transform.basis = Basis(Vector3(1, 0, 0), PI) * transform.basis
# shortened
transform.basis = transform.basis.rotated(Vector3(1, 0, 0), PI)

Spatial 노드를 회전할 경우

# Rotate the transform in X axis
rotate(Vector3(1, 0, 0), PI)
# shortened
rotate_x(PI)

Object의 Space(World)를 회전

# Rotate locally
rotate_object_local(Vector3(1, 0, 0), PI)

 

 

6. 직교 정규화

연속적으로 변환을 행한 경우, 부동 소수점으로 인하여 오차가 발생함. 이를 보정하기 위해 직교 정규화를 함.(프레임당 한번만)

transform = transform.orthonormalized()

주의할 점은 스케일(Scale)을 조정해야 할 경우, 하위 노드(예:MeshInstance)의 스케일을 조정하는 것을 권장하며, 직교 정규화를 한 후에 적용을 해야함.

transform = transform.orthonormalized()
transform = transform.scaled(scale)

 

7. 쿼터니언 보간

# Convert basis to quaternion, keep in mind scale is lost
var a = Quat(transform.basis)
var b = Quat(transform2.basis)
# Interpolate using spherical-linear interpolation (SLERP).
var c = a.slerp(b,0.5) # find halfway point between a and b
# Apply back
transform.basis = Basis(c)

 

<참고>
http://docs.godotengine.org/en/stable/tutorials/3d/using_transforms.html#problems-of-euler-angles

+ Recent posts