Advertisement

Need help converting into DirectxMath

Started by December 30, 2020 04:01 AM
1 comment, last by terrysworkstations 4 years, 1 month ago

I dont understand the code below. There is a function called Transform in the code. Which is taking a VECTOR and a Quaternion. I cannto find a function equivalent to this in DirectX.

function Update( float yaw, float pitch )

// Create a quaternion that rotates about the world up

Quaternion quatYaw = CreateFromAxisAngle( Vector3(0,1,0), yaw )

// Transform the camera offset and up by this quaternion

offset = Transform( offset, quatYaw )

up = Transform( up, quatYaw )

// The forward is target.position - (target.position + offset)

// Which is just -offset

Vector3 forward = - offset

forward.Normalize()

Vector3 left = CrossProduct( up, forward )

left.Normalize()

// Create quaternion that rotates about camera left

Quaternion quatPitch = CreateFromAxisAngle( left, pitch )

// Transform camera offset and up by this quaternion

offset = Transform( offset, quatPitch )

up = Transform( up, quatPitch )

// Now compute the matrix

cameraMatrix = CreateLookAt( target. position + offset ,

target. position, up )

end

I cannot find function in link

XMQuaternionRotationRollPitchYaw function (directxmath.h) - Win32 apps | Microsoft Docs

Nevermind, i used XMVector3Rotate.

This topic is closed to new replies.

Advertisement