diff --git a/README.md b/README.md index eaaeb2cf8..102e29783 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,9 @@ The goal of BabylonCpp is to fully implement the relevant portions of the excellent Babylon.js 3D framework/engine in C++17, facilitating the creation of lightweight, cross-platform 3D games and applications with native performance. -[![BabylonCpp](https://img.youtube.com/vi/HwvctC80qho/0.jpg)](https://www.youtube.com/embed/HwvctC80qho "BabylonCpp") +It includes more than 200 examples, a graphical inspector for all 3D objects (based on [ImGui](https://github.com/ocornut/imgui)), as well as an interactive playground for live coding and experiments. + +[![BabylonCpp](doc/assets/babylon_demo_video.png)](https://youtu.be/McU8_vIEJfQ "BabylonCpp") # Get the Sources diff --git a/assets/screenshots/samples_current/2CylinderEngineGLTFScene.jpg b/assets/screenshots/samples_current/2CylinderEngineGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/2CylinderEngineGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/AlphaBlendModeTestGLTFScene.jpg b/assets/screenshots/samples_current/AlphaBlendModeTestGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/AlphaBlendModeTestGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/AnimatedCubeGLTFScene.jpg b/assets/screenshots/samples_current/AnimatedCubeGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/AnimatedCubeGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/AnimatedMorphCubeGLTFScene.jpg b/assets/screenshots/samples_current/AnimatedMorphCubeGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/AnimatedMorphCubeGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/AnimatedMorphSphereGLTFScene.jpg b/assets/screenshots/samples_current/AnimatedMorphSphereGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/AnimatedMorphSphereGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/AnimatedTriangleGLTFScene.jpg b/assets/screenshots/samples_current/AnimatedTriangleGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/AnimatedTriangleGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/AntiqueCameraGLTFScene.jpg b/assets/screenshots/samples_current/AntiqueCameraGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/AntiqueCameraGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/AvocadoGLTFScene.jpg b/assets/screenshots/samples_current/AvocadoGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/AvocadoGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/BarramundiFishGLTFScene.jpg b/assets/screenshots/samples_current/BarramundiFishGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/BarramundiFishGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/BoomBoxGLTFScene.jpg b/assets/screenshots/samples_current/BoomBoxGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/BoomBoxGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/BoxGLTFScene.jpg b/assets/screenshots/samples_current/BoxGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/BoxGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/BoxInterleavedGLTFScene.jpg b/assets/screenshots/samples_current/BoxInterleavedGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/BoxInterleavedGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/BoxTexturedGLTFScene.jpg b/assets/screenshots/samples_current/BoxTexturedGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/BoxTexturedGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/BoxTexturedNonPowerOfTwoGLTFScene.jpg b/assets/screenshots/samples_current/BoxTexturedNonPowerOfTwoGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/BoxTexturedNonPowerOfTwoGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/BoxVertexColorsGLTFScene.jpg b/assets/screenshots/samples_current/BoxVertexColorsGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/BoxVertexColorsGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/BulbSelfShadowScene.jpg b/assets/screenshots/samples_current/BulbSelfShadowScene.jpg index 6dcde0657..6b4d69080 100644 Binary files a/assets/screenshots/samples_current/BulbSelfShadowScene.jpg and b/assets/screenshots/samples_current/BulbSelfShadowScene.jpg differ diff --git a/assets/screenshots/samples_current/CamerasGLTFScene.jpg b/assets/screenshots/samples_current/CamerasGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/CamerasGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/CellShadingMaterialScene.jpg b/assets/screenshots/samples_current/CellShadingMaterialScene.jpg index 2f3f3f3e9..e5c77cd9a 100644 Binary files a/assets/screenshots/samples_current/CellShadingMaterialScene.jpg and b/assets/screenshots/samples_current/CellShadingMaterialScene.jpg differ diff --git a/assets/screenshots/samples_current/CorsetGLTFScene.jpg b/assets/screenshots/samples_current/CorsetGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/CorsetGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/CubeGLTFScene.jpg b/assets/screenshots/samples_current/CubeGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/CubeGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/CustomRenderTargetsScene.jpg b/assets/screenshots/samples_current/CustomRenderTargetsScene.jpg index 892cb8ce0..5d44ee70a 100644 Binary files a/assets/screenshots/samples_current/CustomRenderTargetsScene.jpg and b/assets/screenshots/samples_current/CustomRenderTargetsScene.jpg differ diff --git a/assets/screenshots/samples_current/DamagedHelmetGLTFScene.jpg b/assets/screenshots/samples_current/DamagedHelmetGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/DamagedHelmetGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/DuckGLTFScene.jpg b/assets/screenshots/samples_current/DuckGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/DuckGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/EnvironmentScene.jpg b/assets/screenshots/samples_current/EnvironmentScene.jpg index 5fa9e6490..b8eb26f67 100644 Binary files a/assets/screenshots/samples_current/EnvironmentScene.jpg and b/assets/screenshots/samples_current/EnvironmentScene.jpg differ diff --git a/assets/screenshots/samples_current/FlightHelmetGLTFScene.jpg b/assets/screenshots/samples_current/FlightHelmetGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/FlightHelmetGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/HighlightLayerScene.jpg b/assets/screenshots/samples_current/HighlightLayerScene.jpg index 0a80985ad..59845f067 100644 Binary files a/assets/screenshots/samples_current/HighlightLayerScene.jpg and b/assets/screenshots/samples_current/HighlightLayerScene.jpg differ diff --git a/assets/screenshots/samples_current/InterpolationTestGLTFScene.jpg b/assets/screenshots/samples_current/InterpolationTestGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/InterpolationTestGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/LanternGLTFScene.jpg b/assets/screenshots/samples_current/LanternGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/LanternGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/PBRMaterialORMWoodScene.jpg b/assets/screenshots/samples_current/PBRMaterialORMWoodScene.jpg index 7ad870d43..aa1715cf3 100644 Binary files a/assets/screenshots/samples_current/PBRMaterialORMWoodScene.jpg and b/assets/screenshots/samples_current/PBRMaterialORMWoodScene.jpg differ diff --git a/assets/screenshots/samples_current/PBRMaterialScene.jpg b/assets/screenshots/samples_current/PBRMaterialScene.jpg index b8036cdb2..48a092004 100644 Binary files a/assets/screenshots/samples_current/PBRMaterialScene.jpg and b/assets/screenshots/samples_current/PBRMaterialScene.jpg differ diff --git a/assets/screenshots/samples_current/PBRMetallicRoughnessGoldMaterialScene.jpg b/assets/screenshots/samples_current/PBRMetallicRoughnessGoldMaterialScene.jpg index d19dea7d3..ed541daa5 100644 Binary files a/assets/screenshots/samples_current/PBRMetallicRoughnessGoldMaterialScene.jpg and b/assets/screenshots/samples_current/PBRMetallicRoughnessGoldMaterialScene.jpg differ diff --git a/assets/screenshots/samples_current/PBRMetallicRoughnessMaterialScene.jpg b/assets/screenshots/samples_current/PBRMetallicRoughnessMaterialScene.jpg index f5eeac4c7..1311b76fc 100644 Binary files a/assets/screenshots/samples_current/PBRMetallicRoughnessMaterialScene.jpg and b/assets/screenshots/samples_current/PBRMetallicRoughnessMaterialScene.jpg differ diff --git a/assets/screenshots/samples_current/PBRMetallicRoughnessTextureMaterialScene.jpg b/assets/screenshots/samples_current/PBRMetallicRoughnessTextureMaterialScene.jpg index 0e7667bb8..904e336c6 100644 Binary files a/assets/screenshots/samples_current/PBRMetallicRoughnessTextureMaterialScene.jpg and b/assets/screenshots/samples_current/PBRMetallicRoughnessTextureMaterialScene.jpg differ diff --git a/assets/screenshots/samples_current/PBRSpecularGlossinessMaterialScene.jpg b/assets/screenshots/samples_current/PBRSpecularGlossinessMaterialScene.jpg index 32b0d8732..39bad73ee 100644 Binary files a/assets/screenshots/samples_current/PBRSpecularGlossinessMaterialScene.jpg and b/assets/screenshots/samples_current/PBRSpecularGlossinessMaterialScene.jpg differ diff --git a/assets/screenshots/samples_current/PBRSpecularGlossinessTextureMaterialScene.jpg b/assets/screenshots/samples_current/PBRSpecularGlossinessTextureMaterialScene.jpg index 640a90387..b0d8c0028 100644 Binary files a/assets/screenshots/samples_current/PBRSpecularGlossinessTextureMaterialScene.jpg and b/assets/screenshots/samples_current/PBRSpecularGlossinessTextureMaterialScene.jpg differ diff --git a/assets/screenshots/samples_current/ReciprocatingSawGLTFScene.jpg b/assets/screenshots/samples_current/ReciprocatingSawGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/ReciprocatingSawGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/SciFiHelmetGLTFScene.jpg b/assets/screenshots/samples_current/SciFiHelmetGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/SciFiHelmetGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/ShaderMaterialPegasusGalaxyScene.jpg b/assets/screenshots/samples_current/ShaderMaterialPegasusGalaxyScene.jpg index 14eafea29..4c789a0a5 100644 Binary files a/assets/screenshots/samples_current/ShaderMaterialPegasusGalaxyScene.jpg and b/assets/screenshots/samples_current/ShaderMaterialPegasusGalaxyScene.jpg differ diff --git a/assets/screenshots/samples_current/ShaderMaterialSeascapeScene.jpg b/assets/screenshots/samples_current/ShaderMaterialSeascapeScene.jpg index 0d146ddb6..dc4e10544 100644 Binary files a/assets/screenshots/samples_current/ShaderMaterialSeascapeScene.jpg and b/assets/screenshots/samples_current/ShaderMaterialSeascapeScene.jpg differ diff --git a/assets/screenshots/samples_current/ShaderMaterialSpeedTracerScene.jpg b/assets/screenshots/samples_current/ShaderMaterialSpeedTracerScene.jpg index e4998fcc2..bc7525059 100644 Binary files a/assets/screenshots/samples_current/ShaderMaterialSpeedTracerScene.jpg and b/assets/screenshots/samples_current/ShaderMaterialSpeedTracerScene.jpg differ diff --git a/assets/screenshots/samples_current/SimpleMaterialGLTFScene.jpg b/assets/screenshots/samples_current/SimpleMaterialGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/SimpleMaterialGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/SimpleMeshesGLTFScene.jpg b/assets/screenshots/samples_current/SimpleMeshesGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/SimpleMeshesGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/SimpleMorphGLTFScene.jpg b/assets/screenshots/samples_current/SimpleMorphGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/SimpleMorphGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/SimpleSkinGLTFScene.jpg b/assets/screenshots/samples_current/SimpleSkinGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/SimpleSkinGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/SimpleTextureGLTFScene.jpg b/assets/screenshots/samples_current/SimpleTextureGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/SimpleTextureGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/StarfieldProceduralTextureScene.jpg b/assets/screenshots/samples_current/StarfieldProceduralTextureScene.jpg index 47376294f..89a692c21 100644 Binary files a/assets/screenshots/samples_current/StarfieldProceduralTextureScene.jpg and b/assets/screenshots/samples_current/StarfieldProceduralTextureScene.jpg differ diff --git a/assets/screenshots/samples_current/SuzanneGLTFScene.jpg b/assets/screenshots/samples_current/SuzanneGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/SuzanneGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/TriangleGLTFScene.jpg b/assets/screenshots/samples_current/TriangleGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/TriangleGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/TriangleWithoutIndicesGLTFScene.jpg b/assets/screenshots/samples_current/TriangleWithoutIndicesGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/TriangleWithoutIndicesGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/TwoSidedPlaneGLTFScene.jpg b/assets/screenshots/samples_current/TwoSidedPlaneGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/TwoSidedPlaneGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/WaterBottleGLTFScene.jpg b/assets/screenshots/samples_current/WaterBottleGLTFScene.jpg new file mode 100644 index 000000000..90ffbc65f Binary files /dev/null and b/assets/screenshots/samples_current/WaterBottleGLTFScene.jpg differ diff --git a/assets/screenshots/samples_current/WaterMaterialScene.jpg b/assets/screenshots/samples_current/WaterMaterialScene.jpg index 70c69df46..fe5954886 100644 Binary files a/assets/screenshots/samples_current/WaterMaterialScene.jpg and b/assets/screenshots/samples_current/WaterMaterialScene.jpg differ diff --git a/assets/screenshots/samples_updated/BuildingInstancesGridScene.jpg b/assets/screenshots/samples_updated/BuildingInstancesGridScene.jpg new file mode 100644 index 000000000..6a1ba8441 Binary files /dev/null and b/assets/screenshots/samples_updated/BuildingInstancesGridScene.jpg differ diff --git a/assets/screenshots/samples_updated/BuildingsSPSScene.jpg b/assets/screenshots/samples_updated/BuildingsSPSScene.jpg new file mode 100644 index 000000000..bd8577299 Binary files /dev/null and b/assets/screenshots/samples_updated/BuildingsSPSScene.jpg differ diff --git a/assets/screenshots/samples_updated/CubeChaosScene.jpg b/assets/screenshots/samples_updated/CubeChaosScene.jpg new file mode 100644 index 000000000..844e4e263 Binary files /dev/null and b/assets/screenshots/samples_updated/CubeChaosScene.jpg differ diff --git a/assets/screenshots/samples_updated/DawnBringerScene.jpg b/assets/screenshots/samples_updated/DawnBringerScene.jpg new file mode 100644 index 000000000..d7926fc4f Binary files /dev/null and b/assets/screenshots/samples_updated/DawnBringerScene.jpg differ diff --git a/assets/screenshots/samples_updated/FireProceduralTextureScene.jpg b/assets/screenshots/samples_updated/FireProceduralTextureScene.jpg new file mode 100644 index 000000000..10a53cdcf Binary files /dev/null and b/assets/screenshots/samples_updated/FireProceduralTextureScene.jpg differ diff --git a/assets/screenshots/samples_updated/LavaMaterialScene.jpg b/assets/screenshots/samples_updated/LavaMaterialScene.jpg new file mode 100644 index 000000000..708bb70b0 Binary files /dev/null and b/assets/screenshots/samples_updated/LavaMaterialScene.jpg differ diff --git a/assets/screenshots/samples_updated/LookAtScene.jpg b/assets/screenshots/samples_updated/LookAtScene.jpg new file mode 100644 index 000000000..37645d30b Binary files /dev/null and b/assets/screenshots/samples_updated/LookAtScene.jpg differ diff --git a/assets/screenshots/samples_updated/ShaderMaterialGeneratorsScene.jpg b/assets/screenshots/samples_updated/ShaderMaterialGeneratorsScene.jpg new file mode 100644 index 000000000..6cecf8caa Binary files /dev/null and b/assets/screenshots/samples_updated/ShaderMaterialGeneratorsScene.jpg differ diff --git a/assets/screenshots/samples_updated/ShaderMaterialMorningCityScene.jpg b/assets/screenshots/samples_updated/ShaderMaterialMorningCityScene.jpg new file mode 100644 index 000000000..09a06572d Binary files /dev/null and b/assets/screenshots/samples_updated/ShaderMaterialMorningCityScene.jpg differ diff --git a/assets/screenshots/samples_updated/ShaderMaterialServerRoomScene.jpg b/assets/screenshots/samples_updated/ShaderMaterialServerRoomScene.jpg new file mode 100644 index 000000000..d110345db Binary files /dev/null and b/assets/screenshots/samples_updated/ShaderMaterialServerRoomScene.jpg differ diff --git a/assets/screenshots/samples_updated/ShaderMaterialSparseGridMarchingScene.jpg b/assets/screenshots/samples_updated/ShaderMaterialSparseGridMarchingScene.jpg new file mode 100644 index 000000000..5d1b79f7d Binary files /dev/null and b/assets/screenshots/samples_updated/ShaderMaterialSparseGridMarchingScene.jpg differ diff --git a/assets/screenshots/samples_updated/TrianglesSPSScene.jpg b/assets/screenshots/samples_updated/TrianglesSPSScene.jpg new file mode 100644 index 000000000..9acba0d5e Binary files /dev/null and b/assets/screenshots/samples_updated/TrianglesSPSScene.jpg differ diff --git a/assets/screenshots/scripts/compare_screenshots.py b/assets/screenshots/scripts/compare_screenshots.py new file mode 100644 index 000000000..51bb24b40 --- /dev/null +++ b/assets/screenshots/scripts/compare_screenshots.py @@ -0,0 +1,62 @@ +# pip install --upgrade scikit-image +# pip install --upgrade imutils + +from skimage.measure import compare_ssim +import argparse +import imutils +import cv2 +import os +import os.path +import numpy as np +import shutil + +THIS_SCRIPT_DIR=os.path.dirname(os.path.abspath(__file__)) + +def compare_image(image_file1, image_file2) -> (float, np.array): + imageA = cv2.imread(image_file1) + imageB = cv2.imread(image_file2) + grayA = cv2.cvtColor(imageA, cv2.COLOR_BGR2GRAY) + grayB = cv2.cvtColor(imageB, cv2.COLOR_BGR2GRAY) + + # compute the Structural Similarity Index (SSIM) between the two + # images, ensuring that the difference image is returned + (score, diff) = compare_ssim(grayA, grayB, full=True) + diff = (diff * 255).astype("uint8") + return score, diff + +def list_images(folder): + r = [] + for root, dirs, files in os.walk(folder, topdown=False): + for file_name in files: + if file_name[-4:] == ".jpg": + r.append(file_name) + return r + +CURRENT_IMAGES_FOLDER = THIS_SCRIPT_DIR + "/../samples_current/" +NEW_IMAGES_FOLDER = THIS_SCRIPT_DIR + "/../samples_new" +UPDATE_IMAGES_FOLDER = THIS_SCRIPT_DIR + "/../samples_updated" + +def do_compare(): + current_images_files = list_images(CURRENT_IMAGES_FOLDER) + new_images_files = list_images(NEW_IMAGES_FOLDER) + if (os.path.isdir(UPDATE_IMAGES_FOLDER)): + shutil.rmtree(UPDATE_IMAGES_FOLDER) + os.mkdir(UPDATE_IMAGES_FOLDER) + + for image_file in new_images_files: + new_image_fullpath = NEW_IMAGES_FOLDER + "/" + image_file + shall_update = False + if image_file in current_images_files: + current_image_fullpath = CURRENT_IMAGES_FOLDER + "/" + image_file + score, diff = compare_image(current_image_fullpath, new_image_fullpath) + print("{} : score {}".format(new_image_fullpath, score)) + if score < 0.7: + shall_update = True + else: + print("{} : NEW".format(new_image_fullpath)) + shall_update = True + + if shall_update: + shutil.copyfile(new_image_fullpath, UPDATE_IMAGES_FOLDER + "/" + image_file) + +do_compare() diff --git a/doc/assets/babylon_demo_video.png b/doc/assets/babylon_demo_video.png new file mode 100644 index 000000000..ad51e174f Binary files /dev/null and b/doc/assets/babylon_demo_video.png differ diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 868898b39..8bada3dde 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -98,11 +98,11 @@ endif() # RuntimeCompiledCPlusPlus if (NOT APPLE) - option(BABYLON_BUILD_SANDBOX "Build the interactive sandbox (modify and run the sandbox code interactively without exiting)" ON) + option(BABYLON_BUILD_PLAYGROUND "Build the interactive playground (modify and run the playground code interactively without exiting)" ON) else() - option(BABYLON_BUILD_SANDBOX "Build the interactive sandbox (modify and run the sandbox code interactively without exiting)" OFF) + option(BABYLON_BUILD_PLAYGROUND "Build the interactive playground (modify and run the playground code interactively without exiting)" OFF) endif() -if (BABYLON_BUILD_SANDBOX) +if (BABYLON_BUILD_PLAYGROUND) set (RuntimeCompiledCPlusPlus_Dir ${CMAKE_CURRENT_SOURCE_DIR}/RuntimeCompiledCPlusPlus/Aurora) SET(BUILD_EXAMPLES OFF CACHE BOOL "Build RuntimeCompiledCPlusPlus examples" FORCE) add_subdirectory(${RuntimeCompiledCPlusPlus_Dir}) diff --git a/external/RuntimeCompiledCPlusPlus b/external/RuntimeCompiledCPlusPlus index 461ea33d7..deedab496 160000 --- a/external/RuntimeCompiledCPlusPlus +++ b/external/RuntimeCompiledCPlusPlus @@ -1 +1 @@ -Subproject commit 461ea33d7fed05d46484695fea1e471a37014e51 +Subproject commit deedab496dc53371ee207e58f43f95a741e3fc52 diff --git a/src/BabylonImGui/CMakeLists.txt b/src/BabylonImGui/CMakeLists.txt index 3c1775e21..2bf44be00 100644 --- a/src/BabylonImGui/CMakeLists.txt +++ b/src/BabylonImGui/CMakeLists.txt @@ -159,8 +159,8 @@ target_compile_definitions(${TARGET} $<$>:${TARGET_UPPER}_STATIC_DEFINE> ) -if (BABYLON_BUILD_SANDBOX) - target_compile_definitions(${TARGET} PRIVATE -DBABYLON_BUILD_SANDBOX) +if (BABYLON_BUILD_PLAYGROUND) + target_compile_definitions(${TARGET} PRIVATE -DBABYLON_BUILD_PLAYGROUND) endif() # Compile options diff --git a/src/BabylonImGui/include/babylon/babylon_imgui/run_scene_with_inspector.h b/src/BabylonImGui/include/babylon/babylon_imgui/run_scene_with_inspector.h index bb1df8a51..7a20ef98d 100644 --- a/src/BabylonImGui/include/babylon/babylon_imgui/run_scene_with_inspector.h +++ b/src/BabylonImGui/include/babylon/babylon_imgui/run_scene_with_inspector.h @@ -10,7 +10,7 @@ namespace BABYLON { - struct SandboxCompilerStatus + struct PlaygroundCompilerStatus { std::shared_ptr _renderableScene = nullptr; bool _isCompiling = false; @@ -30,9 +30,9 @@ namespace BABYLON { using HeartbeatCallback = std::function; std::vector _heartbeatCallbacks; - // this callback is used by the sandbox compiler - using SandboxCompilerCallback = std::function; - SandboxCompilerCallback _sandboxCompilerCallback; + // this callback is used by the playground compiler + using PlaygroundCompilerCallback = std::function; + PlaygroundCompilerCallback _playgroundCompilerCallback; }; void runSceneWithInspector( diff --git a/src/BabylonImGui/src/babylon_imgui/run_scene_with_inspector.cpp b/src/BabylonImGui/src/babylon_imgui/run_scene_with_inspector.cpp index 87fae6bdd..da9f617cb 100644 --- a/src/BabylonImGui/src/babylon_imgui/run_scene_with_inspector.cpp +++ b/src/BabylonImGui/src/babylon_imgui/run_scene_with_inspector.cpp @@ -61,9 +61,9 @@ class BabylonInspectorApp { BabylonInspectorApp() { std::string exePath = BABYLON::System::getExecutablePath(); std::string exeFolder = BABYLON::Filesystem::baseDir(exePath); - std::string sandboxPath = exeFolder + "/../../../src/SamplesRunner/sandbox.cpp"; - sandboxPath = BABYLON::Filesystem::absolutePath(sandboxPath); - _sandboxCodeEditor.setFiles({ sandboxPath }); + std::string playgroundPath = exeFolder + "/../../../src/SamplesRunner/playground.cpp"; + playgroundPath = BABYLON::Filesystem::absolutePath(playgroundPath); + _playgroundCodeEditor.setFiles({ playgroundPath }); } void RunApp( std::shared_ptr initialScene, @@ -76,12 +76,12 @@ class BabylonInspectorApp { bool r = this->render(); for (auto f : _appContext._options._heartbeatCallbacks) f(); - if (_appContext._options._sandboxCompilerCallback) + if (_appContext._options._playgroundCompilerCallback) { - SandboxCompilerStatus sandboxCompilerStatus = _appContext._options._sandboxCompilerCallback(); - if (sandboxCompilerStatus._renderableScene) - setRenderableScene(sandboxCompilerStatus._renderableScene); - _appContext._isCompiling = sandboxCompilerStatus._isCompiling; + PlaygroundCompilerStatus playgroundCompilerStatus = _appContext._options._playgroundCompilerCallback(); + if (playgroundCompilerStatus._renderableScene) + setRenderableScene(playgroundCompilerStatus._renderableScene); + _appContext._isCompiling = playgroundCompilerStatus._isCompiling; } return r; @@ -100,8 +100,8 @@ class BabylonInspectorApp { Scene3d, SamplesCodeViewer, SampleBrowser, -#ifdef BABYLON_BUILD_SANDBOX - SandboxEditor, +#ifdef BABYLON_BUILD_PLAYGROUND + PlaygroundEditor, #endif }; static std::map ViewStateLabels; @@ -166,7 +166,7 @@ class BabylonInspectorApp { ImGui::BeginGroup(); ShowTabBarEnum(ViewStateLabels, &_appContext._viewState); - ImGui::SameLine(0.f, 80.f); + ImGui::SameLine(0., ImGui::GetContentRegionAvailWidth() - 100.f); BABYLON::BabylonLogsWindow::instance().render(); ImGui::SameLine(); if (ImGui::Button(ICON_FA_DOOR_OPEN " Exit")) @@ -183,9 +183,9 @@ class BabylonInspectorApp { _samplesCodeEditor.render(); else if (_appContext._viewState == ViewState::SampleBrowser) _appContext._sampleListComponent.render(); -#ifdef BABYLON_BUILD_SANDBOX - if (_appContext._viewState == ViewState::SandboxEditor) - renderSandbox(); +#ifdef BABYLON_BUILD_PLAYGROUND + if (_appContext._viewState == ViewState::PlaygroundEditor) + renderPlayground(); #endif ImGui::EndGroup(); @@ -265,9 +265,9 @@ class BabylonInspectorApp { void render3d() { -#ifdef BABYLON_BUILD_SANDBOX - bool isInSandboxMode = (_appContext._viewState == ViewState::SandboxEditor); - ImVec2 sceneSize = isInSandboxMode ? getSceneSizeSmall() : getSceneSize(); +#ifdef BABYLON_BUILD_PLAYGROUND + bool isInPlaygroundMode = (_appContext._viewState == ViewState::PlaygroundEditor); + ImVec2 sceneSize = isInPlaygroundMode ? getSceneSizeSmall() : getSceneSize(); #else ImVec2 sceneSize = getSceneSize(); #endif @@ -276,10 +276,10 @@ class BabylonInspectorApp { renderHud(cursorPosBeforeScene3d, sceneSize); } - void renderSandbox() + void renderPlayground() { ImGui::BeginGroup(); - ImGui::Text("Sandbox : you can edit the code below!"); + ImGui::Text("Playground : you can edit the code below!"); ImGui::Text("As soon as you save it, the code will be compiled and the 3D scene will be updated"); render3d(); ImGui::EndGroup(); @@ -289,9 +289,9 @@ class BabylonInspectorApp { BabylonLogsWindow::instance().setVisible(true); } if (ImGui::Button(ICON_FA_PLAY " Run")) - _sandboxCodeEditor.saveAll(); + _playgroundCodeEditor.saveAll(); - _sandboxCodeEditor.render(); + _playgroundCodeEditor.render(); } @@ -345,7 +345,7 @@ class BabylonInspectorApp { AppContext _appContext; ImGuiUtils::CodeEditor _samplesCodeEditor = ImGuiUtils::CodeEditor(true); // true <-> showCheckboxReadOnly - ImGuiUtils::CodeEditor _sandboxCodeEditor; + ImGuiUtils::CodeEditor _playgroundCodeEditor; }; // end of class BabylonInspectorApp @@ -353,8 +353,8 @@ std::map BabylonInspectorApp::ViewS { BabylonInspectorApp::ViewState::Scene3d, ICON_FA_CUBE " 3D Scene"}, { BabylonInspectorApp::ViewState::SampleBrowser, ICON_FA_PALETTE " Browse samples"}, { BabylonInspectorApp::ViewState::SamplesCodeViewer, ICON_FA_EDIT " Samples Code Viewer"}, -#ifdef BABYLON_BUILD_SANDBOX -{ BabylonInspectorApp::ViewState::SandboxEditor, ICON_FA_FLASK " Sandbox"}, +#ifdef BABYLON_BUILD_PLAYGROUND +{ BabylonInspectorApp::ViewState::PlaygroundEditor, ICON_FA_FLASK " Playground"}, #endif }; diff --git a/src/BabylonImGui/src/inspector/samples_browser.cpp b/src/BabylonImGui/src/inspector/samples_browser.cpp index c9ad54333..f095624f2 100644 --- a/src/BabylonImGui/src/inspector/samples_browser.cpp +++ b/src/BabylonImGui/src/inspector/samples_browser.cpp @@ -85,41 +85,46 @@ class SamplesBrowserImpl void render_filter() { bool changed = false; - ImGui::Text("Filter"); - if (ImGui::InputText_String("", _query.query)) + ImGui::PushItemWidth(200); + if (ImGui::InputText_String("Filter", _query.query)) changed = true; - if (ImGui::Checkbox("Include failing", &_query.includeFailures)) - changed = true; - ImGui::SameLine(); - if (ImGui::Checkbox("Only failing", &_query.onlyFailures)) - changed = true; - - if (changed) - fillMatchingSamples(); - ImGui::Text("Matching samples : %zi", nbMatchingSamples()); - - if (OnLoopSamples) - { - ImGui::SameLine(ImGui::GetContentRegionAvailWidth() - 150.f); - if (ImGui::Button("Loop filtered samples")) - { + if (OnLoopSamples) { + ImGui::SameLine(0.f, 50.f); + if (ImGui::Button("Loop filtered samples")) { std::vector filteredSamples; - for (const auto & kv : _matchingSamples) - { + for (const auto& kv : _matchingSamples) { for (auto sampleName : kv.second) filteredSamples.push_back(sampleName); } OnLoopSamples(filteredSamples); } } + + float rightMargin = 150.f; + if (_query.includeFailures) + rightMargin = 300.f; + ImGui::SameLine(ImGui::GetContentRegionAvailWidth() - rightMargin); + if (ImGui::Checkbox("Include failing", &_query.includeFailures)) + changed = true; + if (_query.includeFailures) + { + ImGui::SameLine(); + if (ImGui::Checkbox("Only failing", &_query.onlyFailures)) + changed = true; + } + + if (changed) + fillMatchingSamples(); + + ImGui::Text("Matching samples : %zi", nbMatchingSamples()); } void render_list() { - ImGui::Checkbox("Show original screenshots", &_showOriginalScreenshots); - ImGui::SameLine(); - ImGui::Checkbox("Show current screenshots", &_showCurrentScreenshots); + //ImGui::Checkbox("Show original screenshots", &_showOriginalScreenshots); + //ImGui::SameLine(); + //ImGui::Checkbox("Show screenshots", &_showCurrentScreenshots); enum class CollapseMode { diff --git a/src/SamplesRunner/CMakeLists.txt b/src/SamplesRunner/CMakeLists.txt index fca6d019f..f067561cb 100644 --- a/src/SamplesRunner/CMakeLists.txt +++ b/src/SamplesRunner/CMakeLists.txt @@ -65,8 +65,8 @@ target_link_libraries(${TARGET} Samples ) -if (BABYLON_BUILD_SANDBOX) - target_compile_definitions(${TARGET} PRIVATE -DBABYLON_BUILD_SANDBOX) +if (BABYLON_BUILD_PLAYGROUND) + target_compile_definitions(${TARGET} PRIVATE -DBABYLON_BUILD_PLAYGROUND) target_link_libraries(${TARGET} PRIVATE RuntimeCompiler RuntimeObjectSystem) endif() diff --git a/src/SamplesRunner/main.cpp b/src/SamplesRunner/main.cpp index 77ae93cdf..1d5ae3808 100644 --- a/src/SamplesRunner/main.cpp +++ b/src/SamplesRunner/main.cpp @@ -8,13 +8,13 @@ #include "spawn_screenshots.h" #include "run_standalone_imgui.h" -#ifdef BABYLON_BUILD_SANDBOX +#ifdef BABYLON_BUILD_PLAYGROUND #include #endif int main(int argc, char** argv) { -#ifdef BABYLON_BUILD_SANDBOX +#ifdef BABYLON_BUILD_PLAYGROUND BABYLON::rtc::RtcManager runtimeCompiler; runtimeCompiler.Init(); #endif @@ -68,8 +68,8 @@ int main(int argc, char** argv) options._sceneName = sampleName; options._appWindowParams.FullScreen = flagFullscreen; -#ifdef BABYLON_BUILD_SANDBOX - options._sandboxCompilerCallback = [&runtimeCompiler]() { +#ifdef BABYLON_BUILD_PLAYGROUND + options._playgroundCompilerCallback = [&runtimeCompiler]() { auto compilerStatus = runtimeCompiler.Heartbeat(); return compilerStatus; }; diff --git a/src/SamplesRunner/sandbox.cpp b/src/SamplesRunner/playground.cpp similarity index 86% rename from src/SamplesRunner/sandbox.cpp rename to src/SamplesRunner/playground.cpp index 1b146016f..2b651a39f 100644 --- a/src/SamplesRunner/sandbox.cpp +++ b/src/SamplesRunner/playground.cpp @@ -1,12 +1,10 @@ -#ifdef BABYLON_BUILD_SANDBOX - -// This is the sandbox : you can here enter / modify code during -// the execution, and the scene will be updated automatically! -// You do not need to exit the application! -// -// Do not remove the includes below, -// it is needed to enable "Runtime Compilation" -#include "SamplesRunner/rtc/sandbox_autocompile.h" +#ifdef BABYLON_BUILD_PLAYGROUND + +// This is the playground : you can here enter / modify code during the execution, +// and the scene will be updated automatically! + +// Do not remove the includes below, they are needed to enable Runtime Compilation. +#include "SamplesRunner/rtc/playground_autocompile.h" #include #include "imgui.h" @@ -19,10 +17,10 @@ using namespace BABYLON; -struct SandboxScene : public IRenderableSceneWithHud { +struct PlaygroundScene : public IRenderableSceneWithHud { - SandboxScene(ICanvas* iCanvas = nullptr) : IRenderableSceneWithHud(iCanvas) {} - ~SandboxScene() override = default; + PlaygroundScene(ICanvas* iCanvas = nullptr) : IRenderableSceneWithHud(iCanvas) {} + ~PlaygroundScene() override = default; const char* getName() override { return "Materials Scene"; } void initializeScene(ICanvas* canvas, Scene* scene) override @@ -39,7 +37,7 @@ struct SandboxScene : public IRenderableSceneWithHud { // Creation of 6 spheres auto sphere1 = Mesh::CreateSphere("Sphere1", 10u, 9.f, scene); auto sphere2 = Mesh::CreateSphere("Sphere2", 2u, 9.f, scene); - auto sphere3 = Mesh::CreateSphere("Sphere3", 10u, 9.f, scene); + auto sphere3 = Mesh::CreateSphere("Sphere3", 10u, 18.f, scene); auto sphere4 = Mesh::CreateSphere("Sphere4", 10u, 9.f, scene); auto sphere5 = Mesh::CreateSphere("Sphere5", 10u, 9.f, scene); auto sphere6 = Mesh::CreateSphere("Sphere6", 10u, 9.f, scene); @@ -128,11 +126,11 @@ struct SandboxScene : public IRenderableSceneWithHud { //////////////////////////////////////////// // Do not edit below, these lines enable the Runtime Compilation -REGISTERCLASS(Sandbox) -std::shared_ptr Sandbox::MakeScene() { - return std::make_shared(); +REGISTERCLASS(Playground) +std::shared_ptr Playground::MakeScene() { + return std::make_shared(); } -#endif // #ifdef BABYLON_BUILD_SANDBOX +#endif // #ifdef BABYLON_BUILD_PLAYGROUND diff --git a/src/SamplesRunner/rtc/Readme.md b/src/SamplesRunner/rtc/Readme.md index 2109690e8..a5a466d7c 100644 --- a/src/SamplesRunner/rtc/Readme.md +++ b/src/SamplesRunner/rtc/Readme.md @@ -1,3 +1,3 @@ # rtc : Runtime compilation -These files enable the hot compilation and reload of the sandbox. +These files enable the hot compilation and reload of the playground. diff --git a/src/SamplesRunner/rtc/log_system.cpp b/src/SamplesRunner/rtc/log_system.cpp index 3586c00a5..47dd2c234 100644 --- a/src/SamplesRunner/rtc/log_system.cpp +++ b/src/SamplesRunner/rtc/log_system.cpp @@ -1,4 +1,4 @@ -#ifdef BABYLON_BUILD_SANDBOX +#ifdef BABYLON_BUILD_PLAYGROUND #include #include @@ -62,4 +62,4 @@ void LogSystem::LogInternal(MsgType msgType, const char * format, va_list args) } // namespace BABYLON } // namespace rtc -#endif // BABYLON_BUILD_SANDBOX \ No newline at end of file +#endif // BABYLON_BUILD_PLAYGROUND \ No newline at end of file diff --git a/src/SamplesRunner/rtc/sandbox_autocompile.h b/src/SamplesRunner/rtc/playground_autocompile.h similarity index 75% rename from src/SamplesRunner/rtc/sandbox_autocompile.h rename to src/SamplesRunner/rtc/playground_autocompile.h index 3c78c4eff..089bbede8 100644 --- a/src/SamplesRunner/rtc/sandbox_autocompile.h +++ b/src/SamplesRunner/rtc/playground_autocompile.h @@ -4,7 +4,7 @@ #include #include -class Sandbox : public TInterface +class Playground : public TInterface { public: std::shared_ptr MakeScene() override; diff --git a/src/SamplesRunner/rtc/rtc_manager.cpp b/src/SamplesRunner/rtc/rtc_manager.cpp index d0b6bfc80..6410369ab 100644 --- a/src/SamplesRunner/rtc/rtc_manager.cpp +++ b/src/SamplesRunner/rtc/rtc_manager.cpp @@ -1,4 +1,4 @@ -#ifdef BABYLON_BUILD_SANDBOX +#ifdef BABYLON_BUILD_PLAYGROUND // Adapted from RuntimeCompiledCPlusPlus/Aurora/Examples/ConsoleExample/ConsoleGame.cpp #include @@ -81,7 +81,7 @@ bool RtcManager::Init() SetLibraryPath(); // construct first object - IObjectConstructor* pCtor = _runtimeObjectSystem->GetObjectFactorySystem()->GetConstructor( "Sandbox" ); + IObjectConstructor* pCtor = _runtimeObjectSystem->GetObjectFactorySystem()->GetConstructor( "Playground" ); if( pCtor ) { IObject* pObj = pCtor->Construct(); @@ -102,9 +102,24 @@ bool RtcManager::Init() void RtcManager::SetCompileOptions() { #ifdef _MSC_VER - _runtimeObjectSystem->SetAdditionalCompileOptions("/std:c++17 /DBABYLON_BUILD_SANDBOX"); + _runtimeObjectSystem->SetAdditionalCompileOptions( + " /std:c++17" + " /DBABYLON_BUILD_PLAYGROUND" + #ifdef NDEBUG + " /DNDEBUG" + " /MD" + #else + " /MDd" + #endif + ); #else - _runtimeObjectSystem->SetAdditionalCompileOptions("-std=c++17 -DBABYLON_BUILD_SANDBOX"); + _runtimeObjectSystem->SetAdditionalCompileOptions( + " -std=c++17" + " -DBABYLON_BUILD_PLAYGROUND" + #ifdef NDEBUG + " -DNDEBUG" + #endif + ); #endif // _MSC_VER } @@ -160,7 +175,7 @@ void RtcManager::OnConstructorsAdded() } } -BABYLON::SandboxCompilerStatus RtcManager::Heartbeat() +BABYLON::PlaygroundCompilerStatus RtcManager::Heartbeat() { //check status of any compile if( _runtimeObjectSystem->GetIsCompiledComplete() ) @@ -171,7 +186,7 @@ BABYLON::SandboxCompilerStatus RtcManager::Heartbeat() if(_runtimeObjectSystem->GetIsCompiling() ) { - BABYLON::SandboxCompilerStatus r; + BABYLON::PlaygroundCompilerStatus r; r._isCompiling = true; return r; } @@ -184,15 +199,15 @@ BABYLON::SandboxCompilerStatus RtcManager::Heartbeat() if (_lastCompiledScene) { - BABYLON::SandboxCompilerStatus r; + BABYLON::PlaygroundCompilerStatus r; r._renderableScene = _lastCompiledScene; _lastCompiledScene.reset(); return r; } - return BABYLON::SandboxCompilerStatus(); + return BABYLON::PlaygroundCompilerStatus(); } } // namespace BABYLON } // namespace rtc -#endif // BABYLON_BUILD_SANDBOX +#endif // BABYLON_BUILD_PLAYGROUND diff --git a/src/SamplesRunner/rtc/rtc_manager.h b/src/SamplesRunner/rtc/rtc_manager.h index 2aab47554..4c5bf8a1e 100644 --- a/src/SamplesRunner/rtc/rtc_manager.h +++ b/src/SamplesRunner/rtc/rtc_manager.h @@ -22,7 +22,7 @@ class RtcManager : public IObjectFactoryListener virtual ~RtcManager(); bool Init(); - BABYLON::SandboxCompilerStatus Heartbeat(); + BABYLON::PlaygroundCompilerStatus Heartbeat(); // IObjectFactoryListener virtual void OnConstructorsAdded(); diff --git a/src/imgui_utils/code_editor.cpp b/src/imgui_utils/code_editor.cpp index a648ad4bf..aca662a6a 100644 --- a/src/imgui_utils/code_editor.cpp +++ b/src/imgui_utils/code_editor.cpp @@ -32,6 +32,7 @@ class OneCodeEditor { auto lang = TextEditor::LanguageDefinition::CPlusPlus(); _textEditor.SetLanguageDefinition(lang); + _textEditor.SetPalette(TextEditor::GetLightPalette()); readFile(); } @@ -76,8 +77,16 @@ class OneCodeEditor void save() { - BABYLON::Filesystem::writeFileContents(_filePath.c_str(), _textEditor.GetText()); - _fileContent_Saved = _textEditor.GetText(); + std::string text = _textEditor.GetText(); + // The code editor may add an unwanted additional + // empty line at the end of the text + if (!text.empty()) + { + if (text[text.size() - 1] == '\n') + text = text.substr(0, text.size() - 1); + } + BABYLON::Filesystem::writeFileContents(_filePath.c_str(), text); + _fileContent_Saved = text; } private: