So, you’ve made the decision to dive into the world of 3D game development using the GFX framework? That’s fantastic! In the upcoming tutorials, I’ll walk you through the process of creating your very own game with GFX. Let’s start by taking a look at our basic project. You can get started by downloading the 3D Game Template.

Within this project template, you’ll find the foundation for a basic VS project, complete with a form and a game class. Additionally, all the necessary references should already be set up for you. However, if they’re not, you’ll need to ensure that you’ve referenced the genesis.dll and imported the Bulletsharp NuGet package into your project.

Once you’ve created a new project from the template, remember to set the build to Debug x64 or Release x64. When you run the game, you’ll see an empty form with a black render content.

The Game Class

Take a look at the game class; it’s already set up for your game. The first parameter allows you to create a renderer for your game, while the second parameter defines the viewport. This class essentially manages your game, enabling you to assign scenes and hook into various functions.

C#
// Inital the game class
m_game = new Game(new GLRenderer(this.Handle), new Genesis.Graphics.Viewport(this.ClientSize.Width, this.ClientSize.Height));

The Scene3D Class

The Scene3D class is a special scene class with additional properties compared to the normal scene class. It includes features like the Sun for lighting, the Skybox for the sky, and the camera. To utilize this scene, you’ll need to create a PerspectiveCamera, which enables the display of elements in 3D. Like the normal scene, you can add layers with game elements and hook into various functions.

C#
// Create an camera & a sun
var camera = new PerspectiveCamera(new Vec3(0.0f, 0.0f, 0.0f), new Vec3(this.ClientSize.Width, this.ClientSize.Height), 0.1f, 100f);
var sun = new Light("Sun", new Vec3(0f, 50f, 0f));
sun.Intensity = 0.2f;

// Create an scene
var scene = new Scene3D("MyScene", sun);
scene.Camera = camera;
scene.AddLayer(new Layer("BaseLayer"));
m_game.AddScene(scene);

The Layer Class

Think of the Layer class as a simple container for your game elements. You can add any kind of GameElement to it, and it’s also possible to enable or disable an entire layer.

The GameElement

The GameElement serves as the fundamental element or entity for your game. It could be a Model, an Element3D, or any other class that inherits from the abstract GameElement class. Within this class, you can add behaviors to the GameElement. Using GameBehaviors, you can establish the logic for your game. While there are some pre-made behaviors available, such as collider and character controllers, you’re encouraged to create your own custom behaviors.

C#
// Create an example game element
Qube qube = new Qube("Qube_1", new Vec3(0f, 0f, -5f));
qube.Rotation = new Vec3(-45f, 0f, 45f);
qube.Color = Color.White;
scene.AddGameElement("BaseLayer", qube);

Conclusion

If you take a peek into our template, you’ll notice that a scene is already created and assigned to the game class. The game class loads this scene and kicks off the game. Additionally, there’s already a “BaseLayer” created, which contains a cube game element. In the upcoming guides, we’ll breathe life into this element and add even more excitement to your game. Stay tuned!