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
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 a
TCastleScene), 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
I recognize now that this “auto-detection” is sometimes undesired or even surprising. I would advise most games to set both
AutoNavigationto false right after creating
TCastleSceneManager. CGE editor will do it by default too, soon.
TCastle2DSceneManageris now deprecated, as it is useless. You can now easily request orthographic camera with
Setup2Dmethod, or just set yourself
Camera.ProjectionType= ptOrthographic and configure
Camera.Orthographicproperties). This makes things much simpler. We never needed any special class for 2D, our
TCastleSceneManageris 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
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.