Initial commit
This commit is contained in:
101
Bootstrap.cpp
Normal file
101
Bootstrap.cpp
Normal file
@@ -0,0 +1,101 @@
|
||||
// This file is part of the OGRE project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at https://www.ogre3d.org/licensing.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include "Ogre.h"
|
||||
#include "OgreApplicationContext.h"
|
||||
|
||||
class App
|
||||
: public OgreBites::ApplicationContext
|
||||
{
|
||||
public:
|
||||
App();
|
||||
virtual ~App();
|
||||
|
||||
void setup();
|
||||
void locateResources();
|
||||
};
|
||||
|
||||
App::App()
|
||||
: OgreBites::ApplicationContext("App")
|
||||
{
|
||||
}
|
||||
void App::setup()
|
||||
{
|
||||
OgreBites::ApplicationContext::setup();
|
||||
}
|
||||
void App::locateResources()
|
||||
{
|
||||
OgreBites::ApplicationContext::locateResources();
|
||||
}
|
||||
App::~App()
|
||||
{
|
||||
}
|
||||
//! [key_handler]
|
||||
class KeyHandler : public OgreBites::InputListener
|
||||
{
|
||||
bool keyPressed(const OgreBites::KeyboardEvent& evt) override
|
||||
{
|
||||
if (evt.keysym.sym == OgreBites::SDLK_ESCAPE)
|
||||
{
|
||||
Ogre::Root::getSingleton().queueEndRendering();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
//! [key_handler]
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
//! [constructor]
|
||||
OgreBites::ApplicationContext ctx("OgreTutorialApp");
|
||||
ctx.initApp();
|
||||
//! [constructor]
|
||||
|
||||
//! [setup]
|
||||
// get a pointer to the already created root
|
||||
Ogre::Root* root = ctx.getRoot();
|
||||
Ogre::SceneManager* scnMgr = root->createSceneManager();
|
||||
|
||||
// register our scene with the RTSS
|
||||
Ogre::RTShader::ShaderGenerator* shadergen = Ogre::RTShader::ShaderGenerator::getSingletonPtr();
|
||||
shadergen->addSceneManager(scnMgr);
|
||||
|
||||
// without light we would just get a black screen
|
||||
Ogre::Light* light = scnMgr->createLight("MainLight");
|
||||
Ogre::SceneNode* lightNode = scnMgr->getRootSceneNode()->createChildSceneNode();
|
||||
lightNode->setPosition(0, 10, 15);
|
||||
lightNode->attachObject(light);
|
||||
|
||||
// also need to tell where we are
|
||||
Ogre::SceneNode* camNode = scnMgr->getRootSceneNode()->createChildSceneNode();
|
||||
camNode->setPosition(0, 0, 15);
|
||||
camNode->lookAt(Ogre::Vector3(0, 0, -1), Ogre::Node::TS_PARENT);
|
||||
|
||||
// create the camera
|
||||
Ogre::Camera* cam = scnMgr->createCamera("myCam");
|
||||
cam->setNearClipDistance(5); // specific to this sample
|
||||
cam->setAutoAspectRatio(true);
|
||||
camNode->attachObject(cam);
|
||||
|
||||
// and tell it to render into the main window
|
||||
ctx.getRenderWindow()->addViewport(cam);
|
||||
|
||||
// finally something to render
|
||||
// Ogre::Entity* ent = scnMgr->createEntity("Sinbad.mesh");
|
||||
Ogre::Entity* ent = scnMgr->createEntity("normal-male.glb");
|
||||
Ogre::SceneNode* node = scnMgr->getRootSceneNode()->createChildSceneNode();
|
||||
node->attachObject(ent);
|
||||
//! [setup]
|
||||
|
||||
//! [main]
|
||||
// register for input events
|
||||
KeyHandler keyHandler;
|
||||
ctx.addInputListener(&keyHandler);
|
||||
|
||||
ctx.getRoot()->startRendering();
|
||||
ctx.closeApp();
|
||||
//! [main]
|
||||
return 0;
|
||||
}
|
||||
73
CMakeLists.txt
Normal file
73
CMakeLists.txt
Normal file
@@ -0,0 +1,73 @@
|
||||
project(world2)
|
||||
cmake_minimum_required(VERSION 3.13.0)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(BLENDER /home/slapin/blender-3.6.20-linux-x64/blender)
|
||||
set(CREATE_DIRECTORIES
|
||||
${CMAKE_SOURCE_DIR}/assets/blender/shapes/male
|
||||
${CMAKE_SOURCE_DIR}/assets/blender/shapes/female
|
||||
${CMAKE_SOURCE_DIR}/characters/shapes/male/chibi
|
||||
${CMAKE_SOURCE_DIR}/characters/shapes/female/chibi
|
||||
${CMAKE_SOURCE_DIR}/characters/male
|
||||
${CMAKE_SOURCE_DIR}/characters/female)
|
||||
set(CREATE_SCENES
|
||||
${CMAKE_SOURCE_DIR}/characters/female/vroid-normal-female.scene
|
||||
${CMAKE_SOURCE_DIR}/characters/male/vroid-normal-male.scene
|
||||
)
|
||||
|
||||
# workaround horribly broken assimp cmake, fixed with assimp 5.1
|
||||
add_library(fix::assimp INTERFACE IMPORTED)
|
||||
set_target_properties(fix::assimp PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES "${ASSIMP_LIBRARIES};pugixml"
|
||||
INTERFACE_LINK_DIRECTORIES "${ASSIMP_LIBRARY_DIRS}"
|
||||
)
|
||||
|
||||
# The COMPONENTS part checks that OGRE was built the way we need it
|
||||
# The CONFIG flag makes sure we get OGRE instead of OGRE-next
|
||||
find_package(OGRE REQUIRED COMPONENTS Bites CONFIG)
|
||||
find_package(ZLIB)
|
||||
find_package(SDL2)
|
||||
find_package(assimp)
|
||||
|
||||
# add the source files as usual
|
||||
add_executable(0_Bootstrap Bootstrap.cpp)
|
||||
|
||||
# this also sets the includes and pulls third party dependencies
|
||||
target_link_libraries(0_Bootstrap OgreBites)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_BINARY_DIR}/resources.cfg
|
||||
COMMAND cp ${CMAKE_SOURCE_DIR}/resources.cfg ${CMAKE_BINARY_DIR}/resources.cfg
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/resources/main
|
||||
${CMAKE_BINARY_DIR}/resources/main
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/resources/shaderlib
|
||||
${CMAKE_BINARY_DIR}/resources/shaderlib
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/resources/terrain
|
||||
${CMAKE_BINARY_DIR}/resources/terrain
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/characters
|
||||
${CMAKE_BINARY_DIR}/characters
|
||||
DEPENDS ${CMAKE_SOURCE_DIR}/resources.cfg)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_SOURCE_DIR}/characters/female/vroid-normal-female.scene
|
||||
${CMAKE_SOURCE_DIR}/characters/male/vroid-normal-male.scene
|
||||
${CMAKE_SOURCE_DIR}/assets/blender/vrm-vroid-normal-female.blend
|
||||
${CMAKE_SOURCE_DIR}/assets/blender/vrm-vroid-normal-male.blend
|
||||
${CMAKE_SOURCE_DIR}/assets/blender/shapes/male/vrm-vroid-normal-male-chibi.blend
|
||||
COMMAND mkdir -p ${CREATE_DIRECTORIES}
|
||||
COMMAND ${BLENDER} -b -Y -P ${CMAKE_SOURCE_DIR}/assets/blender/scripts/import_vrm.py
|
||||
COMMAND ${BLENDER} -b -Y -P ${CMAKE_SOURCE_DIR}/assets/blender/scripts/export_models.py
|
||||
# COMMAND ${BLENDER} -b -Y -P ${CMAKE_SOURCE_DIR}/assets/blender/scripts/export_ogre_scene.py
|
||||
COMMAND echo rm -Rf ${CMAKE_SOURCE_DIR}/characters/male/*.material ${CMAKE_SOURCE_DIR}/characters/female/*.material
|
||||
DEPENDS ${CMAKE_SOURCE_DIR}/assets/blender/scripts/export_models.py ${CMAKE_SOURCE_DIR}/assets/blender/scripts/import_vrm.py
|
||||
${CMAKE_SOURCE_DIR}/assets/vroid/buch1.vrm
|
||||
${CMAKE_SOURCE_DIR}/assets/vroid/buch1-chibi.vrm
|
||||
${CMAKE_SOURCE_DIR}/assets/vroid/jane2-dress.vrm
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||
|
||||
add_custom_target(stage_files ALL DEPENDS ${CMAKE_BINARY_DIR}/resources.cfg)
|
||||
|
||||
add_custom_target(remove_scenes COMMAND rm -f ${CREATE_SCENES})
|
||||
|
||||
add_custom_target(import_vrm DEPENDS ${CREATE_SCENES})
|
||||
|
||||
70
resources.cfg
Normal file
70
resources.cfg
Normal file
@@ -0,0 +1,70 @@
|
||||
# Ogre Core Resources
|
||||
[OgreInternal]
|
||||
#FileSystem=./Media/Main
|
||||
FileSystem=resources/main
|
||||
FileSystem=resources/shaderlib
|
||||
#FileSystem=./Media/RTShaderLib
|
||||
FileSystem=./Media/Terrain/
|
||||
|
||||
# Resources required by OgreBites::Trays
|
||||
[Essential]
|
||||
Zip=./Media/packs/SdkTrays.zip
|
||||
Zip=./Media/packs/profiler.zip
|
||||
|
||||
# this line will end up in the [Essential] group
|
||||
FileSystem=./Media/thumbnails
|
||||
|
||||
# Common sample resources needed by many of the samples.
|
||||
# Rarely used resources should be separately loaded by the
|
||||
# samples which require them.
|
||||
[General]
|
||||
# PBR media must come before the scripts that reference it
|
||||
#FileSystem=./Media/PBR
|
||||
#FileSystem=./Media/PBR/filament
|
||||
|
||||
#FileSystem=./Media/materials/programs/GLSL
|
||||
#FileSystem=./Media/materials/programs/GLSL120
|
||||
#FileSystem=./Media/materials/programs/GLSL150
|
||||
#FileSystem=./Media/materials/programs/GLSL400
|
||||
#FileSystem=./Media/materials/programs/GLSLES
|
||||
#FileSystem=./Media/materials/programs/SPIRV
|
||||
#FileSystem=./Media/materials/programs/Cg
|
||||
#FileSystem=./Media/materials/programs/HLSL
|
||||
#FileSystem=./Media/materials/programs/HLSL_Cg
|
||||
#FileSystem=./Media/materials/scripts
|
||||
#FileSystem=./Media/materials/textures
|
||||
#FileSystem=./Media/materials/textures/terrain
|
||||
#FileSystem=./Media/models
|
||||
#FileSystem=./Media/particle
|
||||
#FileSystem=./Media/DeferredShadingMedia
|
||||
#FileSystem=./Media/DeferredShadingMedia/DeferredShading/post
|
||||
#FileSystem=./Media/PCZAppMedia
|
||||
#FileSystem=./Media/materials/scripts/SSAO
|
||||
#FileSystem=./Media/materials/textures/SSAO
|
||||
#FileSystem=./Media/volumeTerrain
|
||||
#FileSystem=./Media/CSMShadows
|
||||
|
||||
#Zip=./Media/packs/cubemap.zip
|
||||
#Zip=./Media/packs/cubemapsJS.zip
|
||||
#Zip=./Media/packs/dragon.zip
|
||||
#Zip=./Media/packs/fresneldemo.zip
|
||||
#Zip=./Media/packs/ogredance.zip
|
||||
#Zip=./Media/packs/Sinbad.zip
|
||||
#Zip=./Media/packs/skybox.zip
|
||||
#Zip=./Media/volumeTerrain/volumeTerrainBig.zip
|
||||
|
||||
#Zip=./Media/packs/DamagedHelmet.zip
|
||||
#Zip=./Media/packs/filament_shaders.zip
|
||||
|
||||
#[BSPWorld]
|
||||
#Zip=./Media/packs/oa_rpg3dm2.pk3
|
||||
#Zip=./Media/packs/ogretestmap.zip
|
||||
|
||||
# Materials for visual tests
|
||||
#[Tests]
|
||||
#FileSystem=/media/slapin/library/ogre/ogre-sdk/Tests/Media
|
||||
|
||||
[Characters]
|
||||
FileSystem=./characters/male
|
||||
FileSystem=./characters/female
|
||||
|
||||
Reference in New Issue
Block a user