View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Direct3D 9 First Person Camera help?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

9 replies to this topic

### #1littletray26  Members

Posted 29 May 2012 - 01:09 AM

Hey, I'm new to gamedev.net and would love some help!

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.

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

Also some basic tips on improving what I have and making it generally better. I'm a beginner so please go easy :3

Thanks!

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


#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);


Edited by littletray26, 29 May 2012 - 01:12 AM.

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

### #2DJTN  Members

Posted 29 May 2012 - 09:26 AM

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

### #3hupsilardee  Members

Posted 29 May 2012 - 12:00 PM

Why did you start a new thread?

### #4littletray26  Members

Posted 29 May 2012 - 05:28 PM

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

### #5littletray26  Members

Posted 29 May 2012 - 05:29 PM

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

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

### #6Veil  Members

Posted 29 May 2012 - 09:05 PM

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

### #7DJTN  Members

Posted 30 May 2012 - 08:40 AM

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

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

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

### #8littletray26  Members

Posted 30 May 2012 - 04:18 PM

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

### #9DJTN  Members

Posted 30 May 2012 - 05:08 PM

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

### #10littletray26  Members

Posted 30 May 2012 - 10:54 PM

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

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.