|
|
To celebrate #ThankYouPatrons day in the weirdest and most-programmer-friendly way possible, today we merge into the “master” branch of Castle Game Engine a big refactor of the camera code! This is a huge work, started 4 months ago, and causing 110 new commits.
It includes a number of new inter-connected features:
-
The API to control the camera (viewer position, direction, up, projection etc.) and navigation is now much simpler. Check out API docs about new
TCastleAbstactViewport.CameraandTCastleAbstactViewport.Navigation. -
You can now configure both camera and navigation visually, using the CGE editor.
When you select a viewport (most usually a
TCastleSceneManagerinstance), or anything inside a viewport (like aTCastleScene), there will appear a new set of buttons on the toolbar. The “hamburger” button there contains a menu with useful operations to configure camera and navigation. The “initial” camera vectors will be stored in the design, as well as the chosen navigation component.(The buttons to translate/rotate/scale scenes are not yet handled — coming soon!)
-
We split previous camera class into two concepts, TCastleCamera (“what is current viewer position/orientation and projection”) and TCastleNavigation (“how to handle user input to change the viewer position/orientation”).
This caused a lot of work to make it right, and also to keep backward-compatibility as much as possible. I’ll list reasons for making it in another post — it’s a story in itself.
-
We provide easy means to turn off “auto-detection” of camera and navigation. Just set
AutoCameraand/orAutoNavigationto false.I recognize now that this “auto-detection” is sometimes undesired or even surprising. I would advise most games to set both
AutoCameraandAutoNavigationto false right after creatingTCastleSceneManager. CGE editor will do it by default too, soon. -
TCastle2DSceneManageris now deprecated, as it is useless. You can now easily request orthographic camera withTCastleSceneManager(callSetup2Dmethod, or just set yourselfCamera.ProjectionType= ptOrthographic and configureCamera.Orthographicproperties). This makes things much simpler. We never needed any special class for 2D, ourTCastleSceneManageris for both 2D and 3D — now it’s obvious 🙂 -
It is now configurable which camera (from which viewport) controls “central” features like headlight, X3D ProximitySensor, audio listener. Set
TCastleSceneManager.MainCamerafor this. -
CGE editor received a number of smaller improvements along the way. E.g. you can now duplicate (Ctrl + D) transformations/scenes too, assigning
SceneManager.MainSceneand other references works.

