• Advertisement
Sign in to follow this  

Direct3D 9 First Person Camera help?

This topic is 2155 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

[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);
Edited by littletray26

Share this post


Link to post
Share on other sites
Advertisement

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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

[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

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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 :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement