More permissive license to use our examples code

Posted on

Zrzut ekranu z 2021-05-02 03-41-29

We change the license of our examples (stuff in examples/ subdirectory) to be more permissive. Namely, all our example code and almost all our example data are now covered by the modified BSD (3-clause) license. It’s a very permissive license that basically says “we keep our copyright, but otherwise do what you want with these files, modify them as you like, and you don’t need to show your modifications to anyone”.

This was always our intention, we want you to use the example code as a basis of your applications without any fuss.

More details, and precise legal words, are in our licensing terms and the modified BSD (3-clause) license text is here.

Comment on this post ➤

Automatic downscaled textures can be now specific to a platform

Posted on

The Unholy Society

We improve the process of automatic texture downscaling. The automatic downscaling is determined by data/material_properties.xml file and documented here. The new features are:

  • Ability to specify any set of scales, not necessarily a continuous range.

  • Ability to specify that some scale values are packaged only for particular platforms. E.g. scale 3 (which means that each size is downscaled 1/4) may only be packaged for Android and iOS, and not for desktops. This is useful, as mobile platforms often have GPUs with more limited memory, so textures often have to be provided there with lower resolution.

New features are documented on manual page about “Auto-generated compressed and scaled textures”.

Thanks go to Eugene Loza for doing this! This is another feature pushed by upcoming The Unholy Society release on mobile 🙂

Comment on this post ➤

Various improvements (2D navigation, PhysicsRayCast, examples upgrades, important bugfixes)

Posted on

camera_2d
  1. The navigation in 2D viewports (with orthographic projection and standard direction/up: -Z/+Y) is now much better. We have a new algorithm TCastleExamineNavigation.ExactMovement that makes the navigation more natural, and we have a dedicated TCastle2DNavigation class (descendant of TCastleExamineNavigation) to make the mouse buttons easiest to discover (just drag with left mouse button). You can assign the TCastle2DNavigation in editor too: just use the “hamburger” menu at the viewport (see the screenshot in this post).

    view3dscene also has now a “2D” navigation button.

  2. We have a new PhysicsRayCast utility, to cast rays using physics engine (Kraft). It is used by examples/platformer/ now.

    Note that it is only a temporary state that we have 2 methods to cast rays: using Kraft (PhysicsRayCast) and not using Kraft (TCastleTransform.RayCast, MyViewport.Items.WorldRayCast — see examples/3d_rendering_processing/collisions demo). In the long run, we want to have a single API to cast rays, and it should always use physics engine, and it should be configurable “what is the current physics engine”.

  3. Subcomponents in the editor (like TCastleTransform.Translation or TCastleScene.RenderOptions) are no longer gray (it was confusing, as one could think “gray means inactive”).

    Thanks go to Andrzej Kilijański for 1-3 above!

  4. A lot of examples have been upgraded to follow latest CGE conventions: DesignUrl, CastleAutoGenerated unit, {$region...} comments and more.

  5. Fixed a fascinating bug with blinking lighting in some cases (see here for details — normal matrix was flipping between 2 different values, due to a determinant of modelview matrix being very very close to zero).

  6. A bug related to using Scene.StopAnimation right after Scene.PlayAnimation was fixed. See details.

  7. Upgraded OpenSSL Windows DLLs to 1.0.2u from 1.0.2n.

Comment on this post ➤

Introducing TUIState.DesignUrl, DesignPreload, DesignedComponent

Posted on

Zrzut ekranu z 2021-05-01 02-52-51

We expose TUIState.DesignUrl (and some friends) as a more comfortable alternative to the TUIState.InsertUserInterface method. InsertUserInterface was a method used by many CGE applications to load a designed UI into a TUIState. Advantages of the new TUIState.DesignUrl approach:

  1. It looks simpler. You do not need to think about UiOwner and FreeAtStop parameters passed to InsertUserInterface. You have TUIState.DesignedComponent to replace previous UiOwner.FindRequiredComponent.

  2. It allows to trivially use new DesignPreload property, a powerful way to load state data in the constructor (instead of at start), which is sometimes desirable — this way state can later start instantly, albeit at the cost of longer application initialization time and larger memory usage (e.g. textures and images used by state are preloaded in memory).

All of CGE examples and templates have been adjusted to use the new approach.

Previous code looked like this:

procedure TStateMenu.Start;
var
  UiOwner: TComponent;
begin
  inherited;

  { Load designed user interface }
  InsertUserInterface('castle-data:/gamestatemenu.castle-user-interface', FreeAtStop, UiOwner);

  { Find components, by name, that we need to access from code }
  MyButton := UiOwner.FindRequiredComponent('MyButton') as TCastleButton;
end;

New code looks like this:

constructor TStateMenu.Create(AOwner: TComponent);
begin
  inherited;
  DesignUrl := 'castle-data:/gamestatemenu.castle-user-interface';
  // DesignPreload := true; // use this to preload design in constructor
end;

procedure TStateMenu.Start;
begin
  inherited;

  { Find components, by name, that we need to access from code }
  MyButton := DesignedComponent('MyButton') as TCastleButton;
end;
Comment on this post ➤