载入中...
搜索中...
未找到
AvatarSkeletal.cpp
浏览该文件的文档.
84 if (kind_ != "vroid" || !boundMesh_ || viseme.empty() || !boundMesh_->hasMorph(morphName)) return false;
117void AvatarInstance::setLookAtWeight(float weight) { lookAtWeight_ = std::clamp(weight, 0.f, 1.f); }
121bool AvatarInstance::attachToBone(const std::string& name, const std::string& boneSemanticOrName,
149 eve::Diagnostic::error(eve::DiagnosticCode::PreconditionViolation, "Avatar has no evaluated skeletal pose",
157 eve::Diagnostic::error(eve::DiagnosticCode::NotFound, "Avatar attachment bone was not found", boneName));
159 const float bx = matrix[0] * localOffset.x + matrix[4] * localOffset.y + matrix[8] * localOffset.z + matrix[12];
160 const float by = matrix[1] * localOffset.x + matrix[5] * localOffset.y + matrix[9] * localOffset.z + matrix[13];
161 const float bz = matrix[2] * localOffset.x + matrix[6] * localOffset.y + matrix[10] * localOffset.z + matrix[14];
164 return eve::Result<eve::AttachmentPoint>::success({x3_ + bx * sx3_ * cosYaw + bz * sz3_ * sinYaw, y3_ + by * sy3_,
187 static_cast<int>(std::floor(animPlayer_->getTime() / duration) - std::floor(oldTime / duration));
197 if (oldClip && oldClip == animPlayer_->getClip() && animPlayer_->getLoop() && oldClip->getDuration() > 0.f) {
200 static_cast<int>(std::floor(animPlayer_->getTime() / duration) - std::floor(oldTime / duration));
207 if (vrm_ && animPlayer_ == vrm_->player.get() && !animPlayer_->getClip()) animSkeleton_->applyBindPose(pose);
241 return animPlayer_ && index >= 0 && index < animPlayer_->getEventCount() ? "base" : std::string{};
285 if (animSkin_ && boundMesh_) (void)updateSkinnedMesh(animSkin_, boundMesh_, pose, skinnedPositions_);
286 for (auto& part : skinnedParts_) part.updateMode = updateSkinnedMesh(part.skin, part.mesh, pose, part.cpuPositions);
291 visual.updateMode = updateSkinnedMesh(visual.skinnedSkin, visual.skinnedMesh, pose, visual.cpuPositions);
295SkinnedPartUpdateMode AvatarInstance::updateSkinnedMesh(animation::AnimSkin* skin, graphics::Mesh* mesh,
301 if (poseBone < 0 || poseBone >= pose->getBoneCount()) return SkinnedPartUpdateMode::Unavailable;
305 if (mesh->hasGpuSkinning() && skin->updateGpuMesh(mesh, pose)) return SkinnedPartUpdateMode::Gpu;
306 if (!gfx || !skin->skinPositionsTo(pose, cpuPositions)) return SkinnedPartUpdateMode::Unavailable;
307 return gfx->updateMeshVertices(mesh, cpuPositions.data(), nullptr, nullptr, skin->getVertexCount(), nullptr, 0)
341 vrm_->gaze(*this, *pose, vrm_->world, lookAtEnabled_, glm::vec3(lookAtX_, lookAtY_, lookAtZ_), lookAtWeight_);
378 const float targetYaw = std::clamp(std::atan2(localX, localZ), -kMaxYaw, kMaxYaw) * lookAtWeight_;
379 const float targetPitch = std::clamp(-std::atan2(dy, horizontal), -kMaxPitch, kMaxPitch) * lookAtWeight_;
465 if (name == "x" || name == "y" || name == "sx" || name == "sy" || name == "x3" || name == "y3" ||
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
Keyframed skeletal animation clip (local TRS tracks per bone). Script type: AnimClip.
Definition AnimClip.h:145
int getPositionKeyCount(int boneIndex) const
Returns the position key count.
Definition AnimClip.cpp:365
void update(float dt)
Legacy seconds facade; explicitly forwards to advance().
Definition AnimLayerMixer.cpp:363
std::string getEventName(int index) const override
Returns the event name.
Definition AnimLayerMixer.cpp:377
AnimPose * getPose() override
Return the most recently combined pose. @ownership Borrowed @lifetime Valid while the owning animatio...
Definition AnimLayerMixer.h:132
std::string getEventPayload(int index) const override
Returns the event payload.
Definition AnimLayerMixer.cpp:382
std::string getEventLayer(int index) const
Source layer name; "base" identifies the base source.
Definition AnimLayerMixer.cpp:372
std::string getEventName(int index) const override
Name of a dispatched event, or empty for invalid index.
Definition AnimPlayer.cpp:150
void update(float dt)
Legacy seconds facade retained for scripts and old callers.
Definition AnimPlayer.cpp:269
std::string getEventPayload(int index) const override
Payload of a dispatched event, or empty for invalid index.
Definition AnimPlayer.cpp:155
int getEventCount() const override
Number of events crossed by the most recent play/update call.
Definition AnimPlayer.h:133
AnimPose * getPose() override
Borrowed pointer accessor. @ownership Borrowed @lifetime Valid while the owning animation object rema...
Definition AnimPlayer.cpp:114
AnimClip * getClip() const
Borrow the selected clip, or null if none is selected. The caller owns the clip and must keep it aliv...
Definition AnimPlayer.h:86
Evaluated local (and optional world) pose for an AnimSkeleton. Script type: AnimPose.
Definition AnimPose.h:17
void applyBindPose(class AnimPose *pose) const
Fill pose locals with bind pose.
Definition AnimSkeleton.cpp:132
void update(float dt)
Legacy seconds facade retained for scripts and old callers.
Definition AnimStateMachine.cpp:323
AnimPose * getPose() override
Borrowed pointer accessor. @ownership Borrowed @lifetime Valid while the owning animation object rema...
Definition AnimStateMachine.cpp:203
Property tween — interpolates named float properties from → to over time.
Definition Tween.h:25
int getPropertyCount() const
Names of all property tracks (stable order = insertion order).
Definition Tween.h:131
std::string getAnimationEventLayer(int index) const
Source layer for an animation event ("base" for the base player).
Definition AvatarSkeletal.cpp:239
std::string getHumanoidBoneName(const std::string &semantic) const
Return the mapped skeleton bone name, or an empty string.
Definition AvatarSkeletal.cpp:78
int autoMapHumanoidBones()
Auto-map common VRM humanoid semantics from the currently bound skeleton.
Definition AvatarSkeletal.cpp:43
bool mapViseme(const std::string &viseme, const std::string &morphName)
Map a VRM viseme/expression semantic to an existing mesh morph.
Definition AvatarSkeletal.cpp:83
bool detachAttachment(const std::string &name)
Remove an attachment without destroying its Renderable3D.
Definition AvatarSkeletal.cpp:137
std::string getAnimationEventPayload(int index) const
Animation event payload, or empty for an invalid index.
Definition AvatarSkeletal.cpp:249
void bindTween(animation::Tween *tween)
Drive x/y/sx/sy and matching parameters from a Tween each update().
Definition AvatarSkeletal.cpp:446
bool attachToBone(const std::string &name, const std::string &boneSemanticOrName, graphics::Renderable3D *renderable, float ox=0.f, float oy=0.f, float oz=0.f)
Attach a non-owned Renderable3D to a mapped humanoid semantic or bone name.
Definition AvatarSkeletal.cpp:121
bool linkSceneNode(scene::Scene *scene, const std::string &nodeId)
Link this avatar to a node in Scene's current host.
Definition AvatarSkeletal.cpp:410
EquipmentVisualChange syncEquipmentAppearance()
Rebuild visuals from the current authoritative slots when their signature changed.
Definition AvatarInstance.cpp:346
eve::Result< eve::AttachmentPoint > sampleAttachmentPoint(std::string_view name, eve::AttachmentPoint localOffset={}) const override
Sample the latest evaluated semantic/bone point in Avatar world space.
Definition AvatarSkeletal.cpp:145
std::string animationEventName(std::size_t index) const override
Return one latest animation event name through the consumer contract.
Definition AvatarSkeletal.cpp:234
void setParameter(const std::string &name, float value)
Sets the parameter.
Definition AvatarInstance.cpp:482
std::string getAnimationEventName(int index) const
Animation event name, or empty for an invalid index.
Definition AvatarSkeletal.cpp:244
bool setLookAtTarget(float x, float y, float z)
Set a world-space target tracked by the mapped humanoid head bone.
Definition AvatarSkeletal.cpp:108
bool setViseme(const std::string &viseme, float weight)
Set a mapped viseme weight and clear the previously active viseme.
Definition AvatarSkeletal.cpp:90
bool mapHumanoidBone(const std::string &semantic, const std::string &boneName)
Map a VRM humanoid semantic (for example "head") to a skeleton bone.
Definition AvatarSkeletal.cpp:36
std::size_t animationEventCount() const noexcept override
Expose latest animation events through the backend-neutral consumer contract.
Definition AvatarSkeletal.cpp:229
void setLookAtWeight(float weight)
Set VRM-style head look-at influence in the range 0..1.
Definition AvatarSkeletal.cpp:117
bool hasParameter(const std::string &name) const
True when parameter.
Definition AvatarInstance.cpp:509
int getAnimationEventCount() const
Number of animation events emitted by the latest update.
Definition AvatarSkeletal.cpp:223
static ILive2DBackend * createLive2DBackend()
Always returns a backend: custom factory, else NullLive2DBackend.
Definition Avatar.cpp:165
virtual void setVisible(bool)
Optional: receive the Avatar's effective visibility.
Definition AvatarInstance.h:98
virtual void setLayer(int)
Optional: receive the Avatar's render sorting layer.
Definition AvatarInstance.h:100
virtual void setTransform(float, float, float, float)
Optional: receive the Avatar's 2D transform.
Definition AvatarInstance.h:96
void setCastOcclusion(bool cast)
Enable or disable volumetric occlusion casting.
Definition RenderSystem.cpp:142
void setSize(float width, float height)
Set unscaled sprite dimensions in pixels.
Definition RenderSystem.cpp:34
void setReceiveLight(bool receive)
Enable or disable 2D light reception.
Definition RenderSystem.cpp:58
Definition Avatar.cpp:12
SkinnedPartUpdateMode
Observable backend selected for a shared-pose skinned part.
Definition AvatarInstance.h:68
@ Unavailable
@ NotFound
@ PreconditionViolation
Plain world-space point shared by animation consumers without a math-library dependency.
Definition AttachmentPoint.h:10