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

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
 
AnimLatticeoperator= (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 AnimLatticefromModel (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.h41 行定义.

构造及析构函数说明

◆ AnimLattice() [1/3]

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

在文件 AnimLattice.cpp42 行定义.

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

引用了 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).

在文件 AnimLattice.cpp155 行定义.

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

被这些函数引用 bindModel().

◆ clearBind()

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

在文件 AnimLattice.cpp182 行定义.

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

引用了 i0, p, px , 以及 v.

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

引用了 i0, p, v, 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.cpp257 行定义.

引用了 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.

在文件 AnimLattice.cpp139 行定义.

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

◆ getBindPositionY()

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

在文件 AnimLattice.cpp193 行定义.

◆ getBindPositionZ()

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

在文件 AnimLattice.cpp197 行定义.

◆ getClamp()

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

在文件 AnimLattice.h78 行定义.

◆ getDeformedNormals()

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

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

在文件 AnimLattice.cpp370 行定义.

◆ getDeformedPositions()

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

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

在文件 AnimLattice.cpp366 行定义.

◆ getDeformedPositionX()

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

Cached deformed position component (requires updateDeformedPositions).

在文件 AnimLattice.cpp344 行定义.

◆ getDeformedPositionY()

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

在文件 AnimLattice.cpp351 行定义.

◆ getDeformedPositionZ()

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

在文件 AnimLattice.cpp358 行定义.

◆ getDivisionsX()

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

在文件 AnimLattice.h57 行定义.

◆ getDivisionsY()

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

在文件 AnimLattice.h58 行定义.

◆ getDivisionsZ()

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

在文件 AnimLattice.h59 行定义.

◆ getOriginX()

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

在文件 AnimLattice.h69 行定义.

◆ getOriginY()

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

在文件 AnimLattice.h70 行定义.

◆ getOriginZ()

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

在文件 AnimLattice.h71 行定义.

◆ getPointCount()

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

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

在文件 AnimLattice.h83 行定义.

◆ getPointOffsetX()

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

在文件 AnimLattice.cpp126 行定义.

◆ getPointOffsetY()

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

在文件 AnimLattice.cpp130 行定义.

◆ getPointOffsetZ()

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

在文件 AnimLattice.cpp134 行定义.

◆ getPointScaleX()

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

在文件 AnimLattice.cpp114 行定义.

◆ getPointScaleY()

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

在文件 AnimLattice.cpp118 行定义.

◆ getPointScaleZ()

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

在文件 AnimLattice.cpp122 行定义.

◆ getSizeX()

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

在文件 AnimLattice.h63 行定义.

◆ getSizeY()

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

在文件 AnimLattice.h64 行定义.

◆ getSizeZ()

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

在文件 AnimLattice.h65 行定义.

◆ getVertexCount()

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

在文件 AnimLattice.h118 行定义.

◆ hasDeformedNormals()

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

True after a successful updateDeformedNormals().

在文件 AnimLattice.h160 行定义.

◆ hasDeformedPositions()

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

True after a successful updateDeformedPositions().

在文件 AnimLattice.h157 行定义.

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

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

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

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

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

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

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

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

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

引用了 deformNormals().

◆ updateDeformedPositions() [1/2]

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

Deform the bound bind positions into the internal cache.

在文件 AnimLattice.cpp321 行定义.

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

引用了 deformPositions().

类成员变量说明

◆ kMinDivisions

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

在文件 AnimLattice.h43 行定义.

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


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