Sound player/scrubber using Castle Game Engine

Posted on

Castle Game Engine sound/music player

I made a simple sound/music player using the Castle Game Engine 🙂 It is available in the engine sources in examples/audio/audio_player_scrubber .

It has all the features you would expect:

  • Volume,
  • Loop,
  • Sound offset (position in time) control,
  • Programmer-designed user-interface (ah, this brings back good memories:).
  • It can open wav and ogg files, and plays them using OpenAL.

It was coded to show that TSound.Offset works cool. It’s a new property added today (for Eugene Loza, see here), allows to get/set the sound offset (aka “position in time”).

You can view the code on GitHub.

Comment on this post ➤

Design-time editing of 3D world (initial fun), many other improvements

Posted on

Editing SceneManager.Items at design-time
Editing SceneManager.Items at design-time
TCastleEdit control demo

First of all, I hope to finish and release Castle Game Engine 6.2.0 this weekend! So, watch this page closely.

The next release 6.4.0 will focus on Delphi compatibility, and start of visual editing (of 3D world and 2D controls) within Lazarus and Delphi. In all the pre-release excitement, I started playing around with it already today 🙂 I added a property RenderAtDesignTime to the Lazarus OpenGL control (patch here), and I made a simple design-time menu to add a sphere to the SceneManager at Lazarus design-time. See the screenshots!

In other news, there is a bunch of engine features done recently, not announced properly yet. Here they are (officially coming in 6.2.0 release this weekend):

  1. Rendering of normalmaps (through CommonSurfaceShader.normalTexture or Appearance.normalMap) was improved to work even when no diffuse texture is defined.
  2. TCastleEdit: a simple edit box. Demo in examples/2d_standard_ui/edit_box/game.pas . Not perfect, but already useful anyway 🙂
  3. New build tool command “generate-program”, to generate perfect starter program code and Lazarus lpi.
  4. Added easy Application.ParseStandardParameters method to the TCastleApplication in CastleWindow, may be useful for your standalone games.
  5. image_convert (in examples/images_videos/) has an additional command-line option –alpha-bleed, to perform “alpha bleeding” in batch mode.
  6. Added TDebug3DCustomTransform – a simple reusable utility to debug bounding boxes and spheres of T3DCustomTransform (like T3DTransform or T3DOrient). A generalized version of what you get for creatures (the ones from CastleCreatures unit) when you use RenderDebug3D.
  7. x3d-nodes-to-pascal is our new tool to parse X3D nodes and produce skeleton code to glue X3D with Object Pascal.
Comment on this post ➤

Updates to the “Modern Object Pascal Introduction for Programmers”

Posted on

I wrote a few new chapters to the “Modern Object Pascal Introduction for Programmers” book:

It is also available now under a shorter URL, on a new domain for our Castle Game Engine. The book is not tied to the Castle Game Engine (I want it to be something useful on it’s own). Although it is also part of my plan for “how Castle Game Engine can succeed”, as it helps programmers interested in Castle Game Engine to use the Object Pascal language 🙂 If you like it, please consider supporting me on Patreon !

Comment on this post ➤

In Space Everyone is Screaming (gamejam game:)

Posted on

in-space-everyone-is-screaming_screen_1
in-space-everyone-is-screaming_screen_3
in-space-everyone-is-screaming_screen_4
in-space-everyone-is-screaming_screen_5
in-space-everyone-is-screaming_screen_10

Simple platformer-shooter done during 12-hour gamejam using Castle Game Engine! Binaries on https://gitlab.com/michaliskambi/in-space-everyone-is-screaming/tags/v1.0 , source code on https://gitlab.com/michaliskambi/in-space-everyone-is-screaming . This is really just a technical beginning, without any playable level design, or fancy enemies swarms, or graphics.. But it’s a working start, with jumping and shooting and enemies, ready to be extended! 🙂

Comment on this post ➤

Build tool, iOS, Android great improvements!

Posted on

DSC_0248
DSC_0235
DSC_0236
DSC_0237
DSC_0238
DSC_0245
DSC_0246
DSC_0247

First of all, I’m proudly attaching a few images of various games using Castle Game Engine running on a real iPhone:)

Our build tool got some significant improvements lately. I hinted about some of them in the recent “Easy compilation for iOS” announcement, but actually there’s more, and some of them benefit all platforms 🙂 Here are the details:

  1. Using the "castle-engine-output" directory for compilation temporary files (.ppu, .o), and for Android and iOS projects. The advantages:

    • The compilation files are kept per OS/CPU, so they can be reused more (no need to recompile everything just because you switch platforms).
    • The Android project is in a predictable location (not in some /tmp/castle-engine-), which is useful to run ‘ndk-gdb’.
    • The iOS project is in a predictable location, which is useful to run XCode.
  2. Project files (lpr) for Android, iOS (and soon — for others too) can be auto-created. So you really don’t have to write anything to recompile your project for a new platform. You only need to provide game_units in CastleEngineManifest.xml, and make sure your units initialize Application.MainWindow . Make sure you define game_units in CastleEngineManifest.xml.

  3. Android packaging process fixes and updates.

    • CGE code fix for using (exact) FPC 3.0.2 to cross-compile to Android.
    • The build tool no longer requires so many things (from Android SDK and NDK) on $PATH. It can guess everything’s location now from ANDROID_HOME (your SDK location).
    • Much improved wiki page about installing Android dependencies. In particular, it contains now screenshots how to use the “SDK Manager”, that is integrated in “Android Studio” and replaces the old “android” GUI tool from previous SDK versions.
  4. iOS-specific improvements:

    • The iOS wiki page was much improved and updated, to describe the process of compiling to iOS.
    • The src/library/compile-iOS.sh script was reworked and updated. Many changes, but in principle it should generate exactly the same thing:)
    • The "castle-engine compile --target=ios" is available, and generates a ready libxxx.a to be inserted into an XCode project.
    • CastleWindow “library” interface (used for iOS in a library) simplified.
    • Package any game for iOS! Just run "castle-engine package --target=ios" and you get an XCode project, that compiles out-of-the-box in XCode, and can be tested and published from XCode. You can add --mode=debug if you like.
Comment on this post ➤

Easy compilation of your games for iOS

Posted on

screenshot
screenshot2
screenshot3
screenshot4
screenshot5
screenshot6
screenshot7

Trivially easy compilation of your games to iOS!!!

You can now take any Castle Game Engine game, and recompile it for iOS (iPhone, iPad) easily. No need to write *any* iOS-specific code. Short instructions:

  1. Follow iOS documentation to get FPC, with a cross-compiler, for iOS targets.
  2. Inside CastleEngineManifest.xml, define game_units="...", listing the necessary game units to be included in your lpr. It’s often just a single unit, that pulls other units along as dependencies.
  3. Run "castle-engine package --target=ios --verbose" in console.
  4. Open the resulting project in XCode. From XCode you can build it, run it in a simulator, publish… I emphasize that the project builds out-of-the-box on Xcode, zero modifications on your side are necessary. Just open the project, and press “Run” button in XCode.

I will be posting more details (and polishing some rough edges) soon 🙂 Learn more about the build tool (“castle-engine”) and CastleEngineManifest.xml at these wiki pages. I just updated them with information about --target=ios and game_units.

Many thanks go to Szymon Stoma and Ten Square Games for making Apple hardware available to me, making it all possible!

And a great many thanks to Jan Adamec, who made the initial iOS work in our engine! Everything I did was just rehashing of that work, to integrate it with the build tool.

Comment on this post (8 comments now) ➤

Support for specular maps (and more) in view3dscene, Blender exporter to CommonSurfaceShader

Posted on

1_blender_monkey_0
2_more_textures_with_specular_maps_0
3_rust_metal_shininess_texture_0
4_synthetic_metal_textures_specular_map_0
  1. I was working intensively on support of CommonSurfaceShader (aka “material on steroids”) in view3dscene and Castle Game Engine, and the following features have been added:

    • specular maps (vary specular color throughout the surface, e.g. making it selectively shiny or “rough”)
    • shininess maps
    • ambient maps
    • configuring displacementFactor for parallax bump mapping
    • support for reflectionFactor and transmissionFactor in ray-tracer

    This is all added to the previous features: support of basic factors (similar to the standard Material features) and normal maps (bump mapping). Bump mapping was also improved a bit.

    The demos are inside bump_mapping/common_surface_shader subdir (you can download complete demo models contents from GitHub). You can open them using the latest view3dscene from snapshots. Or you can just compile the engine from GitHub

    The updated CommonSurfaceShader information is here. The fields marked in bold there are supported in view3dscene / Castle Game Engine. There’s also a lot of text that may help you understand how CommonSurfaceShader works:)

  2. In a (related) news, I have improved our custom Blender exporter to X3D. It now exports the CommonSurfaceShader, including various texture configurations like normal maps, specular maps and so on.

    This means that an artist can configure all the goodies mentioned above from Blender! Just export with “Use CommonSurfaceShader” checkbox, and the resulting file will include CommonSurfaceShader with all the parameters and texture configuration.

    The details are here.

    My notes about exporting X3D to Blender (part of the Castle Game Engine documentation) include a detailed description how to use this feature. See the “Extra material textures (normal maps, specular maps) with CommonSurfaceShader” section here.

    The modifications to the Blender exported are not yet submitted to the Blender developers, but they *will* be:) I want this to be present in Blender out-of-the-box.

    At the end, I wanted to emphasize that this work was sponsored by Castle Game Engine patrons on Patreon. If you like what I’m doing, please consider supporting me, through the page https://www.patreon.com/castleengine . This really helps me spend more time on the engine and view3dscene, and you can also request a particular feature. This month, Robert Daniel Murphy requested “easy export from Blender of normal maps and specular maps”, and look what cool things happened! 🙂

Comment on this post (1 comment now) ➤

Ray-tracer improvements (aka “Did you know our engine has ray-tracer?”)

Posted on

ray_tracer_textures
ray_tracer_smooth_1
ray_tracer_smooth_normals

I was playing with the ray-tracer inside Castle Game Engine this weekend. Although the focus of our engine is real-time rendering (not a software ray-tracer), but there is a distinct pleasure when you’re able to generate pretty images without the help of OpenGL:)

New ray-tracer features:

  • It can now use smooth normal vectors.
  • Classic ray-tracer supports now 2D textures, with bilinear or nearest filtering.
  • It looks at Background.skyColor.

You can try it out e.g. using view3dscene Ctrl + R (“Display -> RayTrace!” menu item). From code, you can use the CastleRayTracer unit.

The ray-tracer in CGE is still just a toy subproject for me. Our ray-tracer does not try to compete with professional, full-featured ray-tracing renderers existing today. But it is a nice demo that, using Castle Game Engine API, you can take a scene and create a decent ray-tracer, because

  1. All the necessary information about the 3D scene is available,
  2. You have a fast structure (octree) to perform ray collisions.

I hope that you enjoy it!:) If anyone here is interested in putting more work into this way of rendering (we have classic ray-tracer and a path-tracer), if you dream about creating a real, full-featured physically-based solution, than please join the development of CGE! I would happily see someone extend the CGE ray-tracer to render some really cool stuff! 🙂

An old gallery of images is here.

Comment on this post ➤

CommonSurfaceShader in view3dscene and Castle Game Engine implemented:)

Posted on

CommonSurfaceShader with bump mapping
CommonSurfaceShader with steep parallax bump mapping and self-shadowing
CommonSurfaceShader defining a mirror for ray-tracer

I’m proud to announce an initial implementation of CommonSurfaceShader in Castle Game Engine and view3dscene! CommonSurfaceShader acts as a powerful “material on steroids” X3D node, in particular with support for normal maps (bump mapping).

1. The documentation

2. The demos

3. To try this *now*, you can use view3dscene from our “nightly builds”. Or you can compile any of the engine tools (like examples/3d_rendering_processing/view_3d_model_basic ) using the engine code from GitHub.

This is happening thanks to the support on Patreon (https://www.patreon.com/castleengine). Robert Daniel Murphy sponsored improving the Blender exporter to be able to export normalmaps (and specular maps and similar) from Blender to Castle Game Engine easily. I took the idea a little further, and implemented it by adding the CommonSurfaceShader node to the engine, and then the Blender exporter will export an X3D file with the CommonSurfaceShader.

This way the Blender exporter will be improved for everyone, e.g. Instant Reality / X3DOM users will also benefit by having an exporter that can write CommonSurfaceShader.

More work is yet ahead (the Blender exporter, and the specular maps are not done yet). But the CommonSurfaceShader, with many basic fields, and normal maps, is supported now!

The CommonSurfaceShader works both for interactive rendering, and for our toy raytracer. It is also understood when editing materials in view3dscene (Edit->Edit Material->… menu items).

P.S. If you like view3dscene, or you’d like to request more view3dscene features like that, please support me on Patreon !:)

Comment on this post ➤