Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 01 Mar 2011
Offline Last Active Feb 02 2013 10:36 AM

Posts I've Made

In Topic: Quaternion Camera rotation

03 July 2012 - 06:39 PM

Actually you helped me quite a lot. Now the only one question that remains and that none of the sites I've read explains is the Orientation of the Camera. What exactly is the camera orientation? O.o

In Topic: Quaternion Camera rotation

03 July 2012 - 08:07 AM

Okay, so I've cleared everything and a fresh start. So the main idea if I get right would be this: (In a very simple case)
We have a position for the camera (Eye)
We have a focus point where the camera looks (LookAt)
And finally we have the World's Up vector (Up XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f))

From this we create the View Matrix which is a 4x4 matrix:
XMStoreFloat4x4(&m_ViewMatrix, XMMatrixLookAtLH(m_Position, m_Target, XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f));

Now to have a quaternion based camera we need the actual direction (orientation) of the camera.
m_Direction = XMQuaternionNormalize(XMQuaternionRotationMatrix(XMLoadFloat4x4(&m_ViewMatrix)));

Aaand here I get lost. As I've watched over tutorials I found that to rebuild the viewMatrix they to a MatrixRotationQuaternion like:
XMStoreFloat4x4(&m_ViewMatrix, XMMatrixRotationQuaternion(m_Direction));

Zero movement or rotation for the camera yet, but if I do this nothing is drawn on my screen. On a second note to actually move or rotate the camera I thought something like this:
void UpdatePosition(const XMVECTOR Direction, float dt = 1.0f); -> Update the position (Eye) of the camera based on deltaTime.
void Move(float dx, float dy, float dz);
Calculate the direction XMVectorSet(dx, dy, dz, 0.0f) - m_Position. Call UpdatePosition. (I may be wrong tho)
void Rotate(float Pitch, float Yaw, float Roll); -y No idea yet but I'll eventually find the answer :D

In Topic: CameraProblems

30 June 2012 - 02:04 PM

thanks a lot. you helped me implement my view matrix creation a lot more efficient. My problem however was the missing of projection matrix. So the Correct Projection matrix would be:

[source lang="cpp"]XMStoreFloat4x4(&m_ProjectionMatrix, XMMatrixTranspose(XMMatrixPerspectiveFovLH(XM_PIDIV2, static_cast<float>(ClientWidth) / static_cast<float>(ClientHeight), 0.01f, 100.0f)));//instead of:XMStoreFloat4x4(&m_ProjectionMatrix, XMMatrixIdentity());[/source]

I should just get some sleep maybe because I'm going nuts of silly things that I don't notice...

Thanks for your recommendation. I'm aware of these, and actually CameraClass will serve as an abstract Camera for the other specific cameras I'm going to implement in the near future. Actually the next would be the Quaternion based camera for a free-look system controlled with mouse from the inherited:

[source lang="cpp"]void MouseDown(WPARAM, int, int) = 0;void MouseUp(WPARAM, int. int) = 0;void MouseMove(WPARAM, int, int) = 0;[/source]
functions. I'm not sure if this is the best way to go but for the first look it seems promising.

In Topic: Update ConstantBuffers using Context::MAP

30 June 2012 - 10:07 AM

Awesome! I knew it'll be something like this... Thanks a lot mate, you saved my day! ;)

In Topic: Unable to draw triangle...

03 June 2012 - 04:39 PM

Ah thanks, but changing those to positive 0.25 doesn't change anything. Only the blue d3d client area is visible but the triangle is nowhere.