Crimild v4.7.0 is out!

Crimild v4.7.0 has just been released!!

This new version includes several new features like the new Audio tools or an improved navigation controller, as well as which is probably the most important one: Behavior Trees.

Behavior Trees are an incredible powerful tool for defining dynamic behaviors for intelligent agents in our simulation based on simple actions and decisions. I’ll be talking about this new feature in length in later posts, since I’m really exited with the results so far.

Other improvements and fixes included in this release:

  • New LineSegment class in math library
  • Fixed particle sorting
  • Path finding support for navigation controllers
  • Other fixes

Check out the full release at Github!

All demo projects have been updated to use the latest release. Make sure to check them out!

Finally, this have been an amazing year for me and Crimild. Special thanks for my Number 1 Fan for her incredible support and constant feedback, challenging me to become better and better every day.

And yes, I have a lot of plans in mind for next year. Many new features and improvements… and lots of refactors, as usual 🙂

Happy New Year!




Stay awhile and listen

A couple of days ago, I pushed to Github the first implementation for a new audio subsystem with the intention of providing a set of tools for audio playback, both in 2D and 3D.

Although Crimild does currently provide a simple 3D audio tool, it is far from useful in productive environments, specially because it lacks of any means to play audio streams, as in music.

Decided to work from scratch in the new system, I managed to complete a working version in just a couple of days and it has already proven to be much more useful than the previous one.

Here’s a brief introduction of what I’ve accomplished so far.

Core abstraction

As with many other systems in Crimild, the new new audio subsystem is split into two parts: the core abstraction and a platform dependent implementation.

A handful of new classes have been added to the core library, describing abstract interfaces for audio-related concepts, like audio sources, listeners and the audio manager itself, which also acts as an abstract factory for those objects (something that I’m planning to replicate for images too in the future).

In addition, two new components are now available: one for audio sources and the other for the audio listener (usually attached to a camera). These components will handle audio spatialization if needed (for 3D audio), using the parent node’s transformation.

But how useful is an audio system that doesn’t play audio, right?


As I was looking for a simple, portable, library that will allow me to implement the actual audio layer in a simple way, I came upon SFML. SFML is an abstraction layer for most of the platform specific functionalities, like window handling, networking and, of course, audio.

SFML provides an API to handle both 2D and 3D sounds and streams, so the implementation was pretty straightforward. Much as with other third-party dependencies (like GLFW), this code is organized in a separate package.


The unique instance for the Audio Manager is stored by the Simulation class itself, in a similar way as with the graphics renderer or other manager. The GLSimulation class, the one used in desktop projects, is already creating a valid instance upon construction, which means client projects should be able to use the new audio facilities right out of the box. No additional setup is needed.

Finally, In order to avoid confusion, I removed the old OpenAL implementation completely.


There are two examples that make use of the new audio system.

AudioRoom presents you with three music instruments in the floor. As you approach them, a music clip is played and it is possible to have more than one instrument at the same time if you move the camera quick enough.

Screen Shot 2017-11-05 at 6.43.45 PM

The Drone example has been enhanced with multiple actors. This example uses several audio sources and a listener attached to the camera to showcase how 3D sound spatialization works.

Screen Shot 2017-11-05 at 6.43.33 PM

Both of the examples are already available in the demo project.

Final comments

The new audio system is already available in the development branch, in Github. I’m still working on this code, so expect changes in the near future.

Now, I have to admit that I’m not 100% comfortable with SFML. Don’t get me wrong, the library is great and extremely useful, but it feels a bit overkill in my case. SFML provides so much functionality, not only for audio, yet I’m only using a minimal part of it, mainly because Crimild already depends on GLFW for window and input management. On the other hand, I haven’t check how to use SFML on iOS yet and that might cause some headaches in the future. Also, there’s no support for MP3 at the moment.

But then again, SFML is extremely simple to use and I’m short of time at the moment, so I guess it’s a good compromise. I’m confident that I would be able to easily change the implementation in the future if needed, since the level of abstraction of the core classes is quite good.

Time will tell.


Right Foot, Left Foot (III)

Continuing with my work on navigation meshes, the latest changes made during the past few days bring a lot of new and exiting improvements:

Visualizing the navigation mesh

Having a good look at how the nav mesh is defined is very important in order to understand where its problems are.

Screen Shot 2017-09-17 at 6.59.59 PM.png

As the image above shows, each cell will display its center and normal vectors now (and correctly ordered)

Vertex order

The first change in the list was to enforce the order of the vertices for each cell to make it clockwise. This is a must in when identifying which points are inside or outside of a given cell. Otherwise, normal vectors won’t be pointing in the right direction and results will end up all mixed up.

I also modified the OBJ loader also transform vertices accordingly.

Edge Sliding

Probably the most noticeable change of all, the new implementation is able to handle collisions with walls and borders in a more friendlier fashion than before. Instead of just stopping movement once a character has reach an unshared edge (a wall, for example), the nav mesh will now compute a sliding vector in order to make the movement more fluid.

Screen Shot 2017-09-17 at 6.59.59 PM copy

In the picture above, the player attempts to walk forward (red arrow). Since there’s no valid cell in that direction, the nav mesh will slide the movement slightly to the up and to the right.

Enhanced navigation controller

All the above changes lead to an enhanced NavigationController component. Now, it will keep track of the current cell (so we don’t have to compute that every iteration) and provide new methods for movement, teleport and snap (soon). And it will update the current node’s position automatically, too.

One big commit

All of these changes, plus a couple more, have been pushed to the devel branch in Github. Feel free to take a look here

Bonus track: Math fixes

I took some time to revise and improve some of the math tools related with nav meshes, like planes, distance and intersection methods. It’s funny how there’s still a lot of room for improvement in code that I’ve been using for the past 10 years or more…