Skip to main content
GameDev.net gamedev.net
🔒 Locked 🎮 Unity

Need help converting into DirectxMath

Started by terrysworkstations Dec 30, 2020 at 4:01 AM 1 replies 3.6k views
Original Post
terrysworkstations
terrysworkstations

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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.