Jump to content
Sal's RuneScape Forum
  • entries
    244
  • comments
    2,657
  • views
    15,298

First Person Camera

Sign in to follow this  
Toungy

21 views

I've finally got the first person camera to work properly in my engine, and it's very simple to use, too! :wub:

 

If you want to enable first person camera mode, you can simply do this:

 

cam->SetType(CT_FirstPerson);

 

There's a so-called 'flying' mode, which allows the camera to also move vertically. To turn this off, simply add:

 

cam->SetFlying(false);

 

This took ages to get working, so I'm happy. :xd:

 

Again, a few changes have been made to how everything is handled, so here's an example program source:

 

#include <TGE.h>
#pragma comment(lib, "TGE.lib")

Interface( MyInterface ) {
Window		* win;
Renderer	* renderer;
Scene		* scene;
Camera		* cam;
Light		* light;
Object		* pyramid;

void Initialise() {
	win = pRoot->CreateWindow("Test Window");
	renderer = pRoot->CreateRenderer(Direct3D9);

	WindowParams winParams;

	winParams.width  = 640;
	winParams.height = 480;
	winParams.posX   = 50;
	winParams.posY   = 50;

	win->SetParams(winParams);
	win->AttachRenderer(renderer);
}

void CreateScene() {
	scene = renderer->CreateScene();
	cam = scene->CreateCamera();
	light = scene->CreateLight();

	cam->SetType(CT_FirstPerson);
	cam->SetPosition(Vector(35, 3, 0));
	cam->SetRotation(Vector(0,-90,0));

	light->SetPosition(Vector(8,3,-5));

	pyramid = scene->CreateObject();
	pyramid->SetType(OT_Pyramid, 6, 10);
}
};

Main() {
pRoot->RegisterInterface(MyInterface);
}

 

I'm pretty happy with how this is turning out. :wub:

Sign in to follow this  


2 Comments


Recommended Comments

Is it already possible to navigate trough the scene by use of arrow keys?Nice Job.
WASD are used for that, I'll add an arrow keys mode later. :)

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×

Important Information

By using this site, you agree to our Guidelines and Privacy Policy.