March 01, 2023

Physics Support in Web

Evergine is a cross-platform graphics engine that was developed using .NET technologies. To bring the engine to the web platform, our team has been taking advantage of the latest technologies, such as .NET 6 and Blazor, which allows us to compile the engine to WebAssembly (WASM) to run natively in the browser.

To render with WebGL in Evergine, Emscripten and its EGL emulation are powerful tools that make the process smoother. This means that you can use the same code that we are using in your existing OpenGL integration, which makes less code to maintain.

Now, let us dive into physics. Evergine uses Bullet Physics as its main physics engine. Bullet Physics is an excellent open-source library maintained by Erwin Coumans that is widely used in the graphic industry.

 

To use Bullet in Evergine, you need to consume the C++ library into our C# Engine. This is where BulletSharpPInvoke comes in. It provides a C# wrapper that makes native calls to the Bullet library using PInvokes. This wrapper is essential because it allows you to use the same codebase on every platform supported by Evergine (Windows, Android, Web…).

Finally, you need to build Bullet libraries for each platform you want to support. In the case of the web platform, we have adapted the provided CMake scripts to use the Emscripten toolchain to produce the final Bullet WASM libraries. As a result, is it possible to use the same physics library on every platform supported by Evergine, including the web platform now.

In conclusion, by using Bullet Physics and adapting it to work with Evergine on the web platform, you can provide your users with more interactive web applications. This is especially exciting now that Evergine supports WebXR, which allows for more immersive web experiences. Overall, this is an impressive technical feat that will benefit developers who use Evergine for their projects.

David avila
Author
David Ávila
Plain Concepts Research

Wait! Don't leave yet.

Sign up for our monthly newsletter to be updated on all the latest news, case studies, and more.

We don't send spam and you can unsubscribe at any time.