Presentation of Xenity Engine
Xenity Engine is a crossplatform game engine based on GameObjects and Components for PlayStation Portable, PsVita, PS3 and Windows. Made in C++ 17.
Xenity engine uses Visual Studio Code to edit your scripts.
It's pink but you can change the color!
Supported platforms:
✔️ Supported
🚧 Work In Progress
Status | Platform |
---|---|
✔️ | Windows |
✔️ | PlayStation Portable |
✔️ | PlayStation Vita |
✔️ | PlayStation 3 |
🚧 | Linux (The UI is a bit glitchy, missing audio and build system) |
Features:
- Basic 2D Rendering (Not great for 2D games)
- 3D Rendering
- 2D Audio
- 3D Audio
- Skyboxes
- Scenes
- Animations
- 3D Physics
- 2D Physics
- C++ Hot Reloading
- C++ Plugins (Started but not finished)
warning
The engine is not perfect. So you may encounter problems during game development like:
- Deleting Meta files will have repercussions on your project. Variables that reference the files will be emptied.
- Duplicating a meta file will cause problems, each meta file has a unique file id in it.
- Audio works "fine" with 44100Hz but on PS3 you need to use 48000Hz audio.
Please make frequent backups of your project, you are not safe from a project corruption!
You can see all limitations here.
If you want to improve the engine, here is the TODO list.
Contact:
Discord: fewnity
Email: fewnity@gmail.com
LinkedIn: https://www.linkedin.com/in/gregory-machefer-grimaud/
Limitations
Here is a list of every limitations of the game engine. These can be limitations for the user or for the game engine developpers.
For users
Editor UI
Multi selection is not supported.
In game UI
There is no gamepad support for UI menus.
Lighting
Lighting does not work great on PsVita and PS3. A shader variant system could fix this.
- Performances are not great,
- Lights on PS3 are limited by 1 on each type.
Objects with a big scale will cause lags if they are moving (Problem caused the light world partitionner).
Audio
Audio works "fine" with 44100Hz but on PS3 you need to use 48000Hz audio or the audio will sound weird.
Rendering
The engine is mono thread, so performances are not great with lot of objects.
There is not split screen support.
2D
2D performances are not great.
Networking
Network sockets get data only every frame. (Limitation easy to fix).
There is no way to know if a socket has been closed or not.
Reflection
The reflection does not support many types.
Physics
There is no layer system. So no system to disable collisions between some colliders.
There is no 2D physics system.
For Xenity maintainers
Rendering
The graphics API interface is OpenGL like, so it's harder to add an new API that is different from OpenGL.
On PSP there is a graphical bug and I'm not able to fix it, looks like it visible when disabling vsync but not sure.
Reflection
The reflection is a little bit hard to maintain.
Other
The overuse of "friend class" is a problem in the engine in general. It's used to hide internal functions to the user.
Installation
To be able to code and compile your game on Windows and to play in the editor,
You have to:
- Install Visual Studio 2022,
- Install Visual Studio Code,
- Set
Compiler path
in theEngine Settings
menu (Window -> Engine Settings
) if your Visual Studio installation/version is different.
To be able to compile your game on game consoles (PlayStation Portable, PlayStation Vita, PlayStation 3), follow this part: Game console support
Game console support
Docker Desktop is needed to compile PSP, PS3 and PsVita games.
The main reason is most SDKs are only working on Linux. Docker is a simple way to install Linux and every SDK and needed tools to compile your game even if your system is running Windows.
Virtualization shoud be enabled in the bios. Click here to see how to check if virtualization is enabled on my system.
The SDKs alone take around 8GB, and Docker will also install a Linux image (this won't affect your Windows system). Please make sure you have at least 20-30GB of free disk space available.
If you are already using Docker, Xenity Engine won't affect your existing images/containers.
Docker Setup
To be able to compile on game consoles you have to:
- Download and install Docker Desktop,
If docker ask you between Hyper-V and WSL, choose WSL. - If you have never used WSL or if Docker asks you do to this, open a CMD and run the
wsl --update
command. Docker requires a minimum version of WSL. - Finish the docker install in Xenity. For this, go to the Docker Configuration menu (
Window -> Docker Configuration
), and follow the instructions.
The process can take several minutes especially if you have a slow computer or a slow internet connection. (The editor will freeze, do not close it).
If anything goes wrong during the installation, check in Docker Desktop if an Image called xenity_x_x_x
(x_x_x
is a version).
If there is an image, delete it and retry the installation from the editor.
Build and run
A build and run option is supported for the PSP to launch the game on an emulator after the build.
You have to:
- Install the PPSSPP Emulator.
- Set
PPSSPP location
in theEngine Settings
menu if your installation location is different.
Game project samples
3 samples of smalls games made with Xenity Engine are available to download on GitHub.
Looking at the code is a great way to understand how the engine works.
They all work on game consoles too.
- Dungeon platformer, it's a platformer in a dungeon. Use of physics, lighting, UI and audio.
- Nano Machines, it's a tiny car controller. Use of physics and particles.
- Cooking game, it's an Overcooked like. Use of physics, audio and particles.
Manual
Here is a manual to learn more about the engine and how to use it.
To learn more about menus and their uses, see Editor UI.
To learn how to use the engine, see Usage.
To check which asset formats to use, see Compatible asset formats.
The editor UI
Here is a presentation of every menu of the editor.
Click on link to get more details.
The project manager window displays all the projects made with Xenity Engine.
The hierarchy window displays all GameObjects of the scene.
The inspector window displays all Components a the selected GameObject.
The file explorer window displays all files of your project.
The game Tab window displays the view of the game's camera.
The scene Tab window displays the view to edit your scene.
The console window displays the logs of the editor and of your game.
The profiler window displays infos about performances.
The project settings window displays the settings of your project.
The engine settings window displays the settings of the Xenity Engine.
The lighting settings window displays the scene's lighting settings.
The docker configuration window displays steps to finish the Docker installation.
The build settings window allow to build your game on various platforms.
The dev kit control window allow to control a development kit.
Project Manager
The project manager window shows the list of projects made with Xenity.
You can create new project, delete them or simply open them.
The hierarchy
The hierarchy window show all GameObjects if your scene.
Interactions:
- You can click on a GameObject to select it and use it in the inspector or in the scene tab.
- You can right click on a GameObject to manage it (delete, create a new GameObject...).
The inspector
The inspector window lists all components of a GameObject.
You have the name of the GameObject and a check box to enable or disable it.
Then the transform of the GameObject that contains the information about the position, rotation and scale.
And finally you have the list of components, you can add new, edit or delete them.
Most components have a check box to enable or disable them.
The file explorer
Ther file explorer Window show all the files of your opened project.
Manage files
- You can double click on folders to open them or use the folder list on the left.
- To move a files you can drag it into a folder.
- To manage a file, you can right click on it and you will see a list of command (delete, rename...).
- You can right click the background of the file explorer and you will see a list of commands (Create files and component class, open folder in explorer...).
Game tab
This window show the view of the game camera. This is the same view in builds.
You can interract with it only in Play mode.
The numbers in the tab name are the view's resolution (width x height).
Scene tab
This window show the view of the editor camera.
Controls
You can move the camera using the arrow keys of the keyboard.
You can move the camera by moving the mouse while holding the mouse wheel button.
You can zoom/unzoom using the mouse wheel button.
You can select objects by left clicking them with the mouse cursor.
The numbers in the tab name are the view's resolution (width x height).
Tools
At the left you have a list of tool modes:
- 1: Move the camera with the mouse.
- 2: Show arrows on the selected object to move it.
- 2: Show circles on the selected object to rotate it.
- 3: Show arrows on the selected object to scale it.
- 4: Toggle the grid.
- 2D: Set the view in 2D mode.
- World: Toggle if the arrows are affected by the rotation of the object.
The console
The console window displays messages, warnings, and errors from both the game and the editor.
It helps you debug your game and understand any issues that occur within the editor.
There are 3 types of messages:
- Log: Informational messages that are not critical. These messages are mostly used for general feedback, such as successful loading of assets or routine operations.
- Warning: Indicates a potential issue that does not stop the game or editor from running, but might lead to problems if ignored. Warnings should be reviewed and addressed when possible.
- Error: Critical issues that usually prevent something from working correctly. Errors often stop certain systems from functioning and should be fixed immediately to ensure the game or editor runs properly.
Here is the list of buttons:
- Console mode/List mode: Console mode will show all messages without colors and ordered from the oldest to the newest message.
List mode enable color and collaps identical messages. - Clear: Remove all messages from the console.
- Clear on play: Remove all messages from the console when launching the game.
- Show Logs: On/Off button to list or not logs in List mode.
- Show Warnings: On/Off button to list or not warnings in List mode.
- Show Errors: On/Off button to list or not errors in List mode.
The profiler
The profiler window provides you information about the performances of your game and of the engine.
In the first part of the profiler, you can see basic information:
- FPS graph: The graph shows the number of frame per seconds. stable graph and high numbers are better.
- FPS average: The average number of frame per seconds. Higher is better.
- DrawCalls Count: When a submesh is rendered, it adds one to this counter. Lower is better, especially on older game consoles.
- Triangles Count: The number of rendered triangles. Lower is better.
- Materials update count: This counts how many times a material has been updated, specifically when its uniforms are modified before rendering. Lower is better.
In the second part of the profiler, show the memory consumption of the engine.
- Used memory: It's the RAM usage (Components, audio clips...).
- Used video memory: It's the RAM usage of the graphics card (FrameBuffers, Textures, Meshes...).
There are some categories (GameObject, Mesh Data and Textures).
- Current allocation is the amount of memory used at this moment.
- Total is the amount of memory allocated since the beginning.
- Alloc count is the number of created objects since the beginning.
- Delete count is the number of deleted objects since the beginning.
Mesh Data and textures are the most important, for example the PSP only have 2MB of video memory. If the PSP is running out of VRAM, the RAM is used instead of textures and mesh data, but it's slower.
In the third part of the profiler, you can see a list of frame. Each frame is recorded (in a limit of 400 frames).
You can select the frame by clicking on the element in the list.
You will see the profiling data in two forms:
- A simple list of C++ functions with the total CPU time used by them.
- A graph that draw each call.
You can pause the profiler with the button to read the value and you can load a profiler record file if you want to profile a build outside the editor.
Project settings
The project settings window show all settings related to the project.
Each projet has it's own settings.
Values:
- Project Name: The name of the project, used by the project manager.
- Game Name: The name of the game, used in builds.
- Company Name: The name of your company. Can be your user name if you don't have one.
- Start Scene: The scene to load when the project is loaded. Used in builds. Should not be empty!
Engine settings
This windows show all settings related to the editor.
The settings are shared between all projects.
Here is the list of settings:
UI color
- Background color: Change the color of the editor background.
- Secondary color: Change the color of borders, buttons...
- Play tint color: Change the color of the background in play mode.
- Is Play Tint Additive: If enabled, the color is added to the background color, if disabled the color is multiplied to the background color.
Compiler options:
- Compiler location: Set the location of MSVC compiler.
- PPSSPP location: Set the location of PPSSPP emulator (Used for build and run).
- Docker location: Set the location of Docker Desktop (Used for game consoles builds).
For PS3 dev kits owner:
- ps3ctrl location: Set the location of ps3ctrl (Software from Sony).
Lighting settings
The lighting settings window show all lighting settings related to the scene.
Options:
- Skybox: Set a skybox for the scene.
- Sky Color: Set the color if the sky if no skybox is set.
Docker configuration
The Docker configuration window shows you the current state of Docker and steps to finish the installation of Docker if Docker is not fully installed.
The Check Docker state button re-check if there is any change about the Docker installation. Here is the list of different states:
- Docker not installed: Docker is not detected on your system. See Game console support to install Docker.
- Docker not running: Docker is found on your system but the software is not running. When building a game Docker is automatically started. You can launch yourself Docker too.
- Missing Docker Image: Docker is running but Xenity Engine can't find the Docker Image (The image includes all the needed files and tools to compile games).
- Running: Docker is ready to use, the configuration is done.
Build settings
This menu allows you to build your game on various platforms such as Windows or PlayStation Portable.
Each platform requires some settings and here are some of them:
- Is Debug Mode: This option enable more logs and a "DEBUG" preprocessor. This enable assertions too. Reduce performances. (Do not enable when shipping the game)
- Enable Profiler: This option enable profiling. You will be able to save profiling data into files. Reduce performances. (Do not enable when shipping the game)
- Icons/Image: You can chose an icon and images for the game. Game consoles use images to show the game in the game list.
- GameID: Game consoles use ids for their games. Each game has an unique ID.
- Use Compilation Cache: Improve compilation speed by reusing compiled code from previous builds. Disable this option if you notice weird behavior in builds with your code.
Some rules about GameID and images are in the notes part. Respect them.
There are two builds button (not for all platforms):
- Build: Ask for a path, build the game and save the binaries in the selected folder.
- Build and Run: Ask for a path, build the game and save the binaries in the selected folder and start the game. (The game will start in a emulator for game consoles).
Dev kit control
If you are an owner of a PlayStation 3 dev kit, this menu can be useful for you.
This window provides a way to control a dev kit using official PS3 tools. (Softwares not included with Xenity Engine).
The Dev kits list shows every registred dev kit in Target Manager.
The Update dev kits list
button will launch Target Manager and get the list of dev kits.
Then you can click on the dev kit to use.
Power Management
You can turn on or off your dev kit from the editor.
If you want to leave the game you can reset the dev kit.
Game Management
If the game's files are located on the dev kit hard drive, you can launch it with the Launch game from ps3 hdd
.
This option is useful with fake dev kit (retail PS3 running dev kit firmware). The file should be located in /dev_hdd0/xenity_engine/XenityBuild.self
.
If the game's files are on your computer, you can launch it with the Launch game from pc
.
This option only works with an official PlayStation dev kit. You have to select the .fake.self file.
Usage
Hera are all the information to learn how to use the engine.
- How to create a project
- How to add an existing project
- How a scene works
- How to import files
- Add your first object in the scene
- How to create a component
- How to play your game in the editor
- How to play your game on game console
- Performances tips
- Common issues
- Where to get help
How to create a project
With Xenity you can work with multiple projects. If you don't have one, let's create one.
Click on Create project
:
This will show a new menu asking for two info:
- Location of the project,
- Name of the project.
By default the project location is User/Documents/Xenity_Projects/
but if you want you can select a new folder.
Then you can finally click on Create project
.
How to add an existing project
If you have a folder containing a Xenity project and the project is not listed in the project list, you can add it.
If you want, there is a list of project samples that you can download, see Game Project Samples.
First click on the Load project
button:
And select the folder of the project, this folder should contains the asset
folder.
Then the project will load and will be added to the project list.
How a scene works
In Xenity, a Scene is a container that holds and manages a collection of GameObjects and their associated Components. It represents a specific state or environment in the game, such as a level, a menu, or a cutscene.
Each GameObject in the scene acts as an entity in the world and can hold one or more Components, which define its behavior or appearance (e.g., a Transform, MeshRenderer, Collider, or Script).
When a scene is loaded, Xenity initializes all the GameObjects and their Components, and the engine begins updating them each frame. Scenes can be loaded, unloaded, or switched during runtime, allowing for smooth transitions between different parts of the game.
If a component or gameobject is destroyed using the Destroy command (see Object Management), the object is destroyed from the memory at the end of the frame.
All assets referenced in the scene will be loaded while the scene is loading. The asset loading is asynchrone on the editor, so textures may look wrong for a small amount of time.
A scene always should have an active camera, you should not add more cameras.
You can load scenes using the SceneManager class. See the Scene asset class.
How to import files
To add files to your Xenity project, you simply have to drag and drop files or folders into the File Explorer.
You can also add files using the Windows file manager into the asset folder of your project. You may have to refresh the file explorer by right clicking on the background and then click on Refresh
.
Add your first object in the scene
Once you have a mesh and a texture, you are almost able to use them in your scene.
You need a material for your mesh. To create one, you can right click on your texture and click on Create a material for this
:
Or you can create an empty material by right clicking on the background and by clicking material
in the Create
menu:
Then you will have a new material. Use the Standard shader if you want to use lighting, or use the Unlit shader if you want a bright texture without lighting. Unlit has way better performances.
Then you can drag and drop your mesh into the scene and set the material in the materials list of the mesh renderer.
There are two ways to change a material variable:
- Drag and drop the asset into the slot,
- Click on the slot to show the list of asset and double click on the asset you want to use.
Each material slot is a material for a submesh. This mesh has 3 submeshes.
I'm only applying a material to one submesh because other submesh are LODs.
And now if you want, you can add more components to your GameObject by clicking Add Component
:
How to create a component
Xenity provides a simple way to create a component for your game.
To modify scripts, please install Visual Studio Code.
First, make a right click on the background of the file explorer, then click on Create C++ class:
Then a menu will ask for information about the new class:
- Class name,
- File name.
If you modify the class name, the file name will be automatically updated with the new name.
And finally, the engine needs to know that this class exists. For this, you have to open game.cpp and add two lines:
- An include to the file,
- A REGISTER_COMPONENT call.
REGISTER_COMPONENT allows you to add parameters about this class, for example the DisableUpdateFunction will prevent the engine from calling the Update function every frame.
warning
Do not move or delete the game.cpp and game.h file, or your project won't work anymore. DDo not use game.cpp for anything other than registering your components.
note
If you have a compilation error, you can see it in the CMD window.
How to play your game in the editor
Xenity allows you to test your game directly in the editor.
For this, you have to compile the code of your game to be able to use scripts you have made.
To compile, open the Game
tab and click on Compile Game
.
Each time you change you game code, you have to compile to apply changes.
You can compile while playing your game, the editor will reload the current scene, but this feature may not work properly. (Heap created by components won't be restored, only reflected variables will be restored).
How to play your game on game console
First of all, to run a homebrew made with Xenity, you need a jailbreaked game console.
It's highly recommended to test your builds on real hardware before publishing your game. If you cannot test, you can ask to some people on homebrew discord servers to test them or ask me.
To build a game on game console, you have to setup Docker, see Game Console Installation. Then you can check the Build Setting Menu, it's the menu to use to make builds.
Preview of the build menu:
Each game console has a special executable file.
- On PSP it's an EBOOT.PBP file, it will directly launch the game. Cannot be renamed.
- On PsVita it's a .vpk file, it will install the game, asset files are in the .vpk file. Can be renamed.
- On PS3 it's a .self, it will directly launch the game. Can be renamed.
Emulation
You can try your game on emulator, but it's not recommended to check performances with them, a game can run smoothly on an emulator but run poorly on real hardware or not even boot! Sometimes emulators won't crash if you code has a bug.
Running on real hardware
PSP
Put the game build folder in the GAME folder of your PSP memory stick then you should see a new game in the game list.
The log file is located next the the EBOOT file.
PsVita
Setup
Xenity games needs some setup to run on a PsVita. The libshacccg.suprx file needs to be extracted and decrypted. This file is needed to enable the shader compiler. This setup has to be done only once.
You can follow this tutorial.
Install the game
Put the .vpk file on the memory card of your PsVita (using FTP or USB), then launch VitaShell, find the .vpk file and press X to install. Confirm the next popup about security. Then a new bubble with the icon of the game should pop on the main PsVita screen.
PS3
Put the game build folder on the hard drive of your PS3 using FTP or put the game folder on an USB key, then launch MultiMan (or another software that can launch .self files) and launch the .self file. If you have a .fake.self file, it's only used by devevelopment kits, you can delete this file if you don't have one.
The log file is located next the the .self file.
Performances tips
Performances on Xenity can be affected for many reasons.
A great way to analyze performances is to use the integrated profiler in the editor.
See the Profiler Menu and the Profiler class.
Physics
On small systems like the PlayStation Portable, performances can be very low with too many rigidbodies. Try to reduce the amount of activated rigidbody in the scene.
Audio
Streaming is very slow on game console, try to avoid having more than one audio source using an audio clip from the storage memory. Only musics should be streamed from the storage memory. Short audio should be in RAM.
See the Loaded In Memory
option in Audio Clip
The Loaded In Memory
option consumes a large amount of memory, that why you should not enable this option for every audio clips.
Rendering
Lighting is extremely heavy on Xenity, try to reduce as much as possible the point/spot light count in you scene. Try to use smaller range for your lights.
Transparency is heavy on PS3 and PsVita, try to avoid them by using Cutout on materials instead.
Common issues
Rendering issues
Black screen
You probably don't have a camera in the scene.
Disapearing triangles on PSP
The hardware clipping on the PSP is not great. There are two ways to reduce this problem:
- Increase the near plane value of the camera
- Reduce the size of the triangles of affected meshes (generally by increasing triangle count with subdivision)
I can't use more than 4 lights on PSP
The PlayStation Portable has a hardware limit of 4 lights per object. For example you can use:
- 1 directional light,
- 1 ambient light,
- 2 point lights.
You can have more lights in the whole scene but only 4 lights will be used for the rendering of a mesh.
Lighting priorities:
- Ambient light has the priority over the directional light,
- Directional light has the priority over the point light,
- Point light has the priority over the spot light.
My material is black in my scene
Check if:
- Use lighting option of your material is checked if you are using the Standard shader or unchecked if you are using Unlit shader,
- You have a light in the scene if you are using Standard shader.
My texture does look transparent on PSP/PS3
By default textures on PSP and PS3 are compressed without alpha channel.
You have to use the RGBA_8888, RGBA_5551, RGBA_4444 types instead of RGBA_5650 type to get transparent textures.
Audio issues
If the audio sounds weird on PlayStation 3, make sure to use 48000Hz audio files. But on other platforms you should use 44000Hz audio files.
Crash
On Windows, if the game crash, you should find a new file next to the game executable called crash_dump.txt containing the call stack of the crash. This will shows you where the crash has happened.
On game consoles, there is no easy way to understand a crash. You can add debug logs in your code to see where logs work and where they stop working. If it's the engine that crashes and not your code, create an issue on the github page of the engine to explain how to reproduce the crash. You can send me your project to help me finding the bug. You can make a pull request if you can fix the bug yourself.
Where to get help
If you have a bug or a problem that is not listed in Common issues, you can create an issue on the github page, or send me a message on Discord or by email. You can send me your project to help me finding a solution for your issue, nothing will be shared.
Discord: fewnity
Email: fewnity@gmail.com
Compatible asset formats
Type | Extensions | Notes |
---|---|---|
Images | .png .jpg .bmp, .tga | |
Audio | .wav .mp3 | (Please use 44100Hz audio, but on PS3 you have to use 48000Hz audio) |
Mesh | .obj .fbx | |
Font | .ttf |
Scripting API reference
This part of the documentation show all details about the classes and lines of code that you can use in Xenity Engine.
- Preprocessors: A list of preprocessors that can be used in your code.
- Editor: List of every editor specific classes and functions.
- Engine: List of every classes, functions and enums that you can use for you game.
Preprocessors
A list of preprocessors that can be used in your code. A preprocessor can be used to change your code at compile time.
Sample:
void MyFunction()
{
#if defined(EDITOR)
Debug::Print("Running in the editor!");
#else
#if defined(__PSP__)
Debug::Print("Running on PSP!");
#elif defined(__vita__)
Debug::Print("Running on PsVita!");
#else
Debug::Print("Running on something else!");
#endif
#endif
}
Platforms
__PSP__
is defined when compiling for PlayStation Portable__vita__
is defined when compiling for PlayStation Vita__PS3__
is defined when compiling for PlayStation 3_WIN32
&_WIN64
is defined when compiling for Windows__LINUX__
is defined when compiling for Linux
Editor
EDITOR
is defined when compiling to play in the editor
Debug
DEBUG
is defined when compiling in debug modeUSE_PROFILER
is defined when compiling with the profiler enabled
Editor
List of every editor specific classes and functions.
Editor classes and functions can't be used in game builds. You can use them only in the editor.
- Gizmo: Class used to rendering shapes in the editor.
- EditorIcons: Class used to get icon textures of the editor.
Gizmo
Add this in your code:
#include <editor/rendering/gizmo.h>
Description
This class is used to draw debug shapes or sprites.
Gizmos can be renderer in OnDrawGizmos
and OnDrawGizmosSelected
events.
warning
Do not create/delete/modify GameObjects or Components in these functions.
Do not call Gizmo functions outsize the events.
How to use Gizmos events:
Override functions you want to use:
class MyComponent : public Component
{
public:
...
private:
void OnDrawGizmos() override;
void OnDrawGizmosSelected() override;
}
Then implement the functions:
void MyComponent::OnDrawGizmos()
{
#if defined(EDITOR)
Gizmo::DrawLine(Vector3(0, 0, 0), Vector3(1, 1, 1));
#endif
}
void MyComponent::OnDrawGizmosSelected()
{
#if defined(EDITOR)
Gizmo::DrawLine(Vector3(1, 1, 1), Vector3(0, 0, 0));
#endif
}
The use of #if defined(EDITOR)
is needed because the Gizmo
class is not visible in game builds.
Static methods
SetColor
Set Gizmo draw color (does not affect sprites).
Parameters:
newColor
: New color to use
void SetColor(const Color& newColor)
Code sample:
const Color redColor = Color::CreateFromRGBAFloat(1, 0, 0, 1);
Gizmo::SetColor(redColor);
DrawLine
Draw a simple line from A to B.
Parameters:
a
: Start pointb
: End point
void DrawLine(const Vector3& a, const Vector3& b)
Code sample:
Gizmo::DrawLine(Vector3(0, 0, 0), Vector3(1, 1, 1));
DrawBillboard
Draw a billboard sprite.
Parameters:
position
: Position of the spritescale
: Scale of the spritetexture
: Texture to drawcolor
: Color of the sprite
void DrawBillboard(
const Vector3& position,
const Vector2& scale,
const std::shared_ptr<Texture>& texture,
const Color& color)
Code sample:
Gizmo::DrawBillboard(
GetTransform()->GetPosition(),
Vector2(0.2f),
EditorIcons::GetIcon(IconName::Icon_Audio_Source),
Color::CreateFromRGBAFloat(1, 1, 1, 0.5f));
DrawSphere
Draw a wired sphere.
Parameters:
position
: Position of the sphererotation
: Rotation of the sphereradius
: Radius of the sphere
void DrawSphere(
const Vector3& position,
const Quaternion& rotation,
const float radius)
Code sample:
Gizmo::DrawSphere(
GetTransform()->GetPosition(),
GetTransform()->GetRotation(),
2.0f);
EditorIcons
Add this in your code:
#include <editor/ui/editor_icons.h>
Description
Class used to get icon textures of the editor.
Can be used for Gizmo.
Static methods
GetIcons
Get the list of all editor icons.
const std::vector<std::shared_ptr<Texture>>& GetIcons()
Code sample:
const std::vector<std::shared_ptr<Texture>>& icons = EditorIcons::GetIcons();
const std::shared_ptr<Texture>& cameraIcon = icons[IconName::Icon_Camera];
GetIcon
Get an icon by its name enum.
Parameters:
iconName
: Icon name Enum
const std::shared_ptr<Texture>& GetIcon(IconName iconName)
Code sample:
const std::shared_ptr<Texture>& cameraIcon = EditorIcons::GetIcon(IconName::Icon_Camera);
IconName Enum
Add this in your code:
#include <editor/ui/editor_icons.h>
Description
Enum that list every icons used in the editor.
Not available in game builds.
Values
Name |
---|
Icon_Folder |
Icon_File |
Icon_Scene |
Icon_Image |
Icon_Mesh |
Icon_Code |
Icon_Header |
Icon_Audio |
Icon_Sky |
Icon_Font |
Icon_Audio_Source |
Icon_Point_Light |
Icon_Sun_Light |
Icon_Spot_Light |
Icon_Camera |
Icon_Material |
Icon_Shader |
Icon_Play |
Icon_Pause |
Icon_Stop |
Icon_Camera_Move |
Icon_Move |
Icon_Rotate |
Icon_Scale |
Icon_Grid |
Icon_Question |
Icon_Platform_Windows |
Icon_Platform_Linux |
Icon_Platform_PSP |
Icon_Platform_PSVITA |
Icon_Platform_PS2 |
Icon_Platform_PS3 |
Icon_Platform_PS4 |
Icon_Count |
Engine
Here is a list of every classes, functions and enums that you can use for you game.
- Application: Class used to manage the application and get information about it.
- Asset: List of all game assets.
- Color: This class stores information about a color.
- Components: List of every components.
- DateTime: This class represents an instant in time.
- Debug: Class used to print text in the console and in file.
- Enumerations: Information about enumerations.
- Event: This class gives the possibility to bind a function to an event.
- FileSystem: This class provides methods to manipulate files and directories.
- GameObject: A GameObject is a class that contains some properties and a list of components.
- Inputs: Category of all inputs classes.
- Math: Category of all math classes.
- Network: Category of all networking classes.
- Noise: Class to generate 1D, 2D, 3D and 4D Perlin noise.
- Object management: List of functions to manage GameObject and Components of your game.
- Physics: Category if all physics classes.
- Reflective: Class used for reflection.
- SceneManager: Class to load scenes.
- Screen: Class to get information and to interact with the screen.
- Time: Class to get time information (Delta time, elapsed time).
- Transform: Class representing a 3D transformation (position, rotation, scale) of a GameObject.
- UI Rendering: Enum about UI rendering.
- Utils: Utility classes.
- VertexDescriptor: Class that store the data structure of a vertex.
Application
Add this in your code:
#include <engine/application.h>
Description
Class used to manage the application and get information about it.
Static methods
OpenURL
Opens the link in a web browser (Only for Windows).
void OpenURL(const std::string& url)
Code sample:
Application::OpenURL("https://google.com");
Quit
Quits the application.
void Quit()
Code sample:
Application::Quit();
GetPlatform
Returns the current platform the application is running on.
Platform GetPlatform()
Code sample:
if(Application::GetPlatform() == Platform::P_PSP)
{
Debug::Print("Running on PSP!");
}
GetXenityVersion
Returns the current version of Xenity Engine.
std::string GetXenityVersion()
Code sample:
if(Application::GetXenityVersion() == "1.0.0")
{
// Special behavior for a specific version of the engine
}
else
{
// ...
}
GetGameName
Returns the name of the game.
std::string GetGameName()
Code sample:
Debug::Print("Game name: " + Application::GetGameName());
GetCompanyName
Returns the name of the company.
std::string GetCompanyName()
Code sample:
Debug::Print("Company name: " + Application::GetCompanyName());
IsInEditor
Returns if the application is running in the editor.
bool IsInEditor()
Code sample:
if(Application::IsInEditor())
{
Debug::Print("Running in editor!");
}
else
{
Debug::Print("Not running in editor!");
}
// For something at compile time
#if defined(EDITOR)
Debug::Print("Running in editor!");
#else
Debug::Print("Not running in editor!");
#endif
GetGameDataFolder
Return the game folder (folder where you can write data).
bool GetGameDataFolder()
Code sample:
std::string fileName = Application::GetGameDataFolder() + "my_file.txt";
std::shared_ptr<File> myFile = FileSystem::MakeFile(fileName);
bool isOpened = myFile->Open(FileMode::WriteCreateFile);
GetGameFolder
Returns the game folder (folder where the game is located, may be read-only).
bool GetGameFolder()
Code sample:
std::string fileName = Application::GetGameFolder() + "my_file.txt";
std::shared_ptr<File> myFile = FileSystem::MakeFile(fileName);
bool isOpened = myFile->Open(FileMode::ReadOnly);
Assets
Here is a list of every game assets.
- AudioClip: Asset that stores audio like a sound effect or a music.
- Font: Asset that stores a text font.
- Icon: Asset that stores an icon.
- Material: Handles the visual appearance of rendered objects, including shaders and textures.
- MeshData: Asset that stores all the data of a mesh.
- Prefab: A prefab stores GameObjects and Components.
- Scene: Asset that represents a game world. A scene stores a list of GameObject and Components.
- Shader: Asset that stores shader code.
- Skybox: Asset that references all textures that compose a skybox.
- Texture: Asset that stores an image.
AudioClip
Add this in your code:
#include <engine/audio/audio_clip.h>
Description
Asset that stores audio like a sound effect or a music.
Used by Audio Source.
Inspector settings
Name | Type | Description |
---|---|---|
Loaded In Memory | CheckBox | Defines if the audio should be fully loaded in memory. When enabled, it's faster to play the audio but consumes a lot of memory. Recommended for sound effects but not for musics. |
Font
Add this in your code:
#include <engine/graphics/ui/font.h>
Description
Asset that stores a text font.
Used by TextRenderer and by TextMesh.
Icon
Add this in your code:
#include <engine/graphics/ui/icon.h>
Description
Asset that stores an icon.
Used in the Build Settings menu.
Material
Add this in your code:
#include <engine/graphics/material.h>
Description
Handles the visual appearance of rendered objects, including shaders and textures.
The Material class allows you to configure how an object should look when drawn on screen.
Inspector settings
Name | Type | Description |
---|---|---|
Shader | Shader | Set the material shader. Standard to use lighting, Unlit to disable lighting. |
Rendering mode | Enum | Set the rendering mode of the material. |
Texture | Texture | Set the material texture. |
Color | Color | Set the color of the material. |
Offset | Vector2 | Set the texture offset. |
Tiling | Vector2 | Set the texture tiling. |
Use lighting | CheckBox | Check this if you are using Standard shader, uncheck this if you are using Unlit shader. |
Public methods
SetAttribute
Set a value to an attribute in the shader when this material is used.
To use only when you are using custom shaders.
Parameters:
attribute
: Attribute namevalue
: New attribute value
void SetAttribute(const char* attribute, const Vector2& value)
void SetAttribute(const char* attribute, const Vector3& value)
void SetAttribute(const char* attribute, const Vector4& value)
void SetAttribute(const char* attribute, const float value)
void SetAttribute(const char* attribute, const int value)
Code sample:
std::shared_ptr<Material> material; // Filled variable
material->SetAttribute("MyAttribute", Vector3(1, 0.5f, 1));
SetShader
Set the material shader.
Parameters:
shader
: Shader to use
void SetShader(const std::shared_ptr<Shader>& shader)
Code sample:
std::shared_ptr<Material> material; // Filled variable
std::shared_ptr<Shader> shader; // Filled variable
material->SetShader(shader);
SetTexture
Set the material texture.
Parameters:
texture
: Texture to use
void SetTexture(const std::shared_ptr<Texture>& texture)
Code sample:
std::shared_ptr<Material> material; // Filled variable
std::shared_ptr<Texture> texture; // Filled variable
material->SetTexture(texture);
SetUseLighting
Set the if the material uses lighting. Disable this only on Unlit shaders.
Parameters:
useLighting
: Does the material uses lighting?
void SetUseLighting(const bool useLighting)
Code sample:
std::shared_ptr<Material> material; // Filled variable
material->SetUseLighting(true);
SetOffset
Set the texture offset.
Parameters:
offset
: Offset of the texture
void SetOffset(const Vector2& offset)
Code sample:
std::shared_ptr<Material> material; // Filled variable
material->SetOffset(Vector2(0.5f, 0.5f));
SetTiling
Set the texture tiling.
Parameters:
tiling
: Tiling of the texture
void SetTiling(const Vector2& tiling)
Code sample:
std::shared_ptr<Material> material; // Filled variable
material->SetTiling(Vector2(2.0f, 2.0f));
GetShader
Get the shader of the material.
const std::shared_ptr<Shader>& GetShader() const
Code sample:
std::shared_ptr<Material> material; // Filled variable
std::shared_ptr<Shader> shader = material->GetShader();
GetTexture
Get the texture of the material.
const std::shared_ptr<Texture>& GetTexture() const
Code sample:
std::shared_ptr<Material> material; // Filled variable
std::shared_ptr<Texture> texture = material->GetTexture();
GetUseLighting
Get if the material uses lighting.
bool GetUseLighting() const
Code sample:
std::shared_ptr<Material> material; // Filled variable
bool isUsingLighting = material->GetUseLighting();
GetRenderingMode
Get the rendering mode of the material.
MaterialRenderingMode GetRenderingMode() const
Code sample:
std::shared_ptr<Material> material; // Filled variable
MaterialRenderingMode mode = material->GetRenderingMode();
GetOffset
Get the texture offset of the material.
const Vector2& GetOffset() const
Code sample:
std::shared_ptr<Material> material; // Filled variable
const Vector2& offset = material->GetOffset();
GetTiling
Get the texture tiling of the material.
const Vector2& GetTiling() const
Code sample:
std::shared_ptr<Material> material; // Filled variable
const Vector2& tiling = material->GetTiling();
GetColor
Get the color of the material.
const Color& GetColor() const
Code sample:
std::shared_ptr<Material> material; // Filled variable
const Color& color = material->GetColor();
SetColor
Set the color of the material.
Parameters:
color
: Color of the material
void SetColor(const Color& color)
Code sample:
std::shared_ptr<Material> material; // Filled variable
material->SetColor(Color::CreateFromRGBAFloat(1, 0.5f, 0.5f, 1));
SetAlphaCutoff
Set the alpha cutoff of the material.
Parameters:
alphaCutoff
: New alpha cutoff value [0.0f;1.0f]
void SetAlphaCutoff(float alphaCutoff)
Code sample:
std::shared_ptr<Material> material; // Filled variable
material->SetAlphaCutoff(0.5f);
GetAlphaCutoff
Get the alpha cutoff of the material.
float GetAlphaCutoff() const
Code sample:
std::shared_ptr<Material> material; // Filled variable
float alphaCutoff = material->GetAlphaCutoff();
MaterialRenderingMode Enum
Add this in your code:
#include <engine/graphics/material_rendering_mode.h>
Description
Enum to define how an object is drawn.
Values
Name | Description |
---|---|
Opaque | The default value, is suitable for rendering opaque objects |
Cutout | Allows you to render objects with either fully transparent or fully opaque areas |
Transparent | Allows you to render transparent objects such as glass, clear plastics, etc |
MeshData
Add this in your code:
#include <engine/graphics/3d_graphics/mesh_data.h>
Description
Asset that stores all the data of a mesh.
Static methods
CreateMeshData
Dynamically create a mesh.
std::shared_ptr<MeshData> CreateMeshData()
Code sample:
std::shared_ptr<MeshData> newMesh = MeshData::CreateMeshData();
Public methods
GetMinBoundingBox
Get the minimum position of the bounding box. (Box including all submeshes).
const Vector3& GetMinBoundingBox() const
Code sample:
std::shared_ptr<MeshData> meshData; // Filled variable
const Vector3& minPos = meshData->GetMinBoundingBox();
GetMaxBoundingBox
Get the maximum position of the bounding box. (Box including all submeshes).
const Vector3& GetMaxBoundingBox() const
Code sample:
std::shared_ptr<MeshData> meshData; // Filled variable
const Vector3& maxPos = meshData->GetMaxBoundingBox();
GetBoundingSphere
Get mesh bounding sphere. (Sphere including all submeshes).
const Sphere& GetBoundingSphere() const
Code sample:
std::shared_ptr<MeshData> meshData; // Filled variable
const Sphere& meshSphere = meshData->GetBoundingSphere();
CreateSubMesh
Create a sub mesh and allocate memory for it.
Parameters:
vertexCount
: The number of vertices allocatedindexCount
: The number of indices allocatedvertexDescriptorList
: The vertex data structure
void CreateSubMesh(uint32_t verticeCount, uint32_t index_count, const VertexDescriptor& vertexDescriptorList)
Code sample:
std::shared_ptr<MeshData> newMesh = MeshData::CreateMeshData();
VertexDescriptor descriptor;
descriptor.AddVertexElement(VertexElements::UV_32_BITS);
descriptor.AddVertexElement(VertexElements::POSITION_32_BITS);
newMesh->CreateSubMesh(6,0, descriptor);
GetSubMesh
Get a submesh by index.
Parameters:
index
: Index of the submesh
const std::unique_ptr<SubMesh>& GetSubMesh(size_t index)
Code sample:
std::shared_ptr<MeshData> meshData; // Filled variable
const std::unique_ptr<SubMesh>& subMesh0 = meshData->GetSubMesh(0);
const std::unique_ptr<SubMesh>& subMesh2 = meshData->GetSubMesh(2);
Update
Update the mesh after a modification on the submeshes.
void Update()
Code sample:
SubMesh
Add this in your code:
#include <engine/graphics/3d_graphics/mesh_data.h>
Description
Class that store vertices and indices of a sub mesh.
Public methods
SetVertex (UV, Color, Position)
Set the data of a vertex.
Parameters:
u
: U texture coordinatev
: v texture coordinatecolor
: colorx
: X positiony
: Y positionz
: Z positionvertexIndex
: Index of the vertex to modify
void SetVertex(float u, float v,
const Color& color,
float x, float y, float z,
uint32_t vertexIndex)
Code sample:
std::shared_ptr<MeshData> meshData; // Filled variable
const std::unique_ptr<SubMesh>& subMesh0 = meshData->GetSubMesh(0);
subMesh0->SetVertex(1.0f, 0.0f, Color::CreateFromRGBA(255, 128, 128, 255), 1.0f, 2.0f, 1.0f, 0);
SetVertex (Position)
Set the data of a vertex.
Parameters:
x
: X positiony
: Y positionz
: Z positionvertexIndex
: Index of the vertex to modify
void SetVertex(float x, float y, float z,
uint32_t vertexIndex)
Code sample:
std::shared_ptr<MeshData> meshData; // Filled variable
const std::unique_ptr<SubMesh>& subMesh0 = meshData->GetSubMesh(0);
subMesh0->SetVertex(1.0f, 2.0f, 1.0f, 0);
SetVertex (UV, Position)
Set the data of a vertex.
Parameters:
u
: U texture coordinatev
: v texture coordinatex
: X positiony
: Y positionz
: Z positionvertexIndex
: Index of the vertex to modify
void SetVertex(float u, float v,
float x, float y, float z,
uint32_t vertexIndex)
Code sample:
std::shared_ptr<MeshData> meshData; // Filled variable
const std::unique_ptr<SubMesh>& subMesh0 = meshData->GetSubMesh(0);
subMesh0->SetVertex(1.0f, 0.0f, 1.0f, 2.0f, 1.0f, 0);
SetVertex (UV, Normal, Position)
Set the data of a vertex.
Parameters:
u
: U texture coordinatev
: v texture coordinatenx
: X normalny
: Y normalnz
: Z normalx
: X positiony
: Y positionz
: Z positionvertexIndex
: Index of the vertex to modify
void SetVertex(float u, float v,
float nx, float ny, float nz,
float x, float y, float z,
uint32_t vertexIndex)
Code sample:
std::shared_ptr<MeshData> meshData; // Filled variable
const std::unique_ptr<SubMesh>& subMesh0 = meshData->GetSubMesh(0);
subMesh0->SetVertex(1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 2.0f, 1.0f, 0);
SetVertex (Normal, Position)
Set the data of a vertex.
Parameters:
nx
: X normalny
: Y normalnz
: Z normalx
: X positiony
: Y positionz
: Z positionvertexIndex
: Index of the vertex to modify
void SetVertex(float nx, float ny, float nz,
float x, float y, float z,
uint32_t vertexIndex)
Code sample:
std::shared_ptr<MeshData> meshData; // Filled variable
const std::unique_ptr<SubMesh>& subMesh0 = meshData->GetSubMesh(0);
subMesh0->SetVertex(0.0f, 0.0f, 1.0f, 1.0f, 2.0f, 1.0f, 0);
SetPosition
Set the position of a vertex.
Parameters:
x
: X positiony
: Y positionz
: Z positionvertexIndex
: Index of the vertex to modify
void SetPosition(float x, float y, float z, uint32_t vertexIndex)
Code sample:
std::shared_ptr<MeshData> meshData; // Filled variable
const std::unique_ptr<SubMesh>& subMesh0 = meshData->GetSubMesh(0);
subMesh0->SetPosition(1.0f, 2.0f, 1.0f, 0);
SetNormal
Set the normal of a vertex.
Parameters:
nx
: X normalny
: Y normalnz
: Z normalvertexIndex
: Index of the vertex to modify
void SetNormal(float nx, float ny, float nz, uint32_t vertexIndex)
Code sample:
std::shared_ptr<MeshData> meshData; // Filled variable
const std::unique_ptr<SubMesh>& subMesh0 = meshData->GetSubMesh(0);
subMesh0->SetNormal(0.0f, 0.0f, 1.0f, 0);
SetUV
Set the UV coordinates of a vertex.
Parameters:
u
: U texture coordinatev
: v texture coordinatevertexIndex
: Index of the vertex to modify
void SetUV(float u, float v, uint32_t vertexIndex)
Code sample:
std::shared_ptr<MeshData> meshData; // Filled variable
const std::unique_ptr<SubMesh>& subMesh0 = meshData->GetSubMesh(0);
subMesh0->SetUV(1.0f, 0.0f, 0);
SetColor
Set the color of a vertex.
Parameters:
color
: colorvertexIndex
: Index of the vertex to modify
void SetColor(const Color& color, uint32_t vertexIndex)
Code sample:
std::shared_ptr<MeshData> meshData; // Filled variable
const std::unique_ptr<SubMesh>& subMesh0 = meshData->GetSubMesh(0);
subMesh0->SetColor(Color::CreateFromRGBA(255, 128, 128, 255), 0);
SetIndex
Set index value.
Parameters:
index
: The new vertex indexvalue
: Index to change
void SetIndex(size_t index, uint32_t value)
Code sample:
std::shared_ptr<MeshData> meshData; // Filled variable
const std::unique_ptr<SubMesh>& subMesh0 = meshData->GetSubMesh(0);
// Make a triangle with the 5,3,4 indices
subMesh0->SetIndex(5, 0);
subMesh0->SetIndex(3, 1);
subMesh0->SetIndex(4, 2);
GetIndices
Get indices data pointer. (unsigned short or unsigned int).
void* GetIndices() const
Code sample:
std::shared_ptr<MeshData> meshData; // Filled variable
const std::unique_ptr<SubMesh>& subMesh0 = meshData->GetSubMesh(0);
if (subMesh->usesShortIndices)
{
unsigned short& index = ((unsigned short*)subMesh->GetIndices())[0];
}
else
{
unsigned int& index = ((unsigned int*)subMesh->GetIndices())[0];
}
Prefab
Add this in your code:
#include <engine/game_elements/prefab.h>
Description
A prefab stores GameObjects and Components.
A prefab is created when dragging a GameObject from the Hierarchy to the File Explorer.
Then you can recreate the GameObject by dragging the prefab from the File Explorer to the Scene tab.
Scene
Add this in your code:
#include <engine/scene_management/scene.h>
Description
Asset that represents a game world. A scene stores a list of GameObject and Components.
A scene should a least contains a camera.
It can be used in the Project Settings menu and by the SceneManager class.
Shader
Add this in your code:
#include <engine/graphics/shader/shader.h>
Description
Asset that stores shader code.
Not used on PSP.
Skybox
Add this in your code:
#include <engine/graphics/skybox.h>
Description
Asset that references all textures that compose a skybox.
Can be used in the Lighting Settigs menu.
Variables
Name | Type | Description |
---|---|---|
front | std::shared_ptr<Texture> | Front skybox texture |
back | std::shared_ptr<Texture> | Back skybox texture |
up | std::shared_ptr<Texture> | Up skybox texture |
down | std::shared_ptr<Texture> | Down skybox texture |
left | std::shared_ptr<Texture> | Left skybox texture |
right | std::shared_ptr<Texture> | Right skybox texture |
Texture
Add this in your code:
#include <engine/graphics/texture/texture.h>
Description
Asset that stores an image.
A texture can be created dynamically.
Inspector settings
Name | Type | Description |
---|---|---|
Resolution | Enum | Max texture resolution |
Filter | Enum | Texture filter |
WrapMode | Enum | Texture wrap mode |
UseMipMap | CheckBox | If enabled, smaller versions of the texture will be generated. Improves rendering but consumes more memory (Not working on PS3). |
PixelPerUnit | Number | Number of pixel per world unit (Used for sprites). |
PSP additional Inspector settings
Name | Type | Description |
---|---|---|
Type | Enum | Type of compression |
TryPutInVram | CheckBox | If true, the texture will try to be stored in video ram instead of ram. (video ram is faster than ram but way smaller) |
PS3 additional Inspector settings
Name | Type | Description |
---|---|---|
Type | Enum | Type of compression |
Static methods
CreateTexture
Dynamically create a texture.
Parameters:
params
: Parameters for the texture creation
std::shared_ptr<Texture> CreateTexture(const TextureConstructorParams& params)
Code sample:
TextureConstructorParams params;
params.width = 128;
params.height = 128;
params.filter = Filter::Bilinear;
params.wrapMode = WrapMode::Repeat;
params.pspTextureType = PSPTextureType::RGBA_4444;
params.ps3TextureType = PS3TextureType::ARGB_4444;
params.hasAlpha = true;
std::shared_ptr<Texture> newTexture = Texture::CreateTexture(params);
Public methods
SetFilter
Set texture filter.
Parameters:
filter
: Filtering mode
void SetFilter(const Filter filter)
Code sample:
std::shared_ptr<Texture> texture; // Filled variable
texture->SetFilter(Filter::Point);
texture->SetFilter(Filter::Bilinear);
SetWrapMode
Set texture wrap mode.
Parameters:
mode
: Wraping mode
void SetWrapMode(const WrapMode mode)
Code sample:
std::shared_ptr<Texture> texture; // Filled variable
texture->SetWrapMode(WrapMode::Point);
texture->SetWrapMode(WrapMode::Bilinear);
GetWidth
Get texture width.
int GetWidth() const
Code sample:
std::shared_ptr<Texture> texture; // Filled variable
int width = texture->GetWidth();
GetHeight
Get texture height.
int GetHeight() const
Code sample:
std::shared_ptr<Texture> texture; // Filled variable
int height = texture->GetHeight();
SetPixelPerUnit
Set texture pixel per unit.
void SetPixelPerUnit(int value)
Code sample:
std::shared_ptr<Texture> texture; // Filled variable
texture->SetPixelPerUnit(100);
GetPixelPerUnit
Get texture pixel per unit.
int GetPixelPerUnit() const
Code sample:
std::shared_ptr<Texture> texture; // Filled variable
int pixelPerUnit = texture->GetPixelPerUnit();
GetUseMipmap
Get if the texture is using mipmap.
bool GetUseMipmap() const
Code sample:
std::shared_ptr<Texture> texture; // Filled variable
bool useMipMap = texture->GetUseMipmap();
GetWrapMode
Get texture wrap mode.
WrapMode GetWrapMode() const
Code sample:
std::shared_ptr<Texture> texture; // Filled variable
WrapMode wrapMode = texture->GetWrapMode();
SetData
Set texture data.
Can be called multiple times.
virtual void SetData(const unsigned char* data) = 0
Code sample:
size_t width = 128;
size_t height = 128;
unsigned char* rawData = new unsigned char[width * height * 4];
struct Pixel
{
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t a;
};
// Create a noise texture
for (size_t y = 0; y < height; y++)
{
for (size_t x = 0; x < width; x++)
{
Pixel& pixel = reinterpret_cast<Pixel*>(rawData)[x + (y * width)];
pixel.r = rand() % 255;
pixel.g = rand() % 255;
pixel.b = rand() % 255;
pixel.a = 255;
}
}
TextureConstructorParams params;
params.width = width;
params.height = height;
params.filter = Filter::Bilinear;
params.wrapMode = WrapMode::Repeat;
params.pspTextureType = PSPTextureType::RGBA_4444;
params.ps3TextureType = PS3TextureType::ARGB_4444;
params.hasAlpha = true;
std::shared_ptr<Material> material; // Filled variable
std::shared_ptr<Texture> newTexture = Texture::CreateTexture(params);
newTexture->SetData(rawData);
material->SetTexture(newTexture);
delete[] rawData;
Filter Enum
Add this in your code:
#include <engine/graphics/texture.h>
Description
Enum to define how a texture should be filtered.
Values
Name | Description |
---|---|
Point | Point filtering selects the nearest texel without interpolation, giving a sharp, pixelated look |
Bilinear | Bilinear filtering smooths textures by interpolating between the four nearest texels, resulting in a softer, more blended appearance |
TextureResolution Enum
Add this in your code:
#include <engine/graphics/texture.h>
Description
Enum to set the maximum resolution of the texture.
Values
Name | Description |
---|---|
R_64x64 | Max resolution to 64x64 |
R_128x128 | Max resolution to 128x128 |
R_256x256 | Max resolution to 256x256 |
R_512x512 | Max resolution to 512x512 |
R_1024x1024 | Max resolution to 1024x1024 |
R_2048x2048 | Max resolution to 2048x2048 |
WrapMode Enum
Add this in your code:
#include <engine/graphics/texture.h>
Description
Enum that defines how texture coordinates outside the [0, 1] range are handled when sampling a texture.
Values
Name | Description |
---|---|
ClampToEdge | Clamps texture coordinates to the nearest edge, causing the texture’s edge pixels to stretch |
Repeat | Wraps texture coordinates around, repeating the texture pattern infinitely |
PSPTextureType Enum
Add this in your code:
#include <engine/graphics/texture.h>
Description
Enum that specifies the pixel format used for textures on the PSP, defining how color data is stored.
Values
Name | Description |
---|---|
RGBA_8888 | Stores 8 bits per channel, offering full 32-bit color with high precision for each component |
RGBA_5551 | Uses 5 bits for red, green, and blue, and 1 bit for alpha, providing a compact 16-bit format with limited transparency support |
RGBA_5650 | Allocates 5 bits for red, 6 for green, and 5 for blue, with no alpha channel, optimizing color depth over transparency |
RGBA_4444 | Provides 4 bits per channel, balancing color and transparency in a compact 16-bit format |
PS3TextureType Enum
Add this in your code:
#include <engine/graphics/texture.h>
Description
Enum that specifies the pixel format used for textures on the PS3, defining how color data is stored.
Values
Name | Description |
---|---|
ARGB_8888 | Stores 8 bits per channel, offering full 32-bit color with high precision for each component |
ARGB_1555 | Uses 5 bits for red, green, and blue, and 1 bit for alpha, providing a compact 16-bit format with limited transparency support |
ARGB_0565 | Allocates 5 bits for red, 6 for green, and 5 for blue, with no alpha channel, optimizing color depth over transparency |
ARGB_4444 | Provides 4 bits per channel, balancing color and transparency in a compact 16-bit format |
Color
Add this in your code:
#include <engine/graphics/color/color.h>
Description
This class stores information about a color.
Static methods
CreateFromRGB
Create a color from 3 uint8_t (alpha = 255).
Parameters:
r
: Red level [0;255]g
: Green level [0;255]b
: Blue level [0;255]
Color CreateFromRGB(uint8_t r, uint8_t g, uint8_t b)
Code sample:
Color red = Color::CreateFromRGB(255, 0, 0);
CreateFromRGBA
Create a color from 4 uint8_t.
Parameters:
r
: Red level [0;255]g
: Green level [0;255]b
: Blue level [0;255]a
: Alpha level [0;255]
Color CreateFromRGBA(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
Code sample:
Color semiTransparentRed = Color::CreateFromRGBA(255, 0, 0, 128);
CreateFromRGBFloat
Create a color from 3 floats (alpha = 1).
Parameters:
r
: Red level [0.0f;1.0f]g
: Green level [0.0f;1.0f]b
: Blue level [0.0f;1.0f]
Color CreateFromRGBFloat(float r, float g, float b)
Code sample:
Color red = Color::CreateFromRGBFloat(1.0f, 0.0f, 0.0f);
CreateFromRGBAFloat
Create a color from 4 floats.
Parameters:
r
: Red level [0.0f;1.0f]g
: Green level [0.0f;1.0f]b
: Blue level [0.0f;1.0f]a
: Alpha level [0.0f;1.0f]
Color CreateFromRGBAFloat(float r, float g, float b, float a)
Code sample:
Color semiTransparentRed = Color::CreateFromRGBAFloat(1.0f, 0.0f, 0.0f, 0.5f);
Public methods
SetFromRGBA
Set color from 4 uint8_t.
Parameters:
r
: Red level [0;255]g
: Green level [0;255]b
: Blue level [0;255]a
: Alpha level [0;255]
Color SetFromRGBA(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
Code sample:
Color myColor = Color();
myColor.SetFromRGBA(255, 0, 0, 128);
myColor.SetFromRGBA(255, 255, 255, 255);
SetFromRGBAFloat
Set color from 4 float.
Parameters:
r
: Red level [0.0f;1.0f]g
: Green level [0.0f;1.0f]b
: Blue level [0.0f;1.0f]a
: Alpha level [0.0f;1.0f]
Color SetFromRGBAFloat(float r, float g, float b, float a)
Code sample:
Color myColor = Color();
myColor.SetFromRGBAFloat(1.0f, 0, 0, 0.5f);
myColor.SetFromRGBAFloat(1.0f, 1.0f, 1.0f, 1.0f);
GetRGBA
Get RGBA.
const RGBA& GetRGBA() const
Code sample:
Color red = Color::CreateFromRGBFloat(1.0f, 0.0f, 0.0f);
RGBA rgba = red.GetRGBA();
const RGBA& rgbaRef = red.GetRGBA(); // Avoid a copy
GetUnsignedIntRGBA
Get RGBA values as an unsigned int in the format RGBA (0xRRGGBBAA).
unsigned int GetUnsignedIntRGBA() const
Code sample:
Color myColor = Color::CreateFromRGBAFloat(1.0f, 0.6f, 0.3f, 0.1f);
unsigned int rgba = myColor.GetUnsignedIntRGBA(); // 0xff994c19
GetUnsignedIntABGR
Get RGBA values as an unsigned int in the format ABGR (0xAABBGGRR).
unsigned int GetUnsignedIntABGR() const
Code sample:
Color myColor = Color::CreateFromRGBAFloat(1.0f, 0.6f, 0.3f, 0.1f);
unsigned int abgr = myColor.GetUnsignedIntABGR(); // 0x194c99ff
GetUnsignedIntARGB
Get RGBA values as an unsigned int in the format ARGB (0xAARRGGBB).
unsigned int GetUnsignedIntARGB() const
Code sample:
Color myColor = Color::CreateFromRGBAFloat(1.0f, 0.6f, 0.3f, 0.1f);
unsigned int argb = myColor.GetUnsignedIntARGB(); // 0x19ff994c
ToString
Return a string representation of the color.
std::string ToString() const
Code sample:
Color myColor = Color::CreateFromRGBAFloat(1.0f, 0.6f, 0.3f, 0.1f);
Debug::Print(myColor.ToString());
// Prints: "{R:1 G:0.6 B:0.3 A:0.1 | RGBA Hex:#ff994c19 | ARGB Hex:#19ff994c | ABGR Hex:#194c99ff}"
RGBA
Add this in your code:
#include <engine/graphics/color/color.h>
Description
This class stores information about a color.
Constructors
RGBA
Parameters:
r
: Red level [0.0f;1.0f]g
: Green level [0.0f;1.0f]b
: Blue level [0.0f;1.0f]a
: Alpha level [0.0f;1.0f]
constexpr RGBA(float r, float g, float b, float a)
Code sample:
RGBA myRGBA = RGBA(1.0f, 0.6f, 0.3f, 0.1f);
Public methods
ToVector4
Get RGBA as a Vector4 [0.0f;1.0f] x = red, y = green, z = blue, w = alpha.
Vector4 ToVector4() const
Code sample:
RGBA myRGBA = RGBA(1.0f, 0.6f, 0.3f, 0.1f);
Vector4 rgbaAsVector4 = myRGBA.ToVector4();
Variables
Name | Type | Description |
---|---|---|
r | float | Red information [0.0f;1.0f] |
g | float | Green information [0.0f;1.0f] |
b | float | Blue information [0.0f;1.0f] |
a | float | Alpha information [0.0f;1.0f] |
Components
Here is a list of all components of the game engine.
- Component: The component class gives you a list of function that you can override in your components.
- AudioSource: Component to play audio clips.
- BillboardRenderer: Component to render a billboard sprite (2D sprite that always faces the camera).
- BoxCollider: Component to add a cube-shaped collider to a GameObject.
- Button: Component that renders a button on the screen.
- Camera: Component for rendering the scene.
- Canvas: Component to render a canvas (UI elements).
- FpsCounter: Component to display the FPS counter in the game.
- ImageRenderer: Component that renders an image on the screen.
- Light: Component to produce light.
- Lod: Component to manage Level of Detail (LOD) for a GameObject.
- MeshRenderer: Component that renders a mesh with materials.
- MissingScript: Special Component that replaces missing components.
- ParticleSystem: Component to spawn particles.
- RectTransform: Component that represents a transform for UI elements.
- Rigidbody: Component to add physics to the GameObject.
- SphereCollider: Component to add a sphere-shaped collider to a GameObject.
- SpriteRenderer: Component that renders a sprite with a texture and material.
- TextMesh: Component for rendering text in 3D space.
- TextRenderer: Component for rendering text in a canvas.
Component
Add this in your code:
#include <engine/component.h>
Description
The component class gives you a list of function that you can override in your components.
Protected variables
Name | Type | Description |
---|---|---|
m_componentName | const std::string* | Pointer to the component name |
Virtual methods
Awake
This function is called once before Start() at the creation of the component.
The engine calls the function when:
- The parent GameObject is active when a scene just loaded
- The parent GameObject goes from inactive to active
The parent GameObject and the component should be enabled.
virtual void Awake()
Code sample:
class API MyComponent : public Component
{
public:
void Awake() override
{
Debug::Print("Awake called!");
}
}
Start
This function is called once after Awake() at the creation of the component.
The engine calls the function when:
- The parent GameObject is active when a scene just loaded
- The parent GameObject goes from inactive to active
The parent GameObject and the component should be enabled.
virtual void Start()
Code sample:
class API MyComponent : public Component
{
public:
void Start() override
{
Debug::Print("Start called!");
}
}
Update
This function called every frame.
The parent GameObject and the component should be enabled.
virtual void Update()
Code sample:
class API MyComponent : public Component
{
public:
void Update() override
{
Debug::Print("Update called!");
}
}
OnComponentAttached
This function called when a component is attached to a component.
It's usefull when you need to setup the component before the Awake being called with an access to the parent GameObject.
This function is called even if the GameObject or the component are disabled compared to the Awake method.
In the constructor of your component if the component you can't get a reference to the parent GameObject.
virtual void OnComponentAttached()
Code sample:
class API MyComponent : public Component
{
public:
void OnTransformPositionUpdated();
void OnComponentAttached() override
{
GetTransformRaw()->GetOnTransformUpdated().Bind(&MyComponent::OnTransformPositionUpdated, this);
}
}
OnDisabled
This function called when a component is disabled.
virtual void OnDisabled()
Code sample:
class API MyComponent : public Component
{
public:
void OnDisabled() override
{
Debug::Print("Component disabled!");
}
}
OnEnabled
This function called when a component is enabled.
virtual void OnEnabled()
Code sample:
class API MyComponent : public Component
{
public:
void OnEnabled() override
{
Debug::Print("Component enabled!");
}
}
OnDrawGizmos
Called each frame to draw gizmos.
The parent GameObject and the component should be enabled.
virtual void OnDrawGizmos()
Code sample:
class API MyComponent : public Component
{
public:
void OnDrawGizmos() override
{
#if defined(EDITOR)
Gizmo::DrawLine(Vector3(0, 0, 0), Vector3(1, 1, 1));
#endif
}
}
OnDrawGizmosSelected
Called each frame to draw gizmos if the object is selected.
The parent GameObject and the component should be enabled.
virtual void OnDrawGizmosSelected()
Code sample:
class API MyComponent : public Component
{
public:
void OnDrawGizmosSelected() override
{
#if defined(EDITOR)
Gizmo::DrawLine(Vector3(0, 0, 0), Vector3(1, 1, 1));
#endif
}
}
ToString
Return a string representation of the component.
virtual std::string ToString()
Code sample:
class API MyComponent : public Component
{
public:
std::string ToString() override
{
return "{" + *m_componentName + ", Value: " + std::to_string(value) + "}";
}
private:
int value = 2;
}
OnCollisionEnter
Function called when a collision has just occured with another collider.
Parameters:
info
: information about the collision
virtual void OnCollisionEnter(CollisionEvent info)
Code sample:
class API MyComponent : public Component
{
public:
void OnCollisionEnter(CollisionEvent info) override
{
Debug::Print("I just hit something!");
}
}
OnCollisionStay
Function called every frame if a collider of the GameObject is still colliding with another collider.
Parameters:
info
: information about the collision
virtual void OnCollisionStay(CollisionEvent info)
Code sample:
class API MyComponent : public Component
{
public:
void OnCollisionStay(CollisionEvent info) override
{
Debug::Print("I'm still colliding with something!");
}
}
OnCollisionExit
Function called when the collision has ended.
Parameters:
info
: information about the collision
virtual void OnCollisionExit(CollisionEvent info)
Code sample:
class API MyComponent : public Component
{
public:
void OnCollisionExit(CollisionEvent info) override
{
Debug::Print("I'm not colliding with something anymore!");
}
}
OnTriggerEnter
Function called when a collider of the GameObject just entered a trigger collider.
Parameters:
info
: information about the collision
virtual void OnTriggerEnter(CollisionEvent info)
Code sample:
class API MyComponent : public Component
{
public:
void OnTriggerEnter(CollisionEvent info) override
{
Debug::Print("I just entered in a trigger!");
}
}
OnTriggerStay
Function called when a collider of the GameObject is still in a trigger collider.
Parameters:
info
: information about the collision
virtual void OnTriggerStay(CollisionEvent info)
Code sample:
class API MyComponent : public Component
{
public:
void OnTriggerStay(CollisionEvent info) override
{
Debug::Print("I'm still in a trigger!");
}
}
OnTriggerExit
Function called when a collider of the GameObject just leave a trigger collider.
Parameters:
info
: information about the collision
virtual void OnTriggerExit(CollisionEvent info)
Code sample:
class API MyComponent : public Component
{
public:
void OnTriggerExit(CollisionEvent info) override
{
Debug::Print("I'm not in a trigger anymore!");
}
}
Public methods
IsEnabled
Get if the component is enabled.
bool IsEnabled() const
Code sample:
std::shared_ptr<Component> component; // Filled variable
component->SetIsEnabled(false);
bool isEnabled = component->IsEnabled(); // = false
SetIsEnabled
Enable or disable the component.
Parameters:
isEnabled
: true to enable, false to disable
void SetIsEnabled(bool isEnabled)
Code sample:
std::shared_ptr<Component> component; // Filled variable
component->SetIsEnabled(false);
bool isEnabled = component->IsLocalActive(); // = false
GetGameObject
Get component's GameObject.
std::shared_ptr <GameObject> GetGameObject() const
Code sample:
std::shared_ptr<Component> component; // Filled variable
std::shared_ptr<GameObject> gameObject = component->GetGameObject();
GetGameObjectRaw
Get component's GameObject raw pointer for faster access (Not safe, use with caution).
GameObject* GetGameObjectRaw() const
Code sample:
std::shared_ptr<Component> component; // Filled variable
GameObject* gameObject = component->GetGameObjectRaw();
GetTransform
Get component's Transform.
std::shared_ptr<Transform> GetTransform() const
Code sample:
std::shared_ptr<Component> component; // Filled variable
std::shared_ptr<Transform> transform = component->GetTransform();
GetTransformRaw
Get component's Transform raw pointer for faster access (Not safe, use with caution).
Transform* GetTransformRaw() const
Code sample:
std::shared_ptr<Component> component; // Filled variable
Transform* transform = component->GetTransformRaw();
GetComponentName
Get component's name.
const std::string& GetComponentName() const
Code sample:
std::shared_ptr<Component> component; // Filled variable
const std::string& name = component->GetComponentName();
AudioSource
Add this in your code:
#include <engine/audio/audio_source.h>
Description
Component to play audio clips.
Public methods
Play
Play audio.
void Play()
Resume
Resume audio.
void Resume()
Pause
Pause audio.
void Pause()
Stop
Stop audio.
void Stop()
SetVolume
Set volume.
Parameters:
volume
: New volume value
void SetVolume(float volume)
SetPanning
Set panning.
Parameters:
panning
: New panning value
void SetPanning(float panning)
SetPanning
Set is looping.
Parameters:
isLooping
: New is looping value
void SetLoop(bool isLooping)
GetVolume
Get volume.
float GetVolume() const
GetPanning
Get panning.
float GetPanning() const
IsPlaying
Get is playing.
bool IsPlaying() const
IsLooping
Get is looping.
bool IsLooping() const
GetAudioClip
Get audio clip.
const std::shared_ptr<AudioClip>& GetAudioClip()
SetAudioClip
Set audio clip.
void SetAudioClip(const std::shared_ptr<AudioClip>& audioClip)
BillboardRenderer
Add this in your code:
#include <engine/graphics/2d_graphics/billboard_renderer.h>
Description
Component to render a billboard sprite (2D sprite that always faces the camera).
Public methods
GetColor
Get the color of the sprite.
const Color& GetColor() const
SetColor
Set the color of the sprite.
Parameters:
Color
: New sprite color
void SetColor(const Color& color)
GetMaterial
Get the material of the sprite.
const std::shared_ptr<Material>& GetMaterial()
SetMaterial
Set the material of the sprite.
Parameters:
material
: New sprite material
void SetMaterial(const std::shared_ptr<Material>& material)
GetTexture
Get the texture of the sprite.
const std::shared_ptr<Texture>& GetTexture()
SetTexture
Set the texture of the sprite.
Parameters:
texture
: New sprite texture
void SetTexture(const std::shared_ptr<Texture>& texture)
BoxCollider
Add this in your code:
#include <engine/physics/box_collider.h>
Description
Component to add a cube-shaped collider to a GameObject.
Public methods
SetSize
Set the size of the box collider.
Parameters:
size
: New size value
void SetSize(const Vector3& size)
SetOffset
Set the offset position of the box collider.
Parameters:
offset
: New offset value
void SetOffset(const Vector3& offset)
GetSize
Get the size of the box collider.
const Vector3& GetSize() const
GetOffset
Get the offset position of the box collider.
const Vector3& GetOffset() const
ToString
Get the size and offset of the box collider in the form of a string.
std::string ToString()
Button
Add this in your code:
#include <engine/graphics/ui/button.h>
Description
Component that renders a button on the screen.
Variables
Name | Type | Description |
---|---|---|
color | Color | Color of the sprite |
Public methods
GetOrderInLayer
Get the order in layer, higher number, higher priority.
int GetOrderInLayer() const
SetOrderInLayer
Set the order in layer.
Parameters:
orderInLayer
: Order in layer, higher number, higher priority
void SetOrderInLayer(int orderInLayer)
GetImage
Get the image.
const std::shared_ptr<Texture>& GetImage() const
SetImage
Set the image.
Parameters:
image
: Image to use
void SetImage(const std::shared_ptr<Texture>& image)
GetOnClickEvent
Get the onClick event, called when the user clicks on the button.
Event<>& GetOnClickEvent()
Code sample:
class MyClass
{
public:
void OnClick() { }
};
std::shared_ptr<Button> button; // Filled variable
MyClass myClassInstance = MyClass();
button->GetOnClickEvent().Bind(&MyClass::MyStaticFunction, &myClassInstance);
Camera
Add this in your code:
#include <engine/graphics/camera.h>
Description
Component for rendering the scene.
Public methods
SetFov
Set field of view (Perspective mode).
Parameters:
fov
: Field of view angle (in degrees)
void SetFov(const float fov)
GetFov
Get field of view in degrees.
float GetFov() const
SetProjectionSize
Set projection size (Orthographic mode).
Parameters:
value
: Projection size
void SetProjectionSize(const float value)
GetProjectionSize
Get projection size.
float GetProjectionSize() const
SetNearClippingPlane
Set near clipping plane.
Parameters:
value
: Near clipping plane
void SetNearClippingPlane(float value)
GetNearClippingPlane
Get near clipping plane.
float GetNearClippingPlane() const
SetFarClippingPlane
Set far clipping plane.
Parameters:
value
: far clipping plane
void SetFarClippingPlane(float value)
GetFarClippingPlane
Get far clipping plane.
float GetFarClippingPlane() const
ScreenTo2DWorld
Get 2D world position from pixel coordinate.
Parameters:
x
: X pixel positiony
: Y pixel position
Vector2 ScreenTo2DWorld(int x, int y)
MouseTo2DWorld
Get 2D world position from mouse's position.
ector2 MouseTo2DWorld()
SetProjectionType
Set projection type.
Parameters:
type
: Projection type
void SetProjectionType(const ProjectionType type)
GetProjectionType
Get projection type.
ProjectionType GetProjectionType() const
GetMouseRay
Get mouse normalized ray direction.
Vector3 GetMouseRay()
GetWidth
Get view width in pixel.
int GetWidth() const
GetHeight
Get view height in pixel.
int GetHeight() const
GetAspectRatio
Get view aspect ratio.
float GetAspectRatio() const
GetUseMultisampling
Get if the camera is using multisampling (Windows Only).
bool GetUseMultisampling() const
SetUseMultisampling
Set if the camera is using multisampling (Windows Only).
Parameters:
useMultisampling
: True to enable Multisampling
void SetUseMultisampling(bool useMultisampling)
GetRawFrameBuffer
Get a copy of the frame buffer.
Heavy operation, use with caution.
std::unique_ptr<uint8_t[]> GetRawFrameBuffer()
ProjectionType Enum
Add this in your code:
#include <engine/graphics/camera_projection_type.h>
Description
Enum to list every camera projection types.
Values
Name | Description |
---|---|
Perspective | A projection where objects appear smaller as they get further away |
Orthographic | A projection where objects retain their size regardless of distance |
Canvas
Add this in your code:
#include <engine/graphics/ui/canvas.h>
Description
Component to render a canvas (UI elements).
FpsCounter
Add this in your code:
#include <engine/tool/fps_counter.h>
Description
Component to display the FPS counter in the game.
Variables
Name | Type | Description |
---|---|---|
showAverage | bool | Should should average fps? |
Public methods
GetTextRenderer
Get the text renderer used for displaying the FPS.
const std::weak_ptr<TextRenderer>& GetTextRenderer()
SetTextRenderer
Set the text renderer to use for displaying the FPS.
Parameters:
textRenderer
: True to enable Multisampling
void SetTextRenderer(const std::shared_ptr<TextRenderer>& textRenderer)
ImageRenderer
Add this in your code:
#include <engine/graphics/ui/image_renderer.h>
Description
Component that renders an image on the screen.
Variables
Name | Type | Description |
---|---|---|
color | Color | Color of the image |
Public methods
GetImage
Get the image.
const std::shared_ptr<Texture>& GetImage() const
SetImage
Set the image.
Parameters:
image
: Image to use
void SetImage(const std::shared_ptr<Texture>& image)
Light
Add this in your code:
#include <engine/lighting/lighting.h>
Description
Component to produce light.
Variables
Name | Type | Description |
---|---|---|
color | Color | Color of the light |
Public methods
SetupPointLight
Setup the light as a point light.
Parameters:
color
: Light colorintensity
: Light intensityrange
: Light Range (Greater or equals to 0)
void SetupPointLight(const Color& color, float intensity, const float range)
SetupDirectionalLight
Setup the light as a directional light.
Parameters:
color
: Light colorintensity
: Light intensity
void SetupDirectionalLight(const Color& color, float intensity)
SetupAmbientLight
Setup the light as an ambient light.
Parameters:
color
: Light colorintensity
: Light intensity
void SetupAmbientLight(const Color& color, const float intensity)
SetupSpotLight
Setup the light as a spot light.
Parameters:
color
: Light colorintensity
: Light intensityrange
: Light Range (Greater or equals to 0)angle
: Spot angle [0;90]
void SetupSpotLight(const Color& color, const float intensity, const float range, const float angle)
SetupSpotLight
Setup the light as a spot light.
Parameters:
color
: Light colorintensity
: Light intensityrange
: Light Range (Greater or equals to 0)angle
: Spot angle [0;90]smoothness
: Spot smoothness [0;1]
void SetupSpotLight(const Color& color, const float intensity, const float range, const float angle, const float smoothness)
SetupSpotLight
Set light range.
Parameters:
value
: Light range (Greater or equals to 0)
void SetRange(float value)
SetSpotAngle
Set spot angle.
Parameters:
value
: Spot angle [0;90]
void SetSpotAngle(float angle)
SetSpotSmoothness
Set spot smoothness.
Parameters:
value
: Spot smoothness [0;1]
void SetSpotSmoothness(float smoothness)
GetType
Get light type.
LightType GetType() const
GetType
Set light type.
Parameters:
type
: Light type
void SetType(LightType type)
GetIntensity
Get light intensity.
float GetIntensity() const
SetIntensity
Set light intensity.
Parameters:
intensity
: Light intensity
void SetIntensity(float intensity)
GetOldConsoleCompatibility
Get if the light should simulate lighting from old consoles (To get the same behavior as PSP)y.
bool GetOldConsoleCompatibility() const
SetOldConsoleCompatibility
Set if the light should simulate lighting from old consoles (To get the same behavior as PSP).
Parameters:
value
: New value
void SetOldConsoleCompatibility(bool value)
Lod
Add this in your code:
#include <engine/graphics/3d_graphics/lod.h>
Description
Component to manage Level of Detail (LOD) for a GameObject.
MeshRenderer
Add this in your code:
#include <engine/graphics/3d_graphics/mesh_renderer.h>
Description
Component that renders a mesh with materials.
Public methods
GetMeshData
Get mesh data.
const std::shared_ptr<MeshData>& GetMeshData() const
SetMeshData
Set mesh data.
Parameters:
meshData
: Mesh data to use
void SetMeshData(const std::shared_ptr <MeshData>& meshData)
GetMaterials
Get materials list.
std::vector<std::shared_ptr<Material>> GetMaterials() const
GetMaterial
Get a material at a specific index.
Parameters:
index
: Index of the material
std::shared_ptr<Material> GetMaterial(int index) const
SetMeshData
Set a material at a specific index.
Parameters:
material
: Material to useindex
: Index of the material
void SetMaterial(const std::shared_ptr <Material>& material, int index)
GetBoundingSphere
Get the bounding sphere of the mesh.
const Sphere& GetBoundingSphere() const
GetUseAdvancedLighting
Get if the mesh can use advanced lighting (point lights, spot lights), improve performance if disabled.
bool GetUseAdvancedLighting() const
SetUseAdvancedLighting
Set if the mesh can use advanced lighting (point lights, spot lights), improve performance if disabled.
Parameters:
value
: Enable advanced lighting?
void SetUseAdvancedLighting(bool value)
MissingScript
Description
Special component used when a script is not found. It stores data of the previous working component to avoid data loss when saving the scene. The user cannot instantiate this component.
It's used when:
- A script has been deleted,
- A script has been renamed,
- The game is not compiled.
ParticleSystem
Add this in your code:
#include <engine/particle_system/particle_system.h>
Description
Component to spawn particles.
Public methods
Play
Emitte all particles when not in loop mode.
void Play()
ResetParticles
Remove all particles and restart the emission.
void ResetParticles()
IsEmitting
Get if the particle system is emitting particles.
bool IsEmitting() const
SetIsEmitting
Set if the particle system is emitting particles.
Parameters:
isEmitting
: Light color
void SetIsEmitting(bool isEmitting)
GetSpawnRate
Get the particle spawn rate.
float GetSpawnRate() const
SetIsEmitting
Set the particle spawn rate.
Parameters:
spawnRate
: Number of particules per seconds
void SetSpawnRate(float spawnRate)
SetScaleOverLifeTimeFunction
Set you own function to set the global scale of the particle over its life time.
The function takes the life time ratio [0;1] and return the scale of the particle.
Parameters:
function
: function The function to set, should be static (nullptr to use the default function)
void SetScaleOverLifeTimeFunction(float (*function)(float))
Code sample:
float GetScaleOverLifeTime(float lifeTime)
{
return std::sin(lifeTime * Math::PI); // Default function in every particle systems
}
std::shared_ptr<ParticleSystem> particleSystem;
particleSystem->SetScaleOverLifeTimeFunction(&GetScaleOverLifeTime);
SetSpeedMultiplierOverLifeTimeFunction
Set you own function to set the speed multiplier of the particle over its life time.
The function takes the life time ratio [0;1] and return the speed multiplier of the particle.
Parameters:
function
: function The function to set, should be static (nullptr to use the default function)
void SetSpeedMultiplierOverLifeTimeFunction(float (*function)(float))
Code sample:
float GetSpeedOverLifeTime(float lifeTime)
{
return 1; // Default function in every particle systems
}
std::shared_ptr<ParticleSystem> particleSystem;
particleSystem->SetScaleOverLifeTimeFunction(&GetSpeedOverLifeTime);
SetColorOverLifeTimeFunction
Set you own function to set the color of the particle over its life time.
The function takes the life time ratio [0;1] and return the color of the particle.
x = red, y = green, z = blue, w = alpha (0 to 1).
Parameters:
function
: function The function to set, should be static (nullptr to use the default function)
void SetColorOverLifeTimeFunction(Vector4 (*function)(float))
Code sample:
Vector4 GetColorOverLifeTime(float lifeTime)
{
return Vector4(1, 1, 1, std::sin(lifeTime * Math::PI)); // Default function in every particle systems
}
std::shared_ptr<ParticleSystem> particleSystem;
particleSystem->SetScaleOverLifeTimeFunction(&GetColorOverLifeTime);
RectTransform
Add this in your code:
#include <engine/game_elements/rect_transform.h>
Description
Component that represents a transform for UI elements.
Variables
Name | Type | Description |
---|---|---|
position | Vector2 | Position of the UI elements between 0 and 1 (Normalized position) |
RigidBody
Add this in your code:
#include <engine/physics/rigidbody.h>
Description
Component to add physics to the GameObject.
Public Methods
GetVelocity
Get the velocity.
const Vector3& GetVelocity() const
SetVelocity
Set the velocity.
Parameters:
velocity
: New velocity
void SetVelocity(const Vector3& velocity)
GetTorque
Get the torque applied to the rigidbody.
Vector3 GetTorque() const
ApplyTorque
Apply torque.
Parameters:
torque
: Torque to apply
void ApplyTorque(const Vector3& torque)
GetAngularVelocity
Get the angular velocity.
Vector3 GetAngularVelocity() const
SetAngularVelocity
Set the angular velocity.
Parameters:
angularVelocity
: Angular velocity to set
void SetAngularVelocity(const Vector3& angularVelocity)
AddAngularVelocity
Add angular velocity.
Parameters:
angularVelocity
: Angular velocity to add
void AddAngularVelocity(const Vector3& angularVelocity)
GetDrag
Get the drag value.
float GetDrag() const
SetDrag
Set the drag value.
Parameters:
drag
: Drag value to set
void SetDrag(float drag)
GetAngularDrag
Get the angular drag value.
float GetAngularDrag() const
SetAngularDrag
Set the angular drag value.
Parameters:
angularDrag
: Angular drag value to set
void SetAngularDrag(float angularDrag)
GetBounce
Get the bounce value.
float GetBounce() const
SetBounce
Set the bounce value.
Parameters:
bounce
: Bounce value to set
void SetBounce(float bounce)
GetGravityMultiplier
Get the gravity multiplier.
float GetGravityMultiplier() const
SetGravityMultiplier
Set the gravity multiplier.
Parameters:
gravityMultiplier
: Gravity multiplier value to set
void SetGravityMultiplier(float gravityMultiplier)
IsStatic
Get if the rigidbody is static.
float IsStatic() const
SetIsStatic
Set if the rigidbody is static.
Parameters:
isStatic
: Is static value to set
void SetIsStatic(float isStatic)
GetMass
Get the mass of the rigidbody.
float GetMass() const
SetMass
Set the mass of the rigidbody.
Parameters:
mass
: Mass value to set
void SetMass(float mass)
GetFriction
Get the friction value.
float GetFriction() const
SetFriction
Set the friction value.
Parameters:
friction
: Friction value to set
void SetFriction(float friction)
Activate
Activate the rigidbody (used to wake up the rigidbody if it was sleeping).
void Activate()
GetLockedMovementAxis
Get locked movement axis.
const LockedAxis& GetLockedMovementAxis() const
SetLockedMovementAxis
Set locked movement axis.
Parameters:
axis
: Axis to lock
void SetLockedMovementAxis(LockedAxis axis)
GetLockedMovementAxis
Get locked rotation axis.
const LockedAxis& GetLockedRotationAxis() const
SetLockedMovementAxis
Set locked rotation axis.
Parameters:
axis
: Axis to lock
void SetLockedMovementAxis(LockedAxis axis)
SphereCollider
Add this in your code:
#include <engine/physics/sphere_collider.h>
Description
Component to add a sphere-shaped collider to a GameObject.
Public Methods
GetSize
Get the radius of the sphere collider.
float GetSize() const
SetSize
Set the radius of the sphere collider.
Parameters:
size
: Radius of the sphere
void SetSize(float size)
GetOffset
Get the offset position of the sphere collider.
const Vector3& GetOffset() const
SetOffset
Set the offset position of the sphere collider.
Parameters:
offset
: Offset position of the sphere
void SetOffset(const Vector3& offset)
SpriteRenderer
Add this in your code:
#include <engine/graphics/2d_graphics/sprite_renderer.h>
Description
Component that renders a sprite with a texture and material.
Public Methods
GetColor
Get the color of the sprite.
const Color& GetColor() const
SetColor
Set the color of the sprite.
Parameters:
color
: New color
void SetColor(const Color& color)
GetMaterial
Get the material of the sprite.
const std::shared_ptr<Material>& GetMaterial() const
SetMaterial
Set the material of the sprite.
Parameters:
material
: New material
void SetMaterial(const std::shared_ptr<Material>& material)
GetTexture
Get the texture of the sprite.
const std::shared_ptr<Texture>& GetTexture() const
SetTexture
Set the texture of the sprite.
Parameters:
texture
: New texture
void SetTexture(const std::shared_ptr<Texture>& texture)
TextMesh
Add this in your code:
#include <engine/graphics/ui/text_mesh.h>
Description
Component for rendering text in 3D space.
Public methods
GetOrderInLayer
Get the order in layer, higher number, higher priority.
int GetOrderInLayer() const
SetOrderInLayer
Set the order in layer.
Parameters:
orderInLayer
: Order in layer, higher number, higher priority
void SetOrderInLayer(int orderInLayer)
GetColor
Get the color of the sprite.
const Color& GetColor() const
SetColor
Set the color of the sprite.
Parameters:
Color
: New sprite color
void SetColor(const Color& color)
GetText
Get text.
const std::string& GetText() const
SetText
Set text.
Parameters:
text
: New text
void SetText(const std::string& text)
GetFont
Get text font.
const std::shared_ptr<Font>& GetFont() const
SetFont
Set text font.
Parameters:
font
: New font
void SetFont(const std::shared_ptr<Font>& font)
GetMaterial
Get the material of the sprite.
const std::shared_ptr<Material>& GetMaterial()
SetMaterial
Set the material of the sprite.
Parameters:
material
: New sprite material
void SetMaterial(const std::shared_ptr<Material>& material)
GetFontSize
Get the font size.
float GetFontSize() const
SetFontSize
Set the font size.
Parameters:
fontSize
: New font size
void SetFontSize(float fontSize)
GetLineSpacing
Get the line spacing.
float GetLineSpacing() const
SetLineSpacing
Set the line spacing.
Parameters:
lineSpacing
: New line spacing
void SetLineSpacing(float lineSpacing)
GetCharacterSpacing
Get the character spacing.
float GetCharacterSpacing() const
SetCharacterSpacing
Set the character spacing.
Parameters:
characterSpacing
: New character spacing
void SetCharacterSpacing(float characterSpacing)
GetVerticalAlignment
Get the vertical alignment.
VerticalAlignment GetVerticalAlignment() const
SetVerticalAlignment
Set the vertical alignment.
Parameters:
verticalAlignment
: New vertical alignment
void SetVerticalAlignment(VerticalAlignment verticalAlignment)
GetHorizontalAlignment
Get the horizontal alignment.
HorizontalAlignment GetHorizontalAlignment() const
SetHorizontalAlignment
Set the horizontal alignment.
Parameters:
horizontalAlignment
: New horizontal alignment
void SetHorizontalAlignment(HorizontalAlignment horizontalAlignment)
TextRenderer
Add this in your code:
#include <engine/graphics/ui/text_renderer.h>
Description
Component for rendering text in a canvas.
Public methods
GetOrderInLayer
Get the order in layer, higher number, higher priority.
int GetOrderInLayer() const
SetOrderInLayer
Set the order in layer.
Parameters:
orderInLayer
: Order in layer, higher number, higher priority
void SetOrderInLayer(int orderInLayer)
GetColor
Get the color of the sprite.
const Color& GetColor() const
SetColor
Set the color of the sprite.
Parameters:
Color
: New sprite color
void SetColor(const Color& color)
GetText
Get text.
const std::string& GetText() const
SetText
Set text.
Parameters:
text
: New text
void SetText(const std::string& text)
GetFont
Get text font.
const std::shared_ptr<Font>& GetFont() const
SetFont
Set text font.
Parameters:
font
: New font
void SetFont(const std::shared_ptr<Font>& font)
GetMaterial
Get the material of the sprite.
const std::shared_ptr<Material>& GetMaterial()
SetMaterial
Set the material of the sprite.
Parameters:
material
: New sprite material
void SetMaterial(const std::shared_ptr<Material>& material)
GetFontSize
Get the font size.
float GetFontSize() const
SetFontSize
Set the font size.
Parameters:
fontSize
: New font size
void SetFontSize(float fontSize)
GetLineSpacing
Get the line spacing.
float GetLineSpacing() const
SetLineSpacing
Set the line spacing.
Parameters:
lineSpacing
: New line spacing
void SetLineSpacing(float lineSpacing)
GetCharacterSpacing
Get the character spacing.
float GetCharacterSpacing() const
SetCharacterSpacing
Set the character spacing.
Parameters:
characterSpacing
: New character spacing
void SetCharacterSpacing(float characterSpacing)
GetVerticalAlignment
Get the vertical alignment.
VerticalAlignment GetVerticalAlignment() const
SetVerticalAlignment
Set the vertical alignment.
Parameters:
verticalAlignment
: New vertical alignment
void SetVerticalAlignment(VerticalAlignment verticalAlignment)
GetHorizontalAlignment
Get the horizontal alignment.
HorizontalAlignment GetHorizontalAlignment() const
SetHorizontalAlignment
Set the horizontal alignment.
Parameters:
horizontalAlignment
: New horizontal alignment
void SetHorizontalAlignment(HorizontalAlignment horizontalAlignment)
DateTime
Add this in your code:
#include <engine/time/date_time.h>
This class represents an instant in time.
Static methods
GetNow
Get the current date and time.
DateTime GetNow()
Code sample:
DateTime currentDateTime = DateTime::GetNow();
Public methods
ToString
Get a string representation of the date and time in the format: "hour:minute:second day/month/year".
std::string ToString() const
Code sample:
DateTime currentDateTime = DateTime::GetNow();
Debug::Print(currentDateTime.ToString());
// Prints: "12:49:53 31/5/2025"
Variables
Name | Type | Description |
---|---|---|
second | uint32_t | Number of seconds |
minute | uint32_t | Number of minutes |
hour | uint32_t | Number of hours |
day | uint32_t | Number of days |
month | uint32_t | Number of months |
year | uint32_t | Number of years |
Debug
Add this in your code:
#include <engine/debug/debug.h>
Description
Class used to print text in the console and in file or remotely to a server (Server part is removed for now).
You can find logs in the xenity_engine_debug.txt
file.
The file will be created in the same folder of the executable file.
For PsVita the file will be created in ux0:data/xenity_engine/
.
Static methods
Print a text.
Parameters:
text
: Text to printhideInEditorConsole
: If true, the text will not be printed in the editor's console
void Print(const std::string& text, bool hideInEditorConsole = false)
Code sample:
Debug::Print("Hello World!"); // Printed in both console and file
Debug::Print("Hello file!", true); // Only printed in the file
PrintWarning
Print a warning.
Parameters:
text
: Text to printhideInEditorConsole
: If true, the text will not be printed in the editor's console
void PrintWarning(const std::string& text, bool hideInEditorConsole = false)
Code sample:
Debug::PrintWarning("I'm a warning.");
// Prints: "[WARNING] I'm a warning."
PrintError
Print an error.
Parameters:
text
: Text to printhideInEditorConsole
: If true, the text will not be printed in the editor's console
void PrintError(const std::string& text, bool hideInEditorConsole = false)
Code sample:
Debug::PrintError("You can't do that!");
// Prints: "[ERROR] You can't do that!"
GetOnDebugLogEvent
Get the event when a debug message is printed.
Event<const std::string&, DebugType>& GetOnDebugLogEvent()
Code sample:
void OnLog(const std::string& text, DebugType debugType)
{
// ...
}
Debug::GetOnDebugLogEvent().Bind(&OnLog);
Debug::PrintWarning("I'm a warning");
Debug::GetOnDebugLogEvent().Unbind(&OnLog);
// OnLog will be called with "I'm a warning" and DebugType::Warning as parameters
Enumerations
Add this in your code:
#include <engine/reflection/enum_utils.h>
If you want to create an enum visible by the editor inspector, you have to use Xenity's custom enums.
ENUM(MyEnum, Value0, Value1, Value2);
You can assigan values to each elements:
ENUM(MyEnum, Value0 = 1, Value1 = 3, Value2 = 8);
The type of value of an enum element is int
.
You are allowed to create a classic C++ enum class, but you won't be able to use it in the inspector.
Event
Add this in your code:
#include <engine/event_system/event_system.h>
Description
This class gives the possibility to bind a function to an event.
When a event object is destroyed, all bound functions are unbound.
This class is using templates.
warning
If your bound functions reference an object that is about to be destroyed, make sure to unbind them manually beforehand.
Failing to do so may lead to undefined behavior such as accessing dangling pointers or crashing the application.
template<typename... Args>
class Event
Event without argument:
Event<> myEvent;
Event with arguments:
Event<int, const std::string&> myEvent;
Public methods
Bind
Bind a simple function.
Parameters:
function
: Pointer to the function to bind
void Bind(void(*function)(Args...))
Code sample:
void MyFunction(int a, const std::string& b) { }
class MyClass
{
public:
static void MyStaticFunction(int a, const std::string& b) { }
};
Event<int, const std::string&> myEvent;
myEvent.Bind(&MyFunction);
myEvent.Bind(&MyClass::MyStaticFunction);
Bind
Bind a function linked to an object.
Parameters:
function
: Pointer to the function to bindobj
: Pointer to the object
template<typename ObjType>
void Bind(void(ObjType::* function)(Args...), ObjType* obj)
Code sample:
class MyClass
{
public:
void MyFunction(int a, const std::string& b) { }
};
MyClass myClassInstance;
Event<int, const std::string&> myEvent;
myEvent.Bind(&MyClass::MyFunction, &myClassInstance);
Unbind
Unbind a simple function.
Parameters:
function
: Pointer to the function to unbind
void Unbind(void(*function)(Args...))
Code sample:
void MyFunction(int a, const std::string& b) { }
class MyClass
{
public:
static void MyStaticFunction(int a, const std::string& b) { }
};
Event<int, const std::string&> myEvent;
myEvent.Bind(&MyFunction);
myEvent.Bind(&MyClass::MyStaticFunction);
//...
myEvent.Unbind(&MyFunction);
myEvent.Unbind(&MyClass::MyStaticFunction);
Unbind
Unbind a function linked to an object.
Parameters:
function
: Pointer to the function to unbindobj
: Pointer to the object
template<typename ObjType>
void Unbind(void(ObjType::* function)(Args...), ObjType* obj)
Code sample:
class MyClass
{
public:
void MyFunction(int a, const std::string& b) { }
};
MyClass myClassInstance;
Event<int, const std::string&> myEvent;
myEvent.Bind(&MyClass::MyFunction, &myClassInstance);
//...
myEvent.Unbind(&MyClass::MyFunction, &myClassInstance);
UnbindAll
Unbind all bound function.
void UnbindAll()
Code sample:
void MyFunction(int a, const std::string b) { }
Event<int, const std::string&> myEvent;
myEvent.Bind(&MyFunction);
//...
myEvent.UnbindAll();
Trigger
Call all bound functions.
Parameters:
args
: All arguments to send
void Trigger(Args... args)
Code sample:
void MyFunction(int a, const std::string b) { }
Event<int, const std::string&> myEvent;
myEvent.Bind(&MyFunction);
myEvent.Trigger(1, "Hello World!");
GetBoundFunctionCount
Get the number of listener.
size_t GetBoundFunctionCount()
Code sample:
void MyFunction(int a, const std::string b) { }
void MyFunction2(int a, const std::string b) { }
Event<int, const std::string&> myEvent;
myEvent.Bind(&MyFunction);
myEvent.Bind(&MyFunction2);
size_t count = myEvent.GetBoundFunctionCount(); // count = 2
FileSystem
Add this in your code:
#include <engine/file_system/file_system.h>
Description
This class provides methods to manipulate files and directories.
Static methods
CreateFolder
Create a directory.
Create parents directories if they do not exist.
Returns true on success.
Parameters:
path
: Path of the folder to create
bool CreateFolder(const std::string& path)
Code sample:
FileSystem::CreateFolder("C:/my_folder/");
Delete
Delete a file or a directory.
Parameters:
path
: Path of file or folder
void Delete(const std::string& path)
Code sample:
FileSystem::Delete("C:/my_folder/my_file.txt");
FileSystem::Delete("C:/my_folder/");
Rename
Rename a file or a directory (Not currently supported on PSP and PS3).
Returns true on success.
Parameters:
path
: File path to renamenewPath
: New file path (should be in the same directory)
bool Rename(const std::string& path, const std::string& newPath)
Code sample:
FileSystem::Rename(
"C:/my_folder/my_file.txt",
"C:/my_folder/my_renamed_file.txt");
CopyFile
Copy a file to a new path (Not currently supported on PS3).
Parameters:
path
: File path to copynewPath
: File destination pathreplace
: If true, replace the file if it already exists
CopyFileResult CopyFile(const std::string& path, const std::string& newPath, bool replace)
Code sample:
CopyFileResult result = FileSystem::CopyFile(
"C:/my_folder/my_file.txt",
"C:/my_folder/my_copied_file.txt"
false); // Result is Success
// Do it again, this time the result will be "FileAlreadyExists"
CopyFileResult result = FileSystem::CopyFile(
"C:/my_folder/my_file.txt",
"C:/my_folder/my_copied_file.txt"
false);
MakeFile
Create a File object from a path (Do not create the file on the system).
Parameters:
path
: File path (Relative or absolute)
std::shared_ptr<File> MakeFile(const std::string& path)
Code sample:
std::shared_ptr<File> file = FileSystem::MakeFile("C:/my_folder/my_file.txt");
if(file->Open(FileMode::WriteCreateFile))
{
// File created thanks to the WriteCreateFile option
}
MakeDirectory
Create a Directory object from a path (Do not create the directory on the system).
Parameters:
path
: Directory path (Relative or absolute)
std::shared_ptr<Directory> MakeDirectory(const std::string& path)
Code sample:
std::shared_ptr<Directory> directory = FileSystem::MakeDirectory("C:/my_folder/");
ConvertWindowsPathToBasicPath
Converts all backslashes ('\') to forward slashes ('/') in the given path.
Parameters:
path
: Path to convert
std::string ConvertWindowsPathToBasicPath(const std::string& path)
Code sample:
Debug::Print(FileSystem::ConvertWindowsPathToBasicPath("C:\\my_folder\\"));
// Prints "C:/my_folder/"
ConvertBasicPathToWindowsPath
Converts all forward slashes ('/') to backslashes ('\') in the given path.
Parameters:
path
: Path to convert
std::string ConvertBasicPathToWindowsPath(const std::string& path)
Code sample:
Debug::Print(FileSystem::ConvertBasicPathToWindowsPath("C:/my_folder/"));
// Prints "C:\my_folder\"
File
Add this in your code:
#include <engine/file_system/file.h>
Description
Class to manage a file (Create, open, read, write).
Public methods
Open
Open the file.
Return true if the file is opened successfully.
Parameters:
fileMode
: The mode to open the file
bool Open(FileMode fileMode)
Code sample:
std::shared_ptr<File> file = FileSystem::MakeFile("C:/my_folder/my_file.txt");
if(file->Open(FileMode::ReadOnly))
{
}
CheckIfExist
Check if the file exists.
Return true if the file exists.
bool CheckIfExist()
Code sample:
std::shared_ptr<File> file = FileSystem::MakeFile("C:/my_folder/my_file.txt");
if(file->CheckIfExist())
{
}
Close
Close file.
bool Close()
Code sample:
std::shared_ptr<File> file = FileSystem::MakeFile("C:/my_folder/my_file.txt");
if(file->Open(FileMode::ReadOnly))
{
// ...
file->Close();
}
Write (String)
Write string data to the file.
Parameters:
data
: The data to write
void Write(const std::string& data)
Code sample:
std::shared_ptr<File> file = FileSystem::MakeFile("my_file.txt");
if(file->Open(FileMode::WriteCreateFile))
{
// ...
file->Write("Hello World!");
}
Write (Binary)
Write binary data to the file.
Parameters:
data
: The data to writesize
: The size of the data in byte
void Write(const unsigned char* data, size_t size)
Code sample:
std::shared_ptr<File> file = FileSystem::MakeFile("my_file.bin");
if(file->Open(FileMode::WriteCreateFile))
{
uint32_t value = 44;
// ...
file->Write(&value, sizeof(uint32_t));
}
ReadAll
Read all the content of the file as a string.
std::string ReadAll()
Code sample:
std::shared_ptr<File> file = FileSystem::MakeFile("my_file.txt");
if(file->Open(FileMode::ReadOnly))
{
std::string content = file->ReadAll();
}
ReadAllBinary
Read all the content of the file as a binary (Need to free the pointer after).
Parameters:
size
: Output: The size of the binary in byte
unsigned char* ReadAllBinary(size_t& size)
Code sample:
std::shared_ptr<File> file = FileSystem::MakeFile("my_file.bin");
if(file->Open(FileMode::ReadOnly))
{
size_t size = 0;
unsigned char* content = file->ReadAllBinary(size);
// ...
free(content);
}
ReadBinary
Read a part of the content of the file as a binary (Need to free the pointer after).
Parameters:
offset
: Read offset in bytesize
: The size to read in byte
unsigned char* ReadBinary(size_t offset, size_t size)
Code sample:
std::shared_ptr<File> file = FileSystem::MakeFile("my_file.bin");
if(file->Open(FileMode::ReadOnly))
{
unsigned char* content = file->ReadBinary(4, 30);
// ...
free(content);
}
GetPath
Get file path.
const std::string& GetPath() const
Code sample:
std::shared_ptr<File> file = FileSystem::MakeFile("C:/my_folder/my_file.txt");
std::string filePath = file->GetPath(); // = C:/my_folder/my_file.txt
GetFolderPath
Get file folder path.
std::string GetFolderPath() const
Code sample:
std::shared_ptr<File> file = FileSystem::MakeFile("C:/my_folder/my_file.txt");
std::string filePath = file->GetFolderPath(); // = C:/my_folder/
GetFileName
Get file name.
const std::string& GetFileName() const
Code sample:
std::shared_ptr<File> file = FileSystem::MakeFile("C:/my_folder/my_file.txt");
std::string filePath = file->GetFileName(); // = my_file
GetFileExtension
Get file extension (dot included).
const std::string& GetFileExtension() const
Code sample:
std::shared_ptr<File> file = FileSystem::MakeFile("C:/my_folder/my_file.txt");
std::string filePath = file->GetFileExtension(); // = .txt
FileMode Enum
Add this in your code:
#include <engine/file_system/file.h>
Description
Enum that list every modes to open a file.
Values
Name | Description |
---|---|
ReadOnly | Only read calls are allowed |
WriteOnly | Only write calls are allowed |
WriteCreateFile | Only read calls are allowed and the file is created if it does not exist |
Directory
Add this in your code:
#include <engine/file_system/directory.h>
Description
Class to manage a directory (Get all files of a folder).
Variables
Name | Type | Description |
---|---|---|
subdirectories | std::vector<std::shared_ptr<Directory>> | List of sub directories (filled with GetAllFiles) |
files | std::vector<std::shared_ptr<File>> | List of files (filled with GetAllFiles) |
Public methods
GetAllFiles
Get all the files of the directory (can be very slow and not currently supported on PS3).
Parameters:
recursive
: If true, get all the files of the subdirectories
std::vector<std::shared_ptr<File>> GetAllFiles(bool recursive)
Code sample:
std::shared_ptr<Directory> directory = FileSystem::MakeDirectory("C:/my_folder/");
std::vector<std::shared_ptr<File>> files = directory->GetAllFiles(true);
CheckIfExist
Check if the directory exists.
bool CheckIfExist() const
Code sample:
std::shared_ptr<Directory> directory = FileSystem::MakeDirectory("C:/my_folder/");
bool directoryExists = directory->CheckIfExist();
GetPath
Get directory path.
const std::string& GetPath() const
Code sample:
std::shared_ptr<Directory> directory = FileSystem::MakeDirectory("C:/my_folder/");
const std::string& path = directory->GetPath(); // = "C:/my_folder/"
CopyFileResult Enum
Add this in your code:
#include <engine/file_system/file_system.h>
Description
Enum to list every different results of a file copy call.
Values
Name | Description |
---|---|
Success | File copied successfully. |
Failed | Failed to copy the file. |
FileAlreadyExists | The file already exists. Enable the replace option. |
GameObject
Add this in your code:
#include <engine/game_elements/gameobject.h>
Description
A GameObject is a class that contains some properties and a list of components.
Includes functions to create GameObjects.
Global Methods
CreateGameObject
Create a GameObject with the default name.
std::shared_ptr<GameObject> CreateGameObject()
Code sample:
std::shared_ptr<GameObject> myGameObject = CreateGameObject();
Debug::Print(myGameObject->GetName()); // Prints "GameObject"
CreateGameObject
Create a GameObject.
Parameters:
name
: Name of the GameObject
std::shared_ptr<GameObject> CreateGameObject(const std::string& name)
Code sample:
std::shared_ptr<GameObject> myGameObject = CreateGameObject("Player");
Debug::Print(myGameObject->GetName()); // Prints "Player"
FindGameObjectByName
Find a GameObject with a name.
Parameters:
name
: Name of the GameObject
std::shared_ptr<GameObject> FindGameObjectByName(const std::string& name)
Code sample:
std::shared_ptr<GameObject> myGameObject = CreateGameObject("Player");
std::shared_ptr<GameObject> result = FindGameObjectByName("Player");
if(myGameObject == result)
{
Debug::Print("GameObject found!");
}
FindGameObjectsByName
Find GameObjects with a name.
Parameters:
name
: Name of the GameObject
std::vector<std::shared_ptr<GameObject>> FindGameObjectsByName(const std::string& name)
Code sample:
std::shared_ptr<GameObject> myGameObject = CreateGameObject("Player");
std::shared_ptr<GameObject> myGameObject2 = CreateGameObject("Player");
std::vector<std::shared_ptr<GameObject>> results = FindGameObjectsByName("Player");
if(results.size() == 2)
{
Debug::Print("Players found!");
}
FindGameObjectById
Find a GameObject with an id.
Parameters:
id
: Unique id of the GameObject
std::shared_ptr<GameObject> FindGameObjectById(const uint64_t id)
Code sample:
std::shared_ptr<GameObject> myGameObject = CreateGameObject("Player");
std::shared_ptr<GameObject> result = FindGameObjectById(myGameObject->GetUniqueId());
if(myGameObject == result)
{
Debug::Print("GameObject found!");
}
FindComponentById
Find a component with an id.
Parameters:
id
: Unique id of the component
std::shared_ptr<GameObject> FindComponentById(const uint64_t id)
Code sample:
std::shared_ptr<GameObject> myGameObject = CreateGameObject("Player");
std::shared_ptr<AudioSource> myAudioSource = myGameObject->AddComponent<AudioSource>();
std::shared_ptr<Component> result = FindComponentById(myAudioSource->GetUniqueId());
if(myAudioSource == result)
{
std::shared_ptr<AudioSource> resultAudioSource = std::dynamic_pointer_cast<AudioSource>(result);
Debug::Print("Component found!");
}
Pubic Methods
AddChild
Add a child to the GameObject.
Parameters:
gameObject
: Child to add
void AddChild(const std::shared_ptr<GameObject>& gameObject)
Code sample:
std::shared_ptr<GameObject> myGameObject = CreateGameObject("Player");
std::shared_ptr<GameObject> myChild = CreateGameObject("Gun");
myGameObject->AddChild(myChild);
SetParent
Set GameObject's parent.
Parameters:
gameObject
: New parent
void SetParent(const std::shared_ptr<GameObject>& gameObject)
Code sample:
std::shared_ptr<GameObject> player0 = CreateGameObject("Player");
std::shared_ptr<GameObject> player1 = CreateGameObject("Player");
std::shared_ptr<GameObject> parent = CreateGameObject("Players");
player0->SetParent(parent);
player1->SetParent(parent);
AddComponent
Add a component.
T
is a component type
template <typename T>
AddComponent()
Code sample:
std::shared_ptr<GameObject> gameObject = CreateGameObject();
std::shared_ptr<Light> lightComp = gameObject->AddComponent<Light>();
std::shared_ptr<AudioSource> audioSourceComp = gameObject->AddComponent<AudioSource>();
GetComponent
Get a component.
T
is a component type
template <typename T>
GetComponent()
Code sample:
std::shared_ptr<GameObject> gameObject = CreateGameObject();
std::shared_ptr<Light> lightComp = gameObject->AddComponent<Light>();
std::shared_ptr<Light> comp = gameObject->GetComponent<Light>();
GetComponents
Get components.
T
is a component type
template <typename T>
GetComponents()
Code sample:
std::shared_ptr<GameObject> gameObject = CreateGameObject();
std::shared_ptr<Light> lightComp = gameObject->AddComponent<Light>();
std::shared_ptr<Light> lightComp2 = gameObject->AddComponent<Light>();
std::vector<std::shared_ptr<Light>> lightsComp = gameObject->GetComponents<Light>();
IsActive
Get if the GameObject is marked as active.
bool IsActive() const
Code sample:
std::shared_ptr<GameObject> gameObject = CreateGameObject();
gameObject->SetActive(false);
bool isActive = gameObject->IsActive(); // = false
//....
std::shared_ptr<GameObject> gameObject = CreateGameObject();
std::shared_ptr<GameObject> child = CreateGameObject();
child->SetParent(child);
gameObject->SetActive(false);
bool isActive = child->IsActive(); // = true
IsLocalActive
Get if the GameObject is active based on his parents active state.
bool IsLocalActive() const
Code sample:
std::shared_ptr<GameObject> gameObject = CreateGameObject();
gameObject->SetActive(false);
bool isActive = gameObject->IsLocalActive(); // = false
//....
std::shared_ptr<GameObject> gameObject = CreateGameObject();
std::shared_ptr<GameObject> child = CreateGameObject();
child->SetParent(child);
gameObject->SetActive(false);
bool isActive = child->IsLocalActive(); // = false
SetActive
Set GameObject as active or not.
Parameters:
active
: Active value
void SetActive(const bool active)
Code sample:
std::shared_ptr<GameObject> gameObject = CreateGameObject();
gameObject->SetActive(false);
bool isActive = gameObject->IsActive(); // = false
GetChildrenCount
Get children count.
uint32_t GetChildrenCount() const
Code sample:
std::shared_ptr<GameObject> gameObject = CreateGameObject();
std::shared_ptr<GameObject> child0 = CreateGameObject();
std::shared_ptr<GameObject> child1 = CreateGameObject();
gameObject->AddChild(child0);
gameObject->AddChild(child1);
uint32_t count = gameObject->GetChildrenCount(); // = 2
GetComponentCount
Get component count.
uint32_t GetComponentCount() const
Code sample:
std::shared_ptr<GameObject> gameObject = CreateGameObject();
gameObject->AddComponent<Light>();
gameObject->AddComponent<Light>();
gameObject->AddComponent<Light>();
uint32_t count = gameObject->GetComponentCount(); // = 3
GetTransform
Get transform.
const std::shared_ptr<Transform>& GetTransform() const
Code sample:
std::shared_ptr<GameObject> gameObject = CreateGameObject();
const std::shared_ptr<Transform>& transform = gameObject->GetTransform();
GetParent
Get parent GameObject.
const std::weak_ptr<GameObject>& GetParent() const
Code sample:
std::shared_ptr<GameObject> gameObject = CreateGameObject();
const std::weak_ptr<GameObject>& parent = gameObject->GetParent();
if(!parent.expired())
{
Debug::Print("The gameobject does not have a parent");
}
else
{
Debug::Print("The gameobject has a parent");
}
GetChild
Get a child by index.
Parameters:
index
: Child index
std::weak_ptr<GameObject> GetChild(int index)
Code sample:
std::shared_ptr<GameObject> gameObject = CreateGameObject();
std::shared_ptr<GameObject> child0 = CreateGameObject();
std::shared_ptr<GameObject> child1 = CreateGameObject();
gameObject->AddChild(child0);
gameObject->AddChild(child1);
std::weak_ptr<GameObject> weakChild1 = gameObject->GetChild(1);
std::shared_ptr<GameObject> sharedChild1 = weakChild1.lock();
if(sharedChild1)
{
// Use child...
}
Inputs
- InputSystem: Class to read inputs (GamePads, Touch Screens, Keyboard, Mouse).
- Touch: This class stores information of finger on a touchscreen.
- KeyCode Enum: Enum that list every keys of a keyboard and buttons of a controller.
InputSystem
Add this in your code:
#include <engine/inputs/input_system.h>
Description
Class to read inputs (GamePads, Touch Screens, Keyboard, Mouse).
Macros
PLAYER_1
value: 0
PLAYER_2
value: 1
PLAYER_3
value: 2
PLAYER_4
value: 3
PLAYER_5
value: 4
PLAYER_6
value: 5
PLAYER_7
value: 6
PLAYER_8
value: 7
Static variables
Name | Type | Description |
---|---|---|
mousePosition | Vector2 | Position of the mouse in pixels |
mouseSpeed | Vector2 | Speed of the mouse (affected by the window resolution) |
mouseSpeedRaw | Vector2 | Raw speed of the mouse |
mouseWheel | float | Speed of the mouse wheel |
Static methods
GetKeyDown
Return true if the key has just been pressed.
Parameters:
keyCode
: Key code to checkcontrollerIndex
: Controller index (0-7)
bool GetKeyDown(const KeyCode keyCode, const int controllerIndex = 0)
Code sample:
if (InputSystem::GetKeyDown(KeyCode::A))
{
Debug::Print("A key pressed");
}
if (InputSystem::GetKeyDown(KeyCode::CIRCLE), PLAYER_1)
{
Debug::Print("CIRCLE button pressed");
}
GetKey
Return true if the key is held.
Parameters:
keyCode
: Key code to checkcontrollerIndex
: Controller index (0-7)
bool GetKey(const KeyCode keyCode, const int controllerIndex = 0)
Code sample:
if (InputSystem::GetKey(KeyCode::A))
{
Debug::Print("A key held");
}
if (InputSystem::GetKey(KeyCode::CIRCLE), PLAYER_1)
{
Debug::Print("CIRCLE button held");
}
GetKeyUp
Return true if the key has just been released.
Parameters:
keyCode
: Key code to checkcontrollerIndex
: Controller index (0-7)
bool GetKeyUp(const KeyCode keyCode, const int controllerIndex = 0)
Code sample:
if (InputSystem::GetKeyUp(KeyCode::A))
{
Debug::Print("A key released");
}
if (InputSystem::GetKeyUp(KeyCode::CIRCLE), PLAYER_1)
{
Debug::Print("CIRCLE button released");
}
GetLeftJoystick
Get left joystick value, values between -1.0f and 1.0f.
Parameters:
controllerIndex
: Controller index (0-7)
Vector2 GetLeftJoystick(const int controllerIndex = 0)
Code sample:
Vector2 left = InputSystem::GetLeftJoystick(PLAYER_1);
GetRightJoystick
Get right joystick value, values between -1.0f and 1.0f.
Parameters:
controllerIndex
: Controller index (0-7)
Vector2 GetRightJoystick(const int controllerIndex = 0)
Code sample:
Vector2 right = InputSystem::GetRightJoystick(PLAYER_1);
GetLeftTrigger
Get left trigger value (R2), values between 0.0f and 1.0f.
Parameters:
controllerIndex
: Controller index (0-7)
static float GetLeftTrigger(const int controllerIndex = 0)
Code sample:
float value = InputSystem::GetLeftTrigger(PLAYER_1);
GetRightTrigger
Get right trigger value (R2), values between 0.0f and 1.0f.
Parameters:
controllerIndex
: Controller index (0-7)
static float GetRightTrigger(const int controllerIndex = 0)
Code sample:
float value = InputSystem::GetRightTrigger(PLAYER_1);
GetTouchScreenCount
Get how many touch screens the device has.
int GetTouchScreenCount()
Code sample:
int touchScreenCount = InputSystem::GetTouchScreenCount(); // = 2 on PsVita
GetTouchCount
Get how many touch inputs the screen has.
Parameters:
screenIndex
: Screen index
int GetTouchCount(const int screenIndex)
Code sample:
int touchCount = InputSystem::GetTouchCount(0);
GetTouch
Get touch data.
Parameters:
touchIndex
: Touch indexscreenIndex
: Screen index
Touch GetTouch(const int touchIndex, const int screenIndex)
Code sample:
int screenIndex = 0;
int touchCount = InputSystem::GetTouchCount(screenIndex);
if (touchCount >= 1)
{
Touch touch = InputSystem::GetTouch(1, screenIndex);
}
HideMouse
Hide mouse.
void HideMouse()
Code sample:
InputSystem::HideMouse();
ShowMouse
Show mouse.
void ShowMouse()
Code sample:
InputSystem::ShowMouse();
Touch
Add this in your code:
#include <engine/inputs/input_system.h>
Description
This class stores information of finger on a touchscreen.
Variables
Name | Type | Description |
---|---|---|
position | Vector2Int | Actual position in pixel of the finger |
startPosition | Vector2Int | Start position in pixel of the finger |
fingerId | int | Id of the finger |
KeyCode Enum
Add this in your code:
#include <engine/inputs/input_system.h>
Description
Enum that list every keys of a keyboard and buttons of a controller.
Values
Name | Value |
---|---|
EMPTY | -1 |
RETURN | 0 |
ESCAPE | 1 |
BACKSPACE | 2 |
TAB | 3 |
SPACE | 4 |
EXCLAIM | 5 |
QUOTEDBL | 6 |
HASH | 7 |
PERCENT | 8 |
DOLLAR | 9 |
AMPERSAND | 10 |
QUOTE | 11 |
LEFTPAREN | 12 |
RIGHTPAREN | 13 |
ASTERISK | 14 |
PLUS | 15 |
COMMA | 16 |
MINUS | 17 |
PERIOD | 18 |
SLASH | 19 |
NUM_0 | 20 |
NUM_1 | 21 |
NUM_2 | 22 |
NUM_3 | 23 |
NUM_4 | 24 |
NUM_5 | 25 |
NUM_6 | 26 |
NUM_7 | 27 |
NUM_8 | 28 |
NUM_9 | 29 |
COLON | 30 |
SEMICOLON | 31 |
LESS | 32 |
EQUALS | 33 |
GREATER | 34 |
QUESTION | 35 |
AT | 36 |
LEFTBRACKET | 37 |
BACKSLASH | 38 |
RIGHTBRACKET | 39 |
CARET | 40 |
UNDERSCORE | 41 |
BACKQUOTE | 42 |
A | 43 |
B | 44 |
C | 45 |
D | 46 |
E | 47 |
F | 48 |
G | 49 |
H | 50 |
I | 51 |
J | 52 |
K | 53 |
L | 54 |
M | 55 |
N | 56 |
O | 57 |
P | 58 |
Q | 59 |
R | 60 |
S | 61 |
T | 62 |
U | 63 |
V | 64 |
W | 65 |
X | 66 |
Y | 67 |
Z | 68 |
CAPSLOCK | 69 |
F1 | 70 |
F2 | 71 |
F3 | 72 |
F4 | 73 |
F5 | 74 |
F6 | 75 |
F7 | 76 |
F8 | 77 |
F9 | 78 |
F10 | 79 |
F11 | 80 |
F12 | 81 |
RIGHT | 82 |
LEFT | 83 |
DOWN | 84 |
UP | 85 |
MOUSE_LEFT | 86 |
MOUSE_RIGHT | 87 |
LEFT_CONTROL | 88 |
RIGHT_CONTROL | 89 |
LEFT_ALT | 90 |
RIGHT_ALT | 91 |
CROSS | 92 |
CIRCLE | 93 |
SQUARE | 94 |
TRIANGLE | 95 |
START | 96 |
SELECT | 97 |
LTRIGGER1 | 98 |
RTRIGGER1 | 99 |
DEL | 100 |
MOUSE_MIDDLE | 101 |
LEFT_SHIFT | 102 |
RIGHT_SHIFT | 103 |
DPAD_LEFT | 104 |
DPAD_RIGHT | 105 |
DPAD_UP | 106 |
DPAD_DOWN | 107 |
L_JOYSTICK_CLICK | 108 |
R_JOYSTICK_CLICK | 109 |
Math
- Quaternion: Class representing rotations in 3D space.
- Vector2Int: Contains integer 2D coordinates.
- Vector2: Contains 2D coordinates.
- Vector3: Contains 3D coordinates.
- Vector4: Contains 4D coordinates.
Quaternion
Add this in your code:
#include <engine/math/quaternion.h>
Description
Class representing rotations in 3D space.
Variables
Name | Type | Description |
---|---|---|
x | float | The x component of the quaternion |
y | float | The y component of the quaternion |
z | float | The z component of the quaternion |
w | float | The w component of the quaternion |
Constructors
Quaternion
Quaternion()
Code sample:
Quaternion q = Quaternion();
// Same as q = Quaternion::Identity();
Quaternion (X,Y,Z,W)
Normalized.
Parameters:
x
: X valuey
: Y valuez
: Z valuew
: W value
Quaternion(float x, float y, float z, float w)
Code sample:
Quaternion q = Quaternion(0.6860413f, 0.3493627f, -0.4916947f, -0.4068529f);
Quaternion (Vector4)
Normalized.
Parameters:
vector
: X, Y, Z, W values
Quaternion(const Vector4& vector)
Code sample:
Quaternion q = Quaternion(Vector4(0.6860413f, 0.3493627f, -0.4916947f, -0.4068529f));
Static methods
Identity
Returns a quaternion representing no rotation (identity quaternion).
Quaternion Identity()
Code sample:
Quaternion identity = Quaternion::Identity();
Euler
Create a quaternion from Euler angles (in degrees).
Parameters:
x
: X angle in degreesy
: Y angle in degreesz
: Z angle in degrees
Quaternion Euler(const float x, const float y, const float z)
Code sample:
Quaternion q = Quaternion::Euler(10, 20, 30);
AngleAxis
Make a quaternion from an angle and axis.
Parameters:
angle
: angle in degreesaxis
: Axis of the rotation
Quaternion AngleAxis(float angle, const Vector3& axis)
Code sample:
Quaternion q = Quaternion::AngleAxis(10, Vector3(1, 0, 0));
Inverse
Get the inverse of the quaternion.
Parameters:
q
: Quaternion to inverse
Quaternion Inverse(const Quaternion& q)
Code sample:
Quaternion q = Quaternion::Euler(10, 20, 30);
Quaternion inverseQ = Quaternion::Inverse(q);
Lerp
Linearly interpolates between quaternions.
Parameters:
a
: First quaternionb
: Second quaterniont
: Interpolation factor (0.0f to 1.0f)
Quaternion Lerp(const Quaternion& a, const Quaternion& b, const float t)
Code sample:
Quaternion a = Quaternion::Euler(10, 20, 30);
Quaternion b = Quaternion::Euler(90, 120, 10);
Quaternion mix = Quaternion::Lerp(a, b, 0.5f); // Mix of A and B
Quaternion lerp0 = Quaternion::Lerp(a, b, 0.0f); // Equals A
Quaternion lerp1 = Quaternion::Lerp(a, b, 1.0f); // Equals B
Dot
Get the dot product of two quaternions.
Parameters:
q1
: First quaternionq2
: Second quaternion
float Dot(const Quaternion& q1, const Quaternion& q2)
Code sample:
Quaternion a = Quaternion::Euler(10, 20, 30);
Quaternion b = Quaternion::Euler(90, 120, 10);
Quaternion result = Quaternion::Dot(a, b);
Public methods
ToEuler
Converts the quaternion to Euler angles (in degrees).
Vector3 ToEuler() const
Code sample:
Quaternion a = Quaternion::Euler(10, 20, 30);
Vector3 euler = a.ToEuler();
Set
Set the quaternion values (Normalizes the quaternion).
Parameters:
x
: X valuey
: Y valuez
: Z valuew
: W value
void Set(const float x, const float y, const float z, const float w)
Code sample:
Quaternion a = Quaternion::Identity();
a.Set(0.6860413f * 2, 0.3493627f * 2, -0.4916947f * 2, -0.4068529f * 2);
// a = (0.6860413f, 0.3493627f, -0.4916947f, -0.4068529f)
Normalize
Normalize the quaternion.
void Normalize()
Code sample:
Quaternion a = Quaternion::Identity();
a.Set(0.6860413f, 0.3493627f, -0.4916947f, -0.4068529f);
a.Normalize();
Normalized
Returns a normalized copy of the quaternion.
Quaternion Normalized() const
Code sample:
Quaternion a = Quaternion::Identity();
a.Set(0.6860413f, 0.3493627f, -0.4916947f, -0.4068529f);
Quaternion normalizedA = a.Normalized();
GetForward
Get the forward direction vector of the quaternion.
Vector3 GetForward() const
Code sample:
Quaternion a = Quaternion::Identity();
a.Set(0.6860413f, 0.3493627f, -0.4916947f, -0.4068529f);
Vector3 forward = a.GetForward();
GetUp
Get the up direction vector of the quaternion.
Vector3 GetUp() const
Code sample:
Quaternion a = Quaternion::Identity();
a.Set(0.6860413f, 0.3493627f, -0.4916947f, -0.4068529f);
Vector3 up = a.GetUp();
GetRight
Get the right direction vector of the quaternion.
Vector3 GetRight() const
Code sample:
Quaternion a = Quaternion::Identity();
a.Set(0.6860413f, 0.3493627f, -0.4916947f, -0.4068529f);
Vector3 right = a.GetRight();
ToString
Return a string representation of the quaternion like "{x:0.0 y:0.0 z:0.0 w:1.0}"
std::string ToString() const
Code sample:
Quaternion a = Quaternion::Identity();
a.Set(0.6860413f, 0.3493627f, -0.4916947f, -0.4068529f);
Debug::Print(a.ToString());
// Prints "{x:0.6860413 y:0.3493627 z:0.4916947 w:0.4068529}"
Operators
Quaternion operator*(const Quaternion& left, const Quaternion& right)
Vector3 operator*(const Quaternion& left, const Vector3& right) // From vector3.h
bool operator==(const Quaternion& left, const Quaternion& right)
bool operator!=(const Quaternion& left, const Quaternion& right)
Vector2
Add this in your code:
#include <engine/math/vector2.h>
Description
Contains 2D coordinates.
Variables
Name | Type | Description |
---|---|---|
x | float | The x component of the vector |
y | float | The y component of the vector |
Constructors
Vector2
Empty vector.
Vector2()
Code sample:
Vector2 vec = Vector2();
// X = Y = 0.0f
Vector2 (X,Y)
Parameters:
x
: X valuey
: Y value
Vector2(float x, float y)
Code sample:
Vector2 vec = Vector2(1.0f, 2.0f);
Vector2 (Single value)
Fill the vector with a single value.
Parameters:
fillValue
: Fill value
Vector2(float fillValue)
Code sample:
Vector2 vec = Vector2(1.0f);
// X = Y = 1.0f
Vector2 (Vector3)
Parameters:
vect
: 3D vector
Vector2(const Vector3& vect)
Code sample:
Vector3 vec3 = Vector3(1.0f, 2.0f, 3.0f);
Vector2 vec = Vector2(vec3);
// X = 1.0f
// Y = 2.0f
Vector2 (Vector2Int)
Parameters:
vect
: 2D integer vector
Vector2(const Vector2Int& vect)
Code sample:
Vector2Int vec2int = Vector2Int(1, 2);
Vector2 vec = Vector2(vec2int);
// X = 1.0f
// Y = 2.0f
Public methods
Max
Get the biggest value of the vector.
float Max()
Code sample:
Vector2 vec = Vector2(1.0f, 3.0f);
float maxValue = vec.Max(); // = 3.0f
Min
Get the smallest value of the vector.
float Min()
Code sample:
Vector2 vec = Vector2(1.0f, 3.0f);
float maxValue = vec.Min(); // = 1.0f
Normalized
Get a copy of this vector with a magnitude of 1 (Does not change vector values).
Vector2 Normalized() const
Code sample:
Vector2 vec = Vector2(1.0f, 2.0f);
Vector2 normalizedVec = vec.Normalized();
Normalize
Makes this vector have a magnitude of 1 (Changes vector values).
Vector2 Normalize()
Code sample:
Vector2 vec = Vector2(1.0f, 2.0f);
vec.Normalize();
Magnitude
Get the length of this vector.
float Magnitude() const
Code sample:
Vector2 vec = Vector2(1.0f, 2.0f);
float magnitude vec.Magnitude();
SquaredMagnitude
Get the squared length of this vector.
float SquaredMagnitude() const
Code sample:
Vector2 vec = Vector2(1.0f, 2.0f);
float squaredMagnitude vec.SquaredMagnitude();
HasInvalidValues
Return True is the vector has invalid values (NaN or Inf).
bool HasInvalidValues() const
Code sample:
Vector2 vec = Vector2(std::nanf(""), std::numeric_limits<float>::infinity()); // This will raise an assert in debug to avoid using nan or inf values
bool valid = vec->HasInvalidValues();
ToString
Return a string representation of the vector like "{x:1.0, y:2.0}"
bool ToString() const
Code sample:
Vector2 vec = Vector2(1.0f, 2.0f);
Debug::Print(vec->ToString()); // Prints "{x:1.0, y:2.0}"
Static methods
Lerp
Linearly interpolates between vectors.
Parameters:
a
: First vectorb
: Second vectort
: Interpolation factor (0.0f to 1.0f)
Vector2 Lerp(const Vector2& a, const Vector2& b, const float t)
Code sample:
Vector2 a = Vector2(1.0f, 3.0f);
Vector2 b = Vector2(2.0f, 2.0f);
Vector2 mix = Vector2::Lerp(a, b, 0.5f); // Mix of A and B
Vector2 lerp0 = Vector2::Lerp(a, b, 0.0f); // Equals A
Vector2 lerp1 = Vector2::Lerp(a, b, 1.0f); // Equals B
Distance
Distance between two vectors.
Parameters:
a
: First vectorb
: Second vector
float Distance(const Vector2& a, const Vector2& b)
Code sample:
Vector2 a = Vector2Int(1.0f, 3.0f);
Vector2 b = Vector2Int(2.0f, 2.0f);
float distance = Vector2::Distance(a, b);
Operators
Vector2 operator+(const Vector2& left, const Vector2& right)
Vector2 operator-(const Vector2& left, const Vector2& right)
Vector2 operator-(const Vector2& vec)
Vector2 operator*(const float value, const Vector2& vec)
Vector2 operator*(const Vector2& left, const Vector2& right)
Vector2 operator*(const Vector2& vec, const float value)
Vector2 operator*(const Vector2& left, const Vector2Int& right);
Vector2 operator*(const Vector2Int& left, const Vector2& right);
Vector2 operator/(const float value, const Vector2& vec)
Vector2 operator/(const Vector2& vec, const float value)
Vector2 operator/(const Vector2& left, const Vector2& right)
Vector2& operator+=(Vector2& vec, const float value)
Vector2& operator-=(Vector2& vec, const float value)
Vector2& operator*=(Vector2& vec, const float value)
Vector2& operator/=(Vector2& vec, const float value)
Vector2& operator+=(Vector2& vec, const Vector2& vecRight)
Vector2& operator-=(Vector2& vec, const Vector2& vecRight)
Vector2& operator*=(Vector2& vec, const Vector2& vecRight)
Vector2& operator/=(Vector2& vec, const Vector2& vecRight)
bool operator==(const Vector2& left, const Vector2& right)
bool operator!=(const Vector2& left, const Vector2& right)
Vector2Int
Add this in your code:
#include <engine/math/vector2_int.h>
Description
Contains integer 2D coordinates.
Variables
Name | Type | Description |
---|---|---|
x | int | The x component of the vector |
y | int | The y component of the vector |
Constructors
Vector2Int
Empty vector.
Vector2Int()
Code sample:
Vector2Int vec = Vector2Int();
// X = Y = 0
Vector2Int (X,Y)
Parameters:
x
: X valuey
: Y value
Vector2Int(int x, int y)
Code sample:
Vector2Int vec = Vector2Int(1, 2);
Vector2Int (Single value)
Fill the vector with a single value.
Parameters:
fillValue
: Fill value
Vector2Int(int fillValue)
Code sample:
Vector2Int vec = Vector2Int(1);
// X = Y = 1
Vector2Int (Vector3)
Parameters:
vect
: 3D vector
Vector2Int(const Vector3& vect)
Code sample:
Vector3 vec3 = Vector3(1.0f, 2.0f, 3.0f);
Vector2Int vec = Vector2Int(vec3);
// X = 1
// Y = 2
Vector2Int (Vector2)
Parameters:
vect
: 2D vector
Vector2Int(const Vector2& vect)
Code sample:
Vector2 vec2 = Vector2(1.0f, 2.0f);
Vector2Int vec = Vector2Int(vec2);
// X = 1
// Y = 2
Public methods
Max
Get the biggest value of the vector.
float Max()
Code sample:
Vector2Int vec = Vector2Int(1, 3);
float maxValue = vec.Max(); // = 3.0f
Min
Get the smallest value of the vector.
float Min()
Code sample:
Vector2Int vec = Vector2Int(1, 3);
float maxValue = vec.Min(); // = 1.0f
Normalized
Get a copy of this vector with a magnitude of 1 (Does not change vector values).
Vector2Int Normalized() const
Code sample:
Vector2Int vec = Vector2Int(1, 2);
Vector2Int normalizedVec = vec.Normalized();
Normalize
Makes this vector have a magnitude of 1 (Changes vector values).
Vector2Int Normalize()
Code sample:
Vector2Int vec = Vector2Int(1, 2);
vec.Normalize();
Magnitude
Get the length of this vector.
float Magnitude() const
Code sample:
Vector2Int vec = Vector2Int(1, 2);
float magnitude vec.Magnitude();
SquaredMagnitude
Get the squared length of this vector.
float SquaredMagnitude() const
Code sample:
Vector2Int vec = Vector2Int(1, 2);
float squaredMagnitude vec.SquaredMagnitude();
ToString
Return a string representation of the vector like "{x:1, y:2}"
bool ToString() const
Code sample:
Vector2Int vec = Vector2Int(1, 2);
Debug::Print(vec->ToString()); // Prints "{x:1, y:2}"
Static methods
Distance
Distance between two vectors.
Parameters:
a
: First vectorb
: Second vector
float Distance(const Vector2Int& a, const Vector2Int& b)
Code sample:
Vector2Int a = Vector2Int(1, 3);
Vector2Int b = Vector2Int(2, 2);
float distance = Vector2Int::Distance(a, b);
Operators
Vector2Int operator+(const Vector2Int& left, const Vector2Int& right)
Vector2Int operator-(const Vector2Int& left, const Vector2Int& right)
Vector2Int operator-(const Vector2Int& vec)
Vector2Int operator*(const float value, const Vector2Int& vec)
Vector2Int operator*(const Vector2Int& left, const Vector2Int& right)
Vector2Int operator*(const Vector2Int& vec, const float value)
Vector2Int operator/(const float value, const Vector2Int& vec)
Vector2Int operator/(const Vector2Int& vec, const float value)
Vector2Int operator/(const Vector2Int& left, const Vector2Int& right)
Vector2Int& operator+=(Vector2Int& vec, const float value)
Vector2Int& operator-=(Vector2Int& vec, const float value)
Vector2Int& operator*=(Vector2Int& vec, const float value)
Vector2Int& operator/=(Vector2Int& vec, const float value)
Vector2Int& operator+=(Vector2Int& vec, const Vector2Int& vecRight)
Vector2Int& operator-=(Vector2Int& vec, const Vector2Int& vecRight)
Vector2Int& operator*=(Vector2Int& vec, const Vector2Int& vecRight)
Vector2Int& operator/=(Vector2Int& vec, const Vector2Int& vecRight)
bool operator==(const Vector2Int& left, const Vector2Int& right)
bool operator!=(const Vector2Int& left, const Vector2Int& right)
Vector3
Add this in your code:
#include <engine/math/vector3.h>
Description
Contains 3D coordinates.
Variables
Name | Type | Description |
---|---|---|
x | float | The x component of the vector |
y | float | The y component of the vector |
z | float | The z component of the vector |
Constructors
Vector3
Empty vector.
Vector3()
Code sample:
Vector3 vec = Vector3();
// X = Y = Z = 0.0f
Vector3 (X,Y,Z)
Parameters:
x
: X valuey
: Y valuez
: Z value
Vector3(float x, float y, float z)
Code sample:
Vector3 vec = Vector3(1.0f, 2.0f, 3.0f);
Vector3 (Single value)
Fill the vector with a single value.
Parameters:
fillValue
: Fill value
Vector3(float fillValue)
Code sample:
Vector3 vec = Vector3(1.0f);
// X = Y = Z = 1.0f
Vector3 (Vector2)
Parameters:
vect
: 2D vector
Vector3(const Vector2& vect)
Code sample:
Vector2 vec2 = Vector2(1.0f, 2.0f);
Vector3 vec = Vector3(vec2);
// X = 1.0f
// Y = 2.0f
// Z = 0.0f
Vector3 (Vector2Int)
Parameters:
vect
: 2D integer vector
Vector3(const Vector2Int& vect)
Code sample:
Vector2Int vec2int = Vector2Int(1, 2);
Vector3 vec = Vector3(vec2int);
// X = 1.0f
// Y = 2.0f
// Z = 0.0f
Public methods
Max
Get the biggest value of the vector.
float Max()
Code sample:
Vector3 vec = Vector3(1.0f, 3.0f, 2.0f);
float maxValue = vec.Max(); // = 3.0f
Min
Get the smallest value of the vector.
float Min()
Code sample:
Vector3 vec = Vector3(1.0f, 3.0f, 2.0f);
float maxValue = vec.Min(); // = 1.0f
Normalized
Get a copy of this vector with a magnitude of 1 (Does not change vector values).
Vector3 Normalized() const
Code sample:
Vector3 vec = Vector3(1.0f, 2.0f, 3.0f);
Vector3 normalizedVec = vec.Normalized();
Normalize
Makes this vector have a magnitude of 1 (Changes vector values).
Vector3 Normalize()
Code sample:
Vector3 vec = Vector3(1.0f, 1.0f, 3.0f);
vec.Normalize();
Magnitude
Get the length of this vector.
float Magnitude() const
Code sample:
Vector3 vec = Vector3(1.0f, 2.0f, 3.0f);
float magnitude vec.Magnitude();
SquaredMagnitude
Get the squared length of this vector.
float SquaredMagnitude() const
Code sample:
Vector3 vec = Vector3(1.0f, 2.0f, 3.0f);
float squaredMagnitude vec.SquaredMagnitude();
Dot
Get the dot product of this vector with another vector.
Parameters:
v
: Other vector
float Dot(const Vector3& v) const
Code sample:
Vector3 vec = Vector3(1.0f, 2.0f, 3.0f);
Vector3 vec2 = Vector3(2.0f, 2.0f, 4.0f);
float dotResult vec.Dot(vec2);
Cross
Get the cross product of this vector with another vector.
Parameters:
v
: Other vector
Vector3 Cross(const Vector3& v) const
Code sample:
Vector3 vec = Vector3(1.0f, 2.0f, 3.0f);
Vector3 vec2 = Vector3(2.0f, 2.0f, 4.0f);
Vector3 crossResult vec.Cross(vec2);
HasInvalidValues
Return True is the vector has invalid values (NaN or Inf).
bool HasInvalidValues() const
Code sample:
Vector3 vec = Vector3(std::nanf(""), std::numeric_limits<float>::infinity(), 3.0f); // This will raise an assert in debug to avoid using nan or inf values
bool valid = vec->HasInvalidValues();
ToString
Return a string representation of the vector like "{x:1.0, y:2.0, z:3.0}"
bool ToString() const
Code sample:
Vector3 vec = Vector3(1.0f, 2.0f, 3.0f);
Debug::Print(vec->ToString()); // Prints "{x:1.0, y:2.0, z:3.0}"
Static methods
Dot
Get the dot product of two vectors.
Parameters:
a
: First vectorb
: Sedond vector
float Dot(const Vector3& a, const Vector3& b)
Code sample:
Vector3 vec = Vector3(1.0f, 2.0f, 3.0f);
Vector3 vec2 = Vector3(2.0f, 2.0f, 4.0f);
float dotResult Vector3::Dot(vec, vec2);
Cross
Get the cross product of two vectors.
Parameters:
a
: First vectorb
: Sedond vector
Vector3 Cross(const Vector3& a, const Vector3& b)
Code sample:
Vector3 vec = Vector3(1.0f, 2.0f, 3.0f);
Vector3 vec2 = Vector3(2.0f, 2.0f, 4.0f);
Vector3 crossResult Vector3::Cross(vec, vec2);
Lerp
Linearly interpolates between vectors.
Parameters:
a
: First vectorb
: Second vectort
: Interpolation factor (0.0f to 1.0f)
Vector3 Lerp(const Vector3& a, const Vector3& b, const float t)
Code sample:
Vector3 a = Vector3(1.0f, 2.0f, 3.0f);
Vector3 b = Vector3(2.0f, 2.0f, 4.0f);
Vector3 mix = Vector3::Lerp(a, b, 0.5f); // Mix of A and B
Vector3 lerp0 = Vector3::Lerp(a, b, 0.0f); // Equals A
Vector3 lerp1 = Vector3::Lerp(a, b, 1.0f); // Equals B
Distance
Distance between two vectors.
Parameters:
a
: First vectorb
: Second vector
float Distance(const Vector3& a, const Vector3& b)
Code sample:
Vector3 a = Vector3(1.0f, 2.0f, 3.0f);
Vector3 b = Vector3(2.0f, 2.0f, 4.0f);
float distance = Vector3::Distance(a, b);
LookAt
Get the look rotation in degrees between two vectors.
Parameters:
from
: First vectorto
: Target position
Vector3 LookAt(const Vector3& from, const Vector3& to)
Code sample:
Vector3 from = Vector3(1.0f, 2.0f, 3.0f);
Vector3 to = Vector3(2.0f, 2.0f, 4.0f);
Vector3 rotation = Vector3::LookAt(a, b);
Operators
Vector3 operator+(const Vector3& left, const Vector3& right)
Vector3 operator-(const Vector3& left, const Vector3& right)
Vector3 operator-(const Vector3& vec)
Vector3 operator*(const float value, const Vector3& vec)
Vector3 operator*(const Vector3& left, const Vector3& right)
Vector3 operator*(const Vector3& vec, const float value)
Vector3 operator*(const Quaternion& left, const Vector3& right)
Vector3 operator/(const float value, const Vector3& vec)
Vector3 operator/(const Vector3& vec, const float value)
Vector3 operator/(const Vector3& left, const Vector3& right)
Vector3& operator+=(Vector3& vec, const float value)
Vector3& operator-=(Vector3& vec, const float value)
Vector3& operator*=(Vector3& vec, const float value)
Vector3& operator/=(Vector3& vec, const float value)
Vector3& operator+=(Vector3& vec, const Vector3& vecRight)
Vector3& operator-=(Vector3& vec, const Vector3& vecRight)
Vector3& operator*=(Vector3& vec, const Vector3& vecRight)
Vector3& operator/=(Vector3& vec, const Vector3& vecRight)
bool operator==(const Vector3& left, const Vector3& right)
bool operator!=(const Vector3& left, const Vector3& right)
Vector4
Add this in your code:
#include <engine/math/vector4.h>
Description
Contains 4D coordinates.
Variables
Name | Type | Description |
---|---|---|
x | float | The x component of the vector |
y | float | The y component of the vector |
z | float | The z component of the vector |
w | float | The w component of the vector |
Constructors
Vector4
Empty vector.
Vector4()
Code sample:
Vector4 vec = Vector4();
// X = Y = Z = W = 0.0f
Vector4 (X,Y,Z,W)
Parameters:
x
: X valuey
: Y valuez
: Z valuew
: W value
Vector4(float x, float y, float z, float w)
Code sample:
Vector4 vec = Vector4(1.0f, 2.0f, 3.0f, 4.0f);
Vector4 (Single value)
Fill the vector with a single value.
Parameters:
fillValue
: Fill value
Vector4(float fillValue)
Code sample:
Vector4 vec = Vector4(1.0f);
// X = Y = Z = W = 1.0f
Vector4 (Vector3)
Parameters:
vect
: 3D vector
Vector4(const Vector3& vect)
Code sample:
Vector3 vec3 = Vector3(1.0f, 2.0f, 3.0f);
Vector4 vec = Vector4(vec3);
// X = 1.0f
// Y = 2.0f
// Z = 3.0f
// W = 0.0f
Vector4 (Vector2)
Parameters:
vect
: 2D vector
Vector4(const Vector2& vect)
Code sample:
Vector2 vec2 = Vector2(1.0f, 2.0f);
Vector4 vec = Vector4(vec2);
// X = 1.0f
// Y = 2.0f
// Z = 0.0f
// W = 0.0f
Vector4 (Vector2Int)
Parameters:
vect
: 2D integer vector
Vector4(const Vector2Int& vect)
Code sample:
Vector2Int vec2int = Vector2Int(1, 2);
Vector4 vec = Vector4(vec2int);
// X = 1.0f
// Y = 2.0f
// Z = 0.0f
// W = 0.0f
Public methods
Max
Get the biggest value of the vector.
float Max()
Code sample:
Vector4 vec = Vector4(1.0f, 3.0f, 4.0f, 2.0f);
float maxValue = vec.Max(); // = 4.0f
Min
Get the smallest value of the vector.
float Min()
Code sample:
Vector4 vec = Vector4(1.0f, 3.0f, 4.0f, 2.0f);
float maxValue = vec.Min(); // = 1.0f
Normalized
Get a copy of this vector with a magnitude of 1 (Does not change vector values).
Vector4 Normalized() const
Code sample:
Vector4 vec = Vector4(1.0f, 2.0f, 3.0f, 4.0f);
Vector4 normalizedVec = vec.Normalized();
Normalize
Makes this vector have a magnitude of 1 (Changes vector values).
Vector4 Normalize()
Code sample:
Vector4 vec = Vector4(1.0f, 2.0f, 3.0f, 4.0f);
vec.Normalize();
Magnitude
Get the length of this vector.
float Magnitude() const
Code sample:
Vector4 vec = Vector4(1.0f, 2.0f, 3.0f, 4.0f);
float magnitude vec.Magnitude();
SquaredMagnitude
Get the squared length of this vector.
float SquaredMagnitude() const
Code sample:
Vector4 vec = Vector4(1.0f, 2.0f, 3.0f, 4.0f);
float squaredMagnitude vec.SquaredMagnitude();
HasInvalidValues
Return True is the vector has invalid values (NaN or Inf).
bool HasInvalidValues() const
Code sample:
Vector4 vec = Vector4(std::nanf(""), std::numeric_limits<float>::infinity(), 3.0f, 4.0f); // This will raise an assert in debug to avoid using nan or inf values
bool valid = vec->HasInvalidValues();
ToString
Return a string representation of the vector like "{x:1.0, y:2.0, z:3.0, w:4.0}"
bool ToString() const
Code sample:
Vector4 vec = Vector4(1.0f, 2.0f, 3.0f, 4.0f);
Debug::Print(vec->ToString()); // Prints "{x:1.0, y:2.0, z:3.0, w:4.0}"
Static methods
Lerp
Linearly interpolates between vectors.
Parameters:
a
: First vectorb
: Second vectort
: Interpolation factor (0.0f to 1.0f)
Vector4 Lerp(const Vector4& a, const Vector4& b, const float t)
Code sample:
Vector4 a = Vector4(1.0f, 3.0f, 2.0f, 6.0f);
Vector4 b = Vector4(2.0f, 2.0f, 4.0f, 1.0f);
Vector4 mix = Vector4::Lerp(a, b, 0.5f); // Mix of A and B
Vector4 lerp0 = Vector4::Lerp(a, b, 0.0f); // Equals A
Vector4 lerp1 = Vector4::Lerp(a, b, 1.0f); // Equals B
Operators
Vector4 operator+(const Vector4& left, const Vector4& right)
Vector4 operator-(const Vector4& left, const Vector4& right)
Vector4 operator-(const Vector4& vec)
Vector4 operator*(const float value, const Vector4& vec)
Vector4 operator*(const Vector4& left, const Vector4& right)
Vector4 operator*(const Vector4& vec, const float value)
Vector4 operator/(const float value, const Vector4& vec)
Vector4 operator/(const Vector4& vec, const float value)
Vector4 operator/(const Vector4& left, const Vector4& right)
Vector4& operator+=(Vector4& vec, const float value)
Vector4& operator-=(Vector4& vec, const float value)
Vector4& operator*=(Vector4& vec, const float value)
Vector4& operator/=(Vector4& vec, const float value)
Vector4& operator+=(Vector4& vec, const Vector4& vecRight)
Vector4& operator-=(Vector4& vec, const Vector4& vecRight)
Vector4& operator*=(Vector4& vec, const Vector4& vecRight)
Vector4& operator/=(Vector4& vec, const Vector4& vecRight)
bool operator==(const Vector4& left, const Vector4& right)
bool operator!=(const Vector4& left, const Vector4& right)
Network
- NetworkManager: Class to create sockets and to manage networking settings.
- Socket: Class to send and received data to/from a server.
NetworkManager
Add this in your code:
#include <engine/network/network.h>
Description
Class to create sockets and to manage networking settings.
Static methods
CreateSocket
Create a socket.
Returns nullptr if the socket creation has failed.
Parameters:
address
: IP addressport
: Port number
std::shared_ptr<Socket> CreateSocket(const std::string& address, int port)
Code sample:
// Fake ip
std::shared_ptr<Socket> socket = NetworkManager::CreateSocket("192.168.1.10", 6004);
// Check if the socket has been created
if(socket)
{
// ...
}
ShowPSPNetworkSetupMenu
Show the network setup menu for the PSP.
This function will only work on the PSP platform.
To make networking working on PSP, the user has to manually connect to a wifi.
For this, a menu of the PSP OS ask to the user to setup a network connection.
void ShowPSPNetworkSetupMenu()
Code sample:
NetworkManager::ShowPSPNetworkSetupMenu();
Socket
Add this in your code:
#include <engine/network/network.h>
Description
Class to send and received data to/from a server.
Created with the NetworkManager class.
The socket will be closed when the object is destroyed.
Public methods
SendData (string)
Send data as a string to the server.
Parameters:
text
: Text to send
void SendData(const std::string& text)
Code sample:
// Fake ip
std::shared_ptr<Socket> socket = NetworkManager::CreateSocket("192.168.1.10", 6004);
if(socket)
{
socket->SendData("Hello World!");
}
SendData (binary)
Send binary data to the server.
Parameters:
data
: Pointer to the data to sendsize
: Size on byte to send
void SendData(const char* data, int size)
Code sample:
// Fake ip
std::shared_ptr<Socket> socket = NetworkManager::CreateSocket("192.168.1.10", 6004);
struct MyStruct
{
int value0 = 1;
int value1 = 2;
};
MyStruct myStruct = MyStruct();
if(socket)
{
socket->SendData(reinterpret_cast<char*>(&myStruct), sizeof(MyStruct));
}
Close
Send data as a string to the server.
void Close()
Code sample:
// Fake ip
std::shared_ptr<Socket> socket = NetworkManager::CreateSocket("192.168.1.10", 6004);
if(socket)
{
socket->SendData("Hello World!");
socket->Close();
}
GetIncommingData
Return recieved data since the last GetIncommingData call.
std::string GetIncommingData()
Code sample:
// Fake ip
std::shared_ptr<Socket> socket = NetworkManager::CreateSocket("192.168.1.10", 6004);
if(socket)
{
std::string data = socket->GetIncommingData();
}
Noise
Add this in your code:
#include <engine/noise/noise.h>
Description
Class to generate 1D, 2D, 3D and 4D Perlin noise.
Static methods
Noise1D
Get 1D Perlin noise.
Parameters:
x
: The x coordinate
float Noise1D(float x)
Code sample:
float value = Noise::Noise1D(0.5f);
Noise2D
Get 2D Perlin noise.
Parameters:
x
: The x coordinatey
: The y coordinate
float Noise2D(float x, float y)
Code sample:
float value = Noise::Noise2D(0.5f, 0.1f);
Noise3D
Get 3D Perlin noise.
Parameters:
x
: The x coordinatey
: The y coordinatez
: The z coordinate
float Noise3D(float x, float y, float z)
Code sample:
float value = Noise::Noise3D(0.5f, 0.1f, 0.3f);
Noise4D
Get 4D Perlin noise.
Parameters:
x
: The x coordinatey
: The y coordinatez
: The z coordinatew
: The w coordinate
float Noise4D(float x, float y, float z, float w)
Code sample:
float value = Noise::Noise4D(0.5f, 0.1f, 0.3f, 0.8f);
Object management
Add this in your code:
#include <engine/tools/gameplay_utility.h>
Description
Class to manage Objects (GameObject and Components).
You can Instantiate, Check and Destroy Objects.
Methods
IsValid
Check if a GameObject or a Component is valid to use.
If an object is waiting to be destroyed, the object is not valid anymore.
Only takes Component, GameObject and Transform.
Parameters:
pointer
: Pointer to the object to check
template <typename T>
bool IsValid(const std::shared_ptr<T>& pointer)
bool IsValid(const std::weak_ptr<T>& pointer)
Code sample:
std::shared_ptr<GameObject> myGameObject = CreateGameObject("MyGO");
if(IsValid(myGameObject))
{
// This object is valid
}
Destroy(myGameObject);
if(IsValid(myGameObject))
{
// This object is not valid anymore, this if won't be executed
}
Instantiate (GameObject)
Create a new GameObject from another.
(Not very recommended, can be buggy, use prefabs instead).
Parameters:
gameObject
: GameObject to duplicate
std::shared_ptr<GameObject> Instantiate(const std::shared_ptr<GameObject>& gameObject)
Code sample:
std::shared_ptr<GameObject> myGameObject = CreateGameObject("MyGO");
std::shared_ptr<GameObject> myGameObject2 = Instantiate(myGameObject);
Instantiate (Prefab)
Create a new GameObject from a prefab.
Parameters:
prefab
: Prefab to instanciate
std::shared_ptr<GameObject> Instantiate(const std::shared_ptr<Prefab>& prefab)
Code sample:
std::shared_ptr<GameObject> myGameObject = Instantiate(myPrefab);
Destroy
Destroy a GameObject or component.
warning
The pointer won't be null right after the Destroy call.
Do not use the object after calling Destroy.
Objects are fully destroy after the begin of the next frame.
Parameters:
component
/gameObject
: component or GameObject to destroy
void Destroy(const std::shared_ptr<Component>& component)
void Destroy(const std::shared_ptr<GameObject>& gameObject);
void Destroy(const std::weak_ptr<Component>& component)
void Destroy(const std::weak_ptr<GameObject>& gameObject);
Code sample:
std::shared_ptr<GameObject> myGameObject = CreateGameObject("MyGO");
Destroy(myGameObject);
Physics
- Collider: Parent class of collider components (BoxCollider, SphereCollider...).
- CollisionEvent: This class stores information of a collision between two colliders.
- Raycast: Class to check collisions with a ray.
Collider
Add this in your code:
#include <engine/physics/collider.h>
Description
Parent class of collider components (BoxCollider, SphereCollider...).
Function of Collider can be used on every colllider component.
Public methods
SetIsTrigger
Set if the collider is a trigger or not.
A trigger collider will not collide with other colliders, but will still generate collision events.
Parameters:
isTrigger
: New isTrigger value
void SetIsTrigger(bool isTrigger)
Code sample:
std::shared_ptr<BoxColldier> boxCollider = GetGameObject()->AddComponent<BoxColldier>();
boxCollider->SetIsTrigger(true);
IsTrigger
Check if the collider is a trigger or not.
bool IsTrigger() const
Code sample:
std::shared_ptr<BoxColldier> boxCollider = GetGameObject()->AddComponent<BoxColldier>();
boxCollider->SetIsTrigger(true);
bool isTrigger = boxCollider->IsTrigger(); // = true
SetGenerateCollisionEvents
Set if the collider should generate collision events or not.
Parameters:
generateCollisionEvents
: New generateCollisionEvents value
void SetGenerateCollisionEvents(bool generateCollisionEvents)
Code sample:
std::shared_ptr<BoxColldier> boxCollider = GetGameObject()->AddComponent<BoxColldier>();
boxCollider->SetGenerateCollisionEvents(true);
GetGenerateCollisionEvents
Check if the collider should generate collision events or not.
bool GetGenerateCollisionEvents() const
Code sample:
std::shared_ptr<BoxColldier> boxCollider = GetGameObject()->AddComponent<BoxColldier>();
boxCollider->SetGenerateCollisionEvents(true);
bool generateCollisionEvents = boxCollider->GetGenerateCollisionEvents(); // = true
CollisionEvent
Add this in your code:
#include <engine/physics/collision_event.h>
Description
This class stores information of a collision between two colliders.
Variables
Name | Type | Description |
---|---|---|
collider | Collider* | Collider A |
otherCollider | Collider* | Collider B |
Raycast
Add this in your code:
#include <engine/physics/raycast.h>
Description
Class to check collisions with a ray.
Public methods
Check
Check if a ray hits a collider.
Return true if the raycast has hit a collider.
Parameters:
startPosition
: The start position of the raydirection
: The direction of the raymaxDistance
: The max distance of the rayraycastHit
: The raycastHit struct that will be filled with the hit information
bool Check(
const Vector3& startPosition,
const Vector3& direction,
const float maxDistance,
RaycastHit& raycastHit)
Code sample:
// Check under the player
RaycastHit hit;
bool hasHit = Raycast::Check(
raycastPointTransform->GetPosition(),
Vector3(0, -1, 0),
0.1f,
hit);
if (hasHit && hit.hitCollider.lock())
{
// There is something under the player
}
RaycastHit
Add this in your code:
#include <engine/physics/raycast.h>
Description
This class stores information of a racyast hit.
Variables
Name | Type | Description |
---|---|---|
hitGameObject | std::weak_ptr<GameObject> | Pointer of the GameObject hit by the ray |
hitCollider | std::weak_ptr<Collider> | Pointer of the Collider hit by the ray |
hitPosition | Vector3 | World position of the hit |
distance | float | Distance between the start position and the hit position |
Profiler
Add this in your code:
#include <engine/debug/profiler.h>
Description
Class used to use the profiler in game builds.
Public methods
GetReflectiveData
Save profiling data to a file at the end of the frame.
Return true if the data can be saved, false if the profiler is disabled.
Parameters:
name
: Name of the profiling data file without the extension, if empty, the name will be "profiler" + the date and time
static bool SaveProfilingData(const std::string& name = "")
Code sample:
Profiler::SaveProfilingData(); // Will be saved in "profiler 14h 37m 42s 9d 7m 2025y.xenp"
Profiler::SaveProfilingData("scene_0"); // Will be saved in "scene_0.xenp"
Reflective
Add this in your code:
#include <engine/reflection/reflection.h>
Description
Class to inherit if you want to access child's variables to fill variables from json or save them to json.
It's used to see variables of a class in the Inspector.
GameObject, Transform and Component implement this class.
The GetReflectiveData function is very important and is mandatory to implement in every class that implement Reflective.
Typedef
ReflectiveData = std::vector<ReflectiveEntry>
Macros
Macros have been added to simplify the usage of the reflection system.
BEGIN_REFLECTION();
is used at the beginning of the GetReflectiveData function to prepare the reflection.
END_REFLECTION();
is used at the end of the GetReflectiveData function to end the reflection.
ADD_VARIABLE(variable);
is used to make a variable visible for the reflection system.
ADD_VARIABLE_CUSTOM(variable, name);
is used to make a variable visible for the reflection system with a custom name.
Public methods
GetReflectiveData
Get all child class variables references (Needs to be implemented).
virtual ReflectiveData GetReflectiveData() = 0
Code sample:
class MyComponent : public Reflective
{
public:
ReflectiveData GetReflectiveData() override;
public:
float publicVariable = 0;
float publicVariable2 = 0;
private:
float m_privateVariable = 1;
};
ReflectiveData MyComponent::GetReflectiveData()
{
BEGIN_REFLECTION();
ADD_VARIABLE(publicVariable);
ADD_VARIABLE(publicVariable2).SetIsSlider(true).SetMaxSliderValue(100.0).SetMinSliderValue(2.0);
ADD_VARIABLE(m_privateVariable).SetIsPublic(false); // false is used to hide the variable from the Inspector view
END_REFLECTION();
}
OnReflectionUpdated
Called when one or more variables have been updated by the inspector or by the scene manager.
virtual void OnReflectionUpdated()
Code sample:
class MyComponent : public Reflective
{
public:
ReflectiveData GetReflectiveData() override;
void OnReflectionUpdated() override;
public:
float publicVariable = 0;
private:
float m_privateVariable = 1;
};
ReflectiveData MyComponent::GetReflectiveData()
{
//...
}
void MyComponent::OnReflectionUpdated()
{
Debug::Print("One or more variables have been updated!");
}
SceneManager
Add this in your code:
#include <engine/scene_manager/scene_manager.h>
Description
Class to load scenes.
Static methods
LoadScene
Load a scene.
Parameters:
scene
: Scene to load
void LoadScene(const std::shared_ptr<Scene>& scene)
Code sample:
std::shared_ptr<Scene> sceneToLoad; // Filled variable
SceneManager::LoadScene(sceneToLoad);
ReloadScene
Reload the current scene.
void ReloadScene()
Code sample:
SceneManager::ReloadScene();
GetOpenedScene
Get opened scene.
const std::shared_ptr<Scene>& GetOpenedScene()
Code sample:
std::shared_ptr<Scene> currentScene = SceneManager::GetOpenedScene();
Screen
Add this in your code:
#include <engine/ui/screen.h>
Description
Class to get information and to interact with the screen.
Static methods
GetWidth
Get the width of the screen in pixels.
int GetWidth()
Code sample:
int width = Screen::GetWidth();
GetHeight
Get the height of the screen in pixels.
int GetHeight()
Code sample:
int height = Screen::GetHeight();
SetFullScreen
Set if the window should be in fullscreen mode.
Only for Windows and Linux, no effect on other platforms.
Does not affect the editor window.
Parameters:
useFullScreenMode
: True to enable fullscreen, false to disable
void SetFullScreen(bool useFullScreenMode)
Code sample:
Screen::SetFullScreen(true);
SetVSync
Set if the window should use VSync (May cause graphical glitch on PSP).
Parameters:
useVSync
: True to enable VSync, false to disable
void SetVSync(bool useVSync)
Code sample:
Screen::SetVSync(true);
IsVSyncEnabled
Get if VSync is enabled.
bool IsVSyncEnabled()
Code sample:
Screen::SetVSync(true);
bool isEnabled = Screen::IsVSyncEnabled(); // Returns true
MakeScreenshot
Make a screenshot of the game (.png).
(Note: on PSP/PsVita, plugins overlays are also captured).
On RPCS3 emulator, you have to enable the "Write Color Buffers" gpu option. You may have to use OpenGL instead of vulkan if there are artifacts.
On PPSSPP emulator, you gave to enable software rendering.
Parameters:
fileName
: The name of the file to save the screenshot (without the extension)
void MakeScreenshot(const std::string& fileName)
Code sample:
Screen::MakeScreenshot("my_screenshot");
Time
Add this in your code:
#include <engine/time/time.h>
Description
Class to get time information (Delta time, elapsed time).
Values are updated every frame.
Static methods
GetTime
Get total scaled elapsed time.
Start at 0 when the game starts.
float GetTime()
Code sample:
float timeA = Time::GetTime(); // = 0.0f
Time::SetTimeScale(0.5f);
// 2 seconds later...
float timeB = Time::GetTime(); // = 1.0f
GetUnscaledTime
Get total unscaled elapsed time (not affected by time scale).
Start at 0 when the game starts.
float GetUnscaledTime()
Code sample:
float timeA = Time::GetUnscaledTime(); // = 0.0f
Time::SetTimeScale(0.5f);
// 2 seconds later...
float timeB = Time::GetUnscaledTime(); // = 2.0f
GetDeltaTime
Get scaled delta time, which is the time elapsed since the last frame * time scale.
float GetDeltaTime()
Code sample:
// Game running at 60 fps with a time scale of 1.0f
float timeA = Time::GetDeltaTime(); // = 0.0166f
// Game running at 60 fps with a time scale of 0.5f
float timeA = Time::GetDeltaTime(); // = 0.0083f
GetUnscaledDeltaTime
Get unscaled delta time which is the time elapsed since the last frame (not affected by time scale).
float GetUnscaledDeltaTime()
Code sample:
// Game running at 60 fps with a time scale of 1.0f
float timeA = Time::GetUnscaledDeltaTime(); // = 0.0166f
// Game running at 60 fps with a time scale of 0.5f
float timeA = Time::GetUnscaledDeltaTime(); // = 0.0166f
GetTimeScale
Get time scale (Speed of the game).
float GetTimeScale()
Code sample:
Time::SetTimeScale(0.4f);
float timeScale = Time::GetTimeScale(); // = 0.4f
SetTimeScale
Get time scale (Speed of the game).
Parameters:
timeScale
: Time scale (minium 0)
void SetTimeScale(float timeScale)
Code sample:
Time::SetTimeScale(0.4f);
Transform
Add this in your code:
#include <engine/game_elements/transform.h>
Description
Class representing a 3D transformation (position, rotation, scale) of a GameObject.
Public Methods
GetPosition
Get world position.
const Vector3& GetPosition() const
SetPosition
Set world position.
Parameters:
position
: New world position
void SetPosition(const Vector3& position)
GetLocalPosition
Get local position.
const Vector3& GetLocalPosition() const
SetLocalPosition
Set local position.
Parameters:
position
: New world position
void SetLocalPosition(const Vector3& position)
GetEulerAngles
Get rotation (in degree).
const Vector3& GetEulerAngles() const
GetLocalEulerAngles
Get local rotation (in degree).
const Vector3& GetLocalEulerAngles() const
GetRotation
Get rotation.
const Quaternion& GetRotation() const
GetLocalRotation
Get local rotation.
const Quaternion& GetLocalRotation() const
SetEulerAngles
Set world rotation in degree.
Parameters:
rotation
: New world rotation
void SetEulerAngles(const Vector3& rotation)
SetLocalEulerAngles
Set local rotation in degree.
Parameters:
rotation
: New local rotation
void SetLocalEulerAngles(const Vector3& rotation)
SetRotation
Set world rotation.
Parameters:
rotation
: New world rotation
void SetRotation(const Quaternion& rotation)
SetLocalRotation
Set local rotation.
Parameters:
rotation
: New local rotation
void SetLocalRotation(const Quaternion& rotation)
GetScale
Get scale.
const Vector3& GetScale() const
GetLocalScale
Get local scale.
const Vector3& GetLocalScale() const
SetLocalScale
Set local scale.
Parameters:
scale
: New local scale
void SetLocalScale(const Vector3& scale)
GetForward
Get forward direction.
Vector3 GetForward() const
GetBackward
Get backward direction.
Vector3 GetBackward() const
GetLeft
Get left direction.
Vector3 GetLeft() const
GetRight
Get right direction.
Vector3 GetRight() const
GetUp
Get up direction.
Vector3 GetUp() const
GetDown
Get down direction.
Vector3 GetDown() const
GetTransformationMatrix
Set transformation matrix.
const glm::mat4& GetTransformationMatrix() const
SetTransformationMatrix
Set transformation matrix.
Parameters:
matrix
: New matrix
void SetTransformationMatrix(const glm::mat4& matrix)
GetGameObject
Get GameObject.
std::shared_ptr<GameObject> GetGameObject() const
GetOnTransformUpdated
Get the event that is called when the transform is updated (new position, or new rotation or new scale).
Event<>& GetOnTransformUpdated()
GetOnTransformScaled
Get the event that is called when the transform is scaled.
Event<>& GetOnTransformScaled()
UI Rendering
- HorizontalAlignment: Enum to horizontally align text with text rendering components.
- VerticalAlignment: Enum to vertically align text with text rendering components.
HorizontalAlignment Enum
Add this in your code:
#include <engine/graphics/ui/text_alignments.h>
Description
Enum to horizontally align text with text rendering components.
Values
Name | Description |
---|---|
Left | Put the text on the left of the pivot |
Center | Put the text at the center of the pivot |
Right | Put the text on the right of the pivot |
VerticalAlignment Enum
Add this in your code:
#include <engine/graphics/ui/text_alignments.h>
Description
Enum to vertically align text with text rendering components.
Values
Name | Description |
---|---|
Top | Put the text on the top of the pivot |
Center | Put the text at the center of the pivot |
Bottom | Put the text on the bottom of the pivot |
Utils
- EndianUtils: Utility class for endian conversion.
EndianUtils
Add this in your code:
#include <engine/tools/endian_utils.h>
Description
Utility class for endian conversion.
Usefull when using binary data on different platforms.
Static methods
IsBigEndian
Checks if the system is big-endian. For examples PC use little-endian, but PlayStation 3 use big-endian.
bool IsBigEndian()
Code sample:
// True on PlayStation 3
// False on most PC, PSP and PsVita
bool isBigEndian = EndianUtils::IsBigEndian();
SwapEndian
Converts an type from little-endian to big-endian or vice versa.
Only use simple types like int32_t, uint16_t, etc. Do not use this for complex types like structs or classes.
Parameters:
value
: Value to swap endian to
template <typename T>
T SwapEndian(T value)
Code sample:
uint32_t value = 123;
uint32_t newValue = EndianUtils::SwapEndian(value); // = 2063597568
VertexDescriptor
Add this in your code:
#include <engine/graphics/3d_graphics/vertex_descriptor.h>
Description
Class that store the data structure of a vertex.
Static methods
GetVertexElementSize
Get the size in bytes of a vertex element.
Parameters:
vertexElement
: Vertex element to check
uint16_t GetVertexElementSize(VertexElement vertexElement)
Code sample:
uint16_t elementSize = VertexDescriptor::GetVertexElementSize(VertexElement::POSITION_32_BITS);
Public methods
AddVertexElement
Add a vertex element to the descriptor.
Parameters:
vertexElement
: Vertex element to add
void AddVertexElement(VertexElement vertexElement)
Code sample:
VertexDescriptor descriptor;
descriptor.AddVertexElement(VertexElement::POSITION_32_BITS);
GetElementFromIndex
Add a vertex element to the descriptor.
Parameters:
index
: Index of the vertex element to get
VertexElement GetElementFromIndex(int32_t index) const
Code sample:
VertexDescriptor descriptor;
descriptor.AddVertexElement(VertexElement::NORMAL_32_BITS);
descriptor.AddVertexElement(VertexElement::POSITION_32_BITS);
VertexElement normalElement = descriptor.GetElementFromIndex(0);
VertexElement positionElement = descriptor.GetElementFromIndex(1);
GetOffsetFromIndex
Get the offset in memory of the vertex element from the index.
Parameters:
index
: Index of the vertex element
uint32_t GetOffsetFromIndex(int32_t index) const
GetPositionIndex
Get the index of the position vertex element.
Return -1 if there is no position vertex element.
```cpp
uint32_t GetPositionIndex() const
GetNormalIndex
Get the index of the normal vertex element.
Return -1 if there is no normal vertex element.
```cpp
uint32_t GetNormalIndex() const
GetUvIndex
Get the index of the UV vertex element.
Return -1 if there is no UV vertex element.
```cpp
uint32_t GetUvIndex() const
GetColorIndex
Get the index of the color vertex element.
Return -1 if there is no color vertex element.
uint32_t GetColorIndex() const
GetPositionOffset
Get the offset in memory of the position vertex element.
Do not use if there is no position vertex element.
uint32_t GetPositionOffset() const
GetNormalOffset
Get the offset in memory of the normal vertex element.
Do not use if there is no normal vertex element.
uint32_t GetNormalOffset() const
GetUvOffset
Get the offset in memory of the UV vertex element.
Do not use if there is no UV vertex element.
uint32_t GetUvOffset() const
GetColorOffset
Get the offset in memory of the color vertex element.
Do not use if there is no color vertex element.
uint32_t GetColorOffset() const
GetVertexElementList
Get the list of all vertex elements.
const std::vector<VertexElementInfo>& GetVertexElementList() const
GetVertexSize
Get the size in byte of a vertex.
uint16_t GetVertexSize() const
VertexElement
Add this in your code:
#include <engine/graphics/3d_graphics/vertex_descriptor.h>
Description
Enum of all different vertex element types.
Values
Name | Description |
---|---|
NONE | Default value, no selected element |
POSITION_32_BITS | Float position |
POSITION_16_BITS | Short position, PSP only, Not tested, may not work |
POSITION_8_BITS | Byte position, PSP only, Not tested, may not work |
NORMAL_32_BITS | Float normal |
NORMAL_16_BITS | Short normal, PSP only, Not tested, may not work |
NORMAL_8_BITS | Byte normal, PSP only, Not tested, may not work |
UV_32_BITS | Float UV |
UV_16_BITS | Short UV, PSP only, Not tested, may not work |
UV_8_BITS | Byte UV, PSP only, Not tested, may not work |
COLOR_4_FLOATS | Float color |
COLOR_32_BITS_UINT | Unsigned int32 color, PSP only |
How to compile the editor
- Install Visual Studio 2022,
- Clone the project
- Open Xenity_Engine.vcxproj
- Set the project
Xenity_Engine_Executable
as startup project, - Select the
Editor
configuration, - Compile.
The engine configuration is used to make game builds from the editor itself.
All dependencies binaries are already in the repository.
Generated files are located in the folder XenityBuild.
How to make a shipping build
- Create a new folder
- build both
Engine
andEditor
configurations, - Copy
Xenity_Engine_Executable.exe
(from theEditor
configuration),Xenity_Engine.dll
,Xenity_Engine.lib
,Xenity_Editor.dll
,Xenity_Editor.lib
into the new folder, - Rename
Xenity_Engine_Executable.exe
toXenity_Engine.exe
- Copy
freetype.dll
,SDL3.dll
,assimp-vc143-mt.dll
into the new folder, - Copy
Makefile.PS3
,CMakeLists.txt
,compile_shaders.sh
,Dockerfile
, into the new folder, - Copy
logo.ico
,res.rc
, into the new folder, - Copy
Roboto Regular.ttf
, into the new folder, - Copy
public_engine_assets
,engine_assets
,vscodeSample
,psvita_images
,psp_images
,icons
, into the new folder, - Copy
Source
,include
,vscodeSample
,psvita_images
,psp_images
,icons
, into the new folder, - Copy
main.cpp
, into the new folder
Done!
Credits
Creator:
Contributors:
Icons (not fully updated):
Question free icon designed by Freepik
Click through rate icons created by Prashanth Rapolu 15
Sphere free icon designed by Freepik
Contrer free icon designed by Freepik