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

Direct3D 9 First Person Camera help?

Started by littletray26 May 29, 2012 at 7:09 AM 8 replies 3k views
Original Post
littletray26
littletray26

[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
hupsilardee
hupsilardee
Why did you start a new thread?
littletray26
littletray26

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
littletray26
littletray26

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
DJTN
DJTN

[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
littletray26
littletray26

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
DJTN
DJTN
That is a good one and he also has one with a "shader approach" that is good.
littletray26
littletray26

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


Thanks, I bought them both

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

Topic Locked

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

Sign in to reply to this topic.