CPU 3D lattice scale-deformer (晶格缩放变形). 更多...
#include <AnimLattice.h>
Public 成员函数 | |
| AnimLattice () | |
| AnimLattice (int divX, int divY, int divZ) | |
| Creates a lattice with the given divisions (each >= 2). | |
| AnimLattice (const AnimLattice &)=delete | |
| AnimLattice & | operator= (const AnimLattice &)=delete |
| void | setDivisions (int divX, int divY, int divZ) |
| Changes divisions; resets all control points to identity and clears the bind. | |
| int | getDivisionsX () const |
| int | getDivisionsY () const |
| int | getDivisionsZ () const |
| void | setSize (float sx, float sy, float sz) |
| World-space size of the lattice box (components must be > 0). | |
| float | getSizeX () const |
| float | getSizeY () const |
| float | getSizeZ () const |
| void | setOrigin (float ox, float oy, float oz) |
| Center of the lattice box in model space. | |
| float | getOriginX () const |
| float | getOriginY () const |
| float | getOriginZ () const |
| void | setClamp (bool clamp) |
| When true (default), vertices outside the box are clamped to the boundary cells; when false, lattice coordinates extrapolate linearly. | |
| bool | getClamp () const |
| int | getPointCount () const |
| Total control point count (divX * divY * divZ). | |
| void | setPointScale (int ix, int iy, int iz, float sx, float sy, float sz) |
| Per-control-point scale (squash / stretch about the lattice origin). | |
| void | setPointOffset (int ix, int iy, int iz, float dx, float dy, float dz) |
| Per-control-point translation offset (local bulge / pinch). | |
| void | setScale (float sx, float sy, float sz) |
| Applies one scale to every control point (whole-lattice squash & stretch). | |
| void | reset () |
| Resets every control point to identity (offset 0, scale 1). | |
| float | getPointScaleX (int ix, int iy, int iz) const |
| float | getPointScaleY (int ix, int iy, int iz) const |
| float | getPointScaleZ (int ix, int iy, int iz) const |
| float | getPointOffsetX (int ix, int iy, int iz) const |
| float | getPointOffsetY (int ix, int iy, int iz) const |
| float | getPointOffsetZ (int ix, int iy, int iz) const |
| void | bindModel (const model3d::ModelData *model, int meshIndex) |
| Binds the current lattice to meshIndex of model (uses current divisions). | |
| void | bindPositions (const float *posXYZ, int count) |
| Binds a packed xyz array (count * 3 floats). Uses current divisions/size/origin. | |
| void | clearBind () |
| int | getVertexCount () const |
| float | getBindPositionX (int vertexIndex) const |
| Bind-pose position component for vertex v (0..vertexCount-1). | |
| float | getBindPositionY (int vertexIndex) const |
| float | getBindPositionZ (int vertexIndex) const |
| void | deformPositions (const float *inPosXYZ, float *outPosXYZ, int count) const |
| Deforms count packed xyz positions into outPosXYZ. Both buffers must hold count * 3 floats; count must equal getVertexCount() when bound (unbound lattices still deform raw positions). | |
| bool | deformPositionsTo (const std::vector< float > &inPosXYZ, std::vector< float > &outPosXYZ) const |
| Convenience: deform into a vector sized count*3. | |
| bool | deformNormals (const float *posXYZ, const float *inNrmXYZ, float *outNrmXYZ, int count) const |
| Transforms normals with the interpolated scale field and renormalizes. posXYZ provides the (deformed) vertex positions used for the lattice-cell lookup; count must equal getVertexCount() when bound. | |
| bool | updateDeformedPositions (const std::vector< float > &inPosXYZ) |
| Deform an input packed xyz array into the internal cache (size vertexCount*3). | |
| bool | updateDeformedPositions () |
| Deform the bound bind positions into the internal cache. | |
| bool | updateDeformedNormals (const std::vector< float > &posXYZ, const std::vector< float > &inNrmXYZ) |
| Deform packed xyz normals (with packed positions for cell lookup) into the internal normal cache. | |
| bool | hasDeformedPositions () const |
| True after a successful updateDeformedPositions(). | |
| bool | hasDeformedNormals () const |
| True after a successful updateDeformedNormals(). | |
| float | getDeformedPositionX (int vertexIndex) const |
| Cached deformed position component (requires updateDeformedPositions). | |
| float | getDeformedPositionY (int vertexIndex) const |
| float | getDeformedPositionZ (int vertexIndex) const |
| std::vector< float > | getDeformedPositions () const |
| Copy of the cached deformed positions (xyz packed; empty when not updated). | |
| std::vector< float > | getDeformedNormals () const |
| Copy of the cached deformed normals (xyz packed; empty when not updated). | |
静态 Public 成员函数 | |
| 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 / empty mesh. Returned pointer is owned by the caller / script GC. | |
静态 Public 属性 | |
| static constexpr int | kMinDivisions = 2 |
详细描述
CPU 3D lattice scale-deformer (晶格缩放变形).
A lattice is a box of control points (divisions x/y/z, each >= 2). Every control point carries a scale and an offset; a bound vertex is deformed by trilinear interpolation of the eight surrounding control points:
p' = origin + offset(p) + scale(p) * (p - origin)
with scale(p) the interpolated diagonal scale and offset(p) the interpolated offsets. Defaults are identity (offset 0, scale 1), so the lattice is a no-op until control points are driven — perfect for procedural squash & stretch / local bulge animations driven per frame from scripts.
Vertices outside the box are clamped to the boundary cells by default (setClamp(false) switches to linear extrapolation).
Script type: AnimLattice (created via anim.newLattice(divX, divY, divZ)).
Typical frame (script): lat.setPointScale(3, 3, 3, 2.0, 1.0, 1.0); lat.updateDeformedPositions(); lat.updateDeformedNormalsFromArray(nrmArray); gfx.updateMeshVertices(mesh, lat.getDeformedPositions(), lat.getDeformedNormals(), [], vertexCount, [], 0);
Pipeline with skinning (C++): skinPositionsTo(pose, skinned) then deformPositions(skinned.data(), out.data(), vertexCount).
在文件 AnimLattice.h 第 41 行定义.
构造及析构函数说明
◆ AnimLattice() [1/3]
| eve::animation::AnimLattice::AnimLattice | ( | ) |
◆ AnimLattice() [2/3]
|
explicit |
Creates a lattice with the given divisions (each >= 2).
在文件 AnimLattice.cpp 第 44 行定义.
引用了 setDivisions().
◆ AnimLattice() [3/3]
|
delete |
成员函数说明
◆ bindModel()
| void eve::animation::AnimLattice::bindModel | ( | const model3d::ModelData * | model, |
| int | meshIndex | ||
| ) |
Binds the current lattice to meshIndex of model (uses current divisions).
在文件 AnimLattice.cpp 第 155 行定义.
引用了 bindPositions(), mesh , 以及 model.
◆ bindPositions()
| void eve::animation::AnimLattice::bindPositions | ( | const float * | posXYZ, |
| int | count | ||
| ) |
Binds a packed xyz array (count * 3 floats). Uses current divisions/size/origin.
在文件 AnimLattice.cpp 第 169 行定义.
被这些函数引用 bindModel().
◆ clearBind()
| void eve::animation::AnimLattice::clearBind | ( | ) |
在文件 AnimLattice.cpp 第 182 行定义.
被这些函数引用 setDivisions().
◆ deformNormals()
| bool eve::animation::AnimLattice::deformNormals | ( | const float * | posXYZ, |
| const float * | inNrmXYZ, | ||
| float * | outNrmXYZ, | ||
| int | count | ||
| ) | const |
Transforms normals with the interpolated scale field and renormalizes. posXYZ provides the (deformed) vertex positions used for the lattice-cell lookup; count must equal getVertexCount() when bound.
在文件 AnimLattice.cpp 第 265 行定义.
被这些函数引用 updateDeformedNormals().
◆ deformPositions()
| void eve::animation::AnimLattice::deformPositions | ( | const float * | inPosXYZ, |
| float * | outPosXYZ, | ||
| int | count | ||
| ) | const |
Deforms count packed xyz positions into outPosXYZ. Both buffers must hold count * 3 floats; count must equal getVertexCount() when bound (unbound lattices still deform raw positions).
在文件 AnimLattice.cpp 第 212 行定义.
被这些函数引用 deformPositionsTo() , 以及 updateDeformedPositions().
◆ deformPositionsTo()
| bool eve::animation::AnimLattice::deformPositionsTo | ( | const std::vector< float > & | inPosXYZ, |
| std::vector< float > & | outPosXYZ | ||
| ) | const |
Convenience: deform into a vector sized count*3.
在文件 AnimLattice.cpp 第 257 行定义.
引用了 deformPositions().
◆ fromModel()
|
static |
Builds a lattice bound to meshIndex of model (Assimp vertices). Throws on null model / invalid mesh / empty mesh. Returned pointer is owned by the caller / script GC.
在文件 AnimLattice.cpp 第 139 行定义.
引用了 AnimLattice(), mesh , 以及 model.
◆ getBindPositionX()
| float eve::animation::AnimLattice::getBindPositionX | ( | int | vertexIndex | ) | const |
Bind-pose position component for vertex v (0..vertexCount-1).
在文件 AnimLattice.cpp 第 189 行定义.
◆ getBindPositionY()
| float eve::animation::AnimLattice::getBindPositionY | ( | int | vertexIndex | ) | const |
在文件 AnimLattice.cpp 第 193 行定义.
◆ getBindPositionZ()
| float eve::animation::AnimLattice::getBindPositionZ | ( | int | vertexIndex | ) | const |
在文件 AnimLattice.cpp 第 197 行定义.
◆ getClamp()
|
inline |
在文件 AnimLattice.h 第 78 行定义.
◆ getDeformedNormals()
| std::vector< float > eve::animation::AnimLattice::getDeformedNormals | ( | ) | const |
Copy of the cached deformed normals (xyz packed; empty when not updated).
在文件 AnimLattice.cpp 第 370 行定义.
◆ getDeformedPositions()
| std::vector< float > eve::animation::AnimLattice::getDeformedPositions | ( | ) | const |
Copy of the cached deformed positions (xyz packed; empty when not updated).
在文件 AnimLattice.cpp 第 366 行定义.
◆ getDeformedPositionX()
| float eve::animation::AnimLattice::getDeformedPositionX | ( | int | vertexIndex | ) | const |
Cached deformed position component (requires updateDeformedPositions).
在文件 AnimLattice.cpp 第 344 行定义.
◆ getDeformedPositionY()
| float eve::animation::AnimLattice::getDeformedPositionY | ( | int | vertexIndex | ) | const |
在文件 AnimLattice.cpp 第 351 行定义.
◆ getDeformedPositionZ()
| float eve::animation::AnimLattice::getDeformedPositionZ | ( | int | vertexIndex | ) | const |
在文件 AnimLattice.cpp 第 358 行定义.
◆ getDivisionsX()
|
inline |
在文件 AnimLattice.h 第 57 行定义.
◆ getDivisionsY()
|
inline |
在文件 AnimLattice.h 第 58 行定义.
◆ getDivisionsZ()
|
inline |
在文件 AnimLattice.h 第 59 行定义.
◆ getOriginX()
|
inline |
在文件 AnimLattice.h 第 69 行定义.
◆ getOriginY()
|
inline |
在文件 AnimLattice.h 第 70 行定义.
◆ getOriginZ()
|
inline |
在文件 AnimLattice.h 第 71 行定义.
◆ getPointCount()
|
inline |
Total control point count (divX * divY * divZ).
在文件 AnimLattice.h 第 83 行定义.
◆ getPointOffsetX()
| float eve::animation::AnimLattice::getPointOffsetX | ( | int | ix, |
| int | iy, | ||
| int | iz | ||
| ) | const |
在文件 AnimLattice.cpp 第 126 行定义.
◆ getPointOffsetY()
| float eve::animation::AnimLattice::getPointOffsetY | ( | int | ix, |
| int | iy, | ||
| int | iz | ||
| ) | const |
在文件 AnimLattice.cpp 第 130 行定义.
◆ getPointOffsetZ()
| float eve::animation::AnimLattice::getPointOffsetZ | ( | int | ix, |
| int | iy, | ||
| int | iz | ||
| ) | const |
在文件 AnimLattice.cpp 第 134 行定义.
◆ getPointScaleX()
| float eve::animation::AnimLattice::getPointScaleX | ( | int | ix, |
| int | iy, | ||
| int | iz | ||
| ) | const |
在文件 AnimLattice.cpp 第 114 行定义.
◆ getPointScaleY()
| float eve::animation::AnimLattice::getPointScaleY | ( | int | ix, |
| int | iy, | ||
| int | iz | ||
| ) | const |
在文件 AnimLattice.cpp 第 118 行定义.
◆ getPointScaleZ()
| float eve::animation::AnimLattice::getPointScaleZ | ( | int | ix, |
| int | iy, | ||
| int | iz | ||
| ) | const |
在文件 AnimLattice.cpp 第 122 行定义.
◆ getSizeX()
|
inline |
在文件 AnimLattice.h 第 63 行定义.
◆ getSizeY()
|
inline |
在文件 AnimLattice.h 第 64 行定义.
◆ getSizeZ()
|
inline |
在文件 AnimLattice.h 第 65 行定义.
◆ getVertexCount()
|
inline |
在文件 AnimLattice.h 第 118 行定义.
◆ hasDeformedNormals()
|
inline |
True after a successful updateDeformedNormals().
在文件 AnimLattice.h 第 160 行定义.
◆ hasDeformedPositions()
|
inline |
True after a successful updateDeformedPositions().
在文件 AnimLattice.h 第 157 行定义.
◆ operator=()
|
delete |
◆ reset()
| void eve::animation::AnimLattice::reset | ( | ) |
Resets every control point to identity (offset 0, scale 1).
在文件 AnimLattice.cpp 第 112 行定义.
◆ setClamp()
|
inline |
When true (default), vertices outside the box are clamped to the boundary cells; when false, lattice coordinates extrapolate linearly.
在文件 AnimLattice.h 第 77 行定义.
◆ setDivisions()
| void eve::animation::AnimLattice::setDivisions | ( | int | divX, |
| int | divY, | ||
| int | divZ | ||
| ) |
Changes divisions; resets all control points to identity and clears the bind.
在文件 AnimLattice.cpp 第 46 行定义.
引用了 clearBind() , 以及 kMinDivisions.
被这些函数引用 AnimLattice() , 以及 AnimLattice().
◆ setOrigin()
| void eve::animation::AnimLattice::setOrigin | ( | float | ox, |
| float | oy, | ||
| float | oz | ||
| ) |
Center of the lattice box in model space.
在文件 AnimLattice.cpp 第 67 行定义.
◆ setPointOffset()
| void eve::animation::AnimLattice::setPointOffset | ( | int | ix, |
| int | iy, | ||
| int | iz, | ||
| float | dx, | ||
| float | dy, | ||
| float | dz | ||
| ) |
◆ setPointScale()
| void eve::animation::AnimLattice::setPointScale | ( | int | ix, |
| int | iy, | ||
| int | iz, | ||
| float | sx, | ||
| float | sy, | ||
| float | sz | ||
| ) |
Per-control-point scale (squash / stretch about the lattice origin).
在文件 AnimLattice.cpp 第 88 行定义.
引用了 p.
◆ setScale()
| void eve::animation::AnimLattice::setScale | ( | float | sx, |
| float | sy, | ||
| float | sz | ||
| ) |
Applies one scale to every control point (whole-lattice squash & stretch).
在文件 AnimLattice.cpp 第 104 行定义.
引用了 p.
◆ setSize()
| void eve::animation::AnimLattice::setSize | ( | float | sx, |
| float | sy, | ||
| float | sz | ||
| ) |
World-space size of the lattice box (components must be > 0).
在文件 AnimLattice.cpp 第 58 行定义.
◆ updateDeformedNormals()
| bool eve::animation::AnimLattice::updateDeformedNormals | ( | const std::vector< float > & | posXYZ, |
| const std::vector< float > & | inNrmXYZ | ||
| ) |
Deform packed xyz normals (with packed positions for cell lookup) into the internal normal cache.
在文件 AnimLattice.cpp 第 329 行定义.
引用了 deformNormals().
◆ updateDeformedPositions() [1/2]
| bool eve::animation::AnimLattice::updateDeformedPositions | ( | ) |
Deform the bound bind positions into the internal cache.
在文件 AnimLattice.cpp 第 321 行定义.
引用了 updateDeformedPositions().
被这些函数引用 updateDeformedPositions().
◆ updateDeformedPositions() [2/2]
| bool eve::animation::AnimLattice::updateDeformedPositions | ( | const std::vector< float > & | inPosXYZ | ) |
Deform an input packed xyz array into the internal cache (size vertexCount*3).
在文件 AnimLattice.cpp 第 310 行定义.
引用了 deformPositions().
类成员变量说明
◆ kMinDivisions
|
staticconstexpr |
在文件 AnimLattice.h 第 43 行定义.
被这些函数引用 AnimLattice() , 以及 setDivisions().
该类的文档由以下文件生成:
- src/modules/animation/AnimLattice.h
- src/modules/animation/AnimLattice.cpp