载入中...
搜索中...
未找到

CPU 3D lattice scale-deformer (晶格缩放变形). 更多...

#include <AnimLattice.h>

Public 成员函数

 AnimLattice ()
 Anim lattice.
 
 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
 Returns the divisions x.
 
int getDivisionsY () const
 Returns the divisions y.
 
int getDivisionsZ () const
 Returns the divisions z.
 
void setSize (float sx, float sy, float sz)
 World-space size of the lattice box (components must be > 0).
 
float getSizeX () const
 Returns the size x.
 
float getSizeY () const
 Returns the size y.
 
float getSizeZ () const
 Returns the size z.
 
void setOrigin (float ox, float oy, float oz)
 Center of the lattice box in model space.
 
float getOriginX () const
 Returns the origin x.
 
float getOriginY () const
 Returns the origin y.
 
float getOriginZ () const
 Returns the origin z.
 
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
 Returns the clamp.
 
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
 Returns the point scale x.
 
float getPointScaleY (int ix, int iy, int iz) const
 Returns the point scale y.
 
float getPointScaleZ (int ix, int iy, int iz) const
 Returns the point scale z.
 
float getPointOffsetX (int ix, int iy, int iz) const
 Returns the point offset x.
 
float getPointOffsetY (int ix, int iy, int iz) const
 Returns the point offset y.
 
float getPointOffsetZ (int ix, int iy, int iz) const
 Returns the point offset z.
 
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 ()
 Clears bind.
 
int getVertexCount () const
 Returns the vertex count.
 
float getBindPositionX (int vertexIndex) const
 Bind-pose position component for vertex v (0..vertexCount-1).
 
float getBindPositionY (int vertexIndex) const
 Returns the bind position y.
 
float getBindPositionZ (int vertexIndex) const
 Returns the bind position z.
 
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
 Returns the deformed position y.
 
float getDeformedPositionZ (int vertexIndex) const
 Returns the deformed position z.
 
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 第 42 行定义.

构造及析构函数说明

◆ AnimLattice() [1/3]

eve::animation::AnimLattice::AnimLattice ( )

Anim lattice.

在文件 AnimLattice.cpp 第 39 行定义.

引用了 kMinDivisions , 以及 setDivisions().

被这些函数引用 fromModel().

◆ AnimLattice() [2/3]

eve::animation::AnimLattice::AnimLattice ( int  divX,
int  divY,
int  divZ 
)
explicit

Creates a lattice with the given divisions (each >= 2).

在文件 AnimLattice.cpp 第 41 行定义.

引用了 setDivisions().

◆ AnimLattice() [3/3]

eve::animation::AnimLattice::AnimLattice ( const AnimLattice &  )
delete

成员函数说明

◆ bindModel()

void eve::animation::AnimLattice::bindModel ( const model3d::ModelData *  model,
int  meshIndex 
)

Binds the current lattice to meshIndex of model (uses current divisions).

在文件 AnimLatticeFromModel.cpp 第 27 行定义.

引用了 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 第 136 行定义.

引用了 count.

被这些函数引用 bindModel().

◆ clearBind()

void eve::animation::AnimLattice::clearBind ( )

Clears bind.

在文件 AnimLattice.cpp 第 149 行定义.

被这些函数引用 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 第 232 行定义.

引用了 count, i0, nx, ny, nz, p, px, py, pz, sx, sy, sz, v , 以及 weight.

被这些函数引用 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 第 179 行定义.

引用了 count, i0, ox, oy, p, sx, sy, sz, v, weight, x, y , 以及 z.

被这些函数引用 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 第 224 行定义.

引用了 count , 以及 deformPositions().

◆ fromModel()

AnimLattice * eve::animation::AnimLattice::fromModel ( const model3d::ModelData *  model,
int  meshIndex,
int  divX,
int  divY,
int  divZ 
)
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.

在文件 AnimLatticeFromModel.cpp 第 11 行定义.

引用了 AnimLattice(), mesh , 以及 model.

被这些函数引用 eve::animation::Animation::newLatticeFromModel().

◆ getBindPositionX()

float eve::animation::AnimLattice::getBindPositionX ( int  vertexIndex) const

Bind-pose position component for vertex v (0..vertexCount-1).

在文件 AnimLattice.cpp 第 156 行定义.

◆ getBindPositionY()

float eve::animation::AnimLattice::getBindPositionY ( int  vertexIndex) const

Returns the bind position y.

在文件 AnimLattice.cpp 第 160 行定义.

◆ getBindPositionZ()

float eve::animation::AnimLattice::getBindPositionZ ( int  vertexIndex) const

Returns the bind position z.

在文件 AnimLattice.cpp 第 164 行定义.

◆ getClamp()

bool eve::animation::AnimLattice::getClamp ( ) const
inline

Returns the clamp.

在文件 AnimLattice.h 第 90 行定义.

◆ getDeformedNormals()

std::vector< float > eve::animation::AnimLattice::getDeformedNormals ( ) const

Copy of the cached deformed normals (xyz packed; empty when not updated).

在文件 AnimLattice.cpp 第 337 行定义.

◆ getDeformedPositions()

std::vector< float > eve::animation::AnimLattice::getDeformedPositions ( ) const

Copy of the cached deformed positions (xyz packed; empty when not updated).

在文件 AnimLattice.cpp 第 333 行定义.

◆ getDeformedPositionX()

float eve::animation::AnimLattice::getDeformedPositionX ( int  vertexIndex) const

Cached deformed position component (requires updateDeformedPositions).

在文件 AnimLattice.cpp 第 311 行定义.

◆ getDeformedPositionY()

float eve::animation::AnimLattice::getDeformedPositionY ( int  vertexIndex) const

Returns the deformed position y.

在文件 AnimLattice.cpp 第 318 行定义.

◆ getDeformedPositionZ()

float eve::animation::AnimLattice::getDeformedPositionZ ( int  vertexIndex) const

Returns the deformed position z.

在文件 AnimLattice.cpp 第 325 行定义.

◆ getDivisionsX()

int eve::animation::AnimLattice::getDivisionsX ( ) const
inline

Returns the divisions x.

在文件 AnimLattice.h 第 60 行定义.

◆ getDivisionsY()

int eve::animation::AnimLattice::getDivisionsY ( ) const
inline

Returns the divisions y.

在文件 AnimLattice.h 第 62 行定义.

◆ getDivisionsZ()

int eve::animation::AnimLattice::getDivisionsZ ( ) const
inline

Returns the divisions z.

在文件 AnimLattice.h 第 64 行定义.

◆ getOriginX()

float eve::animation::AnimLattice::getOriginX ( ) const
inline

Returns the origin x.

在文件 AnimLattice.h 第 78 行定义.

◆ getOriginY()

float eve::animation::AnimLattice::getOriginY ( ) const
inline

Returns the origin y.

在文件 AnimLattice.h 第 80 行定义.

◆ getOriginZ()

float eve::animation::AnimLattice::getOriginZ ( ) const
inline

Returns the origin z.

在文件 AnimLattice.h 第 82 行定义.

◆ getPointCount()

int eve::animation::AnimLattice::getPointCount ( ) const
inline

Total control point count (divX * divY * divZ).

在文件 AnimLattice.h 第 95 行定义.

◆ getPointOffsetX()

float eve::animation::AnimLattice::getPointOffsetX ( int  ix,
int  iy,
int  iz 
) const

Returns the point offset x.

在文件 AnimLattice.cpp 第 123 行定义.

引用了 ox.

◆ getPointOffsetY()

float eve::animation::AnimLattice::getPointOffsetY ( int  ix,
int  iy,
int  iz 
) const

Returns the point offset y.

在文件 AnimLattice.cpp 第 127 行定义.

引用了 oy.

◆ getPointOffsetZ()

float eve::animation::AnimLattice::getPointOffsetZ ( int  ix,
int  iy,
int  iz 
) const

Returns the point offset z.

在文件 AnimLattice.cpp 第 131 行定义.

◆ getPointScaleX()

float eve::animation::AnimLattice::getPointScaleX ( int  ix,
int  iy,
int  iz 
) const

Returns the point scale x.

在文件 AnimLattice.cpp 第 111 行定义.

引用了 sx.

◆ getPointScaleY()

float eve::animation::AnimLattice::getPointScaleY ( int  ix,
int  iy,
int  iz 
) const

Returns the point scale y.

在文件 AnimLattice.cpp 第 115 行定义.

引用了 sy.

◆ getPointScaleZ()

float eve::animation::AnimLattice::getPointScaleZ ( int  ix,
int  iy,
int  iz 
) const

Returns the point scale z.

在文件 AnimLattice.cpp 第 119 行定义.

引用了 sz.

◆ getSizeX()

float eve::animation::AnimLattice::getSizeX ( ) const
inline

Returns the size x.

在文件 AnimLattice.h 第 69 行定义.

◆ getSizeY()

float eve::animation::AnimLattice::getSizeY ( ) const
inline

Returns the size y.

在文件 AnimLattice.h 第 71 行定义.

◆ getSizeZ()

float eve::animation::AnimLattice::getSizeZ ( ) const
inline

Returns the size z.

在文件 AnimLattice.h 第 73 行定义.

◆ getVertexCount()

int eve::animation::AnimLattice::getVertexCount ( ) const
inline

Returns the vertex count.

在文件 AnimLattice.h 第 138 行定义.

◆ hasDeformedNormals()

bool eve::animation::AnimLattice::hasDeformedNormals ( ) const
inline

True after a successful updateDeformedNormals().

在文件 AnimLattice.h 第 182 行定义.

◆ hasDeformedPositions()

bool eve::animation::AnimLattice::hasDeformedPositions ( ) const
inline

True after a successful updateDeformedPositions().

在文件 AnimLattice.h 第 179 行定义.

◆ operator=()

AnimLattice & eve::animation::AnimLattice::operator= ( const AnimLattice &  )
delete

◆ reset()

void eve::animation::AnimLattice::reset ( )

Resets every control point to identity (offset 0, scale 1).

在文件 AnimLattice.cpp 第 109 行定义.

◆ setClamp()

void eve::animation::AnimLattice::setClamp ( bool  clamp)
inline

When true (default), vertices outside the box are clamped to the boundary cells; when false, lattice coordinates extrapolate linearly.

在文件 AnimLattice.h 第 88 行定义.

◆ 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 第 43 行定义.

引用了 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 第 64 行定义.

引用了 ox , 以及 oy.

◆ setPointOffset()

void eve::animation::AnimLattice::setPointOffset ( int  ix,
int  iy,
int  iz,
float  dx,
float  dy,
float  dz 
)

Per-control-point translation offset (local bulge / pinch).

在文件 AnimLattice.cpp 第 93 行定义.

引用了 dx, dy, dz , 以及 p.

◆ 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 第 85 行定义.

引用了 p, sx, sy , 以及 sz.

◆ 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 第 101 行定义.

引用了 p, sx, sy , 以及 sz.

◆ 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 第 55 行定义.

引用了 sx, sy , 以及 sz.

◆ 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 第 296 行定义.

引用了 deformNormals().

◆ updateDeformedPositions() [1/2]

bool eve::animation::AnimLattice::updateDeformedPositions ( )

Deform the bound bind positions into the internal cache.

在文件 AnimLattice.cpp 第 288 行定义.

引用了 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 第 277 行定义.

引用了 deformPositions().

类成员变量说明

◆ kMinDivisions

constexpr int eve::animation::AnimLattice::kMinDivisions = 2
staticconstexpr

在文件 AnimLattice.h 第 44 行定义.

被这些函数引用 AnimLattice() , 以及 setDivisions().


该类的文档由以下文件生成: