Many improvements: behaviors attached to TCastleTransform (a bit like MonoBehaviour), alphaMode and alphaCutoff from X3D 4.0 and glTF, Android services docs, loading/saving from TStream

Posted on

TCastleBillboard behavior
TCastleTransform speed test
  1. We introduce a new class TCastleBehavior which can be attached to any TCastleTransform to perform some job. You can create descendants of it (or use ready descendants of it in CGE) and override methods like Update.

    It’s a nice way to express some ideas. We right now feature TCastleBillboard and TCastleSoundSource build on top of this.

    The first demo is inside examples/creature_behaviors. Also our template “3D FPS Game” already uses it to define TEnemy class.

    If you come from Unity and are interested “what is the equivalent of MonoBehaviour in CGE” then the TCastleBehavior is now the best answer. Documented on CGE for Unity page.

    This is a work in progress!

    • First of all, editor can and will provide support to add and configure behaviors visually. It’s not a big deal, TCastleBehavior is just another TComponent descendant, our architecture of editor/serialization can handle it.

    • TCastleSoundSource can be even better, and it may become the most advised and easy way to setup sounds in CGE.

    • I’m working on TCastleMoveAttack (in CastleBehaviors unit) to provide out-of-the-box creature AI for games. And it will be a basis of new approach for creature AI in CGE, deprecating current CastleCreatures unit.

  2. LoadNode overload that takes a TStream with scene contents, and MimeType as a String.

  3. SaveNode, a better name for Save3D, with simpler API (Save3D has way too many overloads, and is now deprecated). With only 2 overloads, to save to URL or to TStream.

  4. TImageTextureNode utilities to load images from any TStream or TEncodedImage instance, without the need to load from any URL: LoadFromStream, LoadFromImage.

    This simplifies some use-cases of TImageTextureNode, where you don’t have an URL (supported by CGE downloader) but you have a ready TStream or TEncodedImage with image contents. An alternative approach in this case is to use TPixelTextureNode, but this is sometimes cumbersome, as 1. converting at runtime between TImageTextureNode/TPixelTextureNode is bothersome, 2. serializing TPixelTextureNode to file is very verbose (using X3D SFImage text syntax).

  5. I have extended X3D 4.0 to include alpha treatment parameters that correspond to glTF parameters: Appearance.alphaMode and alphaCutoff (in Pascal: TAppearanceNode.AlphaMode and TAppearanceNode.AlphaCutoff). So these are now handled in both X3D 4.0 and glTF in CGE. Testcases: in X3D in my x3d-tests, in glTF in glTF-Sample-Models.

  6. New examples/3d_rendering_processing/transform_speed_test/ – speed test of many TCastleTransform instances.

  7. Documentation how to implement new Android services.

    The above page is directed at Android services. For iOS, there is a shorter section here. But a lot of concepts are (deliberately) very similar between Android and iOS services.

Start the discussion at Castle Game Engine Forum