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

CPU linear-blend skinning binding for one mesh against an AnimSkeleton. 更多...

#include <AnimSkin.h>

Public 成员函数

 AnimSkin ()=default
 Anim skin.
 
 ~AnimSkin ()=default
 Anim skin.
 
 AnimSkin (const AnimSkin &)=delete
 
AnimSkin & operator= (const AnimSkin &)=delete
 
int getVertexCount () const
 
int getBoneCount () const
 Returns the bone count.
 
int getInfluenceCount () const
 Returns the influence count.
 
int getSkeletonBone (int skinBoneIndex) const
 Skeleton bone index used by skin joint i (-1 if unused).
 
std::string getSkinBoneName (int skinBoneIndex) const
 Returns the skin bone name.
 
float getInverseBindElement (int skinBoneIndex, int elementIndex) const
 Inverse-bind matrix element (column-major, 0..15) for skin joint i.
 
bool updateMatrixPalette (const AnimPose *pose) const
 Build and cache the column-major skinning matrix palette for a pose. The palette contains boneWorld * inverseBind and can be uploaded to a GPU storage/uniform buffer without CPU vertex deformation.
 
float getMatrixPaletteElement (int skinBoneIndex, int elementIndex) const
 Cached palette element for one skin bone (elementIndex 0..15).
 
bool bindGpuMesh (graphics::Graphics *gfx, graphics::Mesh *mesh)
 Upload this skin's joint/weight vertex stream to an existing GPU mesh.
 
bool updateGpuMesh (graphics::Mesh *mesh, const AnimPose *pose) const
 Update a bound GPU mesh's matrix palette from a world-computed pose.
 
void skinPositions (const AnimPose *pose, float *outPosXYZ) const
 Linear-blend skin bind-pose positions into outPosXYZ (vertexCount*3 floats). pose must already have computeWorld(skeleton) applied and match the skeleton used at fromModel time.
 
bool skinPositionsTo (const AnimPose *pose, std::vector< float > &outPosXYZ) const
 Convenience: skin into a vector sized vertexCount*3. Returns false if pose is null or bone count mismatches.
 
bool updateSkinnedPositions (const AnimPose *pose)
 Skin into an internal cache readable via getSkinnedPosition*. Returns false if pose is null or there are no vertices.
 
bool hasSkinnedPositions () const
 True after a successful updateSkinnedPositions().
 
float getSkinnedPositionX (int vertexIndex) const
 Cached skinned position component (requires updateSkinnedPositions).
 
float getSkinnedPositionY (int vertexIndex) const
 Returns the skinned position y.
 
float getSkinnedPositionZ (int vertexIndex) const
 Returns the skinned position z.
 
std::vector< float > getSkinnedPositions () const
 Packed skinned positions (xyz, vertexCount*3) as a copy. Empty when updateSkinnedPositions() has not succeeded yet.
 
bool updateSkinnedNormals (const AnimPose *pose)
 Skin the bind-pose normals captured at fromModel with the pose. pose must already have computeWorld(skeleton) applied and match the skeleton used at fromModel time. Returns false when the model mesh has no normals or pose is null.
 
bool hasSkinnedNormals () const
 True after a successful updateSkinnedNormals().
 
std::vector< float > getSkinnedNormals () const
 Packed skinned normals (xyz, vertexCount*3) as a copy.
 
bool applyToMesh (graphics::Graphics *gfx, graphics::Mesh *mesh, const AnimPose *pose)
 Skin positions (and normals when available) and write the result back to a GPU mesh in one call. pose must already have computeWorld() applied. The mesh must be built from the same model/mesh this skin was created from, with matching vertex count. Returns false when the backend cannot update in place (e.g. WebGPU) or arguments are invalid.
 
float getBindPositionX (int vertexIndex) const
 Bind-pose (unskinned) 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.
 
int getVertexBone (int vertexIndex, int influenceIndex) const
 Influence slot i (0..3) for vertex: skeleton bone index or -1.
 
int getVertexSkinJoint (int vertexIndex, int influenceIndex) const
 Influence slot i (0..3) for vertex: skin-local joint index or -1.
 
float getVertexWeight (int vertexIndex, int influenceIndex) const
 Returns the vertex weight.
 

静态 Public 成员函数

static AnimSkin * fromModel (const model3d::ModelData *model, int meshIndex, const AnimSkeleton *skeleton)
 Build skin binding for meshIndex on model, mapping bone names onto skeleton. Throws if the mesh has no bones or no bone names match the skeleton. Returned pointer is owned by the caller / script GC.
 
static Result< std::unique_ptr< AnimSkin > > fromStreams (AnimSkinStreamData streams)
 Construct a caller-owned skin from validated native streams.
 

静态 Public 属性

static constexpr int kMaxInfluences = 4
 

详细描述

CPU linear-blend skinning binding for one mesh against an AnimSkeleton.

Built from Assimp skin data on ModelData (bone names, inverse-bind matrices, per-vertex weights). Call skinPositions() after AnimPose::computeWorld().

Script type: AnimSkin.

在文件 AnimSkin.h 第 47 行定义.

构造及析构函数说明

◆ AnimSkin() [1/2]

eve::animation::AnimSkin::AnimSkin ( )
default

Anim skin.

被这些函数引用 fromModel().

◆ ~AnimSkin()

eve::animation::AnimSkin::~AnimSkin ( )
default

Anim skin.

◆ AnimSkin() [2/2]

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

成员函数说明

◆ applyToMesh()

bool eve::animation::AnimSkin::applyToMesh ( graphics::Graphics *  gfx,
graphics::Mesh *  mesh,
const AnimPose *  pose 
)

Skin positions (and normals when available) and write the result back to a GPU mesh in one call. pose must already have computeWorld() applied. The mesh must be built from the same model/mesh this skin was created from, with matching vertex count. Returns false when the backend cannot update in place (e.g. WebGPU) or arguments are invalid.

在文件 AnimSkin.cpp 第 341 行定义.

引用了 mesh, pose, eve::graphics::Graphics::updateMeshVertices(), updateSkinnedNormals(), updateSkinnedPositions() , 以及 uv.

◆ bindGpuMesh()

bool eve::animation::AnimSkin::bindGpuMesh ( graphics::Graphics *  gfx,
graphics::Mesh *  mesh 
)

Upload this skin's joint/weight vertex stream to an existing GPU mesh.

在文件 AnimSkin.cpp 第 144 行定义.

引用了 getBoneCount(), idx, kMaxInfluences, mesh, eve::graphics::Graphics::setMeshSkinningData(), v , 以及 weights.

◆ fromModel()

AnimSkin * eve::animation::AnimSkin::fromModel ( const model3d::ModelData *  model,
int  meshIndex,
const AnimSkeleton *  skeleton 
)
static

Build skin binding for meshIndex on model, mapping bone names onto skeleton. Throws if the mesh has no bones or no bone names match the skeleton. Returned pointer is owned by the caller / script GC.

在文件 AnimSkinFromModel.cpp 第 43 行定义.

引用了 a, AnimSkin(), b, bone, eve::animation::AnimSkeleton::findBone(), kMaxInfluences, mesh, model, n, name, p, v, w , 以及 weight.

被这些函数引用 eve::animation::Animation::newSkinFromModel() , 以及 eve::avatar::VrmRuntime::prepare().

◆ fromStreams()

Result< std::unique_ptr< AnimSkin > > eve::animation::AnimSkin::fromStreams ( AnimSkinStreamData  streams)
static

Construct a caller-owned skin from validated native streams.

参数
streamsMoved bind geometry, joint identities, inverse binds and four influences per vertex.
返回
Owned skin or a structured diagnostic; no partial skin is published. @thread Synchronous CPU operation. The returned skin has caller-selected thread affinity.

在文件 AnimSkin.cpp 第 55 行定义.

引用了 eve::animation::AnimSkinStreamData::bindNormals, eve::animation::AnimSkinStreamData::bindPositions, eve::animation::AnimSkinStreamData::boneNames, eve::Diagnostic::error(), index, eve::InvalidArgument, eve::animation::AnimSkinStreamData::inverseBindMatrices, kMaxInfluences, message, eve::animation::AnimSkinStreamData::skeletonBones, value, eve::animation::AnimSkinStreamData::vertexCount, eve::animation::AnimSkinStreamData::vertexSkinJoints, eve::animation::AnimSkinStreamData::vertexWeights, vertices , 以及 weight.

◆ getBindPositionX()

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

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

在文件 AnimSkin.cpp 第 168 行定义.

◆ getBindPositionY()

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

Returns the bind position y.

在文件 AnimSkin.cpp 第 172 行定义.

◆ getBindPositionZ()

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

Returns the bind position z.

在文件 AnimSkin.cpp 第 176 行定义.

◆ getBoneCount()

int eve::animation::AnimSkin::getBoneCount ( ) const
inline

Returns the bone count.

在文件 AnimSkin.h 第 76 行定义.

被这些函数引用 eve::procgen_animation::PcgSkinnedMeshPlan::appendSource() , 以及 bindGpuMesh().

◆ getInfluenceCount()

int eve::animation::AnimSkin::getInfluenceCount ( ) const
inline

Returns the influence count.

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

◆ getInverseBindElement()

float eve::animation::AnimSkin::getInverseBindElement ( int  skinBoneIndex,
int  elementIndex 
) const

Inverse-bind matrix element (column-major, 0..15) for skin joint i.

在文件 AnimSkin.cpp 第 114 行定义.

引用了 m.

被这些函数引用 eve::procgen_animation::PcgSkinnedMeshPlan::appendSource().

◆ getMatrixPaletteElement()

float eve::animation::AnimSkin::getMatrixPaletteElement ( int  skinBoneIndex,
int  elementIndex 
) const

Cached palette element for one skin bone (elementIndex 0..15).

在文件 AnimSkin.cpp 第 135 行定义.

引用了 m.

◆ getSkeletonBone()

int eve::animation::AnimSkin::getSkeletonBone ( int  skinBoneIndex) const

Skeleton bone index used by skin joint i (-1 if unused).

在文件 AnimSkin.cpp 第 104 行定义.

被这些函数引用 eve::procgen_animation::PcgSkinnedMeshPlan::appendSource().

◆ getSkinBoneName()

std::string eve::animation::AnimSkin::getSkinBoneName ( int  skinBoneIndex) const

Returns the skin bone name.

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

被这些函数引用 eve::procgen_animation::PcgSkinnedMeshPlan::appendSource().

◆ getSkinnedNormals()

std::vector< float > eve::animation::AnimSkin::getSkinnedNormals ( ) const

Packed skinned normals (xyz, vertexCount*3) as a copy.

在文件 AnimSkin.cpp 第 336 行定义.

◆ getSkinnedPositions()

std::vector< float > eve::animation::AnimSkin::getSkinnedPositions ( ) const

Packed skinned positions (xyz, vertexCount*3) as a copy. Empty when updateSkinnedPositions() has not succeeded yet.

在文件 AnimSkin.cpp 第 274 行定义.

◆ getSkinnedPositionX()

float eve::animation::AnimSkin::getSkinnedPositionX ( int  vertexIndex) const

Cached skinned position component (requires updateSkinnedPositions).

在文件 AnimSkin.cpp 第 258 行定义.

被这些函数引用 eve::particles::sampleSkinSpawn().

◆ getSkinnedPositionY()

float eve::animation::AnimSkin::getSkinnedPositionY ( int  vertexIndex) const

Returns the skinned position y.

在文件 AnimSkin.cpp 第 263 行定义.

被这些函数引用 eve::particles::sampleSkinSpawn().

◆ getSkinnedPositionZ()

float eve::animation::AnimSkin::getSkinnedPositionZ ( int  vertexIndex) const

Returns the skinned position z.

在文件 AnimSkin.cpp 第 268 行定义.

被这些函数引用 eve::particles::sampleSkinSpawn().

◆ getVertexBone()

int eve::animation::AnimSkin::getVertexBone ( int  vertexIndex,
int  influenceIndex 
) const

Influence slot i (0..3) for vertex: skeleton bone index or -1.

在文件 AnimSkin.cpp 第 181 行定义.

引用了 kMaxInfluences.

◆ getVertexCount()

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

在文件 AnimSkin.h 第 74 行定义.

被这些函数引用 eve::procgen_animation::PcgSkinnedMeshPlan::appendSource().

◆ getVertexSkinJoint()

int eve::animation::AnimSkin::getVertexSkinJoint ( int  vertexIndex,
int  influenceIndex 
) const

Influence slot i (0..3) for vertex: skin-local joint index or -1.

在文件 AnimSkin.cpp 第 191 行定义.

引用了 bone , 以及 kMaxInfluences.

被这些函数引用 eve::procgen_animation::PcgSkinnedMeshPlan::appendSource().

◆ getVertexWeight()

float eve::animation::AnimSkin::getVertexWeight ( int  vertexIndex,
int  influenceIndex 
) const

Returns the vertex weight.

在文件 AnimSkin.cpp 第 198 行定义.

引用了 kMaxInfluences , 以及 weight.

被这些函数引用 eve::procgen_animation::PcgSkinnedMeshPlan::appendSource().

◆ hasSkinnedNormals()

bool eve::animation::AnimSkin::hasSkinnedNormals ( ) const
inline

True after a successful updateSkinnedNormals().

在文件 AnimSkin.h 第 146 行定义.

◆ hasSkinnedPositions()

bool eve::animation::AnimSkin::hasSkinnedPositions ( ) const
inline

True after a successful updateSkinnedPositions().

在文件 AnimSkin.h 第 122 行定义.

◆ operator=()

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

◆ skinPositions()

void eve::animation::AnimSkin::skinPositions ( const AnimPose *  pose,
float *  outPosXYZ 
) const

Linear-blend skin bind-pose positions into outPosXYZ (vertexCount*3 floats). pose must already have computeWorld(skeleton) applied and match the skeleton used at fromModel time.

在文件 AnimSkin.cpp 第 206 行定义.

引用了 bx, by, bz, kMaxInfluences, ox, oy, pose, px, py, pz, updateMatrixPalette() , 以及 v.

被这些函数引用 skinPositionsTo() , 以及 updateSkinnedPositions().

◆ skinPositionsTo()

bool eve::animation::AnimSkin::skinPositionsTo ( const AnimPose *  pose,
std::vector< float > &  outPosXYZ 
) const

Convenience: skin into a vector sized vertexCount*3. Returns false if pose is null or bone count mismatches.

在文件 AnimSkin.cpp 第 240 行定义.

引用了 pose , 以及 skinPositions().

◆ updateGpuMesh()

bool eve::animation::AnimSkin::updateGpuMesh ( graphics::Mesh *  mesh,
const AnimPose *  pose 
) const

Update a bound GPU mesh's matrix palette from a world-computed pose.

在文件 AnimSkin.cpp 第 163 行定义.

引用了 mesh, pose , 以及 updateMatrixPalette().

◆ updateMatrixPalette()

bool eve::animation::AnimSkin::updateMatrixPalette ( const AnimPose *  pose) const

Build and cache the column-major skinning matrix palette for a pose. The palette contains boneWorld * inverseBind and can be uploaded to a GPU storage/uniform buffer without CPU vertex deformation.

返回
False when pose is null, otherwise true.

在文件 AnimSkin.cpp 第 122 行定义.

引用了 eve::animation::Mat4::fromTRS(), eve::animation::Mat4::mul(), pose , 以及 world.

被这些函数引用 skinPositions() , 以及 updateGpuMesh().

◆ updateSkinnedNormals()

bool eve::animation::AnimSkin::updateSkinnedNormals ( const AnimPose *  pose)

Skin the bind-pose normals captured at fromModel with the pose. pose must already have computeWorld(skeleton) applied and match the skeleton used at fromModel time. Returns false when the model mesh has no normals or pose is null.

在文件 AnimSkin.cpp 第 279 行定义.

引用了 bx, by, bz, c, eve::animation::Mat4::fromTRS(), kMaxInfluences, eve::animation::Mat4::mul(), nx, ny, nz, pose, v , 以及 world.

被这些函数引用 applyToMesh().

◆ updateSkinnedPositions()

bool eve::animation::AnimSkin::updateSkinnedPositions ( const AnimPose *  pose)

Skin into an internal cache readable via getSkinnedPosition*. Returns false if pose is null or there are no vertices.

在文件 AnimSkin.cpp 第 247 行定义.

引用了 pose , 以及 skinPositions().

被这些函数引用 applyToMesh().

类成员变量说明

◆ kMaxInfluences

constexpr int eve::animation::AnimSkin::kMaxInfluences = 4
staticconstexpr

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