update rigging

This commit is contained in:
MihailRis 2024-06-30 20:35:42 +03:00
parent d4460928e5
commit 50f9bd508a
6 changed files with 34 additions and 18 deletions

View File

@ -36,7 +36,7 @@ vn 1.0000 -0.0000 0.0000
vn -0.0000 -0.0000 1.0000 vn -0.0000 -0.0000 1.0000
vn -1.0000 -0.0000 -0.0000 vn -1.0000 -0.0000 -0.0000
vn 0.0000 0.0000 -1.0000 vn 0.0000 0.0000 -1.0000
usemtl blocks/lamp usemtl $0
s off s off
f 1/1/1 2/2/1 3/3/1 4/4/1 f 1/1/1 2/2/1 3/3/1 4/4/1
f 5/5/2 8/6/2 7/7/2 6/8/2 f 5/5/2 8/6/2 7/7/2 6/8/2

View File

@ -1,12 +0,0 @@
# Blender MTL File: 'None'
# Material Count: 1
newmtl Material
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

View File

@ -15,7 +15,7 @@ function on_fall()
end end
function on_trigger_enter(index, oid) function on_trigger_enter(index, oid)
if ready then if ready and oid == 0 then
entity:despawn() entity:despawn()
end end
end end

View File

@ -214,9 +214,11 @@ assetload::postfunc assetload::model(
auto model = obj::parse(path.u8string(), text).release(); auto model = obj::parse(path.u8string(), text).release();
return [=](Assets* assets) { return [=](Assets* assets) {
for (auto& mesh : model->meshes) { for (auto& mesh : model->meshes) {
if (mesh.texture.find('$') == std::string::npos) {
auto filename = TEXTURES_FOLDER+"/"+mesh.texture; auto filename = TEXTURES_FOLDER+"/"+mesh.texture;
loader->add(AssetType::texture, filename, mesh.texture, nullptr); loader->add(AssetType::texture, filename, mesh.texture, nullptr);
} }
}
assets->store(std::unique_ptr<model::Model>(model), name); assets->store(std::unique_ptr<model::Model>(model), name);
}; };
} catch (const parsing_error& err) { } catch (const parsing_error& err) {

10
src/objects/rigging.cpp Normal file
View File

@ -0,0 +1,10 @@
#include "rigging.hpp"
using namespace rigging;
RigNode::RigNode(size_t index, std::string name, std::vector<std::unique_ptr<RigNode>> subnodes)
: index(index), name(std::move(name)), subnodes(std::move(subnodes)) {
}
RigConfig::RigConfig(std::unique_ptr<RigNode> root) : root(std::move(root)) {
}

View File

@ -5,7 +5,9 @@
#include <vector> #include <vector>
#include <memory> #include <memory>
#include <string>
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <unordered_map>
namespace rigging { namespace rigging {
struct Rig; struct Rig;
@ -15,19 +17,33 @@ namespace rigging {
}; };
class RigNode { class RigNode {
uint index; size_t index;
std::string name;
std::vector<std::unique_ptr<RigNode>> subnodes; std::vector<std::unique_ptr<RigNode>> subnodes;
public: public:
RigNode(uint index); RigNode(size_t index, std::string name, std::vector<std::unique_ptr<RigNode>> subnodes);
size_t getIndex() const {
return index;
}
const auto& getSubnodes() const {
return subnodes;
}
}; };
class RigConfig { class RigConfig {
std::unique_ptr<RigNode> root; std::unique_ptr<RigNode> root;
std::unordered_map<std::string, size_t> indices;
std::vector<RigNode*> nodes;
public:
RigConfig(std::unique_ptr<RigNode> root);
}; };
struct Rig { struct Rig {
RigConfig* config; RigConfig* config;
Pose pose; Pose pose;
std::vector<std::string> textures;
}; };
}; };