First Person Camera
I've finally got the first person camera to work properly in my engine, and it's very simple to use, too!
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.
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.
Sign in to follow this
Followers
0
2 Comments
Recommended Comments
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 accountSign in
Already have an account? Sign in here.
Sign In Now