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

Posted on

Fight in "The Unholy Society" ( unholy-society.com )
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" ( unholy-society.com ) made using Castle Game Engine Editor
Tutorial in "The Unholy Society" ( unholy-society.com ) 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

shot0002
vlcsnap-2018-06-16-09h57m46s961
aluminium.x3dv_0
PlayAnimation demo with animation blending
wyrd_forest_screen_0
physics
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 ➤

Big user-interface and editor improvements

Posted on

editor_0
editor_1
  1. The editor supports selecting, translating and resizing UI controls (possibly with snap). You may have already seen it in the movie.

  2. It is possible to use custom components within the editor.

    New build tool command “castle-engine editor” will run Castle Game Engine Editor within the current project, with possible project-specific components. It will automatically build CGE editor with additional project-specific components included.

    See the editor README, section “Include custom (project-specific) components in the visual designer”.

  3. The editor has menu items to adjust camera (Scene Manager Camera View All), and to reorder 2D scenes (Scene Manager Sort For Correct 2D Blending).

  4. Much more vectors and colors are editable and persistent in the editor. E.g. TCastleLabel.Color, TCastleTransform.Translation/Rotation/Scale.

  5. New property TCastleUserInterface.AutoSizeToChildren allows to adjust size to include all children. In particular useful for TCastleScrollView.ScrollArea.

  6. The user interface coordinates (all positions, sizes) are float-based now. In other words, TCastleUserInterface.Width, TCastleUserInterface.Height, and a lot of “friends” now have a type Single, not Integer. In some cases, we deprecated old integer-based property (like TCastleUserInterface.CalculatedWidth, TCastleUserInterface.ScreenRect) and added a new float-based replacement (like TCastleUserInterface.EffectiveWidth, TCastleUserInterface.RenderRect).

    Note: This change may break backward compatibility in some cases. You may need to adjust your code. This was unfortunately unavoidable, the API looked really messy when I was trying to maintain 100% backward compatibility (having both integer-based and float-based methods and properties). Details in this commit log.

    If you just did MyControl.Width := 100 it will work as before. But if you did e.g. MyInteger := MyControl.Width, or MyInteger := MyControl.Width div 2, it will no longer work, as Width is a floating-point value (Single) now. You will need to adjust your code. You can just write Round(MyControl.Width), or you can adjust your code to use float-based coordinates everywhere too.

    If you use rectangles, you can convert between integer-based (TRectangle) and float-based (TFloatRectangle) using MyFloatRectangle := FloatRectangle(MyIntRectangle) or MyIntRectangle := MyFloatRectangle.Round;.

    If you encounter troubles adjusting your code, please let us know on Discord or forums, we will help!

  7. TCastleUserInterface now has a size (Width, Height, FullSize properties). The TCastleUserInterfaceRect, TUIControl, TUIControlRect are all now just deprecated aliases for TCastleUserInterface.

  8. All UI controls have non-zero size by default. The base TCastleUserInterface class sets width and height to 100. This is more friendly (especially when using the editor) than previous situation when TCastleUserInterfaceRect / TUIControlRect had by default zero size.

Comments on the forum ➤

“Modern Object Pascal Introduction for Programmers” translated to Russian

Posted on

Thanks to Alexander Skvortsov and Yevhen Loza, the complete book “Modern Object Pascal Introduction for Programmers” is now available in Russian. Read it here in the Russian version:

My many thanks go to the translators for the huge task they did. The translation includes the complete text, comments in the example code, and they also improved and enhanced the English text as well.

It’s all merged now into the GitHub repository, where English and Russian sources (in AsciiDoc) live side-by-side.

P.S. If you’re looking for the English version, it’s (as always) here:

Comments on the forum (4) ➤

Article about CGE in Blaise Pascal Magazine (free for Patrons), also: meet me at Lazarus Professional Conference next week

Posted on

game-3d-model
  1. The next issue of Blaise Pascal Magazine will contain a nice long article I wrote about Castle Game Engine! 20 pages, describing how to use the engine from absolute basics, showing how to construct a simple cross-platform 3D game using TCastleWindow, TCastleScene, TCastleTransform, SoundEngine features. I am quite happy with it 🙂

    I will also make the article available for all Patrons of Castle Game Engine at the end of this month (September). If you would like to support the development of CGE, now is the time 🙂

    The article is accompanied by a public example code and data.

  2. I will also be present next week an the Lazarus Professional Conference in Bonn. You can meet me on Saturday (22 September), during Community Day, when we will be showing Castle Game Engine.

    Please drop by to talk, or just to say “hi”:)

Comments on the forum ➤

X3D Standard Plans, Michalis Professional Membership in the Web3D Consortium

Posted on

Shadow maps in Castle Game Engine

Since a week, Michalis is a Professional Member of the Web3D Consortium. These are the people who make X3D specifications, see also our documentation how X3D fits within Castle Game Engine. By being a “professional member” I will have some extra access (e.g. to see draft specs of upcoming X3D versions) and some influence to take X3D into interesting places 🙂

My vision and goals for X3D is documented publicly in my “x3d-tests” wiki. This wiki contains an overview + lots of details what I would like to see in X3D standard. Many of the ideas revolve around bringing X3D more “aligned” with glTF 2.0 feature set. Which is of course closely tied with getting glTF 2.0 into Castle Game Engine, as an X3D scene graph. I believe that this is a solution in which everyone wins, i.e. we will have an engine with perfect interchange format (for which glTF 2.0 is now better, although X3D tries to catch up) and a perfect scene graph (where X3D shines already).

Comments on the forum ➤

Improvements: castle-data protocol, new editor features, AMD Compressonator, better model formats docs…

Posted on

editor_0
editor_1
editor_2
editor_3

We have a number of engine improvements to announce:

Comments on the forum ➤