November Engine Features (Part 6 (and last, for now)): Planets rendering demo

Posted on

Earth, Moon -- demo using Castle Game Engine

A new Castle Game Engine demo shows rendering of an Earth, Moon and a satellite (exported from Blender with normal maps), and animating their transformations by code.

The complete demo source code, with README explaining everything, is here.

This demo was created thanks to the support of Doug Chamberlin on Patreon. Thank you!

Comments on the forum ➤

November Engine Features (Part 5): Sprites (example and tool to create sprite sheets), examine camera improvements

Posted on

Character from "The Unholy Society" ( ) remade as a sprite sheet
sprite_sheet_animation example, using character from "The Unholy Society" ( ) (remade as sprite sheet)
  1. A new example how to render sprites using the TSprite class was added: look in the examples/sprite_sheets/sprite_sheet_animation directory.

    Also, a simple tool to create a sprite sheet from a sequence of images is now available in the examples/sprite_sheets/combine_images_into_sprite_sheet directory.

  2. New features of TExamineCamera:

    1. Disable rotations by RotationEnabled

    2. Configure mouse buttons by MouseButtonRotate, MouseButtonMove, MouseButtonZoom.

    3. Zooming works with orthogonal camera (in which case we need to scale the model, as moving camera closer/further away doesn’t have any visible effect).

  3. LogFileName allows to easily configure log destination.

Comments on the forum ➤

November Engine Features (Part 4): CastleSettings.xml, DPI scaling, cleaner component palette

Posted on

Castle Game Engine Editor - design with checkboxes, labels, edit boxes
  1. You can create a file called CastleSettings.xml to define some UI properties, like UI scaling and default font. This file allows your game and CGE editor to use the same settings (e.g. same default font). In your game just call Window.Container.LoadSettings('castle-data:/CastleSettings.xml'); to load these settings.

  2. DPI scaling is now better.

    TCastleWindowCustom.Dpi and TUIContainer.Dpi (“dots per inch”, aka “pixels per inch”) is now correct in all situations, on all backends. This includes GTK, WinAPI, X11 and LCL backends (in addition to the previous Android and iOS). It is also now valid for TCastleControl.

    Note that in some cases (desktops), this property is configurable by user, and actually means “a user preference how should the user interface be scaled”. Only in some cases (on mobile devices) it actually reflects the physical dimensions of the screen (pixels per physical inch).

    Moreover, you have a new option to scale user interface: usDpiScale. This is great for desktop applications. It follows the auto-scaling of Lazarus LCL applications.

  3. The “Castle” component palette in Lazarus is now much cleaner.

    It now contains only visual components that make most sense to be dropped on a Lazarus form: TCastleControl, TCastle2DControl, TCastleControlCustom. Plus non-visual dialog components.

    Previously, it contained a lot of other CGE components, that were not visualized at design-time in Lazarus. Having them on a component palette was probably more confusing than useful — e.g. you could drop TCastleButton on a Lazarus form, but (surprisingly) it’s a non-visual component for Lazarus (as far as Lazarus LCL is concerned, because it’s actually rendered using OpenGL in CGE).

    The new CGE editor is a solution to visually edit CGE user interface components, like TCastleButton.

    If you need backward compatibility, simply add {$I CASTLE_REGISTER_ALL_COMPONENTS_IN_LAZARUS} to the src/ Reinstall the CGE packages, and the components will appear back. But please note that this is a temporary workaround: In the future, you should either instantiate them by code, or design them using CGE editor and load as `UserInterfaceLoad(‘xxx.castle-user-interface’)`.

Comments on the forum ➤

November Engine Features (Part 3): User interface classes (checkbox, refer to embedded design, …)

Posted on

Castle Game Engine play_animation demo
Castle Game Engine Editor - design with checkboxes, labels, edit boxes

New and improved user interface controls:

  1. New TCastleCheckbox shows a standard checkbox with a caption. It supports the standard properties and events, like Checked, Caption, OnChange and so on.

    I also recommend TCastleCheckbox implementation as a demo of implementing a component by composing some other internal components. In this case, TCastleCheckbox is realized as 2x TCastleImageControl and TCastleLabel instances. This is much easier and more powerful than drawing everything in the component Render method yourself.

  2. A new UI control TCastleDesign allows to reference a xxx.castle-user-interface file. This is especially useful inside the editor, to visually see one xxx.castle-user-interface file embedded inside another yyy.castle-user-interface.

    From code, it is usually more straightforward to load designs using UserInterfaceLoad global function, than to use TCastleDesign.

  3. TCastleLabel is now by default black. This makes it consistent with other UI controls (that generally assume “dark text over light background”), and avoids a confusion when default TCastleLabel isn’t visible over default TCastleRectangleColor (as they were both pure white, in previous engine version).

    On a related note, TCastleSceneManager no longer has pure black background, it has very dark gray (0.1, 0.1, 0.1, 1) background. This way pure black things are clearly visible over it. See Upgrading to Castle Game Engine 6.6 for detailed reasoning.

  4. TCastleScrollView received a number of fixes.

  5. TCastleVerticalGroup and TCastleHorizontalGroup have now configurable AutoSize and by default zero Padding and Spacing (more intuitive).

  6. You can now activate TCastleImageControl.DetectScaleFromUrl. This affects how the auto-scaling works, and detects special filenames like [email protected]. If you load an image file called [email protected] with size 20×20, and set DetectScaleFromUrl to true, then the automatically calculated control size will be 10×10 (2x smaller than the actual image size).

    This is a very useful trick to provide “upscaled” images that work with any UI scaling.

  7. TCastleButton.CustomColorXxx allows to configure button look by a solid color.

  8. The TCastleEdit has a number of new features:

    1. Placeholder text with PlaceholderColor
    2. PasswordChar to present password-input fields,
    3. OnChange event, AutoSize property.
Comments on the forum ➤

November Engine Features (Part 2): TCastleUserInterface (borders, culling, clipping, events…)

Posted on

Fight in "The Unholy Society" ( )
Castle Game Engine Editor - design with borders and scene manager

A lot of work to improve our main user interface class TCastleUserInterface (formerly called TUIControl), from which all other UI controls descend:

  1. Border and BorderColor allow to draw borders around any UI control. Transparent borders are also incredibly useful, to add space around the control, or to reserve free space for sibling controls. For example, this allows to set one control to have height equal to 100 pixels, and the other control to just “fill the rest of the parent”.

    Borders work reliably in all circumstances. Including when you adjust size using AutoSizeToChildren, or FullSize, or WidthFraction or HeightFraction.

  2. To adjust size to a given percent of the parent, WidthFraction and HeightFraction are now available.

    The EffectiveRect documentation summarizes various sizing options.

  3. To better control the AutoSizeToChildren effects, we added new AutoSizeToChildrenPaddingRight and AutoSizeToChildrenPaddingTop.

  4. Any control can now clip overflowing children by using ClipChildren.

  5. Turn on Culling to optimize the case when a resource-intensive control is often off-screen (and thus doesn’t need to be rendered or process other events).

    This also matters if the control is outside of the parent scrollable view (TCastleScrollView) or other parent with ClipChildren. This is very useful when creating a large number of children inside TCastleScrollView.

  6. We have optimized and improved internal measuring of the control. It now uses an internal (protected) PreferredSize method, and is cached for some brief moments (during rendering), and is secured from recursive loop (in case the parent’s size depends on the child, but the child’s size depends on the parent).

  7. A number of events are now available: OnPress, OnRelease, OnMotion, OnUpdate, OnRender. These allow to react to UI events without creating new descendants of each UI class.

  8. SetTransient allows to mark the component as internal. This is useful for internal components of TCastleCheckbox or TCastleDesign.

Comments on the forum ➤

November Engine Features (Part 1): Editor (anchors, 9-slices rulers, copy-paste…), documentation

Posted on

Tutorial in "The Unholy Society" ( ) made using Castle Game Engine Editor
Tutorial in "The Unholy Society" ( ) made using Castle Game Engine Editor
Castle Game Engine Editor - anchors
Table with rows inside a scroll view, made using Castle Game Engine Editor
  1. Castle Game Engine Editor improvements:

    1. Visually edit anchors. Anchors are incredibly important when using our user-interface — they allow you to position controls such that they work regardless of the window size (and UI scaling, if you use it).

    2. Visually adjust TCastleImageControl.ProtectedSides. This allows to configure rendering of images using 3×3 (9-slices) algorithm. The editor now shows the “rulers” that split image into 3×3 parts with different scaling.

    3. Copy-pasting of component within the editor is possible. This way you can quickly duplicate a component hierarchy, or move it between various designs.

    4. TSerializedComponent is an alternative approach to deserializing design files. (xxx.castle-user-interface, xxx.castle-transform) It’s powerful when you need to instantiate the same file multiple times. This way the file is loaded only once (at TSerializedComponent.Create call) and you can instantiate it many times fast (using TSerializedComponent.UserInterfaceLoad method).

  2. Additions to the documentation:
    1. Making mirrors on flat objects, using X3D nodes.

    2. Upgrading to the (upcoming) Castle Game Engine 6.6 — this page lists known places where we (reluctantly) had to break compatibility, and that you will have to adjust when upgrading your games from engine 6.4 to 6.6.

    3. fpcupdeluxe instructions enhanced with AArch64 (64-bit Android devices) information

Comments on the forum ➤

Thank You Patrons – here’s what we did in 2018!

Posted on

PlayAnimation demo with animation blending
Steep parallax bump mapping with self-shadowing on Android
Monkey with bump mapping on Android

Before we go into Castle Game Engine 6.6 release (soon!), I wanted to thank people who support Castle Game Engine on Patreon 🙂 The engine is being developed thanks to your support! Here are some features done explicitly thanks to the requests from Patrons in 2018:

Thank you!

Comments on the forum ➤