载入中...
搜索中...
未找到
AnimLatticeFromModel.cpp
浏览该文件的文档.
2
3#include "common/Exception.h"
4#include "model3d/ModelData.h"
5
6#include <assimp/mesh.h>
7#include <assimp/scene.h>
8
9namespace eve::animation {
10
11AnimLattice* AnimLattice::fromModel(const model3d::ModelData* model, int meshIndex, int divX, int divY, int divZ) {
12 if (!model) {
13 throw Exception("AnimLattice.fromModel: null model");
14 }
15 const aiMesh* mesh = model->getMesh(meshIndex);
16 if (!mesh) {
17 throw Exception("AnimLattice.fromModel: invalid mesh index %d", meshIndex);
18 }
19 if (mesh->mNumVertices == 0 || !mesh->mVertices) {
20 throw Exception("AnimLattice.fromModel: mesh %d has no vertices", meshIndex);
21 }
22 auto* lattice = new AnimLattice(divX, divY, divZ);
23 lattice->bindPositions(reinterpret_cast<const float*>(mesh->mVertices), static_cast<int>(mesh->mNumVertices));
24 return lattice;
25}
26
27void AnimLattice::bindModel(const model3d::ModelData* model, int meshIndex) {
28 if (!model) {
29 throw Exception("AnimLattice.bindModel: null model");
30 }
31 const aiMesh* mesh = model->getMesh(meshIndex);
32 if (!mesh) {
33 throw Exception("AnimLattice.bindModel: invalid mesh index %d", meshIndex);
34 }
35 if (mesh->mNumVertices == 0 || !mesh->mVertices) {
36 throw Exception("AnimLattice.bindModel: mesh %d has no vertices", meshIndex);
37 }
38 bindPositions(reinterpret_cast<const float*>(mesh->mVertices), static_cast<int>(mesh->mNumVertices));
39}
40
41} // namespace eve::animation
Mesh * mesh
glm::mat4 model
EVENGINE_API_FOUNDATION public API.
Definition Exception.h:13
CPU 3D lattice scale-deformer (晶格缩放变形).
Definition AnimLattice.h:42
void bindModel(const model3d::ModelData *model, int meshIndex)
Binds the current lattice to meshIndex of model (uses current divisions).
static AnimLattice * fromModel(const model3d::ModelData *model, int meshIndex, int divX, int divY, int divZ)
Builds a lattice bound to meshIndex of model (Assimp vertices). Throws on null model / invalid mesh /...
void bindPositions(const float *posXYZ, int count)
Binds a packed xyz array (count * 3 floats). Uses current divisions/size/origin.
CPU-side decoded 3D model (Assimp scene owned via medialoader::ModelScene). Does not upload to GPU — ...
Definition ModelData.h:39