TCastleImageTransform – best way now to place image inside a TCastleViewport

Posted on

TCastleImageTransform

We have a new component TCastleImageTransform, which is now the most advised way to place simple image inside a viewport. This is great for static backgrounds in games, backgrounds that move with player, static pieces of 2D levels etc.

So we now have 2 advised (simple, available in editor, full-featured) ways to handle images:

  1. TCastleImageControl (if you want image be a UI)

  2. TCastleImageTransform (if you want image be inside TCastleViewport, which means it is part of the game world, and it moves along with the rest of the world or with game camera).

New TCastleImageTransform allows to easily e.g.:

  • adjust pivot TCastleImageTransform.Pivot – pivot doesn’t have to be in the center, in can be anywhere, e.g. in any corner of the image, whatever is comfortable in your situation.

  • repeat the image a number of times using TCastleImageTransform.RepeatImage.

  • control the image size by referring to “what size it should pretend to have” instead of only by applying a float scale multiplied by the original size, see TCastleImageTransform.Size.

These features were possible previously too (by using image inside TCastleScene) but now they are more comfortable, exposed as more natural properties.

Comments on the forum ➤

More integration with Vampyre Imaging Library, used by default with both FPC and Delphi

Posted on

Castle Game Engine editor with 3D level
Castle Game Engine Lazarus packages
Castle Game Engine images demo

We’re moving further with Vampyre Imaging Library integration, to have more features related to image loading and at the same time less code to maintain in Castle Game Engine.

  1. We now use Vampyre always, by default, with both FPC and Delphi. This makes our code simpler and more consistent.

    Note: our castle_base.lpk depends on Vampyre Lazarus packages, to use Vampyre packages in a clean (Lazarus) way, using all compilation configuration done by Vampyre authors. This is important if you compile using Lazarus (though project LPI file, that in turn uses LPK packages).

    After updating to latest CGE, be sure to use “Preferences -> FPC and Lazarus -> Register Lazarus Packages” in CGE editor,or just open in Lazarus and compile these 2 packages:

    src/vampyre_imaginglib/src/Packages/VampyreImaginePackage.lpk
    src/vampyre_imaginglib/src/Packages/VampyreImaginePackageExt.lpk
    

    This doesn’t matter if you compile using Delphi, or using CGE build tool that executes FPC directly (passing paths to CGE and Vampyre, without relying on Lazarus LPI/LPK information).

  2. We now rely on Vampyre for loading and saving of BMP, PPM and RGBE image formats.

    I completely removed the old code for handling these image formats (without Vampyre) in CGE. This means less code in CGE which makes me happy 🙂 Moreover, Vampyre brings some extra features: handles RLE-compressed BMP files, can save RGBE files with compression.

  3. We synchronized with latest Vampyre Imaging Library code, and reenabled JP2 and TIFF saving using Vampyre. We check TSingleImage.SaveToStream to know if it’s successful.

  4. For now, you can still disable Vampyre usage, by removing {$define USE_VAMPYRE_IMAGING} from our src/common_includes/castleconf.inc.

    If you have a good reason to do this (disable Vampyre), please tell us (on forum or Discord) — we want to know about it. In the future, Vampyre may be just non-optional dependency of CGE, and we’ll integrate more and just use Vampyre as our image container in memory (right now we copy data between Vampyre and CGE TCastleImage, TGPUCompressedImage, instead of referencing it).

Comments on the forum ➤

Many documentation updates

Posted on

component_gallery example - TCastleLabel
component_gallery example - TCastleUserInterface
component_gallery example - TCastleRectangleControl
component_gallery example - TCastleButton
component_gallery example - TCastleButton

Documentation is the theme of recent news, as I work intensively on updating our manual 🙂

  1. Added section about TCastleBehavior.

  2. Improved X3D example to show building a mesh.

  3. Update to user interface page is in progress, using an updated version of examples/component_gallery. It is not yet finished, but I feel it is already better.

  4. Documentation about AAB (Android App Bundle) added, documentation about Android signing updated.

  5. Logging docs updated.

  6. Some outdated pages have been just removed, as they were outdated and described stuff of low importance (like TCastleOnScreenMenu, that is nowadays easier to do as just TCastleVerticalGroup with a number of buttons). Also the order of pages have been reworked, to put most important things at the top.

Comments on the forum (3) ➤

New TCastleTransformReference class, to efficiently reference another TCastleTransform within the same viewport

Posted on

Multiple cars

I implemented TCastleTransformReference to reference another TCastleTransform within the same viewport. This is an efficient way to use the same TCastleTransform multiple times, which is great for memory and speed. Consider using this when you need a lot of copies of something, e.g. lots of trees or grass patches.

All the TCastleTransformReference instances share the same state with the original, e.g. they will play the same animation. In practice, you will probably most often use this with static (not animated) models.

The detailed usage documentation is already part of the manual, at the bottom of “Tutorial: Designing a 3D world” page.

Note: from code, you can even just place the same TCastleTransform instance multiple times within the same viewport using code, even without TCastleTransformReference. This is documented too.

Comments on the forum ➤

Big improvements to Android documentation and building

Posted on

Black Dragon, one of early Android games done using CGE with Paweł Wojciechowicz from Cat-astrophe Games

If you haven’t yet compiled any application for Android, now is the best time!

  1. First of all, our documentation how to setup Android tools and build your first Android application is now much shorter and easier to follow. It properly documents now:

    • The easiest approach to installing Android SDK. I removed a lot of outdated steps that you don’t have to do.

    • It clearly advises fpcupdeluxe and explains how to use it.

    • It documents using CGE editor to switch platforms, build + install + run on Android.

  2. Android building now works with latest Java 17. No need for downgrading to older Java, because older Gradle wrapper couldn’t handle it.

  3. The default Android target platform is now 31. Previously we targeted platform 29. Due to Google Play requirements we had to upgrade to 30, and we decided to take it one step further to 31. (required by latest androidx.core).

Comments on the forum ➤

Oculus Quest 2: Developer Mode for Castle Game Engine enabled!

Posted on

Our own Oculus Quest 2!

With huge thanks to Rick Lentz, I now have Oculus Quest 2 at my disposal! Which means that we’re absolutely going to port Castle Game Engine, with all games and tools (like view3dscene) to it, as our first VR device.

Don’t ask me yet about the timeline 🙂 I’m after a quick 1 hour fun, and enabling “Developer Mode” and scanning Develop for the Quest Platform documentation just now. For us, the Native Development section is relevant, which means that the device can be like a “very special case of Android” from CGE point of view. Which is of course great for us, it means that all technology is just openly documented and we can utilize our integration with regular Android as a basis.

I know, buying VR device was supposed to be our goal on Patreon when we reach 500 USD / month. Well, Christmas came earlier 🙂 Please support the engine development through Patreon, this is what allows us to spend time on new platforms like this!

Comments on the forum ➤

Big documentation update – new manual, with tutorial, about using viewports and scenes (from editor and from code)

Posted on

Viewport with cars in Castle Game Engine editor

Our documentation about viewports and scenes (one of the most important concepts in Castle Game Engine) got a big update! I wrote new pages documenting how to use the editor to setup 3D and 2D worlds, and how to use Pascal API with latest features and best practices. This is a “must read” for everyone using Castle Game Engine!

Chapters:

  1. It starts with introduction to our concepts – viewport, scenes, transformations, camera, navigation.

  2. Then a large new tutorial-like chapter that walks you through setting up viewport and scenes in the editor to make 3D environment.

  3. New chapter covering 2D information, in particular important features of the orthographic camera.

  4. Camera and Navigation chapters describe controlling the camera (“what do you see”) and navigation (“how to react to user input to change camera”).

  5. Writing code to modify scenes and transformations talks about how to access everything from Pascal code, how to react to user input, how to animate things by code etc. This is partially based on the old documentation, but heavily updated to talk how the code plays together with states, editor and generally how it should be done in latest CGE versions. Almost all text was redone to be simpler and reflecting current best practices.

  6. Finally, a short section about using multiple TCastleViewport instances to share the same world.

Various other documentation updates were done:

  1. Installation and Build your first application have been split into 2 separate chapters, and updated to document that you can use Delphi as an alternative to FPC/Lazarus.

  2. OpenAL chapter was refreshed (lots of old outdated content was just removed).

  3. Order of chapters in the manual has changed, to put the most important things at the top.

Of course there are still unfinished things. This is not the end of documentation work 🙂 In particular:

  1. I’m not yet happy with bottom sections of Writing code to modify scenes and transformations, about

    1. (edit: this was fixed the same day as this news) “Building and editing the scene” (they need a better example, simpler and more useful — how to define a mesh; right now they show instead a quite convoluted code to build 2 boxes, which isn’t impressive at all, you can do it already much simpler using TCastleBox, or just without using any code at all – you can do it in editor, you can do it in Blender)

    2. (edit: this was fixed the same day as this news) “Behaviors” (we need a longer explanation and example there). I have ideas for both of these, and will probably do it this weekend.

  2. User interface chapter needs an upgrade, to describe editor, states and all the latest features. It correct right now, but sometimes describing an old approach to doing things, instead of new advised workflows. (hint: the Designing user interface and handling events (press, update) within the state chapter is up-to-date and good, so follow this first!)

  3. Manual about text should also be updated to show usage of TCastleFont and editor more. Following new features announced here.

And also new functionalities will come soon. When reading 3D tutorial it is obvious we should improve how cameras work, and add lights to the editor. So this chapter will be simpler, when we make some details more intuitive in the editor 🙂 I want to address both things very soon, as I announced in my plan for 2022.

Comments on the forum ➤

Documentation macros (in AsciiDoctor, PHP and WordPress shortcodes) to easily make links to API docs and embed images

Posted on

Upcoming viewport manual

Writing engine documentation is so much easier now! In progress: I’m writing important new manual chapters about using viewport within the editor. It is really easier now with AsciiDoctor + macros I describe below, the improvements to our website infrastructure were absolutely worth it.

Following my plans, I have addressed 2 “pain points” of writing documentation: easily linking to API docs and embedding images. Now in AsciiDoctor you can use macros cgeref, cgeimg to easily add a reference / images. Sample of usage:

References to API docs: 

* cgeref:TCastleScene[]
* cgeref:ApplicationProperties[]

// You don't need to care in which unit they are defined.
// You don't need to care how PasDoc generates link to them
// (using anchors, like for procedures, or special pages, like for classes).
// Uses new PasDoc PHP output.

Some images:

cgeimg::block[aaa.png|Description of AAA]
cgeimg::float[dragon_0_wire.png|Dragon,gamma_nogamma_helmet.png|Gamma Correction]
cgeimg::float[
  dragon_0_wire.png|Dragon,
  gamma_nogamma_helmet.png|Gamma Correction
]

// The thumbnails will be auto-generated. 
// The syntax is short, and just exposes the 2 image layouts we need: 
// on the side, or within the main content flow.

I wrote extensive documentation of them in cge-www README.

Analogous PHP functions cgeref, cgeimg can be used in PHP.

Analogous WordPress shortcodes cgeref, cgeimg can be used for WordPress news posts.

Future:

  • We’ll keep the current separation of WordPress vs AsciiDoctor for some time. This works nicely: Use WordPress for news, use AsciiDoctor for non-news. AsciiDoctor is better for version control and grepping. WordPress is better for auto-sending to other social platforms. Maybe a different resolution of this will come one day, for now the current situation actually addresses all needs (for news and non-news) best.

  • The PHP way of writing docs is obsolete. With time, we will migrate all or almost-all of our documentation to AsciiDoctor (I already wrote some EmacsLisp helpers that I’m using for this). I suspect some exceptions (like main page) may remain custom-coded in PHP, but these will be exceptions.

Comments on the forum ➤

PasDoc new feature: PHP output, useful for Castle Game Engine documentation to improve our API links

Posted on

PHP map generated by PasDoc

Following my recent post, I am working intensively on CGE documentation updates.

PasDoc is a Pascal documentation generator, used by Castle Game Engine and many other projects. As it happens, I (Michalis) am also the developer of PasDoc now 🙂

To make it easier to develop a certain macro on CGE website, I have added a PHP output to PasDoc. This generates a map, in PHP language, that allows to map Pascal identifier name -> HTML page containing documentation for it. It allows our documentation (using a mix of AsciiDoctor, PHP, WordPress now) to be more aware of CGE API, and easily link/search to it. See the documentation of PHP output in PasDoc for examples how you can use this.

Comments on the forum ➤

Summary of 2021, plans for 2022!

Posted on

Castle Game Engine + Delphi: terrain example
The Unholy Society - NPC dialogue
Effekseer particle effect in Castle Game Engine editor
Platformer demo - game

I hope you enjoyed the packed series of Castle Game Engine news last week.

It’s time for the first news in 2022: summary of 2021 and plans for 2022!

Before we start, I want to thank everyone who contributed to the engine in 2021. Together, we work on making a great open-source game engine. I have really big plans for what we can achieve in the future. Thank you for joining me in this!

Most important things we did in 2021

  1. 7.0-alpha.1 release with loads of new features.

  2. Sprite Sheet editor, to easily design and use sprite sheets (see news).

  3. Many improvements to TUIState possibilities, docs, creating new state in editor.

  4. TCastleBehavior, a way to enhance TCastleTransform behavior.

  5. Designing fonts, sounds, other non-visual components in the editor.

  6. Primitives like box, sphere, 3D text in editor for easily designing.

  7. Many platformer demo updates, it is also on itch.io now.

  8. While not yet part of CGE repo, we have 2 approaches for particle effects in CGE being developed.

  9. Inspector available under F8 in any debug game.

  10. Delphi port, merged to CGE master now.

  11. Integration with Vampyre Imaging Library.

Plans for 2022

Definitely:

  1. Editor improvements for 3D and 2D levels design:

    1. Better camera/navigation in the CGE editor. Like in most other 3D applications, the “camera that will be used at start of the game” should be a normal 3D entity in the world, separate from “camera that is used at design-time”. See TCastleCameraTransform in examples/creature_behaviors/code/ for start of it.

      Right now, design-time camera/navigation and runtime camera/navigation are the same, which makes it esp. cumbersome to switch navigation for design-time when you don’t want to change the mode for runtime.

    2. Ability to modify lights in CGE editor. New classes TCastlePointLight, TCastleSpotLight, TCastleDirectionalLight, TCastleEnvironmentLight.

      Right now, you have to set up lights in 3D authoring software (like Blender), and export to glTF. At runtime you can modify lights using X3D nodes for lights.

    3. Ability to modify materials in CGE editor of the TCastleScene. Materials present is scene (with names derived from underlying names in glTF, X3D etc.) should be slots that you can configure in the editor. This should also extend currente material config at primitives, like TCastleBox and TCastleSphere.

      Right now, you have to configure materials in 3D authoring software (like Blender). At runtime you can modify materials using X3D nodes for materials.

    4. Physics components (TRigidBody, TCollider and descendants) expressed as behaviors, and with auto-size by default. You should be able to design and test CGE physics in our editor.

    5. Utilities for typical 3D games (CreatureCreatures / CastleResources / CastleLevels / CastleItems / CastlePlayer) should be replaced with a better API and everything should be easy to make in editor. See planned features.

      New class TCastleMoveAttack and remake examples/fps_game/ demo to be designed 100% in editor.

  2. Official Steam integration in CGE. We already used it for The Unholy Society, we want to either “just publish that approach” or propose a new, improved (without an intermediate “wrapper” library) approach.

  3. Nodes optimization. Our current X3D nodes are unnecessarily heavy on memory. This matters in some cases, if you’d like to compose your game world from lots of scenes. This is already in progress, provoked by issue #285.

  4. Documentation and promotion:

    1. Upgrade of the main page to emphasize our features.

    2. Upgrades of the documentation to describe the editor, as I outlined in previous post.

    3. We need to gain more users of the engine. Esp. now that we have Delphi compatibility, which opens us for more devs.

  5. Engine 7.0-alpha2 release ASAP (in January 2022, after some documentation updates).

  6. Engine 7.0 release in 2022!

  7. WebGL port, using recently announced FPC WebAssembly target!

    Yeah — we already planned WebGL port using pure pas2js. Using FPC+WebAssembly means that it is easier to do and result will be more efficient.

Maybe:

  1. Physics abstraction layer, with alternative physics engine being Bullet.

  2. Rendering abstraction layer, with alternative renderer being Vulkan.

  3. Explore USD – Universal Scene Description support, as a first-class citizen, alongside glTF and X3D.

  4. Terrain designer, see planned features.

Comments on the forum ➤