载入中...
搜索中...
未找到
Model3D.cpp
浏览该文件的文档.
64medialoader::ModelScene loadOrThrow(medialoader::ModelLoader &loader, const void *data, size_t size,
145eve::Result<void> Model3D::requestModelData(const std::string &path, const ModelLoadOptions &options) {
151 eve::DiagnosticCode::Unsupported, "Model prefetch requires the thread executor", "model3d.prefetch"));
154 eve::DiagnosticCode::Unsupported, "Initialize Filesystem on the game thread before model prefetch",
185 eve::DiagnosticCode::InvalidArgument, "model and renderable are required", "model3d.foliage-deformation"));
315 if (!value || !value.value().isObject()) throw eve::Exception("Expected model decode options table");
337 [vm = cls.getHandle(), parseOptions](Model3D *self, const std::string &path, ssq::Object object) {
346 cls.addFunc("loadModelDataWithOptions", [vm = cls.getHandle(), parseOptions](Model3D *self, const std::string &path,
362 cls.addFunc("requestModelData", [vm = cls.getHandle()](Model3D *self, const std::string &path) {
371 cls.addFunc("prepareFoliageDeformation", [vm = cls.getHandle()](Model3D *self, ModelData *model, int meshIndex,
373 return script::projectResult(vm, self->prepareFoliageDeformation(model, meshIndex, renderable));
Capability for submitting CPU work onto a worker pool.
The single Squirrel projection for common Result, Status and Value.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
eve::Result< void > request(std::string key)
Queue a cache miss load without blocking for decode to finish.
Definition Resource.cpp:149
Resource * get(std::string key)
Get the cached resource for key; on a miss, load it through the registered IAssetReloader providers a...
Definition Resource.cpp:141
Resource is a game object that is managed by the ResourceManager. It can be loaded from a file or gen...
Definition Resource.h:51
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
static Status failure(StatusCode code, Diagnostic diagnostic)
Construct a failed status with one diagnostic.
Definition Status.h:84
static Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.h:81
Data buffer paired with a filename (used for type identification).
Definition FileData.h:14
virtual void write(std::string filename, const void *data, int64_t size) const =0
Write data to a file.
virtual FileData * read(std::string filename, int64_t size=File::ALL) const =0
Reads data from a file.
Definition Graphics.h:125
medialoader::FileSystem adapter over eve::filesystem (physfs / VFS).
Definition EveFileSystem.h:13
Resource module for decoding 3D models via medialoader (Assimp). Produces ModelData; GPU upload is gr...
Definition Model3D.h:43
ModelData * newModelData(Data *data, std::string hintExt="")
Decode model from in-memory bytes.
Definition Model3D.cpp:89
graphics::Renderable3D * createRenderable(graphics::Graphics *gfx, ModelData *model, int meshIndex)
Creates renderable.
Definition Model3D.cpp:172
ModelData * newModelDataFromFile(std::string path)
Decode model from a VFS path (physfs). Uses EveFileSystem so sidecar files (.mtl, textures) resolve t...
Definition Model3D.cpp:137
bool bakeModel(const std::string &sourcePath, const std::string &destinationPath)
Pack a self-contained source model (normally GLB or embedded FBX) into EVEngine's deterministic ....
Definition Model3D.cpp:189
eve::Result< void > prepareFoliageDeformation(ModelData *model, int meshIndex, graphics::Renderable3D *renderable)
Prepare one default-imported renderable for native PBR vegetation motion.
Definition Model3D.cpp:181
eve::Result< void > requestModelData(const std::string &path)
Queue default-option model decoding on the engine resource worker pool.
Definition Model3D.cpp:141
CPU-side decoded 3D model (Assimp scene owned via medialoader::ModelScene). Does not upload to GPU — ...
Definition ModelData.h:39
float getMaterialAlphaCutoff(int matIndex) const
Returns the material alpha cutoff.
Definition ModelData.cpp:366
float getMaterialBaseColorR(int matIndex) const
Base color: glTF BASE_COLOR, falling back to OBJ/legacy DIFFUSE.
Definition ModelData.cpp:302
float getMaterialMetallicFactor(int matIndex) const
PBR factors; defaults 0 (metallic) / 0.45 (roughness) when absent.
Definition ModelData.cpp:318
float getMaterialBaseColorB(int matIndex) const
Returns the material base color b.
Definition ModelData.cpp:310
float getMaterialBaseColorG(int matIndex) const
Returns the material base color g.
Definition ModelData.cpp:306
float getVertexPosition(int meshIndex, int vertexIndex, int component) const
Source position component for one vertex (component 0=x, 1=y, 2=z).
Definition ModelData.cpp:152
std::string getMaterialAlphaMode(int matIndex) const
glTF alpha mode normalized to "OPAQUE", "MASK", or "BLEND".
Definition ModelData.cpp:354
bool hasVertexColorChannel(int meshIndex, int channel) const
Whether a mesh has the requested vertex-color channel.
Definition ModelData.cpp:268
float getVertexColor(int meshIndex, int channel, int vertexIndex, int component) const
RGBA component (0..3) in a vertex-color channel.
Definition ModelData.cpp:275
int getEmbeddedTextureHeight(int idx) const
0 means a compressed blob (use getEmbeddedTextureImageData to decode).
Definition ModelData.cpp:422
int getBoneWeightCount(int meshIndex, int boneIndex) const
Returns the bone weight count.
Definition ModelData.cpp:522
float getTexCoord(int meshIndex, int channel, int vertexIndex, int component) const
UV component in channel for vertex (component 0=u, 1=v, 2=w).
Definition ModelData.cpp:142
float getMaterialOpacity(int matIndex) const
Returns the material opacity.
Definition ModelData.cpp:336
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.
Definition ModelData.cpp:382
int getMaterialTextureSlotCount(int matIndex, const std::string &type) const
Texture type names (Squirrel strings): "base_color", "diffuse", "normals", "height",...
Definition ModelData.cpp:374
float getInverseBindMatrixElement(int meshIndex, int boneIndex, int elementIndex) const
Inverse-bind (offset) matrix element, column-major, elementIndex in [0,15].
Definition ModelData.cpp:497
std::string getMaterialName(int matIndex) const
Returns the material name.
Definition ModelData.cpp:293
float getTangent(int meshIndex, int vertexIndex, int component) const
Tangent XYZ component for a vertex.
Definition ModelData.cpp:244
int getEmbeddedTextureWidth(int idx) const
Returns the embedded texture width.
Definition ModelData.cpp:415
bool getMaterialTwoSided(int matIndex) const
Returns the material two sided.
Definition ModelData.cpp:345
bool hasTangents(int meshIndex) const
Whether imported tangent and bitangent streams exist.
Definition ModelData.cpp:238
int getTexCoordChannelCount(int meshIndex) const
Number of populated UV channels (0..AI_MAX_NUMBER_OF_TEXTURECOORDS).
Definition ModelData.cpp:129
float getBitangent(int meshIndex, int vertexIndex, int component) const
Bitangent XYZ component for a vertex.
Definition ModelData.cpp:253
float getVertexNormal(int meshIndex, int vertexIndex, int component) const
Source normal component for one vertex (component 0=x, 1=y, 2=z).
Definition ModelData.cpp:161
float getMaterialBaseColorA(int matIndex) const
Returns the material base color a.
Definition ModelData.cpp:314
bool hasTexCoordChannel(int meshIndex, int channel) const
Whether a mesh has the requested UV channel.
Definition ModelData.cpp:135
float getBoneWeightValue(int meshIndex, int boneIndex, int weightIndex) const
Returns the bone weight value.
Definition ModelData.cpp:540
std::string getMorphTargetName(int meshIndex, int morphIndex) const
Returns the morph target name.
Definition ModelData.cpp:463
std::string getAnimationName(int animIndex) const
Returns the animation name.
Definition ModelData.cpp:555
int getVertexColorChannelCount(int meshIndex) const
Number of populated vertex-color channels.
Definition ModelData.cpp:262
int getBoneWeightVertex(int meshIndex, int boneIndex, int weightIndex) const
Returns the bone weight vertex.
Definition ModelData.cpp:530
image::ImageData * getEmbeddedTextureImageData(int idx) const
Returns the embedded texture image data.
Definition ModelData.cpp:429
int getMaterialIndex(int meshIndex) const
Assimp material slot referenced by a mesh; -1 when invalid.
Definition ModelData.cpp:288
int getMaterialTextureEmbeddedIndex(int matIndex, const std::string &type, int slot=0) const
Scene texture index for embedded "*N" references; -1 for external files.
Definition ModelData.cpp:394
float getMaterialRoughnessFactor(int matIndex) const
Returns the material roughness factor.
Definition ModelData.cpp:327
bool hasBones(int meshIndex) const
Assimp skeletal skin data (aiBone / vertex weights) on a mesh.
Definition ModelData.cpp:474
int getFaceVertexIndex(int meshIndex, int triangleIndex, int corner) const
Source vertex index for one triangle corner (corner 0..2).
Definition ModelData.cpp:170
std::string getBoneName(int meshIndex, int boneIndex) const
Returns the bone name.
Definition ModelData.cpp:488
std::string getEmbeddedTextureName(int idx) const
Returns the embedded texture name.
Definition ModelData.cpp:406
int getMorphTargetCount(int meshIndex) const
Assimp morph / blend-shape targets on a mesh (aiAnimMesh).
Definition ModelData.cpp:457
Result< void > prepareFoliageDeformation(ModelData &model, int meshIndex, Renderable3D &renderable)
Definition ModelRenderer.cpp:423
std::string modelCacheKey(const std::string &path, const ModelLoadOptions &options)
Build a deterministic ResourceManager cache key for path + options.
Definition ModelLoader.cpp:147
Renderable3D * buildRenderable(IResourceFactory &gfx, ModelData *model, int meshIndex, const ModelRenderOptions &options)
Definition ModelRenderer.cpp:397
const EditorValue * field(const EditorValue &value, const char *name)
Definition RoadNetworkEditTarget.cpp:15
void markResultHasValue(ssq::Table &result)
Declare that a projected table received a payload the caller attached itself.
Definition SquirrelBinding.cpp:468
std::unique_ptr< T > Owned
C++ owning storage used by an object factory.
Definition RuntimeRegistry.h:33
ssq::Table projectStatusResult(HSQUIRRELVM vm, const Status &status)
Project a checked native status that carries no payload.
Definition SquirrelBinding.cpp:454
ssq::Table projectResult(HSQUIRRELVM vm, Result< void > &&result)
Consume and project a void native Result using the common schema.
Definition SquirrelBinding.cpp:470
Result< Value > valueFromSquirrel(HSQUIRRELVM vm, SQInteger index, const SquirrelValueOptions &options)
Convert one Squirrel value into the canonical owning Value tree.
Definition SquirrelBinding.cpp:342
@ InvalidArgument
@ Unsupported
@ Failed
Definition Container.h:602
Toggles for the Assimp post-processing steps applied by medialoader on decode. All default to on (mat...
Definition Model3D.h:30