├── .github └── workflows │ └── build.yml ├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── CMakeSettings.json ├── LICENSE.md ├── README.md ├── Samples ├── AirHockey │ ├── AirHockey_App.cpp │ ├── Bot.cpp │ ├── GameWorld.cpp │ ├── GameWorld.hpp │ ├── MainMenu.cpp │ ├── MainMenu.hpp │ ├── Paddle.cpp │ ├── Paddle.hpp │ ├── Player.cpp │ ├── Player.hpp │ ├── Puck.cpp │ ├── Puck.hpp │ ├── Table.cpp │ ├── Table.hpp │ ├── meshes │ │ ├── HockeyPaddle.fbx │ │ ├── HockeyPaddle.json │ │ ├── HockeyPuck.fbx │ │ ├── HockeyPuck.json │ │ ├── HockeyTable.fbx │ │ └── HockeyTable.json │ ├── sounds │ │ ├── MusicLicense.txt │ │ ├── Vibing Over Venus.mp3 │ │ ├── hockeyhit1.wav │ │ ├── hockeyhit2.wav │ │ ├── hockeyhit3.wav │ │ └── hockeyhit4.wav │ ├── textures │ │ └── HockeyTable.png │ └── ui │ │ ├── demo.rml │ │ ├── gameover.rml │ │ ├── loading.rml │ │ ├── mainmenu.rml │ │ └── style.rcss ├── Animation │ ├── CameraEntity.cpp │ ├── CameraEntity.hpp │ ├── Character.cpp │ ├── Character.hpp │ ├── Game.cpp │ ├── Level.cpp │ ├── Level.hpp │ ├── meshes │ │ ├── character.anim │ │ ├── character_anims.fbx │ │ ├── character_bones.skeleton │ │ ├── character_skin.json │ │ ├── daefix.txt │ │ ├── level.fbx │ │ ├── level_floors.json │ │ └── level_walls.json │ ├── ui │ │ └── ui.rml │ ├── virtualcontroller.hpp │ └── virtualcontroller.mm ├── AppInfo.hpp ├── Common │ └── FPSSystem.hpp ├── Flags │ ├── Flagpole.cpp │ ├── Flagpole.hpp │ ├── main.cpp │ ├── meshes │ │ ├── flag.anim │ │ ├── flag.fbx │ │ ├── flag.json │ │ ├── flag.skeleton │ │ ├── flagpole.fbx │ │ ├── flagpole.json │ │ ├── flagpole_top.json │ │ ├── grass.json │ │ └── grass.obj │ ├── shaders │ │ ├── flag.fsh │ │ ├── flag.vsh │ │ ├── flag_fsh.json │ │ ├── flag_special.fsh │ │ ├── flag_special_fsh.json │ │ ├── flag_vsh.json │ │ ├── grass.fsh │ │ ├── grass.vsh │ │ ├── grass_fsh.json │ │ └── grass_vsh.json │ ├── textures │ │ ├── flag_ca.svg │ │ ├── flag_mx.svg │ │ └── flag_us.svg │ └── ui │ │ └── ui.rml ├── GUI │ ├── App.cpp │ ├── World.cpp │ ├── World.hpp │ ├── textures │ │ └── gs_tiger.svg │ └── ui │ │ ├── deliveryfast-backlab_agency.json │ │ └── sink.rml ├── Gravity │ ├── main.cpp │ └── ui │ │ └── main.rml ├── Info.plist.in ├── Navigation │ ├── main.cpp │ ├── meshes │ │ ├── maze.fbx │ │ ├── maze.json │ │ ├── target.json │ │ └── target.obj │ └── ui │ │ └── ui.rml ├── Occlusion │ └── App.cpp ├── Perf_Draw │ ├── App.cpp │ ├── Camera.hpp │ ├── CustomMaterials.hpp │ ├── Level.cpp │ ├── Level.hpp │ ├── shaders │ │ ├── instance_colored.fsh │ │ ├── instance_colored.vsh │ │ ├── instance_colored_fsh.json │ │ └── instance_colored_vsh.json │ └── ui │ │ └── main.rml ├── Perf_DrawAnimated │ ├── App.cpp │ ├── Camera.hpp │ ├── PerfC_World.cpp │ ├── PerfC_World.hpp │ ├── Systems.hpp │ ├── textures │ │ ├── tx1.png │ │ ├── tx10.png │ │ ├── tx11.png │ │ ├── tx12.png │ │ ├── tx13.png │ │ ├── tx14.png │ │ ├── tx15.png │ │ ├── tx16.png │ │ ├── tx17.png │ │ ├── tx18.png │ │ ├── tx19.png │ │ ├── tx2.png │ │ ├── tx20.png │ │ ├── tx21.png │ │ ├── tx22.png │ │ ├── tx23.png │ │ ├── tx24.png │ │ ├── tx25.png │ │ ├── tx26.png │ │ ├── tx27.png │ │ ├── tx28.png │ │ ├── tx29.png │ │ ├── tx3.png │ │ ├── tx30.png │ │ ├── tx31.png │ │ ├── tx32.png │ │ ├── tx33.png │ │ ├── tx34.png │ │ ├── tx35.png │ │ ├── tx36.png │ │ ├── tx37.png │ │ ├── tx38.png │ │ ├── tx39.png │ │ ├── tx4.png │ │ ├── tx40.png │ │ ├── tx41.png │ │ ├── tx42.png │ │ ├── tx43.png │ │ ├── tx44.png │ │ ├── tx45.png │ │ ├── tx46.png │ │ ├── tx47.png │ │ ├── tx48.png │ │ ├── tx49.png │ │ ├── tx5.png │ │ ├── tx50.png │ │ ├── tx51.png │ │ ├── tx52.png │ │ ├── tx53.png │ │ ├── tx54.png │ │ ├── tx55.png │ │ ├── tx56.png │ │ ├── tx57.png │ │ ├── tx58.png │ │ ├── tx59.png │ │ ├── tx6.png │ │ ├── tx60.png │ │ ├── tx61.png │ │ ├── tx62.png │ │ ├── tx63.png │ │ ├── tx64.png │ │ ├── tx65.png │ │ ├── tx66.png │ │ ├── tx67.png │ │ ├── tx68.png │ │ ├── tx69.png │ │ ├── tx7.png │ │ ├── tx70.png │ │ ├── tx71.png │ │ ├── tx72.png │ │ ├── tx73.png │ │ ├── tx74.png │ │ ├── tx75.png │ │ ├── tx76.png │ │ ├── tx77.png │ │ ├── tx78.png │ │ ├── tx79.png │ │ ├── tx8.png │ │ ├── tx80.png │ │ └── tx9.png │ └── ui │ │ └── main.rml ├── Perf_ECS │ ├── App.cpp │ ├── Entity_And_Component.hpp │ ├── Level.cpp │ ├── Level.hpp │ └── ui │ │ └── ui.rml ├── Perf_Lighting │ ├── App.cpp │ ├── Level.cpp │ ├── Level.hpp │ ├── LightEntity.cpp │ ├── LightEntity.hpp │ ├── meshes │ │ ├── dragon_stanford.fbx │ │ └── dragon_stanford.json │ └── ui │ │ └── ui.rml ├── Perf_Network │ ├── App.cpp │ ├── ClientMenuLevel.cpp │ ├── ClientMenuLevel.hpp │ ├── Level.cpp │ ├── Level.hpp │ ├── NetEntity.cpp │ ├── NetEntity.hpp │ ├── NetTransform.cpp │ ├── NetTransform.hpp │ └── ui │ │ ├── client.rml │ │ └── server.rml ├── Perf_RigidBodies │ ├── App.cpp │ ├── Level.cpp │ ├── Level.hpp │ ├── Objects.cpp │ ├── Objects.hpp │ ├── meshes │ │ ├── ground.json │ │ └── ground.obj │ ├── textures │ │ └── checkerboard.png │ └── ui │ │ └── ui.rml ├── Playground │ ├── PlayerActor.hpp │ ├── TestEntity.cpp │ ├── TestEntity.hpp │ ├── WorldTest.cpp │ ├── WorldTest.hpp │ ├── main.cpp │ ├── meshes │ │ ├── bunny_decimated.fbx │ │ └── bunny_decimated.json │ └── textures │ │ └── youcantrun.png ├── Rats │ ├── README.md │ ├── app.cpp │ ├── meshes │ │ ├── pipe.json │ │ ├── pipe.obj │ │ ├── rat.json │ │ ├── rat.obj │ │ ├── what.json │ │ └── what.obj │ ├── shaders │ │ ├── what.fsh │ │ ├── what.vsh │ │ ├── what_fsh.json │ │ └── what_vsh.json │ ├── sounds │ │ ├── impact-1.ogg │ │ ├── impact-3.ogg │ │ ├── impact-4.ogg │ │ ├── impact-5.ogg │ │ ├── impact-6.ogg │ │ ├── impact-7.ogg │ │ ├── what.ogg │ │ └── whoosh.ogg │ ├── textures │ │ ├── pipe.png │ │ ├── rat.png │ │ └── what.png │ └── ui │ │ └── main.rml ├── Rendering │ ├── Attributions.md │ ├── main.cpp │ ├── meshes │ │ ├── asteroid_lod0.json │ │ ├── asteroid_lod0.obj │ │ ├── asteroid_lod1.json │ │ ├── asteroid_lod1.obj │ │ ├── asteroid_lod2.json │ │ ├── asteroid_lod2.obj │ │ ├── baked_light.glb │ │ ├── bakedcube.json │ │ ├── bakedplane.json │ │ ├── helmet.json │ │ ├── helmet.obj │ │ ├── wineglass.json │ │ └── wineglass.obj │ ├── shaders │ │ ├── AsteroidInit.csh │ │ ├── AsteroidInit.json │ │ ├── AsteroidMeshSelection.csh │ │ ├── AsteroidMeshSelection.json │ │ ├── AsteroidRender.fsh │ │ ├── AsteroidRender.vsh │ │ ├── AsteroidRender_fsh.json │ │ ├── AsteroidRender_vsh.json │ │ ├── AsteroidShared.glsl │ │ ├── AsteroidUpdate.csh │ │ ├── AsteroidUpdate.json │ │ ├── FireParticleInit.csh │ │ ├── FireParticleInit.json │ │ ├── FireParticleRender.fsh │ │ ├── FireParticleRender.vsh │ │ ├── FireParticleRender_fsh.json │ │ ├── FireParticleRender_vsh.json │ │ ├── FireParticleUpdate.csh │ │ ├── FireParticleUpdate.json │ │ ├── SmokeParticleInit.json │ │ ├── SmokeParticleInitialize.csh │ │ ├── SmokeParticleUpdate.csh │ │ ├── SmokeParticleUpdate.json │ │ ├── sprite_particle_layout.glsl │ │ ├── sprite_particle_layout_transparent.glsl │ │ ├── star.fsh │ │ ├── star.vsh │ │ ├── star_fsh.json │ │ ├── star_vsh.json │ │ ├── unlit_transparent.fsh │ │ ├── unlit_transparent.vsh │ │ ├── unlit_transparent_fsh.json │ │ ├── unlit_transparent_vsh.json │ │ ├── wineglass.fsh │ │ └── wineglass_fsh.json │ └── textures │ │ ├── Default_AO.png │ │ ├── Default_albedo.png │ │ ├── Default_emissive.png │ │ ├── Default_metalness.png │ │ ├── Default_normal.png │ │ ├── Default_roughness.png │ │ ├── bakedshadow.png │ │ ├── fire.png │ │ └── smoke.png ├── SceneViewer │ ├── SceneLoader.cpp │ ├── SceneLoader.hpp │ └── main.cpp ├── Shadows │ ├── main.cpp │ └── meshes │ │ ├── bunny_decimated.fbx │ │ ├── bunny_decimated.json │ │ ├── helmet.json │ │ ├── helmet.obj │ │ ├── pipe.json │ │ ├── pipe.obj │ │ ├── rat.json │ │ ├── rat.obj │ │ ├── triangle.json │ │ ├── triangle.obj │ │ ├── wineglass.json │ │ └── wineglass.obj ├── SoundDynamics │ ├── App.cpp │ ├── AudioExporter.cpp │ ├── AudioExporter.hpp │ ├── AudioMIDI.cpp │ ├── AudioMIDI.hpp │ ├── Level.cpp │ ├── Level.hpp │ ├── Player.cpp │ ├── Player.hpp │ ├── Speaker.cpp │ ├── Speaker.hpp │ ├── Stage.cpp │ ├── meshes │ │ ├── ceiling.json │ │ ├── floor.json │ │ ├── room.fbx │ │ ├── speaker.json │ │ ├── speaker.obj │ │ ├── wall_negx.json │ │ ├── wall_negz.json │ │ ├── wall_posx.json │ │ └── wall_posz.json │ ├── sounds │ │ ├── Aquarium.mp3 │ │ ├── Danse Macabre.mp3 │ │ ├── Licenses.txt │ │ ├── Maple Leaf Rag.mid │ │ ├── String Impromptu Number 1.mp3 │ │ └── The Entertainer.mp3 │ ├── streaming │ │ ├── Harp.sfz │ │ └── Strings │ │ │ └── Harp │ │ │ ├── KSHarp_A2_mf.ogg │ │ │ ├── KSHarp_A4_mf.ogg │ │ │ ├── KSHarp_A6_mf.ogg │ │ │ ├── KSHarp_B1_mf.ogg │ │ │ ├── KSHarp_B3_mf.ogg │ │ │ ├── KSHarp_B5_mf.ogg │ │ │ ├── KSHarp_B6_mf.ogg │ │ │ ├── KSHarp_C3_mf.ogg │ │ │ ├── KSHarp_C5_mf.ogg │ │ │ ├── KSHarp_D2_mf.ogg │ │ │ ├── KSHarp_D4_mf.ogg │ │ │ ├── KSHarp_D6_mf.ogg │ │ │ ├── KSHarp_D7_f.ogg │ │ │ ├── KSHarp_E1_f.ogg │ │ │ ├── KSHarp_E3_mf.ogg │ │ │ ├── KSHarp_E5_mf.ogg │ │ │ ├── KSHarp_F2_mf.ogg │ │ │ ├── KSHarp_F4_mf.ogg │ │ │ ├── KSHarp_F6_mf.ogg │ │ │ ├── KSHarp_F7_f.ogg │ │ │ ├── KSHarp_G1_mp.ogg │ │ │ ├── KSHarp_G3_mf.ogg │ │ │ └── KSHarp_G5_mf.ogg │ ├── textures │ │ └── speaker.png │ └── ui │ │ └── main.rml ├── SystemInfo │ ├── main.cpp │ └── ui │ │ └── ui.rml ├── TextureViewer │ └── main.cpp ├── Transforms │ └── app.cpp ├── VR │ └── main.cpp ├── iosLaunchScreen.storyboard ├── logo.ico ├── logo.png ├── resource.h └── windows.rc ├── appimage.cmake ├── assets ├── HockeyPaddle.blend ├── HockeyPuck.mb ├── HockeyTable.blend ├── SimpleBakeTest.blend ├── animation_level.mb ├── baked_light.blend ├── character.mb ├── character_animations.mb ├── flag.mb ├── flagpole.mb ├── grass.mb ├── maze1.mb ├── physics_scene.mb ├── piano.mb ├── pipe.ma ├── rat.ma ├── room.mb ├── simplerig.mb ├── simplerig2.mb ├── simplerig3.mb ├── speaker.mb ├── target.mb ├── theatre.mb ├── theatre_chair.mb ├── what.ma └── wineglass.ma └── config ├── build-ios.sh ├── build-linux.sh ├── build-mac.sh ├── build-win.bat ├── crosscomp-sources.list ├── init-ios.sh ├── init-linux.sh ├── init-linuxarm.sh ├── init-mac.sh ├── init-tvos.sh ├── init-web.sh ├── init-win.bat └── init-winarm.bat /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | *.DS_Store 3 | *.vscode 4 | .vs/ 5 | deps/physx/physx/include/PxConfig.h 6 | Testing/ 7 | .mayaSwatches 8 | *.blend1 9 | *.blend2 -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "RavEngine"] 2 | path = RavEngine 3 | url = https://github.com/ravbug/RavEngine 4 | -------------------------------------------------------------------------------- /CMakeSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "x64-Debug", 5 | "generator": "Ninja", 6 | "configurationType": "Debug", 7 | "inheritEnvironments": [ "msvc_x64_x64" ], 8 | "buildRoot": "${projectDir}\\out\\build\\${name}", 9 | "installRoot": "${projectDir}\\out\\install\\${name}", 10 | "cmakeCommandArgs": "", 11 | "buildCommandArgs": "", 12 | "ctestCommandArgs": "" 13 | }, 14 | { 15 | "name": "x64-Release", 16 | "generator": "Ninja", 17 | "configurationType": "RelWithDebInfo", 18 | "buildRoot": "${projectDir}\\out\\build\\${name}", 19 | "installRoot": "${projectDir}\\out\\install\\${name}", 20 | "cmakeCommandArgs": "", 21 | "buildCommandArgs": "", 22 | "ctestCommandArgs": "", 23 | "inheritEnvironments": [ "msvc_x64_x64" ], 24 | "variables": [] 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RavEngine Samples 2 | 3 | This repository contains sample programs to demonstrate how to use the [RavEngine C++ game library](https://github.com/RavEngine/RavEngine). 4 | 5 | ## Samples 6 | 1. AirHockey 7 | - A simple air hockey game demonstrating RavEngine fundamentals (WIP) 8 | 1. Playground 9 | - A testing zone, subject to change 10 | 1. Perf-ECS 11 | - ECS raw number crunching benchmark 12 | 1. Perf-Draw 13 | - InstancedStaticMesh demo 14 | 1. Perf-DrawAnimated 15 | - A stress test for high object count with animated lights 16 | 1. Perf-Network 17 | - A networking stress test. Contains both the server and client code in the same target. Launch with no arguments for client, and any argument for server 18 | 1. Perf-Lighting 19 | - GPU-centric lighting and materials performance test with high-polygon models 20 | 1. GUI 21 | - A demonstration of all the different supported GUI widgets 22 | 1. Animation 23 | - Demonstrates the skinned mesh blending capabilities of RavEngine 24 | 1. SoundDynamics 25 | - A virtual soundstage demonstrating the audio reverbation modeling feature 26 | 1. Flags 27 | - Mixing skeletal and vertex animation, along using vector graphics on textures 28 | 1. Gravity 29 | - Creating orbits using PhysX forces 30 | 1. Navigation 31 | - Raycasting and pathfinding across 3D terrain 32 | 1. Occlusion 33 | - Test case for dynamic occlusion culling 34 | 1. Rendering 35 | - Demonstrate the various features of the render engine 36 | 1. Rats 37 | - Crazy? I was crazy once... 38 | 39 | ## How to try the samples without building 40 | 1. Sign in to GitHub in your browser. This is required for accessing the downloads. 41 | 2. Go to [Actions > Build Samples](https://github.com/RavEngine/Samples/actions/workflows/build.yml) on this repository 42 | 3. Find the latest run that has a build for your platform (check the failed runs as well) 43 | 4. Download the Artifact for your platform 44 | 45 | ## How to build the samples 46 | 1. Ensure RavEngine [supports your platform](https://github.com/ravengine/ravengine#supported-platforms). 47 | 2. Ensure you have the minimum required CMake version (see `CMakeLists.txt`), as well as a C++20-compatible compiler and required SDKs for your platform. See the RavEngine repository for [additional dependency requirements](https://github.com/ravbug/ravengine#supported-platforms) for your platform. 48 | 3. Execute in terminal: `git clone https://github.com/RavEngine/Samples --depth=1 --recurse-submodules` 49 | - Do not use GitHub's Download as Zip, this will not include the required submodules. 50 | 4. Navigate your terminal into the `config` directory, and execute the build script for your system. 51 | - macOS: `./build-mac.sh` 52 | - Windows: `build-win.bat` 53 | - Note: Due to a known bug in the Windows configure process, you will need to execute this script twice to build successfully. 54 | - Linux: `./build-linux.sh` 55 | - iOS (device): `./init-ios.sh` (project gen only, open Xcode for code signing) 56 | - tvOS (device): `./init-tvos.sh` (project gen only, open Xcode for code signing) 57 | - UWP: `./init-uwp.bat` (project gen only, use Publish in Visual Studio to generate MSIX installers) 58 | 5. Navigate your terminal to the `build/release` directory, and run the samples. 59 | -------------------------------------------------------------------------------- /Samples/AirHockey/AirHockey_App.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "GameWorld.hpp" 3 | #include 4 | #include "MainMenu.hpp" 5 | #include "RavEngine/App.hpp" 6 | #include "AppInfo.hpp" 7 | #include 8 | #include 9 | #include 10 | 11 | using namespace RavEngine; 12 | 13 | class AirHockey : public RavEngine::App { 14 | void OnStartup(int argc, char** argv) final{ 15 | //setup video settings 16 | RenderEngine::VideoSettings.vsync = true; 17 | 18 | AddWorld(RavEngine::New()); 19 | } 20 | 21 | void OnFatal(const std::string_view msg) final{ 22 | RavEngine::Dialog::ShowBasic("Fatal Error", msg, Dialog::MessageBoxType::Error); 23 | } 24 | }; 25 | 26 | START_APP(AirHockey) 27 | -------------------------------------------------------------------------------- /Samples/AirHockey/Bot.cpp: -------------------------------------------------------------------------------- 1 | #include "Player.hpp" 2 | #include 3 | #include "Puck.hpp" 4 | #include 5 | 6 | using namespace std; 7 | using namespace RavEngine; 8 | 9 | 10 | void BotPlayer::Tick(float scale){ 11 | //define the goal position 12 | vector3 goalpos(0,0, leftSide? 3 : -3); 13 | 14 | //find the closest puck to the goal 15 | Entity closestPuck = GetOwner().GetWorld()->GetComponent().GetOwner(); 16 | auto worldpos = GetOwner().GetTransform().GetWorldPosition(); 17 | float closestDist = 1000; 18 | 19 | 20 | GetOwner().GetWorld()->Filter([&](const PuckComponent& puck, const Transform& transform) mutable { 21 | auto dist = glm::distance(transform.GetWorldPosition(), goalpos); 22 | if (dist <= closestDist) { 23 | closestDist = dist; 24 | closestPuck = puck.GetOwner(); 25 | } 26 | }); 27 | 28 | //if puck is on bot's side of the field, move towards that puck 29 | auto pos = closestPuck.GetTransform().GetWorldPosition(); 30 | 31 | bool shouldChase = (!leftSide && pos.z < 0) || (leftSide && pos.z >= 0); 32 | 33 | vector3 dir; 34 | if (shouldChase){ 35 | dir = glm::normalize(pos - worldpos); 36 | } 37 | else{ 38 | //otherwise, move towards the puck's goal to guard it 39 | dir = glm::normalize(goalpos - worldpos); 40 | } 41 | 42 | pl->MoveUpDown(dir.x); 43 | pl->MoveLeftRight(dir.z); 44 | } 45 | -------------------------------------------------------------------------------- /Samples/AirHockey/GameWorld.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Puck.hpp" 3 | #include "Table.hpp" 4 | #include "Paddle.hpp" 5 | #include "Player.hpp" 6 | #include 7 | 8 | namespace RavEngine{ 9 | class AudioAsset; 10 | } 11 | 12 | using namespace RavEngine; 13 | 14 | class GameWorld : public RavEngine::World { 15 | public: 16 | GameWorld(int numplayers, Ref); 17 | 18 | GameWorld(const GameWorld& other); 19 | 20 | void PostTick(float) override; 21 | 22 | 23 | protected: 24 | GameObject hockeytable = Instantiate(); 25 | GameObject puck = Instantiate(); 26 | 27 | GameObject cameraBoom = Instantiate(); 28 | 29 | Paddle p1; 30 | Paddle p2; 31 | 32 | int numplayers; 33 | 34 | int p1score = 0, p2score = 0, numToWin = 3; 35 | 36 | Rml::Element* Scoreboard = nullptr; 37 | Ref musicAsset; 38 | 39 | void Reset(); 40 | void GameOver(); 41 | }; 42 | -------------------------------------------------------------------------------- /Samples/AirHockey/MainMenu.cpp: -------------------------------------------------------------------------------- 1 | #include "MainMenu.hpp" 2 | #include 3 | #include 4 | #include 5 | #include "GameWorld.hpp" 6 | #include 7 | #include 8 | 9 | using namespace RavEngine; 10 | using namespace std; 11 | 12 | MainMenu::MainMenu(){ 13 | mainMenu = Instantiate(); 14 | mainMenu.EmplaceComponent().SetActive(true); 15 | 16 | auto& menu = mainMenu.EmplaceComponent(); 17 | auto doc = menu.AddDocument("mainmenu.rml"); 18 | menu.AddDocument("loading.rml")->Hide(); 19 | 20 | // shown here is an example of how to bind separate event listeners 21 | // You can also share event listeners by reading data from the event object 22 | struct QuitEventListener: public Rml::EventListener{ 23 | void ProcessEvent(Rml::Event& event) override{ 24 | GetApp()->Quit(); 25 | } 26 | }; 27 | struct StartEventListener: public Rml::EventListener{ 28 | MainMenu* menu; 29 | StartEventListener(const decltype(menu) m) : menu(m) {}; 30 | void ProcessEvent(Rml::Event& event) override{ 31 | menu->LoadGame(1); 32 | } 33 | }; 34 | struct StartMultiplayerEventListener : public Rml::EventListener{ 35 | MainMenu* menu; 36 | StartMultiplayerEventListener(const decltype(menu) m) : menu(m) {}; 37 | void ProcessEvent(Rml::Event& event) override{ 38 | menu->LoadGame(2); 39 | } 40 | }; 41 | struct StartZeroplayerEventListener : public Rml::EventListener{ 42 | MainMenu* menu; 43 | StartZeroplayerEventListener(const decltype(menu) m) : menu(m) {}; 44 | void ProcessEvent(Rml::Event& event) override{ 45 | menu->LoadGame(0); 46 | } 47 | }; 48 | 49 | doc->GetElementById("quitbtn")->AddEventListener(Rml::EventId::Click, new QuitEventListener()); 50 | doc->GetElementById("playsingle")->AddEventListener(Rml::EventId::Click, new StartEventListener(this)); 51 | doc->GetElementById("playmulti")->AddEventListener(Rml::EventId::Click, new StartMultiplayerEventListener(this)); 52 | doc->GetElementById("playzero")->AddEventListener(Rml::EventId::Click, new StartZeroplayerEventListener(this)); 53 | 54 | 55 | Ref im = RavEngine::New(); 56 | im->AddAxisMap("MouseX", Special::MOUSEMOVE_X); 57 | im->AddAxisMap("MouseY", Special::MOUSEMOVE_Y); 58 | 59 | ComponentHandle gh(mainMenu); 60 | 61 | im->BindAxis("MouseX", gh, &GUIComponent::MouseX, CID::ANY, 0); 62 | im->BindAxis("MouseY", gh, &GUIComponent::MouseY, CID::ANY, 0); 63 | im->BindAnyAction(gh->GetData()); 64 | 65 | GetApp()->inputManager = im; 66 | 67 | menu.Debug(); 68 | 69 | // this can take a bit to load, so start loading it in the background 70 | std::thread loaderThread([this] { 71 | musicAsset = New("Vibing Over Venus.mp3", 2); 72 | musicSemaphore.release(); 73 | }); 74 | loaderThread.detach(); 75 | } 76 | 77 | void MainMenu::LoadGame(int numplayers){ 78 | auto& gui = mainMenu.GetComponent(); 79 | gui.GetDocument("mainmenu.rml")->Hide(); 80 | gui.GetDocument("loading.rml")->Show(); 81 | 82 | // make sure the music is loaded 83 | musicSemaphore.acquire(); 84 | Debug::Assert(musicAsset.get() != nullptr, "Semaphore is not correct!"); 85 | auto g = RavEngine::New(numplayers,musicAsset); 86 | 87 | GetApp()->DispatchMainThread([=] { 88 | GetApp()->AddReplaceWorld(shared_from_this(), g); 89 | }); 90 | } 91 | -------------------------------------------------------------------------------- /Samples/AirHockey/MainMenu.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | namespace RavEngine { 8 | class AudioAsset; 9 | } 10 | 11 | class MainMenu : public RavEngine::World, public RavEngine::IInputListener{ 12 | public: 13 | MainMenu(); 14 | private: 15 | void LoadGame(int); 16 | RavEngine::Entity mainMenu; 17 | Ref musicAsset; 18 | std::binary_semaphore musicSemaphore{ 0 }; 19 | }; 20 | -------------------------------------------------------------------------------- /Samples/AirHockey/Paddle.cpp: -------------------------------------------------------------------------------- 1 | #include "Paddle.hpp" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | using namespace RavEngine; 11 | 12 | void Paddle::Create(const ColorRGBA& color) 13 | { 14 | GameObject::Create(); 15 | MeshAssetOptions opt; 16 | 17 | Ref material = New(Material::Manager::Get()); 18 | material->SetAlbedoColor(color); 19 | auto& mesh = EmplaceComponent(New(MeshAsset::Manager::Get("HockeyPaddle", opt)), material); 20 | 21 | //PhysX doesn't have a cylinder primitive, so we use a sphere offset upwards and lock the axes 22 | auto& dyn = EmplaceComponent(FilterLayers::L0, FilterLayers::L0 | FilterLayers::L1); 23 | 24 | dyn.EmplaceCollider(0.5f, New(0.3f, 0.3f, 0.1f), vector3(0, 0.4, 0)); 25 | 26 | dyn.SetMass(2); 27 | dyn.SetAxisLock( 28 | RigidBodyDynamicComponent::AxisLock::Angular_X | 29 | RigidBodyDynamicComponent::AxisLock::Angular_Z 30 | //| RigidBodyDynamicComponent::AxisLock::Linear_Y 31 | ); 32 | 33 | 34 | auto& light = EmplaceComponent(); 35 | light.SetColorRGBA(color); 36 | light.SetIntensity(2); 37 | } 38 | -------------------------------------------------------------------------------- /Samples/AirHockey/Paddle.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | 6 | class Paddle : public RavEngine::GameObject{ 7 | public: 8 | void Create(const RavEngine::ColorRGBA& color); 9 | }; 10 | -------------------------------------------------------------------------------- /Samples/AirHockey/Player.cpp: -------------------------------------------------------------------------------- 1 | #include "Player.hpp" 2 | #include 3 | 4 | using namespace RavEngine; 5 | 6 | void Player::MoveUpDown(float amt) 7 | { 8 | if (std::abs(amt) > 0.1) { 9 | GetOwner().GetComponent().AddForce(vector3(amt, 0, 0) * sensitivity); 10 | } 11 | } 12 | 13 | void Player::MoveLeftRight(float amt) 14 | { 15 | if (std::abs(amt) > 0.1) { 16 | GetOwner().GetComponent().AddForce(vector3(0, 0, amt) * sensitivity); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Samples/AirHockey/Player.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Paddle.hpp" 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class Player : public RavEngine::ComponentWithOwner, public RavEngine::Queryable{ 10 | protected: 11 | decimalType sensitivity = 15; 12 | public: 13 | Player(RavEngine::Entity id) : ComponentWithOwner(id){} 14 | void MoveUpDown(float amt); 15 | 16 | void MoveLeftRight(float amt); 17 | }; 18 | 19 | class BotPlayer : public RavEngine::ScriptComponent{ 20 | protected: 21 | RavEngine::ComponentHandle pl; 22 | bool leftSide; 23 | public: 24 | BotPlayer(RavEngine::Entity owner, decltype(pl) p, bool leftSide) : pl(p), leftSide(leftSide), ScriptComponent(owner){} 25 | 26 | void Tick(float scale) override; 27 | }; 28 | -------------------------------------------------------------------------------- /Samples/AirHockey/Puck.cpp: -------------------------------------------------------------------------------- 1 | #include "Puck.hpp" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | using namespace RavEngine; 16 | 17 | void Puck::Create() 18 | { 19 | GameObject::Create(); 20 | MeshAssetOptions opt; 21 | if (material == nullptr) { 22 | material = New(Material::Manager::Get()); 23 | material->SetAlbedoColor({ 0.2,0.2,0.2,1 }); 24 | } 25 | auto& puckmesh = EmplaceComponent(New(MeshAsset::Manager::Get("HockeyPuck", opt)), material); 26 | 27 | auto& dyn = EmplaceComponent(FilterLayers::L0, FilterLayers::L0 | FilterLayers::L1); 28 | dyn.EmplaceCollider(0.3f, New(0.f, 0.f, 1.f), vector3(0.f, 0.3f, 0.f)); 29 | 30 | //prevent puck from falling over 31 | dyn.SetAxisLock(RigidBodyDynamicComponent::AxisLock::Angular_X | RigidBodyDynamicComponent::AxisLock::Angular_Z); 32 | dyn.SetMass(1.0); 33 | 34 | auto lightEntity = GetWorld()->Instantiate(); 35 | 36 | auto& light = lightEntity.EmplaceComponent(); 37 | light.SetColorRGBA({ 0,0,1,1 }); 38 | light.SetIntensity(2); 39 | 40 | GetTransform().AddChild(ComponentHandle(lightEntity)); 41 | 42 | lightEntity.GetTransform().LocalTranslateDelta(vector3(0, 1, 0)); 43 | 44 | EmplaceComponent(); 45 | 46 | auto& scr = EmplaceComponent(); 47 | 48 | auto callbackptr = New(); 49 | auto me = *this; 50 | callbackptr->OnColliderEnter = [me](PhysicsBodyComponent& other, const ContactPairPoint* contactPoints, size_t numContactPoints) { 51 | me.GetComponent().OnColliderEnter(other, contactPoints, numContactPoints); 52 | }; 53 | 54 | dyn.AddReceiver(callbackptr); 55 | } 56 | 57 | PuckScript::PuckScript(Entity owner) : ScriptComponent(owner), sounds{ 58 | New("hockeyhit1.wav"), 59 | New("hockeyhit2.wav"), 60 | New("hockeyhit3.wav"), 61 | New("hockeyhit4.wav") 62 | } 63 | { 64 | } 65 | 66 | void PuckScript::OnColliderEnter(PhysicsBodyComponent&, const ContactPairPoint* contactPoints, size_t numContactPoints) 67 | { 68 | auto now = GetApp()->GetCurrentTime(); 69 | if (now - lastSoundTime > 0.25) { 70 | GetOwner().GetWorld()->PlaySound(InstantaneousAudioSource(sounds[std::rand() % 4], GetTransform().GetWorldPosition(), 3)); 71 | lastSoundTime = now; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Samples/AirHockey/Puck.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace RavEngine { 8 | class PhysicsBodyComponent; 9 | struct ContactPairPoint; 10 | class AudioAsset; 11 | } 12 | 13 | //marker for querying 14 | struct PuckComponent : public RavEngine::ComponentWithOwner{ 15 | PuckComponent(RavEngine::Entity owner) : ComponentWithOwner(owner){} 16 | }; 17 | 18 | struct PuckScript : public RavEngine::ScriptComponent, public RavEngine::Queryable{ 19 | double lastSoundTime = 0; 20 | 21 | using RavEngine::Queryable::GetQueryTypes; 22 | 23 | RavEngine::Array,4> sounds; 24 | PuckScript(RavEngine::Entity owner); 25 | void Tick(float scale) override{} 26 | void OnColliderEnter(RavEngine::PhysicsBodyComponent&, const RavEngine::ContactPairPoint* contactPoints, size_t numContactPoints); 27 | }; 28 | 29 | class Puck : public RavEngine::GameObject{ 30 | public: 31 | static Ref material; 32 | void Create(); 33 | }; 34 | -------------------------------------------------------------------------------- /Samples/AirHockey/Table.cpp: -------------------------------------------------------------------------------- 1 | #include "Table.hpp" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | using namespace RavEngine; 12 | 13 | void Table::Create() 14 | { 15 | GameObject::Create(); 16 | //create the table 17 | Ref matinst = New< PBRMaterialInstance>(Material::Manager::Get()); 18 | auto tableMeshAsset = MeshAsset::Manager::Get("HockeyTable", MeshAssetOptions{ .keepInSystemRAM = true }); 19 | auto& tablemesh = EmplaceComponent(New(tableMeshAsset), matinst); 20 | 21 | //low-friction 22 | Ref physmat = New(0, 0, 1.5); 23 | Ref floorphysmat = New(0.03, 0.03, 0); //version for floor that is not bouncy 24 | 25 | auto& dyn = EmplaceComponent(/*FilterLayers::L0,FilterLayers::L0 | FilterLayers::L1*/); 26 | dyn.EmplaceCollider(vector3(3, 1.3, 5), floorphysmat); 27 | 28 | constexpr float height = 2.326; 29 | constexpr float zdist = 5; 30 | constexpr float xdist = 3.09; 31 | constexpr float width = 1.1; 32 | 33 | //long-axis borders, with hole for puck to fall through 34 | dyn.EmplaceCollider(vector3(width / 1.8, 2.098 / 2, 0.258 / 2), physmat, vector3(xdist / 2, height, zdist)); 35 | dyn.EmplaceCollider(vector3(width / 1.8, 2.098 / 2, 0.258 / 2), physmat, vector3(xdist / 2, height, -zdist)); 36 | dyn.EmplaceCollider(vector3(width / 1.8, 2.098 / 2, 0.258 / 2), physmat, vector3(-xdist / 2, height, zdist)); 37 | dyn.EmplaceCollider(vector3(width / 1.8, 2.098 / 2, 0.258 / 2), physmat, vector3(-xdist / 2, height, -zdist)); 38 | 39 | //short-axis borders 40 | dyn.EmplaceCollider(vector3(0.6 / 2, 2.162 / 2, 9.877 / 2), physmat, vector3(xdist, height, 0)); 41 | dyn.EmplaceCollider(vector3(0.6 / 2, 2.162 / 2, 9.877 / 2), physmat, vector3(-xdist, height, 0)); 42 | 43 | //prevent paddles from going through 44 | dyn.EmplaceCollider(vector3(width, 0.2, 0.15), physmat, vector3(0, 2.2, zdist)); 45 | dyn.EmplaceCollider(vector3(width, 0.2, 0.15), physmat, vector3(0, 2.2, -zdist)); 46 | 47 | //diagonal boxes on corners 48 | struct cornerbox { 49 | float x, z, angle; 50 | }; 51 | //the corners are rotated different amounts to make the different corners deflect unevenly 52 | constexpr cornerbox corners[] = { {3,4.5,48},{3,-4.5,-44},{-3,-4.5,40},{-3,4.5,-49} }; 53 | 54 | for (const auto& corner : corners) { 55 | dyn.EmplaceCollider(vector3(1, 1, 0.2), physmat, vector3(corner.x, height, corner.z), vector3(0, deg_to_rad(corner.angle), 0)); 56 | } 57 | 58 | //load texture 59 | Ref t = New("HockeyTable.png"); 60 | matinst->SetAlbedoTexture(t); 61 | } 62 | -------------------------------------------------------------------------------- /Samples/AirHockey/Table.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | struct TableDebugRenderer; 5 | 6 | class Table : public RavEngine::GameObject{ 7 | public: 8 | void Create(); 9 | }; 10 | -------------------------------------------------------------------------------- /Samples/AirHockey/meshes/HockeyPaddle.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/AirHockey/meshes/HockeyPaddle.fbx -------------------------------------------------------------------------------- /Samples/AirHockey/meshes/HockeyPaddle.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "HockeyPaddle.fbx", 3 | "scale": 0.5 4 | } -------------------------------------------------------------------------------- /Samples/AirHockey/meshes/HockeyPuck.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/AirHockey/meshes/HockeyPuck.fbx -------------------------------------------------------------------------------- /Samples/AirHockey/meshes/HockeyPuck.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "HockeyPuck.fbx", 3 | "scale": 0.35 4 | } -------------------------------------------------------------------------------- /Samples/AirHockey/meshes/HockeyTable.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/AirHockey/meshes/HockeyTable.fbx -------------------------------------------------------------------------------- /Samples/AirHockey/meshes/HockeyTable.json: -------------------------------------------------------------------------------- 1 | { 2 | "file" : "HockeyTable.fbx" 3 | } -------------------------------------------------------------------------------- /Samples/AirHockey/sounds/MusicLicense.txt: -------------------------------------------------------------------------------- 1 | "Vibing Over Venus" Kevin MacLeod (incompetech.com) 2 | Licensed under Creative Commons: By Attribution 4.0 License 3 | http://creativecommons.org/licenses/by/4.0/ -------------------------------------------------------------------------------- /Samples/AirHockey/sounds/Vibing Over Venus.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/AirHockey/sounds/Vibing Over Venus.mp3 -------------------------------------------------------------------------------- /Samples/AirHockey/sounds/hockeyhit1.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/AirHockey/sounds/hockeyhit1.wav -------------------------------------------------------------------------------- /Samples/AirHockey/sounds/hockeyhit2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/AirHockey/sounds/hockeyhit2.wav -------------------------------------------------------------------------------- /Samples/AirHockey/sounds/hockeyhit3.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/AirHockey/sounds/hockeyhit3.wav -------------------------------------------------------------------------------- /Samples/AirHockey/sounds/hockeyhit4.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/AirHockey/sounds/hockeyhit4.wav -------------------------------------------------------------------------------- /Samples/AirHockey/textures/HockeyTable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/AirHockey/textures/HockeyTable.png -------------------------------------------------------------------------------- /Samples/AirHockey/ui/demo.rml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 16 | 17 | 18 |

19 | Scores: 20 |

21 | 22 |
23 | -------------------------------------------------------------------------------- /Samples/AirHockey/ui/gameover.rml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Samples/AirHockey/ui/loading.rml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | Loading... 13 | 14 | -------------------------------------------------------------------------------- /Samples/AirHockey/ui/mainmenu.rml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | RavEngine 10 | 11 | 12 | AirHockey 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
-------------------------------------------------------------------------------- /Samples/AirHockey/ui/style.rcss: -------------------------------------------------------------------------------- 1 | 2 | tagline, gamename{ 3 | display:block; 4 | text-align:center; 5 | width:100%; 6 | } 7 | header, menu{ 8 | width:100%; 9 | margin: 50dp; 10 | } 11 | tagline, button{ 12 | font-size:30dp; 13 | } 14 | tagline{ 15 | margin-top: 40dp; 16 | } 17 | gamename{ 18 | font-size:100dp; 19 | } 20 | button{ 21 | background-color: #AAAAAAFF; 22 | border: 2dp #DDDDDDFF; 23 | border-radius: 5dp; 24 | display:block; 25 | max-width: 300dp; 26 | text-align: center; 27 | margin:auto; 28 | margin-top: 20dp; 29 | padding: 10dp; 30 | transition: font-size color 1.6s elastic-out; 31 | } 32 | button:hover{ 33 | color:red; 34 | font-size: 35dp; 35 | transition: font-size color 1.6s elastic-out; 36 | } 37 | button:active{ 38 | font-size: 32dp; 39 | transition: font-size color 0.7s elastic-out; 40 | } 41 | -------------------------------------------------------------------------------- /Samples/Animation/CameraEntity.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "Character.hpp" 4 | 5 | struct CameraScript : public RavEngine::ComponentWithOwner { 6 | Character target; 7 | vector3 forwardVector = vector3(0, 0, 0); 8 | vector3 rightVector = vector3(0, 0, 0); 9 | decimalType speedIncrement = 0; 10 | 11 | CameraScript(RavEngine::Entity owner, const decltype(target)& t) : target(t), ComponentWithOwner(owner) {} 12 | void Tick(float); 13 | }; 14 | struct CameraEntity : public RavEngine::GameObject { 15 | void Create(Character); 16 | 17 | // handling input manager events inside an entity handle is possible, but 18 | // not recommended 19 | void MoveForward(float); 20 | void MoveRight(float); 21 | void SpeedIncrement(float); 22 | void Jump(); 23 | void Pound(); 24 | void Wave(); 25 | 26 | inline auto get_id( )const{ 27 | return id.id; 28 | } 29 | 30 | inline auto get(){ 31 | return this; 32 | } 33 | 34 | private: 35 | RavEngine::GameObject cameraEntity, cameraArmBase; 36 | RavEngine::ComponentHandle cameraScript; 37 | }; 38 | 39 | struct CameraScriptRunner : public RavEngine::AutoCTTI{ 40 | void operator()(CameraScript&); 41 | }; 42 | -------------------------------------------------------------------------------- /Samples/Animation/Character.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace RavEngine { 10 | struct MeshCollectionSkinned; 11 | struct MeshCollectionStatic; 12 | } 13 | 14 | struct CharacterScript : public RavEngine::ComponentWithOwner { 15 | 16 | RavEngine::ComponentHandle animator; 17 | RavEngine::ComponentHandle rigidBody; 18 | RavEngine::Tween waveInfluenceTween; 19 | bool tweenEnabled = false; 20 | bool controlsEnabled = true; 21 | constexpr static decimalType sprintSpeed = 2.5, walkSpeed = 2; 22 | 23 | int16_t groundCounter = 0; 24 | 25 | CharacterScript(RavEngine::Entity owner, decltype(animator) a, decltype(rigidBody) r); 26 | 27 | bool OnGround() const; 28 | 29 | void Tick(float fpsScale); 30 | 31 | void Move(const vector3& dir, decimalType speedMultiplier); 32 | 33 | void Jump(); 34 | 35 | void Pound(); 36 | 37 | void OnColliderEnter(RavEngine::PhysicsBodyComponent& other, const RavEngine::ContactPairPoint* contactPoints, size_t numContactPoints); 38 | 39 | void OnColliderExit(RavEngine::PhysicsBodyComponent& other, const RavEngine::ContactPairPoint* contactPoints, size_t numContactPoints); 40 | 41 | void StartPounding(); 42 | 43 | void Wave(); 44 | 45 | }; 46 | 47 | namespace RavEngine { 48 | class MeshAssetSkinned; 49 | class PBRMaterialInstance; 50 | class SkeletonAsset; 51 | } 52 | 53 | 54 | struct Character : public RavEngine::GameObject { 55 | void Create(Ref skinnedMesh, Ref handMesh, Ref handMatInst, Ref materialInstance, Ref skeleton); 56 | void Move(const vector3&, decimalType speedMultiplier = 0); 57 | void Jump(); 58 | void Pound(); 59 | void Wave(); 60 | 61 | // anything that has these 2 calls 62 | // can be a target for input manager 63 | // however, the memory location of the 64 | // bound object must be stable 65 | inline auto get_id() const{ 66 | return id; 67 | } 68 | 69 | inline Character* get() const{ 70 | return const_cast(this); 71 | } 72 | 73 | private: 74 | RavEngine::ComponentHandle rigidBody; 75 | RavEngine::ComponentHandle script; 76 | }; 77 | 78 | struct CharacterScriptRunner : public RavEngine::AutoCTTI { 79 | void operator()(CharacterScript&); 80 | }; 81 | -------------------------------------------------------------------------------- /Samples/Animation/Game.cpp: -------------------------------------------------------------------------------- 1 | #include "Level.hpp" 2 | #include 3 | #include "AppInfo.hpp" 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "virtualcontroller.hpp" 9 | 10 | class Game : public RavEngine::App{ 11 | public: 12 | void OnStartup(int argc, char** argv) final{ 13 | #if TARGET_OS_IOS 14 | InitVirtualController(); 15 | #endif 16 | 17 | AddWorld(RavEngine::New()); 18 | 19 | SetWindowTitle(RavEngine::VFormat("{} | {}", APPNAME, GetRenderEngine().GetCurrentBackendName()).c_str()); 20 | } 21 | void OnFatal(const std::string_view msg) final{ 22 | RavEngine::Dialog::ShowBasic("Fatal Error", msg, RavEngine::Dialog::MessageBoxType::Error); 23 | } 24 | 25 | bool NeedsAudio() const final { 26 | return false; 27 | } 28 | }; 29 | 30 | START_APP(Game) 31 | -------------------------------------------------------------------------------- /Samples/Animation/Level.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include "Character.hpp" 6 | #include "CameraEntity.hpp" 7 | 8 | class Level : public RavEngine::World{ 9 | public: 10 | Level(); 11 | void ChangeChar(); 12 | void PostTick(float) final; 13 | private: 14 | std::vector characters; 15 | uint8_t currentChar = 0; 16 | CameraEntity camera; 17 | }; 18 | -------------------------------------------------------------------------------- /Samples/Animation/meshes/character.anim: -------------------------------------------------------------------------------- 1 | { 2 | "file": "character_anims.fbx" 3 | } -------------------------------------------------------------------------------- /Samples/Animation/meshes/character_anims.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Animation/meshes/character_anims.fbx -------------------------------------------------------------------------------- /Samples/Animation/meshes/character_bones.skeleton: -------------------------------------------------------------------------------- 1 | { 2 | "file": "character_anims.fbx" 3 | } -------------------------------------------------------------------------------- /Samples/Animation/meshes/character_skin.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "character_anims.fbx", 3 | "type": "skinned" 4 | } -------------------------------------------------------------------------------- /Samples/Animation/meshes/daefix.txt: -------------------------------------------------------------------------------- 1 | Run in vi 2 | :%s%\(\s*\)<\([-A-Za-z0-9_\.]*\)[^>]\{-}\zs */>\ze%>\r\1%g 3 | -------------------------------------------------------------------------------- /Samples/Animation/meshes/level.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Animation/meshes/level.fbx -------------------------------------------------------------------------------- /Samples/Animation/meshes/level_floors.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "level.fbx", 3 | "scale": 1.5, 4 | "mesh": "ground" 5 | } -------------------------------------------------------------------------------- /Samples/Animation/meshes/level_walls.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "level.fbx", 3 | "scale": 1.5, 4 | "mesh": "walls" 5 | } -------------------------------------------------------------------------------- /Samples/Animation/ui/ui.rml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 |

12 | 13 |
14 | -------------------------------------------------------------------------------- /Samples/Animation/virtualcontroller.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void InitVirtualController(); 4 | -------------------------------------------------------------------------------- /Samples/Animation/virtualcontroller.mm: -------------------------------------------------------------------------------- 1 | #import "virtualcontroller.hpp" 2 | #if __APPLE__ 3 | 4 | #import 5 | 6 | #if TARGET_OS_IOS 7 | #import 8 | #import 9 | 10 | GCVirtualController *_virtualController; 11 | #endif 12 | 13 | #endif 14 | 15 | void InitVirtualController() { 16 | #if TARGET_OS_IOS 17 | GCVirtualControllerConfiguration *config = [[GCVirtualControllerConfiguration alloc] init]; 18 | // Add elements that your controller-handling code currently supports. 19 | config.elements = [NSSet setWithArray:@[ 20 | GCInputButtonA, 21 | GCInputButtonB, 22 | GCInputButtonX, 23 | GCInputButtonY, 24 | GCInputLeftThumbstick, 25 | GCInputRightThumbstick]]; 26 | config.hidden = NO; 27 | _virtualController = [[GCVirtualController alloc] initWithConfiguration:config]; 28 | 29 | [_virtualController connectWithReplyHandler:nil]; 30 | #endif 31 | } 32 | -------------------------------------------------------------------------------- /Samples/AppInfo.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // generated by CMake, do not modify 3 | // to make changes to this file, see Samples/AppInfo.hpp 4 | #cmakedefine APPNAME "@APPNAME@" 5 | -------------------------------------------------------------------------------- /Samples/Common/FPSSystem.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | struct FPSSystem : public RavEngine::AutoCTTI { 9 | const std::string document, element; 10 | FPSSystem(const decltype(document)& document, const decltype(element)& element) : document(document), element(element){} 11 | 12 | inline void operator()(RavEngine::GUIComponent& gui) const { 13 | auto doc = gui.GetDocument(document); 14 | auto App = RavEngine::GetApp(); 15 | gui.EnqueueUIUpdate([=]{ 16 | doc->GetElementById(element)->SetInnerRML(RavEngine::Format("TPS: {}", 17 | std::round(App->CurrentTPS()))); 18 | }); 19 | }; 20 | }; 21 | -------------------------------------------------------------------------------- /Samples/Flags/Flagpole.cpp: -------------------------------------------------------------------------------- 1 | #include "Flagpole.hpp" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace RavEngine; 9 | using namespace std; 10 | 11 | void Flagpole::Create(){ 12 | GameObject::Create(); 13 | // load meshes 14 | 15 | auto mat = RavEngine::New(Material::Manager::Get()); 16 | EmplaceComponent(MeshCollectionStaticManager::Get("flagpole"), mat); 17 | EmplaceComponent(MeshCollectionStaticManager::Get("flagpole_top"), mat); 18 | 19 | // load animation 20 | auto skeleton = RavEngine::New("flag"); 21 | auto clips = RavEngine::New("flag"); 22 | auto meshAssetSkinned = MeshCollectionSkinnedManager::Get("flag"); 23 | 24 | auto flagEntity = GetWorld()->Instantiate(); 25 | GetTransform().AddChild(flagEntity); 26 | flagEntity.GetTransform().LocalTranslateDelta(vector3(0,8,0)).LocalScaleDelta(vector3(2)); 27 | 28 | auto& skinnedMesh = flagEntity.EmplaceComponent(skeleton,meshAssetSkinned); 29 | 30 | // load the flags 31 | struct name_file{ 32 | std::string name; 33 | std::string filename; 34 | }; 35 | name_file names[] = { 36 | {"United States","flag_us.svg"}, 37 | {"Canada","flag_ca.svg"}, 38 | {"Mexico","flag_mx.svg"} 39 | }; 40 | for(const auto& n : names) 41 | { 42 | auto mat = RavEngine::New(Material::Manager::Get()); 43 | Ref tx = RavEngine::New(n.filename,1024,1024); 44 | mat->SetAlbedoTexture(tx); 45 | flags.push_back({n.name,mat}); 46 | } 47 | 48 | constexpr static RavEngine::CacheBase::unique_key_t flag_special_key = 1; 49 | 50 | // load the special flag, which uses a different shader 51 | { 52 | auto mat = RavEngine::New(Material::Manager::GetWithKey(flag_special_key, "flag_special")); 53 | flags.push_back({"My Room",mat}); 54 | } 55 | 56 | SwitchToFlag(0); 57 | 58 | auto& animcomp = flagEntity.EmplaceComponent(skeleton); 59 | 60 | AnimatorComponent::State all_anim{ 0, clips }; 61 | all_anim.isLooping = true; 62 | auto layer = animcomp.AddLayer(); 63 | layer->InsertState(all_anim); 64 | layer->Goto(0,true); 65 | layer->Play(); 66 | animcomp.debugEnabled = true; 67 | 68 | // load shaders 69 | } 70 | 71 | void Flagpole::SwitchToFlag(uint16_t idx){ 72 | GetTransform().GetChildren()[0].GetOwner().GetComponent().SetMaterial(flags[idx].matInst); 73 | } 74 | 75 | Ref Flagpole::GetCurrentMaterial() 76 | { 77 | auto mat = GetTransform().GetChildren()[0].GetOwner().GetComponent().GetMaterial(); 78 | 79 | return mat; 80 | } 81 | -------------------------------------------------------------------------------- /Samples/Flags/Flagpole.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | struct FlagMatUniforms { 8 | float time = 0; 9 | }; 10 | 11 | struct FlagMat : public RavEngine::LitMaterial { 12 | FlagMat(std::string_view secondShader = "flag") : LitMaterial("flag", secondShader, { 13 | .bindings = { 14 | { 15 | .binding = 0, 16 | .type = RGL::BindingType::Sampler, 17 | .stageFlags = RGL::BindingVisibility::Fragment, 18 | }, 19 | { 20 | .binding = 1, 21 | .type = RGL::BindingType::SampledImage, 22 | .stageFlags = RGL::BindingVisibility::Fragment, 23 | }, 24 | }, 25 | .pushConstantSize = sizeof(FlagMatUniforms) 26 | }, { 27 | .cullMode = RGL::CullMode::None 28 | }) {} 29 | }; 30 | 31 | struct FlagMatInst : public RavEngine::MaterialInstance{ 32 | FlagMatInst(Ref f) : MaterialInstance(f){ 33 | SetAlbedoTexture(RavEngine::Texture::Manager::defaultTexture); 34 | } 35 | void SetTime(float time) { 36 | pushConstantData.time = time; 37 | } 38 | void SetAlbedoTexture(Ref texture) { 39 | textureBindings[1] = texture; 40 | } 41 | 42 | virtual const RGL::untyped_span GetPushConstantData() const override { 43 | return pushConstantData; 44 | } 45 | private: 46 | FlagMatUniforms pushConstantData; 47 | }; 48 | 49 | 50 | struct Flagpole : public RavEngine::GameObject{ 51 | void Create(); 52 | struct entry{ 53 | std::string name; 54 | Ref matInst; 55 | }; 56 | RavEngine::Vector flags; 57 | 58 | void SwitchToFlag(uint16_t idx); 59 | Ref GetCurrentMaterial(); 60 | }; 61 | -------------------------------------------------------------------------------- /Samples/Flags/meshes/flag.anim: -------------------------------------------------------------------------------- 1 | { 2 | "file": "flag.fbx" 3 | } -------------------------------------------------------------------------------- /Samples/Flags/meshes/flag.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Flags/meshes/flag.fbx -------------------------------------------------------------------------------- /Samples/Flags/meshes/flag.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "flag.fbx", 3 | "type": "skinned" 4 | } -------------------------------------------------------------------------------- /Samples/Flags/meshes/flag.skeleton: -------------------------------------------------------------------------------- 1 | { 2 | "file": "flag.fbx" 3 | } -------------------------------------------------------------------------------- /Samples/Flags/meshes/flagpole.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Flags/meshes/flagpole.fbx -------------------------------------------------------------------------------- /Samples/Flags/meshes/flagpole.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "flagpole.fbx", 3 | "mesh": "pole" 4 | } -------------------------------------------------------------------------------- /Samples/Flags/meshes/flagpole_top.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "flagpole.fbx", 3 | "mesh": "poleBall" 4 | } -------------------------------------------------------------------------------- /Samples/Flags/meshes/grass.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "grass.obj" 3 | } -------------------------------------------------------------------------------- /Samples/Flags/shaders/flag.fsh: -------------------------------------------------------------------------------- 1 | 2 | layout(location = 0) in vec2 inUV; 3 | 4 | layout(binding = 0) uniform sampler g_sampler; 5 | layout(binding = 1) uniform texture2D t_diffuse; 6 | 7 | layout(push_constant) uniform UniformBufferObject{ 8 | float time; 9 | } ubo; 10 | 11 | LitOutput frag(EnvironmentData envData) 12 | { 13 | LitOutput fs_out; 14 | 15 | fs_out.color = texture(sampler2D(t_diffuse, g_sampler), inUV); 16 | fs_out.normal = vec3(0,0,1); 17 | fs_out.roughness = 0.5; 18 | fs_out.specular = 0.2; 19 | fs_out.metallic = 0; 20 | fs_out.ao = 1; 21 | fs_out.emissiveColor = vec3(0); 22 | 23 | return fs_out; 24 | } 25 | 26 | 27 | -------------------------------------------------------------------------------- /Samples/Flags/shaders/flag.vsh: -------------------------------------------------------------------------------- 1 | 2 | layout(push_constant) uniform UniformBufferObject{ 3 | float time; 4 | } ubo; 5 | 6 | layout(location = 0) out vec2 outUV; 7 | 8 | LitVertexOut vert(EntityIn entity, EngineData data) 9 | { 10 | mat4 inModel = entity.modelMtx; 11 | LitVertexOut vs_out; 12 | 13 | vec3 a_position = inPosition; 14 | 15 | a_position.z += sin(ubo.time * 10 + a_position.x * -5) / 40; 16 | a_position.y += cos(ubo.time * 10 + a_position.x * -5) / 50; 17 | 18 | vs_out.localPosition = a_position; 19 | 20 | outUV = inUV; 21 | return vs_out; 22 | } 23 | -------------------------------------------------------------------------------- /Samples/Flags/shaders/flag_fsh.json: -------------------------------------------------------------------------------- 1 | { 2 | "shader": "flag.fsh", 3 | "stage": "fragment", 4 | "type": "lit-mesh" 5 | } -------------------------------------------------------------------------------- /Samples/Flags/shaders/flag_special_fsh.json: -------------------------------------------------------------------------------- 1 | { 2 | "shader": "flag_special.fsh", 3 | "stage": "fragment", 4 | "type": "lit-mesh" 5 | } -------------------------------------------------------------------------------- /Samples/Flags/shaders/flag_vsh.json: -------------------------------------------------------------------------------- 1 | { 2 | "shader": "flag.vsh", 3 | "stage": "vertex", 4 | "type": "lit-mesh" 5 | } -------------------------------------------------------------------------------- /Samples/Flags/shaders/grass.fsh: -------------------------------------------------------------------------------- 1 | 2 | layout(location = 0) in float mixFactor; 3 | 4 | layout(push_constant) uniform UniformBufferObject{ 5 | float time; 6 | } ubo; 7 | 8 | LitOutput frag(EnvironmentData envData) 9 | { 10 | LitOutput fs_out; 11 | 12 | fs_out.color = vec4(mix(vec3(110/255.0, 219/255.0, 0),vec3(33/255.0, 143/255.0, 0),mixFactor),1); 13 | fs_out.normal = vec3(0,0,1); 14 | fs_out.roughness = 0.5; 15 | fs_out.specular = 0.2; 16 | fs_out.metallic = 0; 17 | fs_out.ao = 1; 18 | fs_out.emissiveColor = vec3(0); 19 | 20 | return fs_out; 21 | } 22 | -------------------------------------------------------------------------------- /Samples/Flags/shaders/grass.vsh: -------------------------------------------------------------------------------- 1 | layout(push_constant) uniform UniformBufferObject{ 2 | float time; 3 | } ubo; 4 | 5 | layout(location = 0) out float mixFactor; 6 | 7 | LitVertexOut vert(EntityIn entity, EngineData data) 8 | { 9 | mat4 inModel = entity.modelMtx; 10 | LitVertexOut vs_out; 11 | 12 | vec3 a_position = inPosition; 13 | vec4 worldPos = inModel * vec4(a_position, 1); 14 | 15 | const float height = 3.43; 16 | const float extentFactor = 0.5; 17 | 18 | a_position.x += sin(ubo.time * -5 + worldPos.x + worldPos.z) * (a_position.y / height) * extentFactor; 19 | vs_out.localPosition = a_position; 20 | 21 | mixFactor = height - a_position.y; 22 | 23 | return vs_out; 24 | } 25 | -------------------------------------------------------------------------------- /Samples/Flags/shaders/grass_fsh.json: -------------------------------------------------------------------------------- 1 | { 2 | "shader": "grass.fsh", 3 | "stage": "fragment", 4 | "type": "lit-mesh" 5 | } -------------------------------------------------------------------------------- /Samples/Flags/shaders/grass_vsh.json: -------------------------------------------------------------------------------- 1 | { 2 | "shader": "grass.vsh", 3 | "stage": "vertex", 4 | "type": "lit-mesh" 5 | } -------------------------------------------------------------------------------- /Samples/Flags/textures/flag_ca.svg: -------------------------------------------------------------------------------- 1 | 2 | Flag of Canada 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Samples/Flags/textures/flag_us.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Samples/Flags/ui/ui.rml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | Select Flag
12 | 14 | 15 |
16 | -------------------------------------------------------------------------------- /Samples/GUI/App.cpp: -------------------------------------------------------------------------------- 1 | #include "World.hpp" 2 | #include 3 | #include 4 | #include "AppInfo.hpp" 5 | #include 6 | #include 7 | #include 8 | 9 | struct App : public RavEngine::App{ 10 | void OnStartup(int argc, char** argv) final{ 11 | RavEngine::RenderEngine::VideoSettings.vsync = true; 12 | 13 | AddWorld(RavEngine::New<::World>()); 14 | 15 | SetWindowTitle(RavEngine::VFormat("{} | {}", APPNAME, GetRenderEngine().GetCurrentBackendName()).c_str()); 16 | } 17 | void OnFatal(const std::string_view msg) final{ 18 | RavEngine::Dialog::ShowBasic("Fatal Error", msg, RavEngine::Dialog::MessageBoxType::Error); 19 | } 20 | 21 | bool NeedsAudio() const final { 22 | return false; 23 | } 24 | }; 25 | 26 | START_APP(::App) 27 | -------------------------------------------------------------------------------- /Samples/GUI/World.cpp: -------------------------------------------------------------------------------- 1 | #include "World.hpp" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | using namespace RavEngine; 13 | using namespace std; 14 | 15 | struct SingleEntityMarker : public Queryable{}; 16 | 17 | struct FPSSystem : public AutoCTTI { 18 | void operator()(const SingleEntityMarker& s) const{ 19 | GetApp()->DispatchMainThread([](){ 20 | GetApp()->SetWindowTitle(VFormat("RavEngine GUIKitchenSink | {} - {} TPS", GetApp()->GetRenderEngine().GetCurrentBackendName(), (int)GetApp()->CurrentTPS()).c_str()); 21 | }); 22 | } 23 | }; 24 | 25 | ::World::World(){ 26 | //camera and cube 27 | auto camlights = Instantiate(); 28 | camlights.EmplaceComponent().SetActive(true); 29 | camlights.EmplaceComponent(); 30 | camlights.EmplaceComponent().SetIntensity(0.2); 31 | camlights.GetTransform().LocalTranslateDelta(vector3(0,0,5)); 32 | 33 | auto dirlight = Instantiate(); 34 | dirlight.EmplaceComponent().SetIntensity(4); 35 | dirlight.GetTransform().LocalRotateDelta(vector3(deg_to_rad(45),deg_to_rad(45),0)); 36 | 37 | cube = Instantiate(); 38 | auto& cubemesh = cube.EmplaceComponent(New(MeshAsset::Manager::Get("cube")), RavEngine::New(Material::Manager::Get())); 39 | 40 | auto gui = Instantiate(); 41 | auto& doc = gui.EmplaceComponent(); 42 | doc.AddDocument("sink.rml"); 43 | 44 | doc.Debug(); 45 | 46 | //input manager 47 | Ref im = RavEngine::New(); 48 | im->AddAxisMap("MouseX", Special::MOUSEMOVE_X); 49 | im->AddAxisMap("MouseY", Special::MOUSEMOVE_Y); 50 | 51 | ComponentHandle g(gui); 52 | im->BindAxis("MouseX", g, &GUIComponent::MouseX, CID::ANY,0); 53 | im->BindAxis("MouseY", g, &GUIComponent::MouseY, CID::ANY,0); 54 | im->BindAnyAction(g->GetData()); 55 | 56 | GetApp()->inputManager = im; 57 | 58 | //FPS updating system 59 | EmplaceTimedSystem(std::chrono::seconds(1)); 60 | 61 | Debug::Log("{} with ID: {}",type_name(),CTTI()); 62 | } 63 | 64 | void ::World::PostTick(float scale){ 65 | cube.GetTransform().LocalRotateDelta(vector3(deg_to_rad(1) * scale,deg_to_rad(-1 * scale),deg_to_rad(0.5) * scale)); 66 | } 67 | -------------------------------------------------------------------------------- /Samples/GUI/World.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | struct World : public RavEngine::World{ 7 | World(); 8 | void PostTick(float) override; 9 | private: 10 | RavEngine::GameObject cube; 11 | }; 12 | -------------------------------------------------------------------------------- /Samples/GUI/ui/sink.rml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 25 | 26 | 27 | 30 |

31 |

32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 85 | 97 | 98 | 99 |
Common ControlsSpecial Items
46 |

47 | 50 | 53 | 54 | 55 |

56 |

57 |

58 | 59 |

60 |

61 | Select an option: 62 | 67 |

68 |

69 | Range slider 70 | 71 |

72 |

73 | Progress 74 | 75 |

76 |

77 |

78 | Radio Group
79 |
80 |
81 | 82 |
83 |

84 |
86 |

87 | Vector graphics 88 |
89 | 90 |

91 |

92 | Lottie Animations 93 |
94 | 95 |

96 |
100 |

101 | 102 | 103 | -------------------------------------------------------------------------------- /Samples/Gravity/ui/main.rml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | Controls:
12 | WASD: Pan Camera
13 | Arrow Up/Down: Zoom in / out
14 | R: Reset camera 15 | 16 |
17 | -------------------------------------------------------------------------------- /Samples/Info.plist.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NSHighResolutionCapable 6 | 7 | CFBundleDevelopmentRegion 8 | $(DEVELOPMENT_LANGUAGE) 9 | UILaunchStoryboardName 10 | iosLaunchScreen.storyboard 11 | NSBluetoothAlwaysUsageDescription 12 | Press OK, this unused permission will be resolved later 13 | CFBundleExecutable 14 | $(EXECUTABLE_NAME) 15 | CFBundleIconFile 16 | 17 | CFBundleIdentifier 18 | $(PRODUCT_BUNDLE_IDENTIFIER) 19 | CFBundleInfoDictionaryVersion 20 | 6.0 21 | CFBundleName 22 | $(PRODUCT_NAME) 23 | CFBundlePackageType 24 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 25 | CFBundleShortVersionString 26 | 1.0 27 | CFBundleVersion 28 | 1 29 | LSMinimumSystemVersion 30 | $(MACOSX_DEPLOYMENT_TARGET) 31 | NSHumanReadableCopyright 32 | Copyright © $(CURRENTYEAR) Ravbug. All rights reserved. 33 | NSSupportsAutomaticTermination 34 | 35 | NSSupportsSuddenTermination 36 | 37 | CFBundleIconFile 38 | logo.png 39 | UIRequiresFullScreen 40 | 41 | UISupportedInterfaceOrientations 42 | 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /Samples/Navigation/meshes/maze.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Navigation/meshes/maze.fbx -------------------------------------------------------------------------------- /Samples/Navigation/meshes/maze.json: -------------------------------------------------------------------------------- 1 | { 2 | "file" : "maze.fbx" 3 | } -------------------------------------------------------------------------------- /Samples/Navigation/meshes/target.json: -------------------------------------------------------------------------------- 1 | { 2 | "file" : "target.obj" 3 | } -------------------------------------------------------------------------------- /Samples/Navigation/ui/ui.rml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | Click on the board to set destination 12 |
13 | Cell Dim 14 | 15 | 16 | 17 |
18 | Agent Radius 19 | 20 | 21 | 22 |
23 | Max Slope 24 | 25 | 26 | 27 |
28 | 29 | 30 |
31 | -------------------------------------------------------------------------------- /Samples/Perf_Draw/App.cpp: -------------------------------------------------------------------------------- 1 | #include "Level.hpp" 2 | #include 3 | #include "AppInfo.hpp" 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | using namespace std; 10 | 11 | struct Performance_B : public RavEngine::App { 12 | public: 13 | void OnFatal(const std::string_view msg) final{ 14 | RavEngine::Dialog::ShowBasic("Fatal Error", msg, RavEngine::Dialog::MessageBoxType::Error); 15 | } 16 | private: 17 | void OnStartup(int argc, char** argv) final{ 18 | 19 | // load world 20 | AddWorld(RavEngine::New()); 21 | 22 | SetWindowTitle(RavEngine::VFormat("{} | {}", APPNAME, GetRenderEngine().GetCurrentBackendName()).c_str()); 23 | } 24 | 25 | bool NeedsAudio() const final { 26 | return false; 27 | } 28 | }; 29 | 30 | START_APP(Performance_B) 31 | -------------------------------------------------------------------------------- /Samples/Perf_Draw/Camera.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | struct Player : public RavEngine::ComponentWithOwner { 8 | 9 | Player(RavEngine::Entity owner) : ComponentWithOwner(owner){} 10 | 11 | float zoomspeed = 1; 12 | 13 | float fpsScale = 0; 14 | 15 | void Zoom(float amt) { 16 | auto zoomAmt = amt * zoomspeed; 17 | auto& child = GetOwner().GetTransform().GetChildren()[0].GetOwner().GetTransform(); 18 | child.LocalTranslateDelta(vector3(0, 0, zoomAmt * fpsScale) * child.Forward()); 19 | } 20 | void RotateLR(float amt) { 21 | GetOwner().GetTransform().LocalRotateDelta((decimalType)fpsScale * vector3(0, deg_to_rad(amt), 0)); 22 | } 23 | 24 | void RotateUD(float amt) { 25 | GetOwner().GetTransform().LocalRotateDelta((decimalType)fpsScale * vector3(deg_to_rad(amt), 0, 0)); 26 | } 27 | 28 | void Tick(float scale) { 29 | fpsScale = scale; 30 | } 31 | }; 32 | 33 | struct PlayerSystem{ 34 | inline void operator()(Player& p) const{ 35 | auto scale = RavEngine::GetApp()->GetCurrentFPSScale(); 36 | p.Tick(scale); 37 | } 38 | }; 39 | 40 | struct Camera : public RavEngine::GameObject { 41 | void Create() { 42 | RavEngine::GameObject::Create(); 43 | 44 | auto cameraBoom = GetWorld()->Instantiate(); 45 | 46 | EmplaceComponent(); 47 | 48 | auto& ctr = cameraBoom.GetTransform(); 49 | ctr.LocalTranslateDelta(vector3(0, 0, 150)); 50 | GetTransform().AddChild(cameraBoom); 51 | 52 | auto& camera = cameraBoom.EmplaceComponent(); 53 | camera.SetActive(true); 54 | camera.farClip = 800; 55 | } 56 | }; 57 | 58 | -------------------------------------------------------------------------------- /Samples/Perf_Draw/CustomMaterials.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | struct MatInstUniforms { 6 | float time = 0; 7 | }; 8 | 9 | struct InstanceColorMat : public RavEngine::LitMaterial { 10 | InstanceColorMat() : LitMaterial("instance_colored", { .pushConstantSize = sizeof(MatInstUniforms)}) {} 11 | }; 12 | 13 | struct InstanceColorMatInstance : public RavEngine::MaterialInstance{ 14 | InstanceColorMatInstance(Ref m) : MaterialInstance(m) { }; 15 | void SetTime(decltype(MatInstUniforms::time) time) { 16 | pushConstantData.time = time; 17 | } 18 | virtual const RGL::untyped_span GetPushConstantData() const override { 19 | return pushConstantData; 20 | } 21 | private: 22 | MatInstUniforms pushConstantData{}; 23 | }; 24 | -------------------------------------------------------------------------------- /Samples/Perf_Draw/Level.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct PerfB_World : public RavEngine::World { 5 | PerfB_World(); 6 | 7 | enum class meshes { 8 | cube, 9 | cone, 10 | cylinder, 11 | sphere 12 | } prevMesh = meshes::cube; 13 | 14 | void SwitchMesh(meshes nextMesh); 15 | private: 16 | Ref cube, cone, cylinder, sphere; 17 | Ref meshCollection; 18 | Ref matinst; 19 | void PreTick(float fpsscale) override; 20 | }; 21 | -------------------------------------------------------------------------------- /Samples/Perf_Draw/shaders/instance_colored.fsh: -------------------------------------------------------------------------------- 1 | 2 | layout(location = 0) in vec3 v_position; 3 | 4 | layout(push_constant) uniform UniformBufferObject{ 5 | float time; 6 | } ubo; 7 | 8 | LitOutput frag(EnvironmentData envData) 9 | { 10 | LitOutput fs_out; 11 | fs_out.color = vec4(v_position / 200,1); 12 | fs_out.normal = vec3(0,0,1); 13 | fs_out.roughness = 0.5; 14 | fs_out.specular = 0.2; 15 | fs_out.metallic = 0; 16 | fs_out.ao = 1; 17 | fs_out.emissiveColor = vec3(0); 18 | 19 | return fs_out; 20 | } 21 | 22 | -------------------------------------------------------------------------------- /Samples/Perf_Draw/shaders/instance_colored.vsh: -------------------------------------------------------------------------------- 1 | 2 | layout(push_constant) uniform UniformBufferObject{ 3 | float time; 4 | } ubo; 5 | 6 | layout(location = 0) out vec3 v_position; 7 | 8 | #define M_PI 3.1415926 9 | 10 | float rand(vec2 co){ 11 | return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); 12 | } 13 | 14 | LitVertexOut vert(EntityIn entity, EngineData data) 15 | { 16 | uint inEntityID = entity.entityID; 17 | 18 | LitVertexOut vs_out; 19 | 20 | // give every instance a randomish rotation speed 21 | float theta = ubo.time * M_PI / 4 * rand(vec2(inEntityID % 10, inEntityID % 3)); 22 | float scaleInput = ubo.time * M_PI / 4 * rand(vec2(inEntityID % 3, inEntityID % 7)); 23 | 24 | float ct = cos(theta); 25 | float st = sin(theta); 26 | 27 | float ss = sin(scaleInput) / 2 + 0.8; 28 | float cs = cos(scaleInput) / 2 + 0.8; 29 | 30 | // calculate rotation matrices and apply to a_position 31 | mat4 rotmatx = mat4( 32 | vec4(1,0,0,0), 33 | vec4(0,ct,-st,0), 34 | vec4(0,st,ct,0), 35 | vec4(0,0,0,1) 36 | ); 37 | 38 | mat4 rotmaty = mat4( 39 | vec4(ct,0,st,0), 40 | vec4(0,1,0,0), 41 | vec4(-st,0,ct,0), 42 | vec4(0,0,0,1) 43 | ); 44 | 45 | mat4 fullrotmat = rotmatx * rotmaty; 46 | 47 | mat4 transmat = mat4( 48 | vec4(1,0,0,st * 2), 49 | vec4(0,1,0,ct * 2), 50 | vec4(0,0,1,st * 2), 51 | vec4(0,0,0,1) 52 | ); 53 | 54 | mat4 scalemat = mat4( 55 | vec4(ss,0,0,0), 56 | vec4(0,cs,0,0), 57 | vec4(0,0,ss,0), 58 | vec4(0,0,0,1) 59 | ); 60 | 61 | vec4 transformed = vec4(inPosition, 1); 62 | transformed = scalemat * transformed; 63 | transformed = fullrotmat * transformed; 64 | transformed = transpose(transmat) * transformed; 65 | 66 | vs_out.localPosition = transformed.xyz; 67 | 68 | v_position = transformed.xyz; 69 | 70 | return vs_out; 71 | } 72 | -------------------------------------------------------------------------------- /Samples/Perf_Draw/shaders/instance_colored_fsh.json: -------------------------------------------------------------------------------- 1 | { 2 | "shader": "instance_colored.fsh", 3 | "stage": "fragment", 4 | "type": "lit-mesh" 5 | } -------------------------------------------------------------------------------- /Samples/Perf_Draw/shaders/instance_colored_vsh.json: -------------------------------------------------------------------------------- 1 | { 2 | "shader": "instance_colored.vsh", 3 | "stage": "vertex", 4 | "type": "lit-mesh" 5 | } -------------------------------------------------------------------------------- /Samples/Perf_Draw/ui/main.rml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 |
12 |

13 |

14 |

15 | Select Mesh
16 | 22 |

23 |
24 | 25 |
-------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/App.cpp: -------------------------------------------------------------------------------- 1 | #include "PerfC_World.hpp" 2 | #include "RavEngine/App.hpp" 3 | #include "AppInfo.hpp" 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace RavEngine; 9 | class Performance_C : public RavEngine::App{ 10 | void OnStartup(int argc, char** argv) override{ 11 | //setup video settings 12 | RenderEngine::VideoSettings.vsync = false; 13 | 14 | GetRenderEngine().SyncVideoSettings(); 15 | 16 | AddWorld(RavEngine::New()); 17 | 18 | SetWindowTitle(VFormat("{} | {}", APPNAME, GetRenderEngine().GetCurrentBackendName()).c_str()); 19 | } 20 | void OnFatal(const std::string_view msg) final{ 21 | RavEngine::Dialog::ShowBasic("Fatal Error", msg, Dialog::MessageBoxType::Error); 22 | } 23 | bool NeedsAudio() const final { 24 | return false; 25 | } 26 | }; 27 | 28 | 29 | START_APP(Performance_C); 30 | -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/Camera.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | struct Player : public RavEngine::ComponentWithOwner{ 8 | 9 | Player(RavEngine::Entity owner) : ComponentWithOwner(owner){} 10 | float zoomspeed = 1; 11 | 12 | float fpsScale = 0; 13 | 14 | void Zoom(float amt){ 15 | auto zoomAmt = amt * zoomspeed; 16 | auto child = GetOwner().GetTransform().GetChildren()[0]; 17 | child->LocalTranslateDelta(vector3(0, 0, zoomAmt * fpsScale) * child->Forward()); 18 | } 19 | void RotateLR(float amt){ 20 | GetOwner().GetTransform().LocalRotateDelta((decimalType)fpsScale * vector3(0, deg_to_rad(amt), 0)); 21 | } 22 | 23 | void RotateUD(float amt){ 24 | GetOwner().GetTransform().LocalRotateDelta((decimalType)fpsScale * vector3(deg_to_rad(amt), 0, 0)); 25 | } 26 | 27 | void Tick(float scale){ 28 | fpsScale = scale; 29 | } 30 | }; 31 | 32 | struct PlayerSystem{ 33 | inline void operator()(Player& player) const{ 34 | auto fpsScale = RavEngine::GetApp()->GetCurrentFPSScale(); 35 | player.Tick(fpsScale); 36 | } 37 | }; 38 | 39 | struct Camera : public RavEngine::GameObject{ 40 | void Create(){ 41 | GameObject::Create(); 42 | auto cameraBoom = GetWorld()->Instantiate(); 43 | 44 | EmplaceComponent(); 45 | 46 | cameraBoom.GetTransform().LocalTranslateDelta(vector3(0,0,50)); 47 | GetTransform().AddChild(RavEngine::ComponentHandle(cameraBoom)); 48 | 49 | auto& camera = cameraBoom.EmplaceComponent(); 50 | camera.SetActive(true); 51 | camera.farClip = 500; 52 | } 53 | }; 54 | 55 | -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/PerfC_World.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "Systems.hpp" 10 | 11 | namespace RavEngine { 12 | struct MeshCollectionStatic; 13 | } 14 | 15 | class PerfC_World : public RavEngine::World{ 16 | public: 17 | PerfC_World(); 18 | 19 | RavEngine::GameObject lightEntity; 20 | 21 | static constexpr size_t num_meshes = 4; 22 | static RavEngine::Array,num_meshes> meshes; 23 | 24 | static constexpr size_t num_textures = 80; 25 | static RavEngine::Array, num_textures> textures; 26 | 27 | #ifdef _DEBUG 28 | static constexpr size_t num_objects = 5000; //reduced for demo because debug builds are slower 29 | #else 30 | static constexpr size_t num_objects = 40000; 31 | #endif 32 | 33 | static bool TexturesEnabled; 34 | static bool paused; 35 | 36 | bool fullbright = false; 37 | 38 | /** 39 | Pause or unpause the spinning animations 40 | */ 41 | void TogglePause(){ 42 | paused = !paused; 43 | } 44 | 45 | /** 46 | Enable or disable texture display 47 | */ 48 | void ToggleTextures(); 49 | 50 | /** 51 | Enable or disable fullbright lighting 52 | */ 53 | void ToggleFullbright(); 54 | 55 | protected: 56 | 57 | Rml::Element* fpslabel = nullptr; 58 | RavEngine::ComponentHandle hud; 59 | RavEngine::Array, PerfC_World::num_textures> materialInstances; 60 | 61 | void PostTick(float) override; 62 | }; 63 | 64 | struct SpinSystem : public RavEngine::AutoCTTI { 65 | 66 | inline void operator()(const SpinComponent& c, RavEngine::Transform& tr) const{ 67 | //get the entity and spin it based on the component data 68 | if (!PerfC_World::paused){ 69 | auto fpsScale = RavEngine::GetApp()->GetCurrentFPSScale(); 70 | tr.LocalRotateDelta((decimalType)fpsScale * c.spinamt); 71 | } 72 | } 73 | }; 74 | 75 | -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/Systems.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | struct SpinComponent : public RavEngine::AutoCTTI { 5 | SpinComponent(const vector3& amt) : spinamt(amt){}; 6 | vector3 spinamt; 7 | }; 8 | -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx1.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx10.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx11.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx12.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx13.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx14.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx15.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx16.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx17.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx18.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx19.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx2.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx20.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx21.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx22.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx23.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx24.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx25.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx26.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx26.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx27.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx27.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx28.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx28.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx29.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx3.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx30.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx31.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx31.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx32.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx33.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx33.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx34.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx34.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx35.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx35.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx36.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx36.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx37.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx37.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx38.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx38.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx39.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx39.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx4.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx40.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx41.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx41.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx42.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx42.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx43.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx43.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx44.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx44.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx45.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx45.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx46.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx46.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx47.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx47.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx48.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx49.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx49.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx5.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx50.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx51.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx51.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx52.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx52.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx53.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx53.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx54.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx54.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx55.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx55.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx56.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx56.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx57.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx58.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx58.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx59.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx59.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx6.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx60.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx61.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx61.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx62.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx62.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx63.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx63.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx64.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx65.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx65.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx66.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx66.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx67.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx67.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx68.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx68.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx69.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx69.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx7.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx70.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx70.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx71.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx71.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx72.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx73.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx73.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx74.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx74.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx75.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx75.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx76.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx77.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx77.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx78.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx78.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx79.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx79.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx8.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx80.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx80.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/textures/tx9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_DrawAnimated/textures/tx9.png -------------------------------------------------------------------------------- /Samples/Perf_DrawAnimated/ui/main.rml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 |

FPS:

8 | 9 | 10 | 11 |
12 | 13 |
-------------------------------------------------------------------------------- /Samples/Perf_ECS/App.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Level.hpp" 3 | #include "AppInfo.hpp" 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace std; 9 | using namespace RavEngine; 10 | struct Performance_A : public RavEngine::App { 11 | void OnFatal(const std::string_view msg) final{ 12 | RavEngine::Dialog::ShowBasic("Fatal Error", msg, Dialog::MessageBoxType::Error); 13 | } 14 | private: 15 | void OnStartup(int argc, char** argv) final{ 16 | GetRenderEngine().VideoSettings.vsync = false; 17 | GetRenderEngine().SyncVideoSettings(); 18 | 19 | // load world 20 | AddWorld(RavEngine::New()); 21 | 22 | SetWindowTitle(VFormat("{} | {}", APPNAME, GetRenderEngine().GetCurrentBackendName()).c_str()); 23 | } 24 | bool NeedsAudio() const final { 25 | return false; 26 | } 27 | }; 28 | 29 | START_APP(Performance_A) 30 | -------------------------------------------------------------------------------- /Samples/Perf_ECS/Entity_And_Component.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | struct SineComponent: public RavEngine::AutoCTTI { 8 | float value = RavEngine::Random::get(-1.0,1.0); //ensure not every instance runs the same operations 9 | }; 10 | 11 | struct CosComponent: public RavEngine::AutoCTTI { 12 | float value = RavEngine::Random::get(-1.0, 1.0); 13 | }; 14 | 15 | struct CalcSystem { 16 | inline void operator()(SineComponent& sinecomp, CosComponent& coscomp) const{ 17 | auto fpsScale = RavEngine::GetApp()->GetCurrentFPSScale(); 18 | sinecomp.value = std::sin(sinecomp.value + fpsScale); 19 | coscomp.value = std::cos(coscomp.value + fpsScale); 20 | } 21 | }; 22 | 23 | struct SingleSineSystem { 24 | inline void operator()(SineComponent& sinecomp) { 25 | auto fpsScale = RavEngine::GetApp()->GetCurrentFPSScale(); 26 | sinecomp.value = std::sin(sinecomp.value + fpsScale); 27 | } 28 | }; 29 | 30 | struct SingleCosSystem { 31 | inline void operator()(CosComponent& coscomp) { 32 | auto fpsScale = RavEngine::GetApp()->GetCurrentFPSScale(); 33 | coscomp.value = std::cos(coscomp.value + fpsScale); 34 | } 35 | }; 36 | 37 | struct PA_Entity : public RavEngine::Entity { 38 | static uint32_t num_objects; 39 | void Create() { 40 | EmplaceComponent(); 41 | EmplaceComponent(); 42 | num_objects++; 43 | } 44 | }; 45 | -------------------------------------------------------------------------------- /Samples/Perf_ECS/Level.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | struct PerfA_World : public RavEngine::World { 4 | PerfA_World(); 5 | void SetECSMode(int mode); 6 | int lastMode = -1; 7 | }; 8 | -------------------------------------------------------------------------------- /Samples/Perf_ECS/ui/ui.rml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 |

12 | RavEngine ECS Benchmark 13 |

14 |
15 |

16 | 17 |

18 |

19 | Mode
20 | 25 |

26 | 27 |
28 | -------------------------------------------------------------------------------- /Samples/Perf_Lighting/App.cpp: -------------------------------------------------------------------------------- 1 | #include "Level.hpp" 2 | #include 3 | #include "AppInfo.hpp" 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | using namespace std; 10 | 11 | struct LightingApp : public RavEngine::App { 12 | void OnStartup(int argc, char** argv) final{ 13 | 14 | App::GetRenderEngine().VideoSettings.vsync = false; 15 | App::GetRenderEngine().SyncVideoSettings(); 16 | 17 | AddWorld(RavEngine::New()); 18 | 19 | SetWindowTitle(RavEngine::VFormat("{} | {}", APPNAME, GetRenderEngine().GetCurrentBackendName()).c_str()); 20 | } 21 | void OnFatal(const std::string_view msg) final{ 22 | RavEngine::Dialog::ShowBasic("Fatal Error", msg, RavEngine::Dialog::MessageBoxType::Error); 23 | } 24 | 25 | bool NeedsAudio() const final { 26 | return false; 27 | } 28 | }; 29 | 30 | START_APP(LightingApp) 31 | -------------------------------------------------------------------------------- /Samples/Perf_Lighting/Level.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | struct Level : public RavEngine::World { 5 | Level(); 6 | }; 7 | -------------------------------------------------------------------------------- /Samples/Perf_Lighting/LightEntity.cpp: -------------------------------------------------------------------------------- 1 | #include "LightEntity.hpp" 2 | #include 3 | #include 4 | #include 5 | 6 | void LightEntity::Create(Ref mesh) 7 | { 8 | GameObject::Create(); 9 | auto mat = RavEngine::New(RavEngine::Material::Manager::Get()); 10 | EmplaceComponent(mesh,mat); 11 | auto& cc = EmplaceComponent(); 12 | auto& light = EmplaceComponent(); 13 | light.SetIntensity(cc.radius * 2); 14 | light.SetColorRGBA({ RavEngine::Random::get(0.f,1.f),RavEngine::Random::get(0.f,1.f),RavEngine::Random::get(0.f,1.f),1 }); 15 | mat->SetAlbedoColor(light.GetColorRGBA()); 16 | GetTransform().SetLocalScale(0.02); 17 | } 18 | -------------------------------------------------------------------------------- /Samples/Perf_Lighting/LightEntity.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace RavEngine { 7 | struct MeshCollectionStatic; 8 | } 9 | 10 | struct CirculateComponent : public RavEngine::AutoCTTI { 11 | float radius = RavEngine::Random::get(0.2,2.0); 12 | float speed = RavEngine::Random::get(0.2,1.0); 13 | float height = RavEngine::Random::get(0.2,1.2); 14 | }; 15 | 16 | struct CirculateSystem : public RavEngine::AutoCTTI { 17 | inline void operator()(const CirculateComponent& cc, RavEngine::Transform& transform) const{ 18 | auto time = RavEngine::GetApp()->GetCurrentTime(); 19 | transform.SetLocalPosition(vector3(std::cos(time * cc.speed) * cc.radius, std::sin(time * cc.speed) * 0.5 + 1, std::sin(time * cc.speed) * cc.radius)); 20 | } 21 | }; 22 | 23 | struct LightEntity : public RavEngine::GameObject { 24 | void Create(Ref mesh); 25 | }; 26 | -------------------------------------------------------------------------------- /Samples/Perf_Lighting/meshes/dragon_stanford.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_Lighting/meshes/dragon_stanford.fbx -------------------------------------------------------------------------------- /Samples/Perf_Lighting/meshes/dragon_stanford.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "dragon_stanford.fbx", 3 | "scale" : 0.05 4 | } -------------------------------------------------------------------------------- /Samples/Perf_Lighting/ui/ui.rml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 |

12 |

13 |

Number of objects: 1

14 | 15 |

16 | 17 |
18 | -------------------------------------------------------------------------------- /Samples/Perf_Network/App.cpp: -------------------------------------------------------------------------------- 1 | #include "AppInfo.hpp" 2 | #include 3 | #include "Level.hpp" 4 | #include 5 | #include "NetEntity.hpp" 6 | #include "ClientMenuLevel.hpp" 7 | #include 8 | #include 9 | #include 10 | 11 | using namespace std; 12 | using namespace RavEngine; 13 | 14 | // server hosts on 6970 15 | static constexpr auto PORT = 6970; 16 | 17 | struct NetApp : public RavEngine::App { 18 | void OnStartup(int argc, char** argv) final { 19 | 20 | // must register all networked entities 21 | networkManager.RegisterNetworkedEntity(); 22 | networkManager.RegisterNetworkedEntity(); 23 | 24 | auto id = CTTI(); 25 | auto name = type_name(); 26 | 27 | //argc = 2; 28 | constexpr bool serverOverride = 29 | #if !RVE_SERVER 30 | false; 31 | #else 32 | true; 33 | #endif 34 | 35 | // to start as a server, simply launch with any extra argument 36 | if (argc > 1 || serverOverride) { 37 | this->networkManager.server = std::make_unique(); 38 | networkManager.server->OnClientConnecting = [](auto a) { 39 | Debug::Log("Client is connecting, id = {}",a); 40 | }; 41 | networkManager.server->OnClientConnected = [](auto a) { 42 | Debug::Log("Client is connected, id = {}", a); 43 | }; 44 | networkManager.server->OnClientDisconnected = [](auto a) { 45 | Debug::Log("Client disconnected, id = {}", a); 46 | }; 47 | this->networkManager.server->Start(PORT); 48 | Debug::Log("Started server on {}",PORT); 49 | AddWorld(RavEngine::New()); 50 | } 51 | // otherwise we will launch as a client 52 | else { 53 | #if !RVE_SERVER 54 | this->networkManager.client = std::make_unique(); 55 | networkManager.client->OnConnecting = [](auto a) { 56 | Debug::Log("Connecting to server, id = {}",a); 57 | }; 58 | networkManager.client->OnConnected = [](auto a) { 59 | Debug::Log("Sucessfully connected to server, id = {}", a); 60 | }; 61 | AddWorld(RavEngine::New()); 62 | 63 | Debug::Log("Started client on {}", PORT); 64 | #endif 65 | } 66 | #if !RVE_SERVER 67 | 68 | SetWindowTitle(VFormat("{} {} | {}", APPNAME, networkManager.IsServer()? "Server" : "Client", GetRenderEngine().GetCurrentBackendName()).c_str()); 69 | #endif 70 | } 71 | void OnFatal(const std::string_view msg) final{ 72 | #if !RVE_SERVER 73 | RavEngine::Dialog::ShowBasic("Fatal Error", msg, Dialog::MessageBoxType::Error); 74 | #else 75 | Debug::Log("Fatal Error: {}", msg); 76 | #endif 77 | } 78 | bool NeedsAudio() const final { 79 | return false; 80 | } 81 | bool NeedsNetworking() const final { 82 | return true; 83 | } 84 | }; 85 | START_APP(NetApp) 86 | -------------------------------------------------------------------------------- /Samples/Perf_Network/ClientMenuLevel.cpp: -------------------------------------------------------------------------------- 1 | #if !RVE_SERVER 2 | #include "ClientMenuLevel.hpp" 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "Level.hpp" 11 | 12 | using namespace RavEngine; 13 | using namespace std; 14 | 15 | void ClientMenu::OnActivate() 16 | { 17 | // load the menu for joining a server 18 | auto guientity = Instantiate(); 19 | auto& guic = guientity.EmplaceComponent(); 20 | guientity.EmplaceComponent().SetActive(true); 21 | auto doc = guic.AddDocument("client.rml"); 22 | 23 | // input manager to make GUI interactive 24 | auto im = GetApp()->inputManager = RavEngine::New(); 25 | ComponentHandle gh(guientity); 26 | im->AddAxisMap("MouseX", Special::MOUSEMOVE_X); 27 | im->AddAxisMap("MouseY", Special::MOUSEMOVE_Y); 28 | im->BindAxis("MouseX", gh, &GUIComponent::MouseX, CID::ANY, 0); 29 | im->BindAxis("MouseY", gh, &GUIComponent::MouseY, CID::ANY, 0); 30 | im->BindAnyAction(guic.GetData()); 31 | 32 | // connect event listeners 33 | struct ConnectEventListener : public Rml::EventListener { 34 | ClientMenu* world; 35 | Rml::ElementDocument* doc; 36 | ConnectEventListener(decltype(world) w, decltype(doc) d) : world(w), doc(d) {} 37 | 38 | void ProcessEvent(Rml::Event& event) final { 39 | auto field = static_cast(doc->GetElementById("addressfield")); 40 | auto value = field->GetValue(); 41 | auto portfield = static_cast(doc->GetElementById("portfield")); 42 | auto port = std::stoi(portfield->GetValue()); 43 | world->ConnectToServer(value,port); 44 | } 45 | 46 | }; 47 | doc->GetElementById("gobtn")->AddEventListener(Rml::EventId::Click, new ConnectEventListener(this,doc)); 48 | } 49 | 50 | void ClientMenu::ConnectToServer(const std::string& addr, uint16_t port) { 51 | auto& cl = GetApp()->networkManager.client; 52 | cl->Connect(addr,port); 53 | cl->OnConnected = [&](HSteamNetConnection) { 54 | GetApp()->DispatchMainThread([&]{ 55 | Debug::Log("Client successfully connected"); 56 | GetApp()->inputManager.reset(); 57 | GetApp()->AddReplaceWorld(this->shared_from_this(), RavEngine::New()); 58 | }); 59 | }; 60 | cl->OnLostConnection = [&](HSteamNetConnection) { 61 | GetApp()->DispatchMainThread([&]{ 62 | Dialog::ShowBasic("Information", "Disconnected", Dialog::MessageBoxType::Info); 63 | GetApp()->Quit(); 64 | }); 65 | 66 | }; 67 | } 68 | #endif 69 | -------------------------------------------------------------------------------- /Samples/Perf_Network/ClientMenuLevel.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #if !RVE_SERVER 3 | 4 | #include 5 | 6 | class ClientMenu : public RavEngine::World { 7 | public: 8 | void ConnectToServer(const std::string& addr, uint16_t port); 9 | void OnActivate() final; 10 | }; 11 | #endif 12 | -------------------------------------------------------------------------------- /Samples/Perf_Network/Level.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | struct Level : public RavEngine::World { 7 | Level(); 8 | 9 | private: 10 | void ServerUpdateGUI(); 11 | void SetupServer(); 12 | void SetupClient(); 13 | }; 14 | 15 | struct RelayComp : public RavEngine::ComponentWithOwner, public RavEngine::Queryable { 16 | void RequestSpawnObject(RavEngine::RPCMsgUnpacker& upk, HSteamNetConnection origin); 17 | RelayComp(RavEngine::Entity owner) : ComponentWithOwner(owner){} 18 | }; 19 | 20 | enum ManagerRPCs { 21 | SpawnReq, 22 | UpdateReq 23 | }; 24 | 25 | struct ManagementRelay : public RavEngine::Entity { 26 | inline void Create() { 27 | auto& rpc = EmplaceComponent(); 28 | EmplaceComponent(); 29 | RavEngine::ComponentHandle relay(this); 30 | rpc.RegisterServerRPC(SpawnReq, [relay](auto& a, auto b) mutable{ 31 | relay->RequestSpawnObject(a,b); 32 | }, RavEngine::RPCComponent::Directionality::Bidirectional); 33 | } 34 | }; 35 | -------------------------------------------------------------------------------- /Samples/Perf_Network/NetEntity.cpp: -------------------------------------------------------------------------------- 1 | #include "NetEntity.hpp" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace RavEngine; 9 | 10 | void NetEntity::Create() 11 | { 12 | GameObject::Create(); 13 | auto& rpc = EmplaceComponent(); 14 | EmplaceComponent(); 15 | ComponentHandle nettransform(this); 16 | auto world = GetWorld(); 17 | auto fn = [nettransform, world](auto unpacker, auto b) mutable { 18 | nettransform->UpdateTransform(unpacker, b); 19 | }; 20 | rpc.RegisterServerRPC(to_underlying(RPCs::UpdateTransform), fn); 21 | rpc.RegisterClientRPC(to_underlying(RPCs::UpdateTransform), fn, RPCComponent::Directionality::Bidirectional); 22 | #if !RVE_SERVER 23 | if (!matinst) { 24 | matinst = New(Material::Manager::Get()); 25 | } 26 | EmplaceComponent(MeshCollectionStaticManager::Get("cube"), matinst); 27 | #endif 28 | GetTransform().SetLocalScale(0.1); 29 | EmplaceComponent(); 30 | } 31 | 32 | void MoveEntities::operator()(PathData& pathdata, NetworkIdentity& netid, Transform& transform) const 33 | { 34 | // use the sine of global time 35 | if (netid.IsOwner()) { 36 | 37 | auto t = GetApp()->GetCurrentTime(); 38 | 39 | auto pos = vector3( 40 | std::sin(t * pathdata.xtiming + pathdata.offset) * pathdata.scale, 41 | std::sin(t * pathdata.ytiming + pathdata.offset) * pathdata.scale, 42 | std::sin(t * pathdata.ztiming + pathdata.offset) * pathdata.scale 43 | ); 44 | transform.SetWorldPosition(pos); 45 | auto rot = quaternion(pos); 46 | transform.SetLocalRotation(rot); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Samples/Perf_Network/NetEntity.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "NetTransform.hpp" 4 | 5 | struct MoveEntities : public RavEngine::AutoCTTI { 6 | void operator()(PathData& pathdata, RavEngine::NetworkIdentity& netid, RavEngine::Transform& transform) const; 7 | }; 8 | 9 | struct NetEntity : public RavEngine::GameObject { 10 | #if !RVE_SERVER 11 | static Ref matinst; 12 | #endif 13 | 14 | void Create(); 15 | 16 | // invoked when spawned over the network 17 | // called *in addition to* not *instead of* Create() 18 | void ClientCreate() { 19 | EmplaceComponent(); 20 | } 21 | }; 22 | -------------------------------------------------------------------------------- /Samples/Perf_Network/NetTransform.cpp: -------------------------------------------------------------------------------- 1 | #include "NetTransform.hpp" 2 | 3 | using namespace std; 4 | using namespace RavEngine; 5 | 6 | void NetTransform::UpdateTransform(RavEngine::RPCMsgUnpacker& upk, HSteamNetConnection origin) 7 | { 8 | auto owner = GetOwner(); 9 | // update server's copy of this transform 10 | auto& itr = owner.GetComponent(); 11 | itr.mtx.lock(); 12 | std::optional td; 13 | if ((td = upk.Get())) { 14 | auto currentpos = owner.GetTransform().GetLocalPosition(); 15 | RavEngine::Debug::Assert(!std::isnan(currentpos.x), "CurrentPos was NaN!"); 16 | RavEngine::Debug::Assert(!std::isnan(td.value()[0]), "NetworkPos was NaN!"); 17 | // create the tween 18 | // another system will tick this tween 19 | itr.translate = decltype(itr.translate)([=](decimalType x, decimalType y, decimalType z) mutable { 20 | if (isnan(x) || isnan(y) || isnan(z)) { //sometimes the value is NaN??? 21 | return; 22 | } 23 | owner.GetTransform().SetLocalPosition(vector3(x, y, z)); 24 | }, currentpos.x, currentpos.y, currentpos.z); 25 | auto t = td.value(); 26 | itr.translate.AddKeyframe(0.1, RavEngine::TweenCurves::LinearCurve, t[0], t[1], t[2]); 27 | } 28 | std::optional qd; 29 | if ((qd = upk.Get())) { 30 | auto currentRot = owner.GetTransform().GetLocalRotation(); 31 | 32 | itr.rotate = decltype(itr.rotate)([=](decimalType w, decimalType x, decimalType y, decimalType z) mutable{ 33 | if (isnan(w) || isnan(x) || isnan(y) || isnan(z)) { 34 | return; 35 | } 36 | owner.GetTransform().SetLocalRotation(quaternion(w, x, y, z)); 37 | }, currentRot.w, currentRot.x, currentRot.y, currentRot.z); 38 | auto r = qd.value(); 39 | itr.rotate.AddKeyframe(0.1, RavEngine::TweenCurves::LinearCurve, r[0], r[1], r[2], r[3]); 40 | } 41 | itr.ok = true; 42 | itr.mtx.unlock(); 43 | 44 | // now RPC all the clients except the sender of this message to update their copy of this object 45 | // as well 46 | auto& rpc = owner.GetComponent(); 47 | if (GetApp()->networkManager.IsServer() && td && qd){ 48 | rpc.InvokeClientRPCToAllExcept(RavEngine::to_underlying(RPCs::UpdateTransform), origin, RavEngine::NetworkBase::Reliability::Unreliable, td.value(), qd.value()); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Samples/Perf_Network/NetTransform.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | enum class RPCs { 10 | UpdateTransform, 11 | }; 12 | 13 | struct InterpolationTransform : public RavEngine::AutoCTTI { 14 | RavEngine::SpinLock mtx; 15 | RavEngine::Tween translate; 16 | RavEngine::Tween rotate; 17 | bool ok = false; 18 | }; 19 | 20 | struct NetTransform : public RavEngine::ComponentWithOwner { 21 | NetTransform(RavEngine::Entity owner) : ComponentWithOwner(owner){} 22 | void UpdateTransform(RavEngine::RPCMsgUnpacker& upk, HSteamNetConnection origin); 23 | }; 24 | 25 | // stores the information for animating objects on the client 26 | struct PathData: public RavEngine::AutoCTTI { 27 | float xtiming = RavEngine::Random::get(0.1,0.5), ytiming = RavEngine::Random::get(0.1, 0.5), ztiming = RavEngine::Random::get(0.1, 0.5); 28 | float offset = RavEngine::Random::get(-10.0, 10.0); 29 | float scale = 4; 30 | }; 31 | 32 | struct TweenEntities : public RavEngine::AutoCTTI { 33 | 34 | inline void operator()(InterpolationTransform& itr) const{ 35 | if (itr.ok) { 36 | auto fpsScale = RavEngine::GetApp()->GetCurrentFPSScale(); 37 | itr.mtx.lock(); 38 | itr.translate.Step(fpsScale); 39 | itr.rotate.Step(fpsScale); 40 | itr.mtx.unlock(); 41 | } 42 | } 43 | }; 44 | 45 | struct SyncNetTransforms : public RavEngine::AutoCTTI { 46 | inline void operator()(NetTransform&, RavEngine::Transform& transform, RavEngine::RPCComponent& rpc) { 47 | rpc.InvokeServerRPC(RavEngine::to_underlying(RPCs::UpdateTransform), RavEngine::NetworkBase::Reliability::Unreliable, Vec3toRaw(transform.GetWorldPosition()), QuatToRaw(transform.GetWorldRotation())); 48 | } 49 | }; 50 | -------------------------------------------------------------------------------- /Samples/Perf_Network/ui/client.rml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 |

Connect to server:

12 | 13 |
14 | -------------------------------------------------------------------------------- /Samples/Perf_Network/ui/server.rml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | Server GUI 12 |

13 | 14 |
15 | -------------------------------------------------------------------------------- /Samples/Perf_RigidBodies/App.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Level.hpp" 3 | #include "AppInfo.hpp" 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | struct App : public RavEngine::App{ 10 | void OnStartup(int argc, char** argv) override{ 11 | AddWorld(RavEngine::New()); 12 | App::GetRenderEngine().VideoSettings.vsync = false; 13 | App::GetRenderEngine().SyncVideoSettings(); 14 | 15 | SetWindowTitle(RavEngine::VFormat("{} | {}", APPNAME, GetRenderEngine().GetCurrentBackendName()).c_str()); 16 | } 17 | void OnFatal(const std::string_view msg) final{ 18 | RavEngine::Dialog::ShowBasic("Fatal Error", msg, RavEngine::Dialog::MessageBoxType::Error); 19 | } 20 | bool NeedsAudio() const final { 21 | return false; 22 | } 23 | }; 24 | 25 | START_APP(App) 26 | -------------------------------------------------------------------------------- /Samples/Perf_RigidBodies/Level.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | struct Level : public RavEngine::World{ 5 | Level(); 6 | }; 7 | -------------------------------------------------------------------------------- /Samples/Perf_RigidBodies/Objects.cpp: -------------------------------------------------------------------------------- 1 | #include "Objects.hpp" 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace RavEngine; 8 | 9 | void Ground::Create() 10 | { 11 | GameObject::Create(); 12 | auto mat = New(Material::Manager::Get()); 13 | MeshAssetOptions opt; 14 | opt.keepInSystemRAM = true; 15 | auto mesh = MeshAsset::Manager::Get("ground", opt); //need to retain the mesh data in system memory 16 | EmplaceComponent(New(mesh), mat); 17 | EmplaceComponent(); 18 | auto& rs = EmplaceComponent(); 19 | rs.EmplaceCollider(mesh, New(0.3, 0.3, 0.1)); 20 | 21 | // system memory copy is no longer needed 22 | //mesh->DeallocSystemCopy(); 23 | } 24 | 25 | void RigidBody::Create(Ref mat, Ref mesh, Ref physmat, BodyType type) 26 | { 27 | GameObject::Create(); 28 | EmplaceComponent(mesh, mat); 29 | auto& rd = EmplaceComponent(); 30 | 31 | switch (type) { 32 | case BodyType::Sphere: 33 | rd.EmplaceCollider(1.f, physmat); 34 | break; 35 | case BodyType::Cube: 36 | rd.EmplaceCollider(vector3(1, 1, 1), physmat); 37 | break; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Samples/Perf_RigidBodies/Objects.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace RavEngine { 5 | class MeshAsset; 6 | class PBRMaterialInstance; 7 | class PhysicsMaterial; 8 | struct MeshCollectionStatic; 9 | } 10 | 11 | struct RotationComponent : public RavEngine::AutoCTTI{ 12 | float xspeed = 0.5, yspeed = 0.2, zspeed = 0.4, maxDeg = 10; 13 | }; 14 | 15 | struct Ground : public RavEngine::GameObject{ 16 | void Create(); 17 | }; 18 | 19 | struct RigidBody : public RavEngine::GameObject{ 20 | enum class BodyType{ 21 | Sphere, 22 | Cube 23 | }; 24 | 25 | void Create(Ref mat, Ref mesh, Ref physmat, BodyType type); 26 | }; 27 | -------------------------------------------------------------------------------- /Samples/Perf_RigidBodies/meshes/ground.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "ground.obj" 3 | } -------------------------------------------------------------------------------- /Samples/Perf_RigidBodies/textures/checkerboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Perf_RigidBodies/textures/checkerboard.png -------------------------------------------------------------------------------- /Samples/Perf_RigidBodies/ui/ui.rml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 |

12 |

13 |

Number of objects: 1

14 |

15 | 16 |
17 | -------------------------------------------------------------------------------- /Samples/Playground/PlayerActor.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "RavEngine/GameObject.hpp" 3 | #include "RavEngine/CameraComponent.hpp" 4 | #include "RavEngine/IInputListener.hpp" 5 | #include "RavEngine/ScriptComponent.hpp" 6 | #include 7 | #include 8 | #include 9 | 10 | class PlayerActor; 11 | struct PlayerScript : public RavEngine::ScriptComponent, public RavEngine::IInputListener, public RavEngine::Queryable { 12 | using Queryable::GetQueryTypes; 13 | 14 | PlayerScript(RavEngine::Entity owner) : ScriptComponent(owner){} 15 | 16 | RavEngine::Entity cameraEntity; 17 | decimalType dt = 0; 18 | decimalType movementSpeed = 0.3; 19 | decimalType sensitivity = 0.1; 20 | 21 | decimalType scaleMovement(decimalType f) { 22 | return f * dt * movementSpeed; 23 | } 24 | 25 | decimalType scaleRotation(decimalType f) { 26 | return deg_to_rad(sensitivity * dt * f); 27 | } 28 | 29 | void MoveForward(float amt) { 30 | auto& tn = GetOwner().GetTransform(); 31 | tn.LocalTranslateDelta(scaleMovement(amt) * tn.Forward()); 32 | } 33 | void MoveRight(float amt) { 34 | auto& tn = GetOwner().GetTransform(); 35 | tn.LocalTranslateDelta(scaleMovement(amt) * tn.Right()); 36 | } 37 | 38 | void MoveUp(float amt) { 39 | auto& tn = GetOwner().GetTransform(); 40 | tn.LocalTranslateDelta(scaleMovement(amt) * tn.Up()); 41 | } 42 | 43 | void LookUp(float amt) { 44 | cameraEntity.GetTransform().LocalRotateDelta(vector3(scaleRotation(amt), 0, 0)); 45 | } 46 | void LookRight(float amt) { 47 | GetOwner().GetTransform().LocalRotateDelta(quaternion(vector3(0, scaleRotation(amt), 0))); 48 | } 49 | 50 | void Tick(float scale) override{ 51 | dt = scale; 52 | //prevent camera from flipping over 53 | vector3 rotation = glm::eulerAngles(cameraEntity.GetTransform().GetLocalRotation()); 54 | rotation.x = std::clamp(rotation.x, -RavEngine::PI/2.f, RavEngine::PI/2.f); 55 | cameraEntity.GetTransform().SetLocalRotation(rotation); 56 | } 57 | }; 58 | 59 | class PlayerActor : public RavEngine::GameObject, public RavEngine::IInputListener { 60 | public: 61 | RavEngine::ComponentHandle script; 62 | void Create() { 63 | GameObject::Create(); 64 | EmplaceComponent(); 65 | script = RavEngine::ComponentHandle(this); 66 | 67 | //create a child entity for the camera 68 | auto cameraEntity = GetWorld()->Instantiate(); 69 | auto& cam = cameraEntity.EmplaceComponent(); 70 | script->cameraEntity = cameraEntity; 71 | 72 | //set the active camera 73 | cam.SetActive(true); 74 | 75 | GetTransform().AddChild(RavEngine::ComponentHandle(cameraEntity)); 76 | 77 | EmplaceComponent(); 78 | } 79 | }; 80 | -------------------------------------------------------------------------------- /Samples/Playground/TestEntity.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // TestEntity.cpp 3 | // RavEngine_Test 4 | // 5 | // Copyright © 2020 Ravbug. 6 | // 7 | 8 | #include "TestEntity.hpp" 9 | #include "RavEngine/PhysicsLinkSystem.hpp" 10 | #include "RavEngine/PhysicsCollider.hpp" 11 | #include 12 | #include "RavEngine/PhysicsSolver.hpp" 13 | #include 14 | #include "RavEngine/StaticMesh.hpp" 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | using namespace std; 21 | using namespace physx; 22 | using namespace RavEngine; 23 | 24 | STATIC(TestEntity::sharedMat); 25 | STATIC(TestEntity::sharedMatInst); 26 | STATIC(TestEntityController::objectcount); 27 | 28 | void TestEntity::CommonInit(){ 29 | 30 | //default staticmesh 31 | if (!sharedMatInst) { 32 | sharedMatInst = RavEngine::New(Material::Manager::Get()); 33 | } 34 | auto& mesh = EmplaceComponent(MeshCollectionStaticManager::Get("bunny_decimated"), sharedMatInst); 35 | 36 | auto& script = EmplaceComponent(); 37 | auto& r = EmplaceComponent(FilterLayers::L0, FilterLayers::L0 | FilterLayers::L1); 38 | 39 | auto handler = RavEngine::New(); 40 | ComponentHandle scripthandle(this); 41 | handler->OnColliderEnter = [scripthandle](RavEngine::PhysicsBodyComponent& other, const RavEngine::ContactPairPoint* contactPoints, size_t numContactPoints) mutable{ 42 | scripthandle->OnColliderEnter(other,contactPoints,numContactPoints); 43 | }; 44 | 45 | handler->OnColliderExit = [scripthandle](RavEngine::PhysicsBodyComponent& other, const RavEngine::ContactPairPoint* contactPoints, size_t numContactPoints) mutable{ 46 | scripthandle->OnColliderExit(other,contactPoints,numContactPoints); 47 | }; 48 | 49 | r.AddReceiver(handler); 50 | 51 | //add a box collision to the PhysX component 52 | if (!sharedMat) { 53 | sharedMat = RavEngine::New(0.5, 0.5, 0.5); 54 | } 55 | r.EmplaceCollider(1.f, 1.f, sharedMat); 56 | 57 | r.setDynamicsWorldPose(vector3(rand() % 10 - 5, rand() % 10 - 5, rand() % 10 - 5), GetTransform().GetWorldRotation()); 58 | 59 | script.objectcount++; 60 | } 61 | 62 | 63 | void TestEntityController::Tick(float scale) { 64 | 65 | if (GetOwner().GetTransform().GetWorldPosition().y < -40) { 66 | auto e = GetOwner(); 67 | assert(markedForDeletion == false); 68 | markedForDeletion = true; 69 | GetApp()->DispatchMainThread([e]() mutable { 70 | e.Destroy(); 71 | objectcount--; 72 | }); 73 | 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Samples/Playground/TestEntity.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // TestEntity.hpp 3 | // RavEngine_Test 4 | // 5 | // Copyright © 2020 Ravbug. 6 | // 7 | 8 | #pragma once 9 | 10 | #include "RavEngine/GameObject.hpp" 11 | #include "RavEngine/PhysicsCollider.hpp" 12 | #include "RavEngine/PhysicsBodyComponent.hpp" 13 | #include "RavEngine/WeakRef.hpp" 14 | #include "RavEngine/PhysicsMaterial.hpp" 15 | #include "RavEngine/Material.hpp" 16 | #include "RavEngine/PhysicsCallback.hpp" 17 | #include "RavEngine/ScriptComponent.hpp" 18 | #include "RavEngine/BuiltinMaterials.hpp" 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | struct TestEntityController : public RavEngine::ScriptComponent, public RavEngine::Queryable { 30 | using RavEngine::Queryable::GetQueryTypes; 31 | TestEntityController(RavEngine::Entity owner) : ScriptComponent(owner) {} 32 | void Tick(float scale) override; 33 | 34 | void OnColliderEnter(RavEngine::PhysicsBodyComponent&, const RavEngine::ContactPairPoint* contactPoints, size_t numContactPoints) { 35 | contactCount++; 36 | } 37 | void OnColliderExit(RavEngine::PhysicsBodyComponent&, const RavEngine::ContactPairPoint* contactPoints, size_t numContactPoints) { 38 | contactCount--; 39 | } 40 | 41 | static int objectcount; 42 | int contactCount = 0; 43 | bool markedForDeletion = false; 44 | }; 45 | 46 | class TestEntity : public RavEngine::GameObject, public RavEngine::PhysicsCallback{ 47 | protected: 48 | static Ref sharedMat; 49 | static Ref sharedMatInst; 50 | void CommonInit(); 51 | public: 52 | void Create() { 53 | GameObject::Create(); 54 | CommonInit(); 55 | } 56 | }; 57 | -------------------------------------------------------------------------------- /Samples/Playground/WorldTest.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // WorldTest.hpp 3 | // RavEngine_Test 4 | // 5 | // Copyright © 2020 Ravbug. 6 | // 7 | 8 | #pragma once 9 | 10 | #include "RavEngine/World.hpp" 11 | #include "PlayerActor.hpp" 12 | #include "RavEngine/IInputListener.hpp" 13 | #include "RavEngine/App.hpp" 14 | #include "RavEngine/Debug.hpp" 15 | 16 | class TestWorld : public RavEngine::World{ 17 | public: 18 | void PostTick(float fpsScale) override; 19 | PlayerActor player; 20 | 21 | void ResetCam(); 22 | void SpawnEntities(float); 23 | 24 | TestWorld(); 25 | 26 | void SampleFPS() { 27 | RavEngine::Debug::Log("TPS: {}", RavEngine::GetApp()->CurrentTPS()); 28 | } 29 | protected: 30 | float scale = 1; 31 | }; 32 | -------------------------------------------------------------------------------- /Samples/Playground/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // main.cpp 3 | // RavEngine_Sample_Playground 4 | // 5 | // Copyright © 2020 Ravbug. 6 | // 7 | 8 | #include "WorldTest.hpp" 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "TestEntity.hpp" 15 | #include "AppInfo.hpp" 16 | #include 17 | 18 | class TestApp : public RavEngine::App{ 19 | void OnStartup(int argc, char** argv) override{ 20 | 21 | //setup video settings 22 | RavEngine::RenderEngine::VideoSettings.vsync = false; 23 | 24 | //create a world 25 | AddWorld(RavEngine::New()); 26 | 27 | SetWindowTitle(RavEngine::VFormat("{} | {}", APPNAME, GetRenderEngine().GetCurrentBackendName()).c_str()); 28 | } 29 | void OnFatal(const std::string_view msg) final{ 30 | RavEngine::Dialog::ShowBasic("Fatal Error", msg, RavEngine::Dialog::MessageBoxType::Error); 31 | } 32 | bool NeedsAudio() const final { 33 | return false; 34 | } 35 | }; 36 | 37 | 38 | START_APP(TestApp) 39 | -------------------------------------------------------------------------------- /Samples/Playground/meshes/bunny_decimated.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Playground/meshes/bunny_decimated.fbx -------------------------------------------------------------------------------- /Samples/Playground/meshes/bunny_decimated.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "bunny_decimated.fbx" 3 | } -------------------------------------------------------------------------------- /Samples/Playground/textures/youcantrun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Playground/textures/youcantrun.png -------------------------------------------------------------------------------- /Samples/Rats/README.md: -------------------------------------------------------------------------------- 1 | ## Crazy? I was crazy once... 2 | 3 | Third party resources 4 | - https://freesound.org/people/Artninja/sounds/700222/ 5 | 6 | "Sergio's Magic Dustbin" Kevin MacLeod (incompetech.com) 7 | Licensed under Creative Commons: By Attribution 4.0 License 8 | http://creativecommons.org/licenses/by/4.0/ -------------------------------------------------------------------------------- /Samples/Rats/meshes/pipe.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "pipe.obj" 3 | } -------------------------------------------------------------------------------- /Samples/Rats/meshes/rat.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "rat.obj", 3 | "scale": 0.2 4 | } -------------------------------------------------------------------------------- /Samples/Rats/meshes/what.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "what.obj", 3 | "scale": 0.25 4 | } -------------------------------------------------------------------------------- /Samples/Rats/shaders/what.fsh: -------------------------------------------------------------------------------- 1 | 2 | layout(location = 0) in vec2 inUV; 3 | 4 | layout(binding = 0) uniform sampler g_sampler; 5 | layout(binding = 1) uniform texture2D t_tex; 6 | 7 | UnlitOut frag() 8 | { 9 | UnlitOut fs_out; 10 | fs_out.color = texture(sampler2D(t_tex, g_sampler), inUV); 11 | 12 | return fs_out; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /Samples/Rats/shaders/what.vsh: -------------------------------------------------------------------------------- 1 | 2 | layout(location = 0) out vec2 outUV; 3 | 4 | UnlitVertexOut vert(EntityIn entity, EngineData data) 5 | { 6 | UnlitVertexOut vs_out; 7 | 8 | outUV = inUV; 9 | 10 | vs_out.localPosition = inPosition; 11 | 12 | return vs_out; 13 | } 14 | -------------------------------------------------------------------------------- /Samples/Rats/shaders/what_fsh.json: -------------------------------------------------------------------------------- 1 | { 2 | "shader": "what.fsh", 3 | "stage": "fragment", 4 | "type": "unlit-mesh" 5 | } -------------------------------------------------------------------------------- /Samples/Rats/shaders/what_vsh.json: -------------------------------------------------------------------------------- 1 | { 2 | "shader": "what.vsh", 3 | "stage": "vertex", 4 | "type": "unlit-mesh" 5 | } -------------------------------------------------------------------------------- /Samples/Rats/sounds/impact-1.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Rats/sounds/impact-1.ogg -------------------------------------------------------------------------------- /Samples/Rats/sounds/impact-3.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Rats/sounds/impact-3.ogg -------------------------------------------------------------------------------- /Samples/Rats/sounds/impact-4.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Rats/sounds/impact-4.ogg -------------------------------------------------------------------------------- /Samples/Rats/sounds/impact-5.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Rats/sounds/impact-5.ogg -------------------------------------------------------------------------------- /Samples/Rats/sounds/impact-6.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Rats/sounds/impact-6.ogg -------------------------------------------------------------------------------- /Samples/Rats/sounds/impact-7.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Rats/sounds/impact-7.ogg -------------------------------------------------------------------------------- /Samples/Rats/sounds/what.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Rats/sounds/what.ogg -------------------------------------------------------------------------------- /Samples/Rats/sounds/whoosh.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Rats/sounds/whoosh.ogg -------------------------------------------------------------------------------- /Samples/Rats/textures/pipe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Rats/textures/pipe.png -------------------------------------------------------------------------------- /Samples/Rats/textures/rat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Rats/textures/rat.png -------------------------------------------------------------------------------- /Samples/Rats/textures/what.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Rats/textures/what.png -------------------------------------------------------------------------------- /Samples/Rats/ui/main.rml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | [WASD] - Move camera
12 | [Esc] - Toggle mouse
13 | [Return] - Reset Camera
14 | [R] - Create Rat
15 | [H] - What
16 | 17 |
18 | -------------------------------------------------------------------------------- /Samples/Rendering/Attributions.md: -------------------------------------------------------------------------------- 1 | ### Asset attributions 2 | - Helmet model and textures from [KhronosGroup/glTF-Sample-Assets](https://github.com/KhronosGroup/glTF-Sample-Assets) 3 | - smoke particle texture by Freepik: https://www.freepik.com/free-vector/cartoon-smoke-element-animation-frames_13763535.htm 4 | - fire particle texture by macrovector: https://www.freepik.com/free-vector/light-fire-flames-animation-collection_10271988.htm -------------------------------------------------------------------------------- /Samples/Rendering/meshes/asteroid_lod0.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "asteroid_lod0.obj" 3 | } -------------------------------------------------------------------------------- /Samples/Rendering/meshes/asteroid_lod1.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "asteroid_lod1.obj" 3 | } -------------------------------------------------------------------------------- /Samples/Rendering/meshes/asteroid_lod2.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "asteroid_lod2.obj" 3 | } -------------------------------------------------------------------------------- /Samples/Rendering/meshes/baked_light.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Rendering/meshes/baked_light.glb -------------------------------------------------------------------------------- /Samples/Rendering/meshes/bakedcube.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "baked_light.glb", 3 | "mesh": "Cube", 4 | "bake_transform": true 5 | } -------------------------------------------------------------------------------- /Samples/Rendering/meshes/bakedplane.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "baked_light.glb", 3 | "mesh": "Plane", 4 | "bake_transform" : true 5 | } -------------------------------------------------------------------------------- /Samples/Rendering/meshes/helmet.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "helmet.obj" 3 | } -------------------------------------------------------------------------------- /Samples/Rendering/meshes/wineglass.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "wineglass.obj" 3 | } -------------------------------------------------------------------------------- /Samples/Rendering/shaders/AsteroidInit.csh: -------------------------------------------------------------------------------- 1 | #include "AsteroidShared.glsl" 2 | 3 | #include "utility.glsl" 4 | 5 | ParticleData init(ParticleInitData initData) 6 | { 7 | uint particleID = initData.particleID; 8 | 9 | ParticleData data; 10 | 11 | data.velocity = normalize(vec3( 12 | rand(vec2(particleID,particleID)) * 2 - 1, 13 | rand(vec2(particleID+1,particleID+1)), 14 | rand(vec2(particleID+2,particleID+2)) * 2 - 1 15 | )) * 0.2; 16 | data.rot = vec4(0,0,0,1); 17 | data.scale = vec3(rand(vec2(particleID,particleID))) * 0.4 + 0.2; 18 | data.pos = (initData.emitterModel * vec4(0, 0, 0, 1)).xyz; 19 | data.alpha = 1; 20 | 21 | return data; 22 | } -------------------------------------------------------------------------------- /Samples/Rendering/shaders/AsteroidInit.json: -------------------------------------------------------------------------------- 1 | { 2 | "shader": "AsteroidInit.csh", 3 | "type": "particle-init", 4 | "stage": "compute" 5 | } -------------------------------------------------------------------------------- /Samples/Rendering/shaders/AsteroidMeshSelection.csh: -------------------------------------------------------------------------------- 1 | #include "utility.glsl" 2 | #include "AsteroidShared.glsl" 3 | 4 | uint choose_mesh(in ParticleData data, uint particleID){ 5 | 6 | uint ID = uint(rand(vec2(particleID,particleID)) * 3); 7 | 8 | return ID; 9 | } 10 | -------------------------------------------------------------------------------- /Samples/Rendering/shaders/AsteroidMeshSelection.json: -------------------------------------------------------------------------------- 1 | { 2 | "shader": "AsteroidMeshSelection.csh", 3 | "type": "mesh-particle-selection", 4 | "stage" : "compute" 5 | } -------------------------------------------------------------------------------- /Samples/Rendering/shaders/AsteroidRender.vsh: -------------------------------------------------------------------------------- 1 | layout(push_constant, std430) uniform UniformBufferObject{ 2 | uint bytesPerParticle; 3 | uint positionOffset; 4 | uint scaleOffset; 5 | uint rotationOffset; 6 | uint alphaOffset; 7 | } ubo; 8 | 9 | #include "RavEngine/meshparticle.glsl" 10 | 11 | layout(location = 0) out vec2 outUV; 12 | layout(location = 1) out flat float alphaFactor; 13 | 14 | ParticleVertexOut vert(uint particleID, ParticleMatrices matrices){ 15 | 16 | MeshParticleVertexOut mesh_out = mesh_particle_vert(particleID, matrices, 17 | ubo.bytesPerParticle, ubo.positionOffset, ubo.scaleOffset, ubo.rotationOffset 18 | ); 19 | 20 | outUV = inUV; 21 | 22 | ParticleVertexOut vs_out; 23 | vs_out.localPosition = mesh_out.localPosition; 24 | 25 | const uint particleDataOffset = (particleID * ubo.bytesPerParticle) / 4; 26 | const uint alphaOffset = particleDataOffset + ubo.alphaOffset / 4; 27 | 28 | alphaFactor = uintBitsToFloat(particleDataBytes[alphaOffset]); 29 | 30 | return vs_out; 31 | } -------------------------------------------------------------------------------- /Samples/Rendering/shaders/AsteroidRender_fsh.json: -------------------------------------------------------------------------------- 1 | { 2 | "shader": "AsteroidRender.fsh", 3 | "stage": "fragment", 4 | "type": "lit-particle-mesh", 5 | "opacity": "transparent" 6 | } -------------------------------------------------------------------------------- /Samples/Rendering/shaders/AsteroidRender_vsh.json: -------------------------------------------------------------------------------- 1 | { 2 | "shader": "AsteroidRender.vsh", 3 | "stage": "vertex", 4 | "type": "lit-particle-mesh", 5 | "defines": [ 6 | "CUSTOM_INDEXING 1" 7 | ] 8 | } -------------------------------------------------------------------------------- /Samples/Rendering/shaders/AsteroidShared.glsl: -------------------------------------------------------------------------------- 1 | struct ParticleData{ 2 | vec4 rot; 3 | vec3 pos; 4 | vec3 scale; 5 | vec3 velocity; 6 | float alpha; 7 | }; -------------------------------------------------------------------------------- /Samples/Rendering/shaders/AsteroidUpdate.csh: -------------------------------------------------------------------------------- 1 | #include "AsteroidShared.glsl" 2 | #include "RavEngine/quat.glsl" 3 | 4 | layout(push_constant, std430) uniform UniformBufferObject{ 5 | float fpsScale; 6 | } ubo; 7 | 8 | const float kGraivty = 0.5 / 60; 9 | const float scaleDelta = 0.005; 10 | 11 | #include "utility.glsl" 12 | 13 | void update(inout ParticleData data, inout float newLife, uint particleID) 14 | { 15 | newLife += ubo.fpsScale; 16 | 17 | data.velocity.y -= kGraivty * ubo.fpsScale; 18 | 19 | data.scale -= scaleDelta * ubo.fpsScale; 20 | 21 | data.pos += data.velocity; 22 | data.rot = quatAdd(data.rot, eulerToQuat(degToRad(vec3(1,1,1) * ubo.fpsScale))) ; 23 | 24 | if (data.pos.y < data.scale.y){ 25 | data.velocity.y = abs(data.velocity.y); 26 | } 27 | 28 | if (newLife > 250){ 29 | data.alpha = remap(newLife, 250, 300, 1, 0); 30 | } 31 | 32 | if (newLife > 300) 33 | { 34 | // destroy the particle 35 | 36 | newLife = 0; 37 | } 38 | } -------------------------------------------------------------------------------- /Samples/Rendering/shaders/AsteroidUpdate.json: -------------------------------------------------------------------------------- 1 | { 2 | "shader": "AsteroidUpdate.csh", 3 | "type": "particle-update", 4 | "stage": "compute" 5 | } -------------------------------------------------------------------------------- /Samples/Rendering/shaders/FireParticleInit.csh: -------------------------------------------------------------------------------- 1 | #include "sprite_particle_layout_transparent.glsl" 2 | 3 | #include "utility.glsl" 4 | 5 | ParticleData init(ParticleInitData initData) 6 | { 7 | uint particleID = initData.particleID; 8 | 9 | ParticleData data; 10 | data.scale = vec2(0.1,1); 11 | vec4 pos = vec4( 12 | rand(vec2(particleID,particleID)), 13 | rand(vec2(particleID * 2,particleID * 2)), 14 | rand(vec2(particleID / 2,particleID / 2)), 15 | 1 16 | ); 17 | 18 | pos = initData.emitterModel * pos; 19 | 20 | data.pos = pos.xyz; 21 | 22 | data.animationFrame = 0; 23 | 24 | data.alpha = 1; 25 | 26 | return data; 27 | } -------------------------------------------------------------------------------- /Samples/Rendering/shaders/FireParticleInit.json: -------------------------------------------------------------------------------- 1 | { 2 | "shader": "FireParticleInit.csh", 3 | "type": "particle-init", 4 | "stage": "compute" 5 | } -------------------------------------------------------------------------------- /Samples/Rendering/shaders/FireParticleRender.fsh: -------------------------------------------------------------------------------- 1 | 2 | layout(binding = 0) uniform sampler g_sampler; 3 | layout(binding = 1) uniform texture2D t_spritesheet; 4 | 5 | layout(location = 0) in vec2 inUV; 6 | layout(location = 1) in flat float alphaFactor; 7 | 8 | UnlitOut frag(){ 9 | UnlitOut fs_out; 10 | 11 | fs_out.color = texture(sampler2D(t_spritesheet, g_sampler), inUV); 12 | 13 | if (fs_out.color.a < 0.5){ 14 | discard; 15 | } 16 | 17 | fs_out.color.a *= alphaFactor; 18 | 19 | return fs_out; 20 | } 21 | -------------------------------------------------------------------------------- /Samples/Rendering/shaders/FireParticleRender.vsh: -------------------------------------------------------------------------------- 1 | 2 | #include "RavEngine/billboard.glsl" 3 | 4 | layout(push_constant, std430) uniform UniformBufferObject{ 5 | ivec2 spritesheetDim; 6 | ivec2 numSprites; 7 | uint bytesPerParticle; 8 | uint particlePositionOffset; 9 | uint particleScaleOffset; 10 | uint particleFrameOffset; 11 | uint particleAlphaOffset; 12 | } ubo; 13 | 14 | layout(location = 0) out vec2 out_uv; 15 | layout(location = 1) out flat float alphaFactor; 16 | 17 | ParticleVertexOut vert(uint particleID, ParticleMatrices matrices, vec2 inVertex){ 18 | 19 | BillboardVertexResult vertdata = billboard_vert(particleID, matrices, inVertex, 20 | ubo.spritesheetDim, ubo.numSprites, 21 | ubo.bytesPerParticle, ubo.particlePositionOffset, ubo.particleScaleOffset, ubo.particleFrameOffset 22 | ); 23 | 24 | ParticleVertexOut v_out; 25 | 26 | v_out.localPosition = vertdata.localPosition; 27 | out_uv = vertdata.uv; 28 | 29 | const uint particleDataOffset = (particleID * ubo.bytesPerParticle) / 4; 30 | const uint particleAlphaOffset = particleDataOffset + ubo.particleAlphaOffset / 4; 31 | 32 | alphaFactor = uintBitsToFloat(particleDataBytes[particleAlphaOffset]); 33 | 34 | return v_out; 35 | } 36 | -------------------------------------------------------------------------------- /Samples/Rendering/shaders/FireParticleRender_fsh.json: -------------------------------------------------------------------------------- 1 | { 2 | "shader": "FireParticleRender.fsh", 3 | "stage": "fragment", 4 | "type": "unlit-particle-quad", 5 | "opacity": "transparent" 6 | } -------------------------------------------------------------------------------- /Samples/Rendering/shaders/FireParticleRender_vsh.json: -------------------------------------------------------------------------------- 1 | { 2 | "shader": "FireParticleRender.vsh", 3 | "stage": "vertex", 4 | "type": "unlit-particle-quad", 5 | "defines": [ 6 | "CUSTOM_INDEXING 1" 7 | ] 8 | } -------------------------------------------------------------------------------- /Samples/Rendering/shaders/FireParticleUpdate.csh: -------------------------------------------------------------------------------- 1 | #include "ravengine_shader.glsl" 2 | 3 | layout(push_constant, std430) uniform UniformBufferObject{ 4 | float fpsScale; 5 | } ubo; 6 | 7 | 8 | #include "sprite_particle_layout_transparent.glsl" 9 | 10 | #include "utility.glsl" 11 | 12 | const float maxLife = 20; 13 | 14 | void update(inout ParticleData data, inout float newLife, uint particleID) 15 | { 16 | data.scale += ubo.fpsScale * 0.05; 17 | 18 | data.pos.y += ubo.fpsScale * 0.01; 19 | 20 | vec2 movevec = vec2( 21 | rand(vec2(particleID, particleID)) * 2 - 1, 22 | rand(vec2(particleID * 2, particleID * 2)) * 2 - 1 23 | ); 24 | 25 | float life = maxLife; 26 | 27 | movevec *= 0.02; 28 | 29 | data.pos.x += movevec.x; 30 | data.pos.z += movevec.y; 31 | 32 | newLife += ubo.fpsScale; 33 | 34 | data.animationFrame = uint(remap(newLife,0,life,0,11)); 35 | 36 | if (data.animationFrame >= 6){ 37 | data.alpha = remap(data.animationFrame, 6,11, 1,0); 38 | } 39 | 40 | if (newLife > life){ 41 | // destroy the particle 42 | 43 | newLife = 0; 44 | } 45 | } -------------------------------------------------------------------------------- /Samples/Rendering/shaders/FireParticleUpdate.json: -------------------------------------------------------------------------------- 1 | { 2 | "shader": "FireParticleUpdate.csh", 3 | "type": "particle-update", 4 | "stage": "compute" 5 | } -------------------------------------------------------------------------------- /Samples/Rendering/shaders/SmokeParticleInit.json: -------------------------------------------------------------------------------- 1 | { 2 | "shader": "SmokeParticleInitialize.csh", 3 | "type": "particle-init", 4 | "stage" : "compute" 5 | } -------------------------------------------------------------------------------- /Samples/Rendering/shaders/SmokeParticleInitialize.csh: -------------------------------------------------------------------------------- 1 | 2 | #include "sprite_particle_layout.glsl" 3 | 4 | #include "utility.glsl" 5 | 6 | ParticleData init(ParticleInitData initData) 7 | { 8 | uint particleID = initData.particleID; 9 | 10 | ParticleData data; 11 | data.scale = vec2(0.1,0.1); 12 | vec4 pos = vec4( 13 | rand(vec2(particleID,particleID)), 14 | rand(vec2(particleID * 2,particleID * 2)), 15 | rand(vec2(particleID / 2,particleID / 2)), 16 | 1 17 | ); 18 | 19 | pos = initData.emitterModel * pos; 20 | 21 | data.pos = pos.xyz; 22 | 23 | data.animationFrame = 0; 24 | 25 | return data; 26 | } -------------------------------------------------------------------------------- /Samples/Rendering/shaders/SmokeParticleUpdate.csh: -------------------------------------------------------------------------------- 1 | 2 | #include "ravengine_shader.glsl" 3 | 4 | layout(push_constant, std430) uniform UniformBufferObject{ 5 | float fpsScale; 6 | } ubo; 7 | 8 | 9 | #include "sprite_particle_layout.glsl" 10 | 11 | #include "utility.glsl" 12 | 13 | const float maxLife = 200; 14 | 15 | void update(inout ParticleData data, inout float newLife, uint particleID) 16 | { 17 | data.scale += ubo.fpsScale * 0.005; 18 | 19 | data.pos.y += ubo.fpsScale * 0.1; 20 | 21 | vec2 movevec = vec2( 22 | rand(vec2(particleID, particleID)) * 2 - 1, 23 | rand(vec2(particleID * 2, particleID * 2)) * 2 - 1 24 | ); 25 | 26 | float life = maxLife; 27 | 28 | movevec *= 0.02; 29 | 30 | data.pos.x += movevec.x; 31 | data.pos.z += movevec.y; 32 | 33 | newLife += ubo.fpsScale; 34 | 35 | data.animationFrame = uint(remap(newLife,0,life,0,9)); 36 | 37 | if (newLife > life){ 38 | // destroy the particle 39 | 40 | newLife = 0; 41 | } 42 | } -------------------------------------------------------------------------------- /Samples/Rendering/shaders/SmokeParticleUpdate.json: -------------------------------------------------------------------------------- 1 | { 2 | "shader": "SmokeParticleUpdate.csh", 3 | "type": "particle-update", 4 | "stage" : "compute" 5 | } -------------------------------------------------------------------------------- /Samples/Rendering/shaders/sprite_particle_layout.glsl: -------------------------------------------------------------------------------- 1 | struct ParticleData{ 2 | vec3 pos; 3 | vec2 scale; 4 | uint animationFrame; 5 | }; 6 | -------------------------------------------------------------------------------- /Samples/Rendering/shaders/sprite_particle_layout_transparent.glsl: -------------------------------------------------------------------------------- 1 | struct ParticleData{ 2 | vec3 pos; 3 | vec2 scale; 4 | uint animationFrame; 5 | float alpha; 6 | }; 7 | -------------------------------------------------------------------------------- /Samples/Rendering/shaders/star.vsh: -------------------------------------------------------------------------------- 1 | 2 | layout(push_constant, std430) uniform UniformBufferObject{ 3 | float time; 4 | } ubo; 5 | 6 | layout(location = 0) out vec2 outUV; 7 | 8 | UnlitVertexOut vert(EntityIn entity, EngineData data) 9 | { 10 | UnlitVertexOut vs_out; 11 | 12 | vs_out.localPosition = inPosition; 13 | outUV = inUV; 14 | 15 | return vs_out; 16 | } 17 | -------------------------------------------------------------------------------- /Samples/Rendering/shaders/star_fsh.json: -------------------------------------------------------------------------------- 1 | { 2 | "shader": "star.fsh", 3 | "stage": "fragment", 4 | "type": "unlit-mesh" 5 | } -------------------------------------------------------------------------------- /Samples/Rendering/shaders/star_vsh.json: -------------------------------------------------------------------------------- 1 | { 2 | "shader": "star.vsh", 3 | "stage": "vertex", 4 | "type": "unlit-mesh" 5 | } -------------------------------------------------------------------------------- /Samples/Rendering/shaders/unlit_transparent.fsh: -------------------------------------------------------------------------------- 1 | 2 | UnlitOut frag() 3 | { 4 | UnlitOut mat_out; 5 | 6 | mat_out.color = vec4(0,0,1,0.5); 7 | 8 | return mat_out; 9 | } -------------------------------------------------------------------------------- /Samples/Rendering/shaders/unlit_transparent.vsh: -------------------------------------------------------------------------------- 1 | 2 | 3 | UnlitVertexOut vert(EntityIn entity, EngineData data) 4 | { 5 | UnlitVertexOut vs_out; 6 | 7 | vs_out.localPosition = inPosition; 8 | 9 | return vs_out; 10 | } 11 | -------------------------------------------------------------------------------- /Samples/Rendering/shaders/unlit_transparent_fsh.json: -------------------------------------------------------------------------------- 1 | { 2 | "shader": "unlit_transparent.fsh", 3 | "stage": "fragment", 4 | "type": "unlit-mesh", 5 | "opacity": "transparent" 6 | } -------------------------------------------------------------------------------- /Samples/Rendering/shaders/unlit_transparent_vsh.json: -------------------------------------------------------------------------------- 1 | { 2 | "shader": "unlit_transparent.vsh", 3 | "stage": "vertex", 4 | "type": "unlit-mesh" 5 | } -------------------------------------------------------------------------------- /Samples/Rendering/shaders/wineglass.fsh: -------------------------------------------------------------------------------- 1 | 2 | layout(location = 0) in vec2 inUV; 3 | 4 | vec3 colors[] = { 5 | vec3(0.3,0,0), 6 | vec3(0,0.3,0), 7 | vec3(0,0,0.3) 8 | }; 9 | 10 | LitOutput frag(EnvironmentData envData) 11 | { 12 | LitOutput mat_out; 13 | 14 | mat_out.color = vec4(colors[0],0.5); 15 | 16 | mat_out.normal = vec3(0,0,1); 17 | 18 | mat_out.ao = 1; 19 | 20 | mat_out.roughness = 0; 21 | mat_out.specular = 0.8; 22 | mat_out.metallic = 0.2; 23 | mat_out.emissiveColor = vec3(0,0,0); 24 | 25 | return mat_out; 26 | } -------------------------------------------------------------------------------- /Samples/Rendering/shaders/wineglass_fsh.json: -------------------------------------------------------------------------------- 1 | { 2 | "shader": "wineglass.fsh", 3 | "stage": "fragment", 4 | "type": "lit-mesh", 5 | "opacity": "transparent" 6 | } -------------------------------------------------------------------------------- /Samples/Rendering/textures/Default_AO.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Rendering/textures/Default_AO.png -------------------------------------------------------------------------------- /Samples/Rendering/textures/Default_albedo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Rendering/textures/Default_albedo.png -------------------------------------------------------------------------------- /Samples/Rendering/textures/Default_emissive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Rendering/textures/Default_emissive.png -------------------------------------------------------------------------------- /Samples/Rendering/textures/Default_metalness.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Rendering/textures/Default_metalness.png -------------------------------------------------------------------------------- /Samples/Rendering/textures/Default_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Rendering/textures/Default_normal.png -------------------------------------------------------------------------------- /Samples/Rendering/textures/Default_roughness.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Rendering/textures/Default_roughness.png -------------------------------------------------------------------------------- /Samples/Rendering/textures/bakedshadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Rendering/textures/bakedshadow.png -------------------------------------------------------------------------------- /Samples/Rendering/textures/fire.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Rendering/textures/fire.png -------------------------------------------------------------------------------- /Samples/Rendering/textures/smoke.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Rendering/textures/smoke.png -------------------------------------------------------------------------------- /Samples/SceneViewer/SceneLoader.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | struct aiScene; 8 | 9 | namespace RavEngine { 10 | class Entity; 11 | class MeshAsset; 12 | class PBRMaterialInstance; 13 | 14 | struct PreloadedAsset { 15 | std::string_view name; 16 | }; 17 | 18 | struct PreloadedLight : public PreloadedAsset { 19 | // light details here... 20 | }; 21 | 22 | struct ImportedObject : public PreloadedAsset { 23 | vector3 translate, scale; 24 | quaternion rotation; 25 | Ref mesh; 26 | Ref material; 27 | }; 28 | 29 | struct SceneLoader{ 30 | 31 | /** 32 | * Construct a SceneLoader. This will load the scene file into an intermediate representation. 33 | */ 34 | SceneLoader(const char* sceneFile); 35 | /** 36 | * Construct a SceneLoader. This will load the scene file into an intermediate representation. 37 | */ 38 | SceneLoader(const std::string& sceneFile); 39 | 40 | /** 41 | Construct a SceneLoader from the user's filesystem. This will load the scene file into an intermediate representation 42 | */ 43 | SceneLoader(const Filesystem::Path& pathOnDisk); 44 | 45 | /** 46 | * Unloads internal representation 47 | */ 48 | ~SceneLoader(); 49 | /** 50 | * Load the scene nodes for this scene 51 | * @param func the function to invoke with each node 52 | */ 53 | void LoadObjects(const Function& func); 54 | 55 | private: 56 | const aiScene* scene; 57 | const std::string scene_path; 58 | }; 59 | 60 | 61 | } 62 | -------------------------------------------------------------------------------- /Samples/Shadows/meshes/bunny_decimated.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/Shadows/meshes/bunny_decimated.fbx -------------------------------------------------------------------------------- /Samples/Shadows/meshes/bunny_decimated.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "bunny_decimated.fbx" 3 | } -------------------------------------------------------------------------------- /Samples/Shadows/meshes/helmet.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "helmet.obj" 3 | } -------------------------------------------------------------------------------- /Samples/Shadows/meshes/pipe.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "pipe.obj" 3 | } -------------------------------------------------------------------------------- /Samples/Shadows/meshes/rat.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "rat.obj", 3 | "scale": 0.2 4 | } -------------------------------------------------------------------------------- /Samples/Shadows/meshes/triangle.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "triangle.obj" 3 | } -------------------------------------------------------------------------------- /Samples/Shadows/meshes/triangle.obj: -------------------------------------------------------------------------------- 1 | # Blender v2.82 (sub 7) OBJ File: '' 2 | # www.blender.org 3 | mtllib triangle.mtl 4 | o triangle_Cube 5 | v 1.000000 0.000000 -1.000000 6 | v 1.000000 0.000000 1.000000 7 | v -1.000000 0.000000 -1.000000 8 | vt 0.875000 0.500000 9 | vt 0.625000 0.750000 10 | vt 0.625000 0.500000 11 | vn 0.0000 1.0000 0.0000 12 | usemtl Material 13 | s off 14 | f 3/1/1 2/2/1 1/3/1 15 | -------------------------------------------------------------------------------- /Samples/Shadows/meshes/wineglass.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "wineglass.obj" 3 | } -------------------------------------------------------------------------------- /Samples/SoundDynamics/App.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "AppInfo.hpp" 3 | #include "Level.hpp" 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace RavEngine; 9 | 10 | struct SoundDynamics : public RavEngine::App { 11 | void OnStartup(int argc, char** argv) final { 12 | auto world = RavEngine::New(); 13 | AddWorld(world); 14 | 15 | SetWindowTitle(VFormat("{} | {}", APPNAME, GetRenderEngine().GetCurrentBackendName()).c_str()); 16 | } 17 | 18 | void OnFatal(const std::string_view msg) final{ 19 | RavEngine::Dialog::ShowBasic("Fatal Error", msg, Dialog::MessageBoxType::Error); 20 | } 21 | }; 22 | 23 | START_APP(SoundDynamics) 24 | -------------------------------------------------------------------------------- /Samples/SoundDynamics/AudioExporter.cpp: -------------------------------------------------------------------------------- 1 | #if 0 2 | #include "AudioExporter.hpp" 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace RavEngine; 8 | 9 | void AudioExporter::ExportWavOneShot(Ref asset, const Filesystem::Path &outputPath){ 10 | drwav outputFile; 11 | drwav_data_format outputFormat {}; 12 | outputFormat.container = drwav_container_riff; 13 | outputFormat.format = DR_WAVE_FORMAT_PCM; 14 | outputFormat.channels = asset->GetNChanels(); 15 | outputFormat.sampleRate = AudioPlayer::GetSamplesPerSec(); 16 | outputFormat.bitsPerSample = 16; 17 | 18 | #if !defined(_WIN32) 19 | drwav_bool32 outputFileOk = drwav_init_file_write(&outputFile, outputPath.c_str(), &outputFormat, nullptr); 20 | #else 21 | drwav_bool32 outputFileOk = drwav_init_file_write_w(&outputFile, outputPath.c_str(), &outputFormat, nullptr); 22 | #endif 23 | 24 | auto sampleCount = asset->GetNumSamples(); 25 | 26 | std::vector interleavedPcm(sampleCount); 27 | 28 | drwav_f32_to_s16(interleavedPcm.data(),asset->GetData(),sampleCount); 29 | drwav_write_pcm_frames(&outputFile, sampleCount, interleavedPcm.data()); 30 | 31 | drwav_uninit(&outputFile); 32 | } 33 | #endif 34 | -------------------------------------------------------------------------------- /Samples/SoundDynamics/AudioExporter.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace RavEngine { 6 | class AudioAsset; 7 | 8 | struct AudioExporter{ 9 | /** 10 | Write an AudioAsset to disk in one-shot as a wav file 11 | @param asset the asset to write 12 | @param destination where to write it 13 | */ 14 | static void ExportWavOneShot(Ref asset, const Filesystem::Path& destination); 15 | }; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /Samples/SoundDynamics/Level.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace RavEngine { 5 | struct AudioAsset; 6 | struct AudioMIDIPlayer; 7 | struct AudioDataProvider; 8 | } 9 | 10 | struct Level : public RavEngine::World { 11 | Level(); 12 | RavEngine::UnorderedMap> tracks; 13 | 14 | void ToggleMouse(); 15 | }; 16 | -------------------------------------------------------------------------------- /Samples/SoundDynamics/Player.cpp: -------------------------------------------------------------------------------- 1 | #include "Player.hpp" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace RavEngine; 9 | using namespace std; 10 | 11 | void Player::Create() { 12 | GameObject::Create(); 13 | auto cameraEntity = GetWorld()->Instantiate(); 14 | 15 | auto& camera = cameraEntity.EmplaceComponent(); 16 | camera.SetActive(true); 17 | 18 | // microphone / ear 19 | cameraEntity.EmplaceComponent(); 20 | 21 | // child entity w/ camera 22 | 23 | // static rigid body 24 | auto& body = EmplaceComponent(); 25 | 26 | auto physicsMaterial = RavEngine::New(0,0,0); 27 | body.EmplaceCollider(1.f,physicsMaterial); 28 | 29 | ComponentHandle ctr(cameraEntity); 30 | GetTransform().AddChild(ctr); 31 | 32 | auto& player = EmplaceComponent(); 33 | player.childTransform = ctr; 34 | } 35 | -------------------------------------------------------------------------------- /Samples/SoundDynamics/Player.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | struct PlayerController : public RavEngine::ScriptComponent { 10 | float scaleFactor = 0; 11 | float movementSpeed = 0.1; 12 | float rotationSpeed = 0.05; 13 | RavEngine::ComponentHandle childTransform; 14 | 15 | inline decimalType scale(float amt) { 16 | return amt * scaleFactor * movementSpeed * RavEngine::GetApp()->GetMainWindow()->GetRelativeMouseMode(); 17 | } 18 | 19 | inline void MoveForward(float amt) { 20 | auto& tr = GetTransform(); 21 | tr.LocalTranslateDelta(tr.Forward() * scale(amt)); 22 | } 23 | 24 | inline void MoveRight(float amt) { 25 | auto& tr = GetTransform(); 26 | tr.LocalTranslateDelta(tr.Right() * scale(amt)); 27 | } 28 | 29 | inline void MoveUp(float amt) { 30 | auto& tr = GetTransform(); 31 | tr.LocalTranslateDelta(tr.Up() * scale(amt)); 32 | } 33 | 34 | inline void LookUp(float amt) { 35 | childTransform->LocalRotateDelta(vector3(deg_to_rad(amt * rotationSpeed * RavEngine::GetApp()->GetMainWindow()->GetRelativeMouseMode()), 0, 0)); 36 | } 37 | 38 | inline void LookRight(float amt) { 39 | auto& tr = GetTransform(); 40 | tr.LocalRotateDelta(vector3(0, deg_to_rad(amt * rotationSpeed * RavEngine::GetApp()->GetMainWindow()->GetRelativeMouseMode()), 0)); 41 | } 42 | 43 | void Tick(float scale) final { 44 | scaleFactor = scale; 45 | } 46 | PlayerController(RavEngine::Entity owner) : ScriptComponent(owner){} 47 | }; 48 | struct Player : public RavEngine::GameObject { 49 | void Create(); 50 | }; 51 | -------------------------------------------------------------------------------- /Samples/SoundDynamics/Speaker.cpp: -------------------------------------------------------------------------------- 1 | #include "Speaker.hpp" 2 | #include 3 | #include "AudioMIDI.hpp" 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace RavEngine; 9 | using namespace std; 10 | 11 | STATIC(Speaker::speakerInstance); 12 | 13 | void Speaker::Create(Ref a) { 14 | GameObject::Create(); 15 | // audio source 16 | auto sourceEntity = GetWorld()->Instantiate(); 17 | auto& audio = sourceEntity.EmplaceComponent(a); 18 | 19 | 20 | GetTransform().AddChild(sourceEntity); 21 | sourceEntity.GetTransform().LocalTranslateDelta(vector3(0, 3, 0)); 22 | 23 | if (!speakerInstance) { 24 | speakerInstance = RavEngine::New(Material::Manager::Get()); 25 | auto texture = Texture::Manager::Get("speaker.png"); 26 | speakerInstance->SetAlbedoTexture(texture); 27 | } 28 | EmplaceComponent(MeshCollectionStaticManager::Get("speaker"), speakerInstance); 29 | } 30 | -------------------------------------------------------------------------------- /Samples/SoundDynamics/Speaker.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | struct Speaker : public RavEngine::GameObject { 7 | 8 | void Create(Ref a); 9 | 10 | static Ref speakerInstance; 11 | 12 | }; 13 | 14 | namespace RavEngine { 15 | struct AudioRoom; 16 | } 17 | 18 | struct Stage : public RavEngine::GameObject { 19 | void Create(); 20 | GameObject roomEntity; 21 | RavEngine::ComponentHandle GetRoom() { 22 | return RavEngine::ComponentHandle(roomEntity); 23 | } 24 | RavEngine::Array, 6> wallMaterials; 25 | }; 26 | -------------------------------------------------------------------------------- /Samples/SoundDynamics/Stage.cpp: -------------------------------------------------------------------------------- 1 | #include "Speaker.hpp" 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | using namespace RavEngine; 8 | 9 | constexpr static bool useGeometrySpace = false; 10 | 11 | void Stage::Create() { 12 | GameObject::Create(); 13 | roomEntity = GetWorld()->Instantiate(); 14 | 15 | if constexpr (useGeometrySpace) { 16 | auto& audioRoom = roomEntity.EmplaceComponent(); 17 | audioRoom.SetAudioSourceRadius(50); 18 | audioRoom.SetMeshRadius(50); 19 | } 20 | else { 21 | auto& audioRoom = roomEntity.EmplaceComponent(); 22 | audioRoom.SetHalfExts({50,50,50}); 23 | } 24 | 25 | GetTransform().AddChild(roomEntity); 26 | 27 | 28 | Array faceOrder{ 29 | "wall_negx", 30 | "wall_posx", 31 | "floor", 32 | "ceiling", 33 | "wall_negz", 34 | "wall_posz" 35 | }; 36 | 37 | for(const auto& name : faceOrder){ 38 | auto pos = std::distance(faceOrder.begin(),std::find(faceOrder.begin(), faceOrder.end(), name)); 39 | auto inst = RavEngine::New(Material::Manager::Get()); 40 | auto rm = MeshCollectionStaticManager::Get(std::string(name)); 41 | EmplaceComponent(rm, inst); 42 | this->wallMaterials[pos] = inst; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /Samples/SoundDynamics/meshes/ceiling.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "room.fbx", 3 | "mesh": "ceiling" 4 | } -------------------------------------------------------------------------------- /Samples/SoundDynamics/meshes/floor.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "room.fbx", 3 | "mesh": "floor" 4 | } -------------------------------------------------------------------------------- /Samples/SoundDynamics/meshes/room.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/SoundDynamics/meshes/room.fbx -------------------------------------------------------------------------------- /Samples/SoundDynamics/meshes/speaker.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "speaker.obj" 3 | } -------------------------------------------------------------------------------- /Samples/SoundDynamics/meshes/wall_negx.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "room.fbx", 3 | "mesh": "wall_negx" 4 | } -------------------------------------------------------------------------------- /Samples/SoundDynamics/meshes/wall_negz.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "room.fbx", 3 | "mesh": "wall_negz" 4 | } -------------------------------------------------------------------------------- /Samples/SoundDynamics/meshes/wall_posx.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "room.fbx", 3 | "mesh": "wall_posx" 4 | } -------------------------------------------------------------------------------- /Samples/SoundDynamics/meshes/wall_posz.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "room.fbx", 3 | "mesh": "wall_posz" 4 | } -------------------------------------------------------------------------------- /Samples/SoundDynamics/sounds/Aquarium.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/SoundDynamics/sounds/Aquarium.mp3 -------------------------------------------------------------------------------- /Samples/SoundDynamics/sounds/Danse Macabre.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/SoundDynamics/sounds/Danse Macabre.mp3 -------------------------------------------------------------------------------- /Samples/SoundDynamics/sounds/Licenses.txt: -------------------------------------------------------------------------------- 1 | "The Entertainer" Kevin MacLeod (incompetech.com) 2 | Licensed under Creative Commons: By Attribution 4.0 License 3 | http://creativecommons.org/licenses/by/4.0/ 4 | 5 | "Aquarium" Kevin MacLeod (incompetech.com) 6 | Licensed under Creative Commons: By Attribution 4.0 License 7 | http://creativecommons.org/licenses/by/4.0/ 8 | 9 | "String Impromptu Number 1" Kevin MacLeod (incompetech.com) 10 | Licensed under Creative Commons: By Attribution 4.0 License 11 | http://creativecommons.org/licenses/by/4.0/ 12 | 13 | "Danse Macabre" Kevin MacLeod (incompetech.com) 14 | Licensed under Creative Commons: By Attribution 4.0 License 15 | http://creativecommons.org/licenses/by/4.0/ 16 | 17 | 18 | Maple Leaf Rag arrangement by Cosmic Piano available at: https://www.youtube.com/watch?v=SIhcN4x7V6Y -------------------------------------------------------------------------------- /Samples/SoundDynamics/sounds/Maple Leaf Rag.mid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/SoundDynamics/sounds/Maple Leaf Rag.mid -------------------------------------------------------------------------------- /Samples/SoundDynamics/sounds/String Impromptu Number 1.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/SoundDynamics/sounds/String Impromptu Number 1.mp3 -------------------------------------------------------------------------------- /Samples/SoundDynamics/sounds/The Entertainer.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/SoundDynamics/sounds/The Entertainer.mp3 -------------------------------------------------------------------------------- /Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_A2_mf.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_A2_mf.ogg -------------------------------------------------------------------------------- /Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_A4_mf.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_A4_mf.ogg -------------------------------------------------------------------------------- /Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_A6_mf.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_A6_mf.ogg -------------------------------------------------------------------------------- /Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_B1_mf.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_B1_mf.ogg -------------------------------------------------------------------------------- /Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_B3_mf.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_B3_mf.ogg -------------------------------------------------------------------------------- /Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_B5_mf.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_B5_mf.ogg -------------------------------------------------------------------------------- /Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_B6_mf.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_B6_mf.ogg -------------------------------------------------------------------------------- /Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_C3_mf.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_C3_mf.ogg -------------------------------------------------------------------------------- /Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_C5_mf.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_C5_mf.ogg -------------------------------------------------------------------------------- /Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_D2_mf.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_D2_mf.ogg -------------------------------------------------------------------------------- /Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_D4_mf.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_D4_mf.ogg -------------------------------------------------------------------------------- /Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_D6_mf.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_D6_mf.ogg -------------------------------------------------------------------------------- /Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_D7_f.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_D7_f.ogg -------------------------------------------------------------------------------- /Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_E1_f.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_E1_f.ogg -------------------------------------------------------------------------------- /Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_E3_mf.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_E3_mf.ogg -------------------------------------------------------------------------------- /Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_E5_mf.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_E5_mf.ogg -------------------------------------------------------------------------------- /Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_F2_mf.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_F2_mf.ogg -------------------------------------------------------------------------------- /Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_F4_mf.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_F4_mf.ogg -------------------------------------------------------------------------------- /Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_F6_mf.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_F6_mf.ogg -------------------------------------------------------------------------------- /Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_F7_f.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_F7_f.ogg -------------------------------------------------------------------------------- /Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_G1_mp.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_G1_mp.ogg -------------------------------------------------------------------------------- /Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_G3_mf.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_G3_mf.ogg -------------------------------------------------------------------------------- /Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_G5_mf.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/SoundDynamics/streaming/Strings/Harp/KSHarp_G5_mf.ogg -------------------------------------------------------------------------------- /Samples/SoundDynamics/textures/speaker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/SoundDynamics/textures/speaker.png -------------------------------------------------------------------------------- /Samples/SoundDynamics/ui/main.rml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 |
10 |

11 |

12 | Select Music 13 |
14 | 16 |

17 |
18 |

19 | Press ESC to toggle mouse 20 |

21 |
22 | 23 |
-------------------------------------------------------------------------------- /Samples/SystemInfo/ui/ui.rml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

8 | 9 |
10 | 11 | -------------------------------------------------------------------------------- /Samples/TextureViewer/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | using namespace RavEngine; 13 | using namespace std; 14 | 15 | 16 | 17 | struct TextureViewerWorld : public RavEngine::World { 18 | 19 | Ref mat; 20 | ComponentHandle planeTransform; 21 | TextureViewerWorld() { 22 | 23 | auto cubeEntity = Instantiate(); 24 | 25 | mat = RavEngine::New(Material::Manager::Get()); 26 | auto mesh = MeshCollectionStaticManager::Get("quad"); 27 | cubeEntity.EmplaceComponent(mesh, mat); 28 | cubeEntity.GetTransform().LocalRotateDelta(vector3{deg_to_rad(90),0.f,0.f}); 29 | planeTransform = cubeEntity; 30 | 31 | auto cameraEntity = Instantiate(); 32 | 33 | auto& cameraComponent = cameraEntity.EmplaceComponent(); 34 | 35 | cameraComponent.SetActive(true); 36 | 37 | cubeEntity.GetTransform().LocalTranslateDelta(vector3(0, 0, -5)); 38 | 39 | auto lightsEntity = Instantiate(); 40 | lightsEntity.EmplaceComponent().SetIntensity(4); 41 | lightsEntity.EmplaceComponent().SetIntensity(0.2); 42 | 43 | lightsEntity.GetTransform().LocalRotateDelta(vector3{ deg_to_rad(45), deg_to_rad(45),0 }); 44 | } 45 | 46 | void LoadTexture(const Filesystem::Path& path) { 47 | auto tx = New(path); 48 | mat->SetAlbedoTexture(tx); 49 | auto dim = tx->GetTextureSize();; 50 | auto aspect = (float)dim.width / dim.height; 51 | planeTransform->SetLocalScale({ aspect,1,1 }); 52 | } 53 | }; 54 | 55 | struct TextureViewerApp : public RavEngine::App { 56 | constexpr static SDL_DialogFileFilter filters[] = { {"Any file", "*"} }; 57 | 58 | Ref world; 59 | 60 | void OnStartup(int argc, char** argv) final { 61 | 62 | SetWindowTitle("TextureViewer"); 63 | 64 | world = RavEngine::New(); 65 | 66 | AddWorld(world); 67 | LoadNewTexture(); 68 | } 69 | 70 | void OnFatal(const std::string_view msg) final { 71 | RavEngine::Dialog::ShowBasic("Fatal Error", msg, Dialog::MessageBoxType::Error); 72 | } 73 | 74 | void LoadNewTexture() { 75 | SDL_ShowOpenFileDialog([](void* userdata, const char* const* filelist, int filter) { 76 | 77 | auto app = static_cast(userdata); 78 | if (filelist == nullptr) { 79 | Debug::Fatal("An error occured: {}", SDL_GetError()); 80 | app->Quit(); 81 | } 82 | if (filelist && *filelist) { 83 | Filesystem::Path chosenFile(*filelist); 84 | app->DispatchMainThread([app,chosenFile] { 85 | app->world->LoadTexture(chosenFile); 86 | }); 87 | } 88 | else { 89 | app->Quit(); 90 | } 91 | 92 | 93 | }, this, GetMainWindow()->window, filters, std::size(filters), NULL, false); 94 | } 95 | }; 96 | 97 | START_APP(TextureViewerApp) -------------------------------------------------------------------------------- /Samples/VR/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "AppInfo.hpp" 9 | #include 10 | #include 11 | 12 | using namespace RavEngine; 13 | using namespace std; 14 | 15 | struct Level : public RavEngine::World{ 16 | GameObject cube; 17 | GameObject cameraRoot = Instantiate(),cameraBoom = Instantiate(), camera = Instantiate(); 18 | 19 | Level() { 20 | // load ground plane 21 | auto ground = Instantiate(); 22 | ground.EmplaceComponent(MeshCollectionStaticManager::Get("quad"), New(Material::Manager::Get())); 23 | ground.GetTransform().LocalScaleDelta(vector3(5,1,5)); 24 | 25 | cube = Instantiate(); 26 | auto cubeMat = New(Material::Manager::Get()); 27 | cubeMat->SetAlbedoColor({0,0,1,1}); 28 | cube.EmplaceComponent(MeshCollectionStaticManager::Get("cube"), cubeMat); 29 | cube.GetTransform() 30 | .LocalTranslateDelta(vector3(1,0.7,0)) 31 | .LocalRotateDelta(vector3(deg_to_rad(45),deg_to_rad(90),0)) 32 | //.LocalRotateDelta(vector3(0,0,deg_to_rad(45))) 33 | .SetLocalScale(0.5); 34 | 35 | // create lights and camera 36 | camera.EmplaceComponent().SetActive(true); 37 | camera.GetTransform().LocalTranslateDelta(vector3(0, 0, 5)); 38 | cameraRoot.GetTransform().AddChild(cameraBoom); 39 | cameraBoom.GetTransform().AddChild(camera); 40 | 41 | auto light = Instantiate(); 42 | auto& dl = light.EmplaceComponent(); 43 | dl.debugEnabled = false; 44 | dl.SetIntensity(3); 45 | dl.SetCastsShadows(true); 46 | light.EmplaceComponent().SetIntensity(0.2); 47 | light.GetTransform().LocalRotateDelta(vector3(0, 0, deg_to_rad(45))).LocalTranslateDelta(vector3(0,2,0)); 48 | 49 | } 50 | }; 51 | 52 | // level boilerplate 53 | struct VRApp : public RavEngine::App { 54 | VRApp() { 55 | wantsXR = true; 56 | } 57 | void OnStartup(int argc, char** argv) final{ 58 | AddWorld(RavEngine::New()); 59 | SetWindowTitle(VFormat("{} | {}", APPNAME, GetRenderEngine().GetCurrentBackendName()).c_str()); 60 | } 61 | void OnFatal(const std::string_view msg) final { 62 | RavEngine::Dialog::ShowBasic("Fatal Error", msg, RavEngine::Dialog::MessageBoxType::Error); 63 | } 64 | bool NeedsAudio() const final { 65 | return false; 66 | } 67 | }; 68 | START_APP(VRApp); 69 | -------------------------------------------------------------------------------- /Samples/logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/logo.ico -------------------------------------------------------------------------------- /Samples/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/logo.png -------------------------------------------------------------------------------- /Samples/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by windows.rc 4 | // 5 | #define IDI_ICON1 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /Samples/windows.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/Samples/windows.rc -------------------------------------------------------------------------------- /appimage.cmake: -------------------------------------------------------------------------------- 1 | function(make_appimage) 2 | set(optional) 3 | set(args EXE NAME DIR_ICON ICON OUTPUT_NAME OUTPUT_ARCH CROSSCOMP) 4 | set(list_args ASSETS) 5 | cmake_parse_arguments( 6 | PARSE_ARGV 0 7 | ARGS 8 | "${optional}" 9 | "${args}" 10 | "${list_args}" 11 | ) 12 | 13 | if(${ARGS_UNPARSED_ARGUMENTS}) 14 | message(WARNING "Unparsed arguments: ${ARGS_UNPARSED_ARGUMENTS}") 15 | endif() 16 | 17 | 18 | # download AppImageTool if needed (TODO: non-x86 build machine?) 19 | SET(AIT_PATH "${CMAKE_BINARY_DIR}/AppImageTool-x86_64.AppImage" CACHE INTERNAL "") 20 | if (NOT EXISTS "${AIT_PATH}") 21 | file(DOWNLOAD https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage "${AIT_PATH}") 22 | execute_process(COMMAND chmod +x ${AIT_PATH}) 23 | endif() 24 | if(ARGS_CROSSCOMP) # need to also download runtime 25 | SET(AIT_RUNTIME_PATH "${CMAKE_BINARY_DIR}/runtime-${ARGS_OUTPUT_ARCH}" CACHE INTERNAL "") 26 | if (NOT EXISTS "${AIT_RUNTIME_PATH}") 27 | file(DOWNLOAD https://github.com/AppImage/AppImageKit/releases/download/continuous/runtime-${ARGS_OUTPUT_ARCH} "${AIT_RUNTIME_PATH}") 28 | endif() 29 | endif() 30 | 31 | # make the AppDir 32 | set(APPDIR "${CMAKE_BINARY_DIR}/AppDir") 33 | file(REMOVE_RECURSE "${APPDIR}") # remove if leftover 34 | file(MAKE_DIRECTORY "${APPDIR}") 35 | 36 | # copy executable to appdir 37 | file(COPY "${ARGS_EXE}" DESTINATION "${APPDIR}" FOLLOW_SYMLINK_CHAIN) 38 | get_filename_component(EXE_NAME "${ARGS_EXE}" NAME) 39 | 40 | # create the script that will launch the AppImage 41 | file(WRITE "${APPDIR}/AppRun" 42 | "#!/bin/sh 43 | cd \"$(dirname \"$0\")\"; 44 | ./${EXE_NAME} $@" 45 | ) 46 | execute_process(COMMAND chmod +x "${APPDIR}/AppRun") 47 | 48 | # copy assets to appdir 49 | foreach(ITEM ${ARGS_ASSETS}) 50 | if(EXISTS ${ITEM}) 51 | file(COPY ${ITEM} DESTINATION "${APPDIR}") 52 | endif() 53 | endforeach() 54 | 55 | # copy icon thumbnail 56 | file(COPY ${ARGS_DIR_ICON} DESTINATION "${APPDIR}") 57 | get_filename_component(THUMB_NAME "${ARGS_DIR_ICON}" NAME) 58 | file(RENAME "${APPDIR}/${THUMB_NAME}" "${APPDIR}/.DirIcon") 59 | 60 | # copy icon highres 61 | file(COPY ${ARGS_ICON} DESTINATION "${APPDIR}") 62 | get_filename_component(ICON_NAME "${ARGS_ICON}" NAME) 63 | get_filename_component(ICON_EXT "${ARGS_ICON}" EXT) 64 | file(RENAME "${APPDIR}/${ICON_NAME}" "${APPDIR}/${ARGS_NAME}${ICON_EXT}") 65 | 66 | # Create the .desktop file 67 | file(WRITE "${APPDIR}/${ARGS_NAME}.desktop" 68 | "[Desktop Entry] 69 | Type=Application 70 | Name=${ARGS_NAME} 71 | Icon=${ARGS_NAME} 72 | Categories=X-None;" 73 | ) 74 | 75 | # Invoke AppImageTool 76 | if(ARGS_CROSSCOMP) 77 | # when cross-compiling, set runtime file 78 | set(AIT_RUNTIME "--runtime-file" CACHE INTERNAL "") 79 | endif() 80 | execute_process(COMMAND ${AIT_PATH} ${APPDIR} ${ARGS_OUTPUT_NAME} ${AIT_RUNTIME} ${AIT_RUNTIME_PATH}) 81 | file(REMOVE_RECURSE "${APPDIR}") 82 | 83 | endfunction() 84 | 85 | -------------------------------------------------------------------------------- /assets/HockeyPaddle.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/assets/HockeyPaddle.blend -------------------------------------------------------------------------------- /assets/HockeyPuck.mb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/assets/HockeyPuck.mb -------------------------------------------------------------------------------- /assets/HockeyTable.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/assets/HockeyTable.blend -------------------------------------------------------------------------------- /assets/SimpleBakeTest.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/assets/SimpleBakeTest.blend -------------------------------------------------------------------------------- /assets/animation_level.mb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/assets/animation_level.mb -------------------------------------------------------------------------------- /assets/baked_light.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/assets/baked_light.blend -------------------------------------------------------------------------------- /assets/character.mb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/assets/character.mb -------------------------------------------------------------------------------- /assets/character_animations.mb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/assets/character_animations.mb -------------------------------------------------------------------------------- /assets/flag.mb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/assets/flag.mb -------------------------------------------------------------------------------- /assets/flagpole.mb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/assets/flagpole.mb -------------------------------------------------------------------------------- /assets/grass.mb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/assets/grass.mb -------------------------------------------------------------------------------- /assets/maze1.mb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/assets/maze1.mb -------------------------------------------------------------------------------- /assets/physics_scene.mb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/assets/physics_scene.mb -------------------------------------------------------------------------------- /assets/piano.mb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/assets/piano.mb -------------------------------------------------------------------------------- /assets/room.mb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/assets/room.mb -------------------------------------------------------------------------------- /assets/simplerig.mb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/assets/simplerig.mb -------------------------------------------------------------------------------- /assets/simplerig2.mb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/assets/simplerig2.mb -------------------------------------------------------------------------------- /assets/simplerig3.mb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/assets/simplerig3.mb -------------------------------------------------------------------------------- /assets/speaker.mb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/assets/speaker.mb -------------------------------------------------------------------------------- /assets/target.mb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/assets/target.mb -------------------------------------------------------------------------------- /assets/theatre.mb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/assets/theatre.mb -------------------------------------------------------------------------------- /assets/theatre_chair.mb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RavEngine/Samples/c80d6c27968e2e5c29f986a62bc57eb8ef9b671f/assets/theatre_chair.mb -------------------------------------------------------------------------------- /config/build-ios.sh: -------------------------------------------------------------------------------- 1 | ./init-ios.sh 2 | cd build/ios; 3 | cmake --build . --config release --target install 4 | 5 | -------------------------------------------------------------------------------- /config/build-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #export CC=/usr/bin/clang; 4 | #export CXX=/usr/bin/clang++; 5 | ./init-linux.sh 6 | cd ../build/linux 7 | cmake --build . --config debug --target install 8 | -------------------------------------------------------------------------------- /config/build-mac.sh: -------------------------------------------------------------------------------- 1 | ./init-mac.sh 2 | cd ../build/mac 3 | cmake --build . --config release --target install 4 | -------------------------------------------------------------------------------- /config/build-win.bat: -------------------------------------------------------------------------------- 1 | @echo OFF 2 | 3 | init-win.bat && cd build\win && cmake --build . --config release --target install 4 | -------------------------------------------------------------------------------- /config/crosscomp-sources.list: -------------------------------------------------------------------------------- 1 | Types: deb 2 | URIs: http://archive.ubuntu.com/ubuntu/ 3 | Suites: noble 4 | Components: main restricted universe 5 | Architectures: amd64 6 | 7 | Types: deb 8 | URIs: http://security.ubuntu.com/ubuntu/ 9 | Suites: noble-security 10 | Components: main restricted universe 11 | Architectures: amd64 12 | 13 | Types: deb 14 | URIs: http://archive.ubuntu.com/ubuntu/ 15 | Suites: noble-updates 16 | Components: main restricted universe 17 | Architectures: amd64 18 | 19 | Types: deb 20 | URIs: http://ports.ubuntu.com/ubuntu-ports/ 21 | Suites: noble 22 | Components: main restricted multiverse universe 23 | Architectures: arm64 24 | 25 | Types: deb 26 | URIs: http://ports.ubuntu.com/ubuntu-ports/ 27 | Suites: noble-updates 28 | Components: main restricted multiverse universe 29 | Architectures: arm64 -------------------------------------------------------------------------------- /config/init-ios.sh: -------------------------------------------------------------------------------- 1 | cd .. 2 | mkdir -p build && mkdir -p build/ios && cd build/ios && cmake -Wno-dev -G "Xcode" -DENABLE_VISIBILITY=ON -DCMAKE_SYSTEM_NAME=iOS ../.. 3 | -------------------------------------------------------------------------------- /config/init-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd .. 3 | mkdir -p build && mkdir -p build/linux && cd build/linux && cmake -G "Ninja" -Wno-dev -DCMAKE_BUILD_TYPE=Debug ../.. 4 | -------------------------------------------------------------------------------- /config/init-linuxarm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd .. 3 | mkdir -p build && mkdir -p build/linuxarm && cd build/linuxarm && CC=/usr/bin/aarch64-linux-gnu-gcc CXX=/usr/bin/aarch64-linux-gnu-g++ cmake -G "Ninja" -Wno-dev -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_PROCESSOR=aarch64 ../.. 4 | -------------------------------------------------------------------------------- /config/init-mac.sh: -------------------------------------------------------------------------------- 1 | cd .. 2 | mkdir -p build && mkdir -p build/mac && cd build/mac && cmake -Wno-dev -G "Xcode" ../.. 3 | -------------------------------------------------------------------------------- /config/init-tvos.sh: -------------------------------------------------------------------------------- 1 | cd .. 2 | mkdir -p build && mkdir -p build/tvos && cd build/tvos && cmake -Wno-dev -G "Xcode" -DCMAKE_SYSTEM_NAME=tvOS ../.. 3 | -------------------------------------------------------------------------------- /config/init-web.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd .. 3 | mkdir -p build && mkdir -p build/web && cd build/web && emcmake cmake ../.. 4 | -------------------------------------------------------------------------------- /config/init-win.bat: -------------------------------------------------------------------------------- 1 | @echo OFF 2 | 3 | cd .. 4 | mkdir build 5 | cd build 6 | mkdir win 7 | cd win 8 | cmake -Wno-dev ..\.. 9 | cd ..\.. 10 | -------------------------------------------------------------------------------- /config/init-winarm.bat: -------------------------------------------------------------------------------- 1 | @echo OFF 2 | 3 | cd .. 4 | mkdir build 5 | cd build 6 | mkdir winarm 7 | cd winarm 8 | cmake -Wno-dev -AARM64 ..\.. 9 | cd ..\.. 10 | --------------------------------------------------------------------------------