Compare commits
2 Commits
e967844558
...
a62d781aa0
| Author | SHA1 | Date | |
|---|---|---|---|
| a62d781aa0 | |||
| fea7c71788 |
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
@@ -10,6 +10,9 @@
|
||||
"variant": "cpp",
|
||||
"tuple": "cpp",
|
||||
"iostream": "cpp",
|
||||
"string_view": "cpp"
|
||||
"string_view": "cpp",
|
||||
"atomic": "cpp",
|
||||
"memory_resource": "cpp",
|
||||
"stop_token": "cpp"
|
||||
}
|
||||
}
|
||||
@@ -70,6 +70,7 @@ add_subdirectory(src/characters)
|
||||
add_subdirectory(src/gamedata)
|
||||
add_subdirectory(src/miniaudio)
|
||||
add_subdirectory(src/sound)
|
||||
add_subdirectory(src/sceneloader)
|
||||
add_subdirectory(audio/gui)
|
||||
add_subdirectory(tests)
|
||||
add_subdirectory(lua-scripts)
|
||||
@@ -101,6 +102,7 @@ target_link_libraries(Game OgreBites OgreBullet OgrePaging OgreTerrain OgreMeshL
|
||||
${BULLET_COLLISION_LIBRARY} ${BULLET_MATH_LIBRARY}
|
||||
GameData
|
||||
sound
|
||||
sceneloader
|
||||
flecs::flecs_static
|
||||
-Wl,--as-needed
|
||||
)
|
||||
|
||||
BIN
assets/blender/edited-normal-female.blend
(Stored with Git LFS)
BIN
assets/blender/edited-normal-female.blend
(Stored with Git LFS)
Binary file not shown.
BIN
assets/blender/edited-normal-male.blend
(Stored with Git LFS)
BIN
assets/blender/edited-normal-male.blend
(Stored with Git LFS)
Binary file not shown.
BIN
assets/blender/mixamo/female/hanging-climb.fbx
(Stored with Git LFS)
Normal file
BIN
assets/blender/mixamo/female/hanging-climb.fbx
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/blender/mixamo/female/hanging-idle.fbx
(Stored with Git LFS)
Normal file
BIN
assets/blender/mixamo/female/hanging-idle.fbx
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/blender/mixamo/female/sitting.fbx
(Stored with Git LFS)
Normal file
BIN
assets/blender/mixamo/female/sitting.fbx
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/blender/mixamo/male/hanging-climb.fbx
(Stored with Git LFS)
Normal file
BIN
assets/blender/mixamo/male/hanging-climb.fbx
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/blender/mixamo/male/hanging-idle.fbx
(Stored with Git LFS)
Normal file
BIN
assets/blender/mixamo/male/hanging-idle.fbx
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/blender/mixamo/male/sitting.fbx
(Stored with Git LFS)
Normal file
BIN
assets/blender/mixamo/male/sitting.fbx
(Stored with Git LFS)
Normal file
Binary file not shown.
@@ -6,7 +6,7 @@ class VRMDataFemale:
|
||||
editfile = "modelling-vroid-normal-female.blend"
|
||||
armature_name = "female"
|
||||
mixamo_animation_path = basepath + "/assets/blender/mixamo/female/"
|
||||
mixamo_animations = ["idle", "walking", "running", "jump", "left_turn", "right_turn", "swimming", "treading_water"]
|
||||
mixamo_animations = ["idle", "walking", "running", "jump", "left_turn", "right_turn", "swimming", "treading_water", "sitting", "hanging-climb", "hanging-idle"]
|
||||
fbx_scale = 0.89
|
||||
class VRMDataMale:
|
||||
path = "buch1.vrm"
|
||||
@@ -14,7 +14,7 @@ class VRMDataMale:
|
||||
editfile = "modelling-vroid-normal-male.blend"
|
||||
armature_name = "male"
|
||||
mixamo_animation_path = basepath + "/assets/blender/mixamo/male/"
|
||||
mixamo_animations = ["idle", "walking", "running", "jump", "left_turn", "right_turn", "swimming", "treading_water"]
|
||||
mixamo_animations = ["idle", "walking", "running", "jump", "left_turn", "right_turn", "swimming", "treading_water", "sitting", "hanging-climb", "hanging-idle"]
|
||||
fbx_scale = 1.0
|
||||
class VRMDataMaleBabyShape:
|
||||
path = "buch1-chibi.vrm"
|
||||
|
||||
BIN
assets/blender/vehicles/boat.blend
(Stored with Git LFS)
BIN
assets/blender/vehicles/boat.blend
(Stored with Git LFS)
Binary file not shown.
@@ -229,10 +229,12 @@ function StartGameQuest()
|
||||
print('activate...')
|
||||
local mc_is_free = function()
|
||||
this.boat_id = ecs_vehicle_set("boat", 0, 0, -20, 1.75)
|
||||
this.boat2_id = ecs_vehicle_set("boat", -10, 0, -20, 1.55)
|
||||
this.trigger_id = ecs_child_character_trigger(this.boat_id, "entered_boat", 0, 0, 0, 3, 3)
|
||||
this.npc_id = ecs_npc_set("normal-female.glb", 0, 2, -20, 1.75)
|
||||
this.boat = true
|
||||
local npc = ecs_npc_set("normal-female.glb", 0, 2, -20, 1.75)
|
||||
ecs_character_physics_control(npc, false)
|
||||
-- ecs_set_slot(this.boat_id, this.npc_id, "captain_seat")
|
||||
-- ecs_character_physics_control(this.npc_id, false)
|
||||
ecs_character_params_set("player", "gravity", true)
|
||||
ecs_character_params_set("player", "buoyancy", true)
|
||||
end
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#include <iostream>
|
||||
#include <Ogre.h>
|
||||
#include <OgreMeshManager.h>
|
||||
#include <pugixml.hpp>
|
||||
#include "loader.h"
|
||||
#include "Components.h"
|
||||
#include "GameData.h"
|
||||
#include "BoatModule.h"
|
||||
@@ -35,7 +38,7 @@ BoatModule::BoatModule(flecs::world &ecs)
|
||||
ECS::get<EngineData>()
|
||||
.mWorld->addRigidBody(
|
||||
0, boat.mEnt,
|
||||
Ogre::Bullet::CT_HULL,
|
||||
Ogre::Bullet::CT_TRIMESH,
|
||||
nullptr, 2, 0x7fffffff);
|
||||
} else if (type.resourceName.find(".scene") !=
|
||||
std::string::npos) {
|
||||
@@ -48,7 +51,16 @@ BoatModule::BoatModule(flecs::world &ecs)
|
||||
Ogre::SceneNode *attachment =
|
||||
eng.mScnMgr->getRootSceneNode()
|
||||
->createChildSceneNode();
|
||||
attachment->loadChildren(type.resourceName);
|
||||
Ogre::DataStreamPtr scene =
|
||||
Ogre::ResourceGroupManager::getSingleton()
|
||||
.openResource(
|
||||
type.resourceName,
|
||||
Ogre::ResourceGroupManager::
|
||||
AUTODETECT_RESOURCE_GROUP_NAME);
|
||||
SceneLoader loader;
|
||||
loader.load(scene, "General", attachment,
|
||||
(int)e.raw_id());
|
||||
// attachment->loadChildren(type.resourceName);
|
||||
std::vector<Ogre::Node *> v =
|
||||
attachment->getChildren();
|
||||
int i;
|
||||
@@ -69,13 +81,15 @@ BoatModule::BoatModule(flecs::world &ecs)
|
||||
boat.mNode->_setDerivedOrientation(
|
||||
type.orientation);
|
||||
boat.mEnt = static_cast<Ogre::Entity *>(
|
||||
boat.mNode->getAttachedObject("boat"));
|
||||
boat.mNode->getAttachedObject(
|
||||
std::to_string((int)e.raw_id()) +
|
||||
"/boat"));
|
||||
BoatBody &body = e.ensure<BoatBody>();
|
||||
body.body =
|
||||
ECS::get<EngineData>()
|
||||
.mWorld->addRigidBody(
|
||||
0, boat.mEnt,
|
||||
Ogre::Bullet::CT_HULL,
|
||||
Ogre::Bullet::CT_TRIMESH,
|
||||
nullptr, 2, 0x7fffffff);
|
||||
#if 0
|
||||
boat.mEnt = eng.mScnMgr->getEntity("boat");
|
||||
@@ -84,6 +98,59 @@ BoatModule::BoatModule(flecs::world &ecs)
|
||||
BoatBody &body =
|
||||
e.ensure<BoatBody>();
|
||||
#endif
|
||||
std::vector<Ogre::Node *> slots =
|
||||
boat.mNode->getChildren();
|
||||
for (i = 0; i < slots.size(); i++) {
|
||||
Ogre::Any any =
|
||||
static_cast<Ogre::SceneNode *>(
|
||||
slots[i])
|
||||
->getUserObjectBindings()
|
||||
.getUserAny("type");
|
||||
if (!any.has_value())
|
||||
continue;
|
||||
Ogre::String obj_type =
|
||||
Ogre::any_cast<Ogre::String>(
|
||||
any);
|
||||
std::cout << "child type: " << obj_type
|
||||
<< std::endl;
|
||||
}
|
||||
if (slots.size() > 0) {
|
||||
VehicleSlots &vs =
|
||||
e.ensure<VehicleSlots>();
|
||||
for (i = 0; i < slots.size(); i++) {
|
||||
Ogre::Any any =
|
||||
static_cast<Ogre::SceneNode
|
||||
*>(
|
||||
slots[i])
|
||||
->getUserObjectBindings()
|
||||
.getUserAny(
|
||||
"type");
|
||||
if (!any.has_value())
|
||||
continue;
|
||||
Ogre::String obj_type =
|
||||
Ogre::any_cast<
|
||||
Ogre::String>(
|
||||
any);
|
||||
any = static_cast<
|
||||
Ogre::SceneNode *>(
|
||||
slots[i])
|
||||
->getUserObjectBindings()
|
||||
.getUserAny(
|
||||
"name");
|
||||
if (!any.has_value())
|
||||
continue;
|
||||
Ogre::String obj_name =
|
||||
Ogre::any_cast<
|
||||
Ogre::String>(
|
||||
any);
|
||||
vs.seats[obj_name] = {
|
||||
obj_type,
|
||||
static_cast<Ogre::SceneNode
|
||||
*>(
|
||||
slots[i])
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
e.modified<BoatBody>();
|
||||
});
|
||||
|
||||
@@ -2,5 +2,5 @@ project(gamedata)
|
||||
find_package(OGRE REQUIRED COMPONENTS Bites Bullet Paging Terrain Overlay CONFIG)
|
||||
add_library(GameData STATIC GameData.cpp CharacterModule.cpp WaterModule.cpp SunModule.cpp TerrainModule.cpp GUIModule.cpp LuaData.cpp WorldMapModule.cpp
|
||||
BoatModule.cpp EventTriggerModule.cpp)
|
||||
target_link_libraries(GameData PUBLIC OgreMain OgreBites OgreBullet OgrePaging OgreTerrain OgreOverlay flecs::flecs_static lua)
|
||||
target_include_directories(GameData PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(GameData PUBLIC OgreMain OgreBites OgreBullet OgrePaging OgreTerrain OgreOverlay flecs::flecs_static lua sceneloader)
|
||||
target_include_directories(GameData PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
@@ -733,6 +733,33 @@ CharacterModule::CharacterModule(flecs::world &ecs)
|
||||
<< "\n";
|
||||
});
|
||||
#endif
|
||||
ecs.system<const EngineData, const CharacterBase, CharacterSlot>(
|
||||
"UpdatePhysics2")
|
||||
.kind(flecs::OnUpdate)
|
||||
.with<CharacterDisablePhysics>()
|
||||
.each([](flecs::entity e, const EngineData &eng,
|
||||
const CharacterBase &ch, CharacterSlot &slot) {
|
||||
if (slot.parent_e.has<VehicleSlots>()) {
|
||||
const VehicleSlots &slots =
|
||||
slot.parent_e.get<VehicleSlots>();
|
||||
if (slots.seats.find(slot.slot_name) ==
|
||||
slots.seats.end())
|
||||
// invalid setting
|
||||
e.remove<CharacterSlot>();
|
||||
if (slot.activated)
|
||||
return;
|
||||
Ogre::SceneNode *slot_base =
|
||||
slots.seats.at(slot.slot_name).second;
|
||||
Ogre::Vector3 position =
|
||||
slot_base->_getDerivedPosition();
|
||||
Ogre::Quaternion orientation =
|
||||
slot_base->_getDerivedOrientation();
|
||||
ch.mBodyNode->_setDerivedPosition(position);
|
||||
ch.mBodyNode->_setDerivedOrientation(
|
||||
orientation);
|
||||
slot.activated = true;
|
||||
}
|
||||
});
|
||||
ecs.system<const EngineData, const CharacterBody>("UpdatePhysics")
|
||||
.kind(flecs::OnUpdate)
|
||||
.with<CharacterUpdatePhysicsState>()
|
||||
|
||||
@@ -11,6 +11,11 @@ struct CharacterGravity {};
|
||||
struct CharacterBuoyancy {};
|
||||
struct CharacterDisablePhysics {};
|
||||
struct CharacterUpdatePhysicsState {};
|
||||
struct CharacterSlot {
|
||||
flecs::entity parent_e;
|
||||
Ogre::String slot_name;
|
||||
bool activated;
|
||||
};
|
||||
struct CharacterBase {
|
||||
Ogre::String type;
|
||||
float mTimer;
|
||||
|
||||
@@ -76,5 +76,10 @@ struct InWater {};
|
||||
struct TerrainReady {};
|
||||
struct WaterReady {};
|
||||
struct GroundCheckReady {};
|
||||
struct VehicleSlots {
|
||||
std::unordered_map<Ogre::String,
|
||||
std::pair<Ogre::String, Ogre::SceneNode *> >
|
||||
seats;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
@@ -399,6 +399,20 @@ LuaData::LuaData()
|
||||
return 0;
|
||||
});
|
||||
lua_setglobal(L, "ecs_character_physics_control");
|
||||
lua_pushcfunction(L, [](lua_State *L) -> int {
|
||||
OgreAssert(lua_gettop(L) == 3, "Bad parameters");
|
||||
luaL_checktype(L, 1, LUA_TNUMBER); // parent
|
||||
luaL_checktype(L, 2, LUA_TNUMBER); // object
|
||||
luaL_checktype(L, 3, LUA_TSTRING); // slot
|
||||
int parent = lua_tointeger(L, 1);
|
||||
int object = lua_tointeger(L, 2);
|
||||
Ogre::String slot = lua_tostring(L, 3);
|
||||
flecs::entity parent_e = idmap.get_entity(parent);
|
||||
flecs::entity object_e = idmap.get_entity(object);
|
||||
object_e.set<CharacterSlot>({ parent_e, slot, false });
|
||||
return 0;
|
||||
});
|
||||
lua_setglobal(L, "ecs_set_slot");
|
||||
}
|
||||
|
||||
LuaData::~LuaData()
|
||||
|
||||
6
src/sceneloader/CMakeLists.txt
Normal file
6
src/sceneloader/CMakeLists.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
project(sceneloader)
|
||||
add_library(sceneloader loader.cpp)
|
||||
target_include_directories(sceneloader PUBLIC .)
|
||||
target_link_libraries(sceneloader PUBLIC OgreMain PRIVATE pugixml)
|
||||
target_link_libraries(sceneloader PUBLIC OgreTerrain)
|
||||
|
||||
1245
src/sceneloader/loader.cpp
Normal file
1245
src/sceneloader/loader.cpp
Normal file
File diff suppressed because it is too large
Load Diff
79
src/sceneloader/loader.h
Normal file
79
src/sceneloader/loader.h
Normal file
@@ -0,0 +1,79 @@
|
||||
#ifndef LOADER_H_
|
||||
#define LOADER_H_
|
||||
#include <OgreColourValue.h>
|
||||
#include <OgreQuaternion.h>
|
||||
#include <OgreResourceGroupManager.h>
|
||||
#include <OgreString.h>
|
||||
#include <OgrePlugin.h>
|
||||
#include <OgreCodec.h>
|
||||
|
||||
class SceneLoader {
|
||||
public:
|
||||
SceneLoader();
|
||||
virtual ~SceneLoader();
|
||||
|
||||
void load(Ogre::DataStreamPtr &stream, const Ogre::String &groupName,
|
||||
Ogre::SceneNode *rootNode, int counter);
|
||||
|
||||
void exportScene(Ogre::SceneNode *rootNode,
|
||||
const Ogre::String &outFileName);
|
||||
|
||||
const Ogre::ColourValue &getBackgroundColour()
|
||||
{
|
||||
return mBackgroundColour;
|
||||
}
|
||||
|
||||
protected:
|
||||
void writeNode(pugi::xml_node &parentXML, const Ogre::SceneNode *node);
|
||||
void processScene(pugi::xml_node &XMLRoot);
|
||||
|
||||
void processNodes(pugi::xml_node &XMLNode);
|
||||
void processExternals(pugi::xml_node &XMLNode);
|
||||
void processEnvironment(pugi::xml_node &XMLNode);
|
||||
void processTerrainGroup(pugi::xml_node &XMLNode);
|
||||
void processBlendmaps(pugi::xml_node &XMLNode);
|
||||
void processUserData(pugi::xml_node &XMLNode,
|
||||
Ogre::UserObjectBindings &userData);
|
||||
void processLight(pugi::xml_node &XMLNode,
|
||||
Ogre::SceneNode *pParent = 0);
|
||||
void processCamera(pugi::xml_node &XMLNode,
|
||||
Ogre::SceneNode *pParent = 0);
|
||||
|
||||
void processNode(pugi::xml_node &XMLNode, Ogre::SceneNode *pParent = 0);
|
||||
void processLookTarget(pugi::xml_node &XMLNode,
|
||||
Ogre::SceneNode *pParent);
|
||||
void processTrackTarget(pugi::xml_node &XMLNode,
|
||||
Ogre::SceneNode *pParent);
|
||||
void processEntity(pugi::xml_node &XMLNode, Ogre::SceneNode *pParent);
|
||||
void processParticleSystem(pugi::xml_node &XMLNode,
|
||||
Ogre::SceneNode *pParent);
|
||||
void processBillboardSet(pugi::xml_node &XMLNode,
|
||||
Ogre::SceneNode *pParent);
|
||||
void processPlane(pugi::xml_node &XMLNode, Ogre::SceneNode *pParent);
|
||||
void processNodeAnimations(pugi::xml_node &XMLNode,
|
||||
Ogre::SceneNode *pParent);
|
||||
void processNodeAnimation(pugi::xml_node &XMLNode,
|
||||
Ogre::SceneNode *pParent);
|
||||
void processKeyframe(pugi::xml_node &XMLNode,
|
||||
Ogre::NodeAnimationTrack *pTrack);
|
||||
|
||||
void processFog(pugi::xml_node &XMLNode);
|
||||
void processSkyBox(pugi::xml_node &XMLNode);
|
||||
void processSkyDome(pugi::xml_node &XMLNode);
|
||||
void processSkyPlane(pugi::xml_node &XMLNode);
|
||||
|
||||
void processLightRange(pugi::xml_node &XMLNode, Ogre::Light *pLight);
|
||||
void processLightAttenuation(pugi::xml_node &XMLNode,
|
||||
Ogre::Light *pLight);
|
||||
void processLightSourceSize(pugi::xml_node &XMLNode,
|
||||
Ogre::Light *pLight);
|
||||
|
||||
Ogre::SceneManager *mSceneMgr;
|
||||
Ogre::SceneNode *mAttachNode;
|
||||
Ogre::String m_sGroupName;
|
||||
Ogre::ColourValue mBackgroundColour;
|
||||
Ogre::String mNamePrefix;
|
||||
int counter;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user