Some strange shit happens
This commit is contained in:
parent
4d9a5b0a6e
commit
c655678486
@ -3,9 +3,19 @@
|
|||||||
{
|
{
|
||||||
"id": "npc_01_default",
|
"id": "npc_01_default",
|
||||||
"name": "NPC Default Guard",
|
"name": "NPC Default Guard",
|
||||||
"texturePath": "resources/w/default_skin001.png",
|
"animationIdlePath": "resources/w/new_anims/gg_stand_idle003.anim",
|
||||||
"animationIdlePath": "resources/w/default_idle002.anim",
|
"animationWalkPath": "resources/w/new_anims/gg_run003.anim",
|
||||||
"animationWalkPath": "resources/w/default_walk001.anim",
|
"meshTextures": {
|
||||||
|
"Body": "resources/w/new_anims/male_packed0_diffuse.png",
|
||||||
|
"Bottoms": "resources/w/new_anims/male_packed1_diffuse.png",
|
||||||
|
"Eyelashes": "resources/w/new_anims/male_packed0_diffuse.png",
|
||||||
|
"Eyes": "resources/w/new_anims/male_packed0_diffuse.png",
|
||||||
|
"Eyewear": "resources/w/new_anims/male_packed0_diffuse.png",
|
||||||
|
"Gloves": "resources/w/new_anims/male_packed1_diffuse.png",
|
||||||
|
"Hair": "resources/w/new_anims/male_packed0_diffuse.png",
|
||||||
|
"Shoes": "resources/w/new_anims/male_packed1_diffuse.png",
|
||||||
|
"Tops": "resources/w/new_anims/male_packed2_diffuse.png"
|
||||||
|
},
|
||||||
"positionX": 0.0,
|
"positionX": 0.0,
|
||||||
"positionY": 0.0,
|
"positionY": 0.0,
|
||||||
"positionZ": -10.0,
|
"positionZ": -10.0,
|
||||||
|
|||||||
BIN
resources/w/new_anims/male_packed0_diffuse.png
(Stored with Git LFS)
Normal file
BIN
resources/w/new_anims/male_packed0_diffuse.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
resources/w/new_anims/male_packed1_diffuse.png
(Stored with Git LFS)
Normal file
BIN
resources/w/new_anims/male_packed1_diffuse.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
resources/w/new_anims/male_packed2_diffuse.png
(Stored with Git LFS)
Normal file
BIN
resources/w/new_anims/male_packed2_diffuse.png
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -74,6 +74,27 @@ void Character::setPathPlanner(PathPlanner planner) {
|
|||||||
pathPlanner = std::move(planner);
|
pathPlanner = std::move(planner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Character::setTexture(std::shared_ptr<ZL::Texture> texture)
|
||||||
|
{
|
||||||
|
for (auto& animEntry : animations) {
|
||||||
|
for (const auto& name : animEntry.second.model.meshNamesOrdered) {
|
||||||
|
meshTextures[name] = texture;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Character::setTexture(const std::string& meshName, std::shared_ptr<Texture> tex) {
|
||||||
|
meshTextures[meshName] = std::move(tex);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
void Character::setTexture(std::shared_ptr<Texture> tex) {
|
||||||
|
for (auto& animEntry : animations) {
|
||||||
|
for (const auto& name : animEntry.second.model.meshNamesOrdered) {
|
||||||
|
meshTextures[name] = tex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
AnimationState Character::resolveActiveState() const {
|
AnimationState Character::resolveActiveState() const {
|
||||||
|
|
||||||
if (animations.count(currentState)) return currentState;
|
if (animations.count(currentState)) return currentState;
|
||||||
@ -299,7 +320,7 @@ void Character::draw(Renderer& renderer) {
|
|||||||
|
|
||||||
AnimationState drawState = resolveActiveState();
|
AnimationState drawState = resolveActiveState();
|
||||||
auto it = animations.find(drawState);
|
auto it = animations.find(drawState);
|
||||||
if (it == animations.end() || !texture) return;
|
if (it == animations.end()) return;
|
||||||
|
|
||||||
renderer.shaderManager.PushShader(defaultShaderName);
|
renderer.shaderManager.PushShader(defaultShaderName);
|
||||||
renderer.RenderUniform1i(textureUniformName, 0);
|
renderer.RenderUniform1i(textureUniformName, 0);
|
||||||
@ -315,10 +336,12 @@ void Character::draw(Renderer& renderer) {
|
|||||||
renderer.RotateMatrix(modelCorrectionRotation.toRotationMatrix());
|
renderer.RotateMatrix(modelCorrectionRotation.toRotationMatrix());
|
||||||
|
|
||||||
auto& anim = it->second;
|
auto& anim = it->second;
|
||||||
glBindTexture(GL_TEXTURE_2D, texture->getTexID());
|
|
||||||
for (const auto& name : anim.model.meshNamesOrdered) {
|
for (const auto& name : anim.model.meshNamesOrdered) {
|
||||||
auto mit = anim.model.meshes.find(name);
|
auto mit = anim.model.meshes.find(name);
|
||||||
if (mit == anim.model.meshes.end()) continue;
|
if (mit == anim.model.meshes.end()) continue;
|
||||||
|
auto tit = meshTextures.find(name);
|
||||||
|
if (tit == meshTextures.end() || !tit->second) continue;
|
||||||
|
glBindTexture(GL_TEXTURE_2D, tit->second->getTexID());
|
||||||
modelMutable.AssignFrom(mit->second.mesh);
|
modelMutable.AssignFrom(mit->second.mesh);
|
||||||
modelMutable.RefreshVBO();
|
modelMutable.RefreshVBO();
|
||||||
renderer.DrawVertexRenderStruct(modelMutable);
|
renderer.DrawVertexRenderStruct(modelMutable);
|
||||||
@ -335,7 +358,7 @@ void Character::draw(Renderer& renderer) {
|
|||||||
void Character::drawGpuSkinning(Renderer& renderer) {
|
void Character::drawGpuSkinning(Renderer& renderer) {
|
||||||
AnimationState drawState = resolveActiveState();
|
AnimationState drawState = resolveActiveState();
|
||||||
auto it = animations.find(drawState);
|
auto it = animations.find(drawState);
|
||||||
if (it == animations.end() || !texture)
|
if (it == animations.end())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -372,9 +395,14 @@ void Character::drawGpuSkinning(Renderer& renderer) {
|
|||||||
static_cast<int>(anim.gpuSkinningShaderData.skinningMatrices.size()), false,
|
static_cast<int>(anim.gpuSkinningShaderData.skinningMatrices.size()), false,
|
||||||
anim.gpuSkinningShaderData.skinningMatrices[0].data());
|
anim.gpuSkinningShaderData.skinningMatrices[0].data());
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, texture->getTexID());
|
for (const auto& name : anim.model.meshNamesOrdered) {
|
||||||
|
auto pit = anim.gpuSkinningShaderData.perMesh.find(name);
|
||||||
anim.gpuSkinningShaderData.RenderVBO(renderer, anim.model.meshNamesOrdered);
|
if (pit == anim.gpuSkinningShaderData.perMesh.end()) continue;
|
||||||
|
auto tit = meshTextures.find(name);
|
||||||
|
if (tit == meshTextures.end() || !tit->second) continue;
|
||||||
|
glBindTexture(GL_TEXTURE_2D, tit->second->getTexID());
|
||||||
|
pit->second.RenderVBO(renderer);
|
||||||
|
}
|
||||||
|
|
||||||
renderer.PopMatrix();
|
renderer.PopMatrix();
|
||||||
|
|
||||||
@ -474,6 +502,8 @@ void Character::drawShadowDepthCpu(Renderer& renderer) {
|
|||||||
for (const auto& name : anim.model.meshNamesOrdered) {
|
for (const auto& name : anim.model.meshNamesOrdered) {
|
||||||
auto mit = anim.model.meshes.find(name);
|
auto mit = anim.model.meshes.find(name);
|
||||||
if (mit == anim.model.meshes.end()) continue;
|
if (mit == anim.model.meshes.end()) continue;
|
||||||
|
auto tit = meshTextures.find(name);
|
||||||
|
if (tit == meshTextures.end() || !tit->second) continue;
|
||||||
modelMutable.AssignFrom(mit->second.mesh);
|
modelMutable.AssignFrom(mit->second.mesh);
|
||||||
modelMutable.RefreshVBO();
|
modelMutable.RefreshVBO();
|
||||||
renderer.DrawVertexRenderStruct(modelMutable);
|
renderer.DrawVertexRenderStruct(modelMutable);
|
||||||
@ -514,7 +544,13 @@ void Character::drawShadowDepthGpuSkinning(Renderer& renderer) {
|
|||||||
it->second.gpuSkinningShaderData.skinningMatrices[0].data());
|
it->second.gpuSkinningShaderData.skinningMatrices[0].data());
|
||||||
|
|
||||||
CheckGlError(__FILE__, __LINE__);
|
CheckGlError(__FILE__, __LINE__);
|
||||||
it->second.gpuSkinningShaderData.RenderVBO(renderer, it->second.model.meshNamesOrdered);
|
for (const auto& name : it->second.model.meshNamesOrdered) {
|
||||||
|
auto pit = it->second.gpuSkinningShaderData.perMesh.find(name);
|
||||||
|
if (pit == it->second.gpuSkinningShaderData.perMesh.end()) continue;
|
||||||
|
auto tit = meshTextures.find(name);
|
||||||
|
if (tit == meshTextures.end() || !tit->second) continue;
|
||||||
|
pit->second.RenderVBO(renderer);
|
||||||
|
}
|
||||||
|
|
||||||
CheckGlError(__FILE__, __LINE__);
|
CheckGlError(__FILE__, __LINE__);
|
||||||
renderer.PopMatrix();
|
renderer.PopMatrix();
|
||||||
@ -538,7 +574,7 @@ void Character::drawWithShadow(Renderer& renderer, const Eigen::Matrix4f& lightF
|
|||||||
void Character::drawCpuWithShadow(Renderer& renderer, const Eigen::Matrix4f& lightFromCamera, GLuint shadowMapTex, const Eigen::Vector3f& lightDirCamera) {
|
void Character::drawCpuWithShadow(Renderer& renderer, const Eigen::Matrix4f& lightFromCamera, GLuint shadowMapTex, const Eigen::Vector3f& lightDirCamera) {
|
||||||
AnimationState drawState = resolveActiveState();
|
AnimationState drawState = resolveActiveState();
|
||||||
auto it = animations.find(drawState);
|
auto it = animations.find(drawState);
|
||||||
if (it == animations.end() || !texture) return;
|
if (it == animations.end()) return;
|
||||||
|
|
||||||
static const std::string shadowShader = "default_shadow";
|
static const std::string shadowShader = "default_shadow";
|
||||||
|
|
||||||
@ -563,10 +599,12 @@ void Character::drawCpuWithShadow(Renderer& renderer, const Eigen::Matrix4f& lig
|
|||||||
renderer.RotateMatrix(modelCorrectionRotation.toRotationMatrix());
|
renderer.RotateMatrix(modelCorrectionRotation.toRotationMatrix());
|
||||||
|
|
||||||
auto& anim = it->second;
|
auto& anim = it->second;
|
||||||
glBindTexture(GL_TEXTURE_2D, texture->getTexID());
|
|
||||||
for (const auto& name : anim.model.meshNamesOrdered) {
|
for (const auto& name : anim.model.meshNamesOrdered) {
|
||||||
auto mit = anim.model.meshes.find(name);
|
auto mit = anim.model.meshes.find(name);
|
||||||
if (mit == anim.model.meshes.end()) continue;
|
if (mit == anim.model.meshes.end()) continue;
|
||||||
|
auto tit = meshTextures.find(name);
|
||||||
|
if (tit == meshTextures.end() || !tit->second) continue;
|
||||||
|
glBindTexture(GL_TEXTURE_2D, tit->second->getTexID());
|
||||||
modelMutable.AssignFrom(mit->second.mesh);
|
modelMutable.AssignFrom(mit->second.mesh);
|
||||||
modelMutable.RefreshVBO();
|
modelMutable.RefreshVBO();
|
||||||
renderer.DrawVertexRenderStruct(modelMutable);
|
renderer.DrawVertexRenderStruct(modelMutable);
|
||||||
@ -586,7 +624,7 @@ void Character::drawCpuWithShadow(Renderer& renderer, const Eigen::Matrix4f& lig
|
|||||||
void Character::drawGpuSkinningWithShadow(Renderer& renderer, const Eigen::Matrix4f& lightFromCamera, GLuint shadowMapTex, const Eigen::Vector3f& lightDirCamera) {
|
void Character::drawGpuSkinningWithShadow(Renderer& renderer, const Eigen::Matrix4f& lightFromCamera, GLuint shadowMapTex, const Eigen::Vector3f& lightDirCamera) {
|
||||||
AnimationState drawState = resolveActiveState();
|
AnimationState drawState = resolveActiveState();
|
||||||
auto it = animations.find(drawState);
|
auto it = animations.find(drawState);
|
||||||
if (it == animations.end() || !texture) return;
|
if (it == animations.end()) return;
|
||||||
|
|
||||||
CheckGlError(__FILE__, __LINE__);
|
CheckGlError(__FILE__, __LINE__);
|
||||||
|
|
||||||
@ -627,10 +665,15 @@ void Character::drawGpuSkinningWithShadow(Renderer& renderer, const Eigen::Matri
|
|||||||
it->second.gpuSkinningShaderData.skinningMatrices[0].data());
|
it->second.gpuSkinningShaderData.skinningMatrices[0].data());
|
||||||
|
|
||||||
CheckGlError(__FILE__, __LINE__);
|
CheckGlError(__FILE__, __LINE__);
|
||||||
glBindTexture(GL_TEXTURE_2D, texture->getTexID());
|
|
||||||
|
|
||||||
CheckGlError(__FILE__, __LINE__);
|
for (const auto& name : it->second.model.meshNamesOrdered) {
|
||||||
it->second.gpuSkinningShaderData.RenderVBO(renderer, it->second.model.meshNamesOrdered);
|
auto pit = it->second.gpuSkinningShaderData.perMesh.find(name);
|
||||||
|
if (pit == it->second.gpuSkinningShaderData.perMesh.end()) continue;
|
||||||
|
auto tit = meshTextures.find(name);
|
||||||
|
if (tit == meshTextures.end() || !tit->second) continue;
|
||||||
|
glBindTexture(GL_TEXTURE_2D, tit->second->getTexID());
|
||||||
|
pit->second.RenderVBO(renderer);
|
||||||
|
}
|
||||||
|
|
||||||
renderer.PopMatrix();
|
renderer.PopMatrix();
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
namespace ZL {
|
namespace ZL {
|
||||||
|
|
||||||
@ -30,9 +31,11 @@ public:
|
|||||||
void loadAnimation(AnimationState state, const std::string& filename, const std::string& zipFile = "");
|
void loadAnimation(AnimationState state, const std::string& filename, const std::string& zipFile = "");
|
||||||
void loadBinaryAnimation(AnimationState state, const std::string& filename, const std::string& zipFile = "");
|
void loadBinaryAnimation(AnimationState state, const std::string& filename, const std::string& zipFile = "");
|
||||||
|
|
||||||
void setTexture(std::shared_ptr<Texture> texture) {
|
// Assigns the given texture to a specific mesh (by name, as defined in the animation file).
|
||||||
this->texture = texture;
|
void setTexture(const std::string& meshName, std::shared_ptr<Texture> texture);
|
||||||
}
|
// Assigns the given texture to every mesh in every loaded animation.
|
||||||
|
// Call AFTER loading animations so the mesh names are known.
|
||||||
|
void setTexture(std::shared_ptr<ZL::Texture> texture);
|
||||||
void update(int64_t deltaMs);
|
void update(int64_t deltaMs);
|
||||||
// onArrived is called once when the character reaches this target.
|
// onArrived is called once when the character reaches this target.
|
||||||
// From Python you can chain further commands (walk, wait, trigger others).
|
// From Python you can chain further commands (walk, wait, trigger others).
|
||||||
@ -87,7 +90,7 @@ private:
|
|||||||
|
|
||||||
std::map<AnimationState, BoneAnimationDataNew> animations;
|
std::map<AnimationState, BoneAnimationDataNew> animations;
|
||||||
VertexRenderStruct modelMutable;
|
VertexRenderStruct modelMutable;
|
||||||
std::shared_ptr<Texture> texture;
|
std::unordered_map<std::string, std::shared_ptr<Texture>> meshTextures;
|
||||||
|
|
||||||
Eigen::Vector3f walkTarget = Eigen::Vector3f(0.f, 0.f, 0.f);
|
Eigen::Vector3f walkTarget = Eigen::Vector3f(0.f, 0.f, 0.f);
|
||||||
Eigen::Vector3f requestedWalkTarget = Eigen::Vector3f(0.f, 0.f, 0.f);
|
Eigen::Vector3f requestedWalkTarget = Eigen::Vector3f(0.f, 0.f, 0.f);
|
||||||
|
|||||||
11
src/Game.cpp
11
src/Game.cpp
@ -24,6 +24,17 @@
|
|||||||
|
|
||||||
namespace ZL
|
namespace ZL
|
||||||
{
|
{
|
||||||
|
void set_Texture(Character& npc, TextureDataStruct& texture)
|
||||||
|
{
|
||||||
|
auto tt = std::make_shared<Texture>(texture);
|
||||||
|
npc.setTexture(tt);
|
||||||
|
}
|
||||||
|
void set_Texture(Character& npc, const std::string& meshName, TextureDataStruct& texture)
|
||||||
|
{
|
||||||
|
auto tt = std::make_shared<Texture>(texture);
|
||||||
|
npc.setTexture(meshName, tt);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef EMSCRIPTEN
|
#ifdef EMSCRIPTEN
|
||||||
const char* CONST_ZIP_FILE = "resources.zip";
|
const char* CONST_ZIP_FILE = "resources.zip";
|
||||||
#else
|
#else
|
||||||
|
|||||||
@ -11,7 +11,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <cfloat>
|
#include <cfloat>
|
||||||
#include "GameConstants.h"
|
#include "GameConstants.h"
|
||||||
|
#include "Character.h"
|
||||||
|
|
||||||
|
|
||||||
namespace ZL
|
namespace ZL
|
||||||
@ -91,7 +91,7 @@ namespace ZL
|
|||||||
std::cout << "Load resurces step 9" << std::endl;
|
std::cout << "Load resurces step 9" << std::endl;
|
||||||
|
|
||||||
// Load NPCs from JSON
|
// Load NPCs from JSON
|
||||||
npcs = GameObjectLoader::loadAndCreateNpcs("resources/config2/npcs.json", CONST_ZIP_FILE);
|
npcs = GameObjectLoader::loadAndCreate_Npcs("resources/config2/npcs.json", CONST_ZIP_FILE);
|
||||||
|
|
||||||
auto ghostTexture = std::make_shared<Texture>(CreateTextureDataFromPng("resources/w/ghost_skin001.png", CONST_ZIP_FILE));
|
auto ghostTexture = std::make_shared<Texture>(CreateTextureDataFromPng("resources/w/ghost_skin001.png", CONST_ZIP_FILE));
|
||||||
|
|
||||||
|
|||||||
@ -6,9 +6,12 @@
|
|||||||
#include "render/TextureManager.h"
|
#include "render/TextureManager.h"
|
||||||
#include "utils/Utils.h"
|
#include "utils/Utils.h"
|
||||||
#include <Eigen/Geometry>
|
#include <Eigen/Geometry>
|
||||||
|
#include "../Character.h"
|
||||||
namespace ZL {
|
namespace ZL {
|
||||||
|
|
||||||
|
void set_Texture(Character& npc, TextureDataStruct& texture);
|
||||||
|
void set_Texture(Character& npc, const std::string& meshName, TextureDataStruct& texture);
|
||||||
|
|
||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
std::vector<GameObjectData> GameObjectLoader::loadFromJson(const std::string& jsonPath, const std::string& zipPath)
|
std::vector<GameObjectData> GameObjectLoader::loadFromJson(const std::string& jsonPath, const std::string& zipPath)
|
||||||
@ -34,6 +37,7 @@ namespace ZL {
|
|||||||
throw std::runtime_error("Failed to load UI file: " + jsonPath);
|
throw std::runtime_error("Failed to load UI file: " + jsonPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
json j;
|
json j;
|
||||||
try {
|
try {
|
||||||
j = json::parse(content);
|
j = json::parse(content);
|
||||||
@ -340,6 +344,13 @@ namespace ZL {
|
|||||||
data.id = item.value("id", "npc_unknown");
|
data.id = item.value("id", "npc_unknown");
|
||||||
data.name = item.value("name", "Unknown NPC");
|
data.name = item.value("name", "Unknown NPC");
|
||||||
data.texturePath = item.value("texturePath", "");
|
data.texturePath = item.value("texturePath", "");
|
||||||
|
if (item.contains("meshTextures") && item["meshTextures"].is_object()) {
|
||||||
|
for (auto it = item["meshTextures"].begin(); it != item["meshTextures"].end(); ++it) {
|
||||||
|
if (it.value().is_string()) {
|
||||||
|
data.meshTextures[it.key()] = it.value().get<std::string>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
data.interactionRadius = item.value("interactionRadius", 0.0f);
|
data.interactionRadius = item.value("interactionRadius", 0.0f);
|
||||||
data.animationIdlePath = item.value("animationIdlePath", "");
|
data.animationIdlePath = item.value("animationIdlePath", "");
|
||||||
data.animationWalkPath = item.value("animationWalkPath", "");
|
data.animationWalkPath = item.value("animationWalkPath", "");
|
||||||
@ -378,7 +389,7 @@ namespace ZL {
|
|||||||
return npcs;
|
return npcs;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::unique_ptr<Character>> GameObjectLoader::loadAndCreateNpcs(
|
std::vector<std::unique_ptr<Character>> GameObjectLoader::loadAndCreate_Npcs(
|
||||||
const std::string& jsonPath,
|
const std::string& jsonPath,
|
||||||
const std::string& zipPath)
|
const std::string& zipPath)
|
||||||
{
|
{
|
||||||
@ -424,12 +435,32 @@ namespace ZL {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load texture
|
// Load textures: per-mesh map takes precedence; fall back to single texturePath.
|
||||||
try {
|
try {
|
||||||
auto texture = std::make_shared<Texture>(CreateTextureDataFromPng(npcData.texturePath, zipPath.c_str()));
|
if (!npcData.meshTextures.empty()) {
|
||||||
npc->setTexture(texture);
|
std::unordered_map<std::string, std::shared_ptr<Texture>> cache;
|
||||||
|
for (const auto& entry : npcData.meshTextures) {
|
||||||
|
const std::string& meshName = entry.first;
|
||||||
|
const std::string& path = entry.second;
|
||||||
|
/*auto cit = cache.find(path);
|
||||||
|
if (cit == cache.end()) {
|
||||||
|
auto tex = std::make_shared<Texture>(CreateTextureDataFromPng(path, zipPath.c_str()));
|
||||||
|
cit = cache.emplace(path, std::move(tex)).first;
|
||||||
|
std::cout << " Loaded texture: " << path << std::endl;
|
||||||
|
}*/
|
||||||
|
//npc->setTexture(meshName, std::make_shared<Texture>(CreateTextureDataFromPng(path, zipPath.c_str())));
|
||||||
|
set_Texture(*npc, meshName, CreateTextureDataFromPng(path, zipPath.c_str()));
|
||||||
|
//std::cout << xxa(*npc, CreateTextureDataFromPng(path, zipPath.c_str())) << std::endl;
|
||||||
|
std::cout << " -> mesh '" << meshName << "'" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//auto texture = std::make_shared<Texture>(CreateTextureDataFromPng(npcData.texturePath, zipPath.c_str()));
|
||||||
|
set_Texture(*npc, CreateTextureDataFromPng(npcData.texturePath, zipPath.c_str()));
|
||||||
|
//std::cout << xxa(*npc, CreateTextureDataFromPng(npcData.texturePath, zipPath.c_str())) << std::endl;
|
||||||
std::cout << " Loaded texture: " << npcData.texturePath << std::endl;
|
std::cout << " Loaded texture: " << npcData.texturePath << std::endl;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
std::cerr << "GameObjectLoader: Failed to load texture for '" << npcData.name << "': " << e.what() << std::endl;
|
std::cerr << "GameObjectLoader: Failed to load texture for '" << npcData.name << "': " << e.what() << std::endl;
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@ -3,15 +3,18 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <map>
|
||||||
#include "external/nlohmann/json.hpp"
|
#include "external/nlohmann/json.hpp"
|
||||||
#include "TextModel.h"
|
#include "TextModel.h"
|
||||||
#include "InteractiveObject.h"
|
#include "InteractiveObject.h"
|
||||||
#include "Character.h"
|
//#include "Character.h"
|
||||||
|
//#include "render/TextureManager.h"
|
||||||
|
|
||||||
namespace ZL {
|
namespace ZL {
|
||||||
|
|
||||||
struct Texture;
|
//struct Texture;
|
||||||
struct VertexRenderStruct;
|
//struct VertexRenderStruct;
|
||||||
class Renderer;
|
//class Renderer;
|
||||||
class Character;
|
class Character;
|
||||||
|
|
||||||
struct GameObjectData {
|
struct GameObjectData {
|
||||||
@ -45,6 +48,7 @@ namespace ZL {
|
|||||||
std::string id;
|
std::string id;
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string texturePath;
|
std::string texturePath;
|
||||||
|
std::map<std::string, std::string> meshTextures;
|
||||||
std::string animationIdlePath;
|
std::string animationIdlePath;
|
||||||
std::string animationWalkPath;
|
std::string animationWalkPath;
|
||||||
float positionX = 0.0f;
|
float positionX = 0.0f;
|
||||||
@ -82,7 +86,7 @@ namespace ZL {
|
|||||||
const std::string& zipPath = ""
|
const std::string& zipPath = ""
|
||||||
);
|
);
|
||||||
|
|
||||||
static std::vector<std::unique_ptr<Character>> loadAndCreateNpcs(
|
static std::vector<std::unique_ptr<ZL::Character>> loadAndCreate_Npcs(
|
||||||
const std::string& jsonPath,
|
const std::string& jsonPath,
|
||||||
const std::string& zipPath = ""
|
const std::string& zipPath = ""
|
||||||
);
|
);
|
||||||
@ -91,3 +95,4 @@ namespace ZL {
|
|||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ZL
|
} // namespace ZL
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user