Need help with my Camera Class! Please!!

Hey guys, this is my first post asking for help on this forum for about 7-8 years. I'm using DirectX(I know should go under Windows or Game programming,but nobody browses those and this is a C++ question in general anyway.

I have my camera class, from Camera.cpp and camera.h.
They all have three functions that work perfectly(actually two of them work)

when I go


Code:
m_camera.Yaw(DeltaY);
m_camera.Pitch(DeltaX);

She works. Beautifully, I might add. However...

Code:
m_camera.Roll(DeltaZ);

Does nothing. Even if I just put

Code:
m_camera.Roll(10.00f); //(or any over float value)

It simply does not roll.

Since this forum(unlike cprogramming.com's forum has a character limit I uploaded both Camera.cpp and Camera.h into a .txt document:

Here is Camera.cpp/Camera.h:
http://www.yiffclan.org/code.txt

What gives? Yaw and Pitch work PERFECT, but not Roll(). Why? What am I missing? I know some you experts out there can help me find the answer.

Thank you so much for your time and consideration. And mods, please don't move this another subforum that nobody reads. This is mostly a C++ issue, after all, not a graphics API issue.

Thank you!

P.S. Your code formatting doesn't work on Chrome for me, and nor does preview. So if this post looks messy, I apologize--I click preview and I only get a couple chinese characters in a small blue table rather than an actual preview.

Please help me guys. The engine I'm writing means a lot to me personally.

@ TomTheFox

Have you tried calling the roll function WITHOUT using the f in the parenthesis? You know, just sending the 10.00. The function is only looking for a number, and I think the letter would probably mess things up.
> m_camera.Roll(10.00f);
10 radians is a lot.

> m_camera.Roll(DeltaZ);
> Does nothing.
> It simply does not roll.
the code of Roll() and Yawn() are practically the same
you could run through a debugger and observe the rotation matrix and the vector changing.
the difference between them is the vectors that change

now look at your Update() function
1
2
3
4
5
void CCamera::Update() {
	//...
	// Calculate the new view matrix
	D3DXVECTOR3 up = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
	D3DXMatrixLookAtLH(&m_view, &m_position, &m_lookAt, &up);
you don't give a damn about m_up, so any changes to it are irrelevant.
I also doubt that you'll notice the changes in m_right.


> The function is only looking for a number, and I think the letter would
> probably mess things up.
┬┐are you serious?
10.00 is a double

10.00f is a float
Last edited on
Thank you for your answers. I have tried several times with and without the f, m_camera.Roll(10) or even m_camera.Roll(1000) changes nothing. It simply refuses to roll along the axis. I'm pretty sure this camera code is solid, much of it is borrowed code as I am still learning. I highly doubt that putting an f after the parameter that requires a float in the first place would affect anything, and as it turns out, it doesn't.

Any suggestions?
1
2
3
4
void CCamera::Update(){
   //...
   //D3DXVECTOR3 up = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
   D3DXMatrixLookAtLH(&m_view, &m_position, &m_lookAt, &m_up);
Last edited on
void CCamera::Update(){
//...
//D3DXVECTOR3 up = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
D3DXMatrixLookAtLH(&m_view, &m_position, &m_lookAt, &m_up);


No, that just killed the camera completely and I nothing but gray.
10 radians is 573 degrees.
this isnt critical in pure math, but maybe try something between 0 and 2 pi just in case it matters to your function?
just try like .5 or something.

note that some things, you can't tell if it is working. If, for example, you draw a circle at 0,0 with a 500 pixel radius, and then roll your camera, you can't tell: its a circle.
Topic archived. No new replies allowed.