Build a Simple OpenVR application

OpenVR is an API and runtime that allows access to VR hardware from multiple vendors without requiring applications to have specific knowledge of the hardware they are targeting. This repository is an SDK that contains the API and samples. The runtime is under SteamVR in Tools on Steam.

This article describes the necessary steps you should follow to build, load, and run a simple WaveEngine application on the OpenVR platform.

Continue reading Build a Simple OpenVR application

New async/await features

We have improved the async/await support in WaveEngine 2.4.0 by replacing our Dispatcher and TaskScheduler services with a custom implementation of .Net TaskScheduler and creating some useful helpers.

Porting project

The biggest change is the substitution of Dispatcher and TaskScheduler services. The new way to execute code in the foreground or background threads is by using the new helper methods from WaveForegroundTask and WaveBackgroundTask static classes.

To port current projects using the new classes, we need to change the following:

  • If you are using WaveServices.Dispatcher, you must replace it to use WaveForegroundTask.

  • If you are using WaveServices.TaskScheduler, you must replace it to use WaveBackgroundTask.

Both new ways to execute code return a .Net Task, which integrates easily with async .Net code.

Foreground and Background threads

Before we start to review the new included features, it is good to know these details:

  • When a task is executed in the Foreground thread, like with the Dispatcher service, it is executed in the next update cycle.
  • With the Background thread, the tasks are executed sequentially in a specific thread that can access the graphic resources. This allows us, for example, to load textures. The old TaskScheduler executes the code in a .Net thread and without taking concurrency issues into account when accessing the graphic context. In comparison, this new service ensures that each task is executed in the same thread and sequentially.

ConfigureWaveAwait

One useful helper introduced in the new WaveEngine version is the ConfigureWaveAwait extension method.
It allows us to configure how the await continuation is handled. Just as the .Net ConfigureAwait extension method allows us to configure if we want that the continuation of the await is executed on the captured context, the method ConfigureWaveAwait allows us to configure where the await continuation is executed: in the Foreground or the Background thread.

A simple way to test this new method is to load an image from a URL into a sprite:

The WaveTaskContinueOn enum also includes other options. The Default option acts as if the ConfigureWaveAwait has not been used, and the ThreadPool option acts as if the ConfigureAwait(false) from .Net has been used.

Async/await and GameActions

With the inclusion of GameActions, WaveEngine has acquired an excellent way to define a flow of actions that is integrated perfectly with the common scenarios in a game (like animations, play sounds, wait for a condition, etc.).

In this release, we have included the AsTask extension method that simplifies the way that .Net Tasks and GameAction interact with each other.

A simple sample using all of these new features:

I hope you find it useful when you want to use async code in your game. It is the first step and we will work to include new async APIs and features in next releases.

NinePatch native support

WaveEngine 2.4.0 includes official native support for NinePatch textures (also known as 9-slice). To know more about what that kind of textures is, read our previous post about it.

As this version allows you to add textures and mark them as “NinePatchType: FromTexture”. This option will be automatically selected if your texture has the extension “*.9.png”.

When this mode is selected, the exporter will extract the stretch and content regions from the texture and remove them from the final asset. Keep it in mind if you need power of two textures (e.g., if your final texture must be 256×256, the source image size must be 258×258)

Continue reading NinePatch native support

New OpenGL adapter on Windows

In WaveEngine 2.3.1 we have added a new adapter on Windows for OpenGL, this allows WaveEngine developers to run their games using DirectX and OpenGL on Windows. This will be really handy to adapt their assets (like shaders or textures) faster to our OpenGL platforms (Linux, MacOS, iOS and Android).

Continue reading New OpenGL adapter on Windows

New serializer using Protobuf-NET

In Wave Engine 2.3.1 we have started to use Protobuf-NET as the default serializer in all game description files (scenes, prefabs, materials, etc…).

Protobuf-NET is a contract based serializer for .NET code, that happens to write data in the “protocol buffers” serialization format engineered by Google.

The inclusion of Protobuf-NET gives us the following advantages:

  • Performance Boost: Reduce app startup time and other serialization related actions up to 5X  (scene navigations, prefab instantiations …)
  • Reduce app package size
  • Binary files: Avoid to deploy plain xml files in app packages
  • Support DataContract attributes: You don’t need to change your components code

Continue reading New serializer using Protobuf-NET

What’s new in Wave Engine 2.3.1

Wave Engine 2.3.1 has been released today.  This version adds some important features that we think our community will enjoy, like binary scene serialization and OpenGL support in Windows. Let’s have a look in detail.

Bokeh lens sample

Continue reading What’s new in Wave Engine 2.3.1

Appear and disappear effect in WaveEngine

In this article, I’m going to show how to create a cool effect to make the NPCs in your game appear or disappear. One of the issues that you need to resolve when you kill an enemy in your game is how to hide it from your scene. Unless, of course, you want to pile up enemy bodies.

We are going to create a custom shader in WaveEngine for our aim. If you do not already know it, we recommend reading this article before you start.

Follow the steps to create the project effect.

Continue reading Appear and disappear effect in WaveEngine

Facing navigation flow with Wave Engine

The navigation flow in games is a very important part that can be difficult to deal with. In this article we will introduce a possible strategy to solve this.

Wave Engine provides generic services and tools to manage scene transitions and basic navigation. However, distributing the navigation logic between different scenes and behaviors can be tricky at times and difficult to scale.

To solve this, an interesting approach is to use a service that contains all the navigation logic, managing transitions and deferred loading between scenes. Later, a simple and generic component can be used to link navigation events to buttons in the scene and hardware buttons. Continue reading Facing navigation flow with Wave Engine

How components resolve their dependencies

In this article we will learn how components resolve their dependencies with other components and how the custom attribute [RequiredComponent] works.

Entity and Components

As you know, an Entity represents a logic element of our game and it is an empty box where you can put component insides which define what the entity can do.

The logic hierarchy is handle by the EntityManager which stores the struct of all the entities in our scene. For example:

Continue reading How components resolve their dependencies