Direct3D 9 First Person Camera help?

Started by
8 comments, last by littletray26 11 years, 10 months ago

[background=rgb(250, 251, 252)]Hey, I'm new to gamedev.net and would love some help![/background]




[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]

[background=rgb(250, 251, 252)]I've just started writing a game which I plan to be FPS. I've got the Camera class done which I'll dump the code for below.[/background][/font]


[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]

[background=rgb(250, 251, 252)]I was just wondering if anyone could help me (like walk me through and explain each step) to convert this camera to a First Person Camera? Or link me to a tutorial that would? I started not long ago so I have a basic understanding of Vectors but I don't really understand anything like "normalizing" so I do need a bit of assistance [/background][/font]


[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]

[background=rgb(250, 251, 252)]tongue.png[/background][/font]




[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]

[background=rgb(250, 251, 252)]Also some basic tips on improving what I have and making it generally better. I'm a beginner so please go easy :3[/background][/font]




[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]

[background=rgb(250, 251, 252)]Thanks![/background][/font]




===Camera source file===

//Camera source file
#include "Camera.h"

Camera::Camera(D3DXVECTOR3 pos, D3DXVECTOR3 lookAt, D3DXVECTOR3 up, float FOV, float aspect)
{
Camera::pos = pos;
Camera::lookAt = lookAt;
Camera::up = up;

D3DXMatrixPerspectiveFovLH(&projection, FOV, aspect, 0, 100);
}

void Camera::UpdateLook()
{
D3DXMatrixLookAtLH(&view, &pos, &lookAt, &up);
}



===Camera.h===


//Camera header

#include "Main.h"

class Camera
{
private:
D3DXVECTOR3 pos;
D3DXVECTOR3 lookAt;
D3DXVECTOR3 up;

public:
D3DXMATRIX view;
D3DXMATRIX projection;

Camera(D3DXVECTOR3 pos, D3DXVECTOR3 lookAt, D3DXVECTOR3 up, float FOV, float aspect);
void UpdateLook();

};



===Where Camera is in main file===


//Draw Code
camera.UpdateLook();
rd3dDevice->SetTransform(D3DTS_VIEW, &camera.view);
rd3dDevice->SetTransform(D3DTS_PROJECTION, &camera.projection);
The majority of Internet Explorer users don't understand the concept of a browsing application, or that there are options.
They just see the big blue 'e' and think "Internet". The thought process usually does not get much deeper than that.

Worms are the weirdest and nicest creatures, and will one day prove themselves to the world.

I love the word Clicky
Advertisement
This will get you going:

http://msdn.microsoft.com/en-us/library/windows/apps/hh452773.aspx

Considering you don't understand normalizing I'd suggest you find a good book that details the DirectX api first.


GameDev has a book section that can help you with that too:
http://www.gamedev.net/page/books/index.html


Cheers,
Dj
Why did you start a new thread?

Why did you start a new thread?


Because I thought it would be better suited in the "XNA / DirectX" Category, and I didn't know how to move it.
The majority of Internet Explorer users don't understand the concept of a browsing application, or that there are options.
They just see the big blue 'e' and think "Internet". The thought process usually does not get much deeper than that.

Worms are the weirdest and nicest creatures, and will one day prove themselves to the world.

I love the word Clicky

Considering you don't understand normalizing I'd suggest you find a good book that details the DirectX api first.



Thanks for your reply.

I can't find any Direct3D 9 books. They're all Direct3D 10 or 11. Do you know any good D3D9 ones?
The majority of Internet Explorer users don't understand the concept of a browsing application, or that there are options.
They just see the big blue 'e' and think "Internet". The thought process usually does not get much deeper than that.

Worms are the weirdest and nicest creatures, and will one day prove themselves to the world.

I love the word Clicky
I can give you a sample where the camera is pretty much FPS(controlled by mouse,locked to terrain height).If you are using Visual Studio 2010 when you convert it,find any reference of dxerr9 and change it to just dxerr and also in the Linker->Input change dxerr9.lib to just dxerr.lib The camera class in that sample is pretty clean and simple - http://www.2shared.com/file/lW3WhoUH/Walk_Terrain_Demo.html

[quote name='DJTN' timestamp='1338305176' post='4944339']
Considering you don't understand normalizing I'd suggest you find a good book that details the DirectX api first.



Thanks for your reply.

I can't find any Direct3D 9 books. They're all Direct3D 10 or 11. Do you know any good D3D9 ones?
[/quote]


Introduction to 3D Game Programming With DirectX 9.0 by Frank Luna

Introduction to 3D Game Programming With DirectX 9.0 by Frank Luna


I only found "Introduction to 3D Game Programming with DirectX 9.0c - Frank Luna" is that it?
The majority of Internet Explorer users don't understand the concept of a browsing application, or that there are options.
They just see the big blue 'e' and think "Internet". The thought process usually does not get much deeper than that.

Worms are the weirdest and nicest creatures, and will one day prove themselves to the world.

I love the word Clicky
That is a good one and he also has one with a "shader approach" that is good.

That is a good one and he also has one with a "shader approach" that is good.


Thanks, I bought them both :P

Skimmed through it a bit before, doesn't seem like something that you'd learn with but more of a book full of code, information and math you can reference to which is exactly what I needed! Many thanks :)
The majority of Internet Explorer users don't understand the concept of a browsing application, or that there are options.
They just see the big blue 'e' and think "Internet". The thought process usually does not get much deeper than that.

Worms are the weirdest and nicest creatures, and will one day prove themselves to the world.

I love the word Clicky

This topic is closed to new replies.

Advertisement