Skip to main content
gamedev.net
🔒 Locked

program design advice

Started by himizu 2 replies 600+ views
Original Post
himizu
himizu
Hi, I wasn't sure if here or the beginners forum was the best place to put this so I opted for here. I'm wanting to make a game (isn't everyone), a karting game actually, and i'm kinda thinking myself in circles as to what is the best way to hold camera info and where to keep it. What i'm really aiming for is a camera that will track the player in a kinda 3rd person camera like most karting games (mario kart, diddy kong racing) but i also want it to be able to get it to do fly overs of the level and stuff. So the way i thought of doing it was having a camera class, graphics class, and a the player class, and the graphics class has a camera class which it gathers information from so it can render the world and camera view etc. The player class sends its position to the graphics which forwards it on to the camera and the camera adjusts to suit it etc but this seems a really bad way to do it, so i'd like some advice as to what the best way to implement a camera into this kinda system and how to get it to track the player sometimes but also able to track a flyover object or something. Thanks in advance.
Thergothon
Thergothon
Attach the camera to whatever object you wish it to follow, give the camera some displacement from the origin (in this case the object), and use matrix concatenation to get the final position of the camera. This way you can just add the camera and forget about it. Moving the player will cause the camera to also move. So yeah, explained badly, but look into scene graphs.
Vich
Vich
I would suggest to make a Camera base class that has general camera properties and then derive a FlyOverCamera and a ChaseCamera from that class. Also, make a system that enables you to blend from one camera to another in a given amount of time. That should do the trick :)
[www.LifeIsDigital.net - My open source projects and articles.
JasonBlochowiak
JasonBlochowiak
Quote:
Original post by Vich
I would suggest to make a Camera base class that has general camera properties and then derive a FlyOverCamera and a ChaseCamera from that class. Also, make a system that enables you to blend from one camera to another in a given amount of time. That should do the trick :)


I would recommend separating the camera from the camera controller. The camera, and its properties (like, for example, FOV) are a separate logical entity from the controller. In my last project, we simply referred to the controller as cCameraMan - there were then subclasses of cCameraMan that (at least purportedly - the final code ended up unfortunately messy for unrelated reasons) implemented different types of camera control.

Topic Locked

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

Sign in to reply to this topic.