载入中...
搜索中...
未找到
ModelData.h
浏览该文件的文档.
1#pragma once
2
3#include "common/Resource.h"
4
5#include "medialoader/model/ModelScene.h"
6
7#include <string>
8
9struct aiMesh;
10struct aiScene;
11struct aiMaterial;
12
13namespace eve {
14namespace image {
15class ImageData;
16}
17namespace model3d {
18
23class ModelData : public Resource {
24public:
25 explicit ModelData(medialoader::ModelScene scene, std::string uri = "");
26 ~ModelData() override;
27
28 bool empty() const;
29 int getMeshCount() const;
30 int getMaterialCount() const;
31 int getVertexCount(int meshIndex) const;
32 int getFaceCount(int meshIndex) const;
33 bool hasNormals(int meshIndex) const;
34 bool hasTexCoords(int meshIndex) const;
35
36 // ---- material accessors ----
38 int getMaterialIndex(int meshIndex) const;
39 std::string getMaterialName(int matIndex) const;
41 float getMaterialBaseColorR(int matIndex) const;
42 float getMaterialBaseColorG(int matIndex) const;
43 float getMaterialBaseColorB(int matIndex) const;
44 float getMaterialBaseColorA(int matIndex) const;
46 float getMaterialMetallicFactor(int matIndex) const;
47 float getMaterialRoughnessFactor(int matIndex) const;
48 float getMaterialOpacity(int matIndex) const;
49 bool getMaterialTwoSided(int matIndex) const;
50
56 int getMaterialTextureSlotCount(int matIndex, const std::string &type) const;
58 std::string getMaterialTexturePath(int matIndex, const std::string &type, int slot = 0) const;
60 int getMaterialTextureEmbeddedIndex(int matIndex, const std::string &type, int slot = 0) const;
61
62 // ---- embedded textures (glTF / FBX can embed PNG/JPEG blobs) ----
63 int getEmbeddedTextureCount() const;
64 std::string getEmbeddedTextureName(int idx) const;
65 int getEmbeddedTextureWidth(int idx) const;
67 int getEmbeddedTextureHeight(int idx) const;
74
76 int getMorphTargetCount(int meshIndex) const;
77 std::string getMorphTargetName(int meshIndex, int morphIndex) const;
78
80 bool hasBones(int meshIndex) const;
81 int getBoneCount(int meshIndex) const;
82 std::string getBoneName(int meshIndex, int boneIndex) const;
84 float getInverseBindMatrixElement(int meshIndex, int boneIndex, int elementIndex) const;
85 int getBoneWeightCount(int meshIndex, int boneIndex) const;
86 int getBoneWeightVertex(int meshIndex, int boneIndex, int weightIndex) const;
87 float getBoneWeightValue(int meshIndex, int boneIndex, int weightIndex) const;
88
90 int getAnimationCount() const;
91 std::string getAnimationName(int animIndex) const;
92
93 const aiScene *getScene() const;
94 const aiMesh *getMesh(int meshIndex) const;
95
97 void adopt(eve::Resource &replacement) override;
98
99private:
100 const aiMesh *meshAt(int meshIndex) const;
101 const aiMaterial *materialAt(int matIndex) const;
102
103 medialoader::ModelScene scene;
104};
105
106} // namespace model3d
107} // namespace eve
std::string type
int idx
std::string image
Resource is a game object that is managed by the ResourceManager. It can be loaded from a file or gen...
Definition Resource.h:35
std::string uri
Definition Resource.h:62
Represents raw pixel data.
Definition ImageData.h:26
CPU-side decoded 3D model (Assimp scene owned via medialoader::ModelScene). Does not upload to GPU — ...
Definition ModelData.h:23
int getEmbeddedTextureCount() const
float getMaterialBaseColorR(int matIndex) const
Base color: glTF BASE_COLOR, falling back to OBJ/legacy DIFFUSE.
float getMaterialMetallicFactor(int matIndex) const
PBR factors; defaults 0 (metallic) / 0.45 (roughness) when absent.
float getMaterialBaseColorB(int matIndex) const
float getMaterialBaseColorG(int matIndex) const
int getFaceCount(int meshIndex) const
bool hasNormals(int meshIndex) const
int getEmbeddedTextureHeight(int idx) const
0 means a compressed blob (use getEmbeddedTextureImageData to decode).
int getBoneCount(int meshIndex) const
int getBoneWeightCount(int meshIndex, int boneIndex) const
float getMaterialOpacity(int matIndex) const
std::string getMaterialTexturePath(int matIndex, const std::string &type, int slot=0) const
External file path, or "*N" for an embedded texture. Empty when absent.
int getMaterialTextureSlotCount(int matIndex, const std::string &type) const
Texture type names (Squirrel strings): "base_color", "diffuse", "normals", "height",...
float getInverseBindMatrixElement(int meshIndex, int boneIndex, int elementIndex) const
Inverse-bind (offset) matrix element, column-major, elementIndex in [0,15].
std::string getMaterialName(int matIndex) const
int getEmbeddedTextureWidth(int idx) const
bool getMaterialTwoSided(int matIndex) const
int getAnimationCount() const
Scene-level animation clips (aiAnimation).
float getMaterialBaseColorA(int matIndex) const
const aiScene * getScene() const
Definition ModelData.cpp:65
float getBoneWeightValue(int meshIndex, int boneIndex, int weightIndex) const
std::string getMorphTargetName(int meshIndex, int morphIndex) const
std::string getAnimationName(int animIndex) const
bool hasTexCoords(int meshIndex) const
int getBoneWeightVertex(int meshIndex, int boneIndex, int weightIndex) const
image::ImageData * getEmbeddedTextureImageData(int idx) const
int getMaterialCount() const
Definition ModelData.cpp:92
int getMaterialIndex(int meshIndex) const
Assimp material slot referenced by a mesh; -1 when invalid.
int getMaterialTextureEmbeddedIndex(int matIndex, const std::string &type, int slot=0) const
Scene texture index for embedded "*N" references; -1 for external files.
float getMaterialRoughnessFactor(int matIndex) const
bool hasBones(int meshIndex) const
Assimp skeletal skin data (aiBone / vertex weights) on a mesh.
const aiMesh * getMesh(int meshIndex) const
Definition ModelData.cpp:85
std::string getBoneName(int meshIndex, int boneIndex) const
int getVertexCount(int meshIndex) const
Definition ModelData.cpp:97
void adopt(eve::Resource &replacement) override
Replace this scene with replacement's (cache reload).
Definition ModelData.cpp:58
std::string getEmbeddedTextureName(int idx) const
int getMorphTargetCount(int meshIndex) const
Assimp morph / blend-shape targets on a mesh (aiAnimMesh).
Definition Build.cpp:11