mirror of
https://github.com/luanti-org/luanti.git
synced 2025-11-10 11:55:27 +01:00
Refactor: Remove obsolete IAnimatedMeshSceneNode interface (#16631)
This commit is contained in:
@@ -2,8 +2,9 @@
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#include "CAnimatedMeshSceneNode.h"
|
||||
#include "AnimatedMeshSceneNode.h"
|
||||
#include "CBoneSceneNode.h"
|
||||
#include "ISceneNode.h"
|
||||
#include "IVideoDriver.h"
|
||||
#include "ISceneManager.h"
|
||||
#include "S3DVertex.h"
|
||||
@@ -29,12 +30,12 @@ namespace scene
|
||||
{
|
||||
|
||||
//! constructor
|
||||
CAnimatedMeshSceneNode::CAnimatedMeshSceneNode(IAnimatedMesh *mesh,
|
||||
AnimatedMeshSceneNode::AnimatedMeshSceneNode(IAnimatedMesh *mesh,
|
||||
ISceneNode *parent, ISceneManager *mgr, s32 id,
|
||||
const core::vector3df &position,
|
||||
const core::vector3df &rotation,
|
||||
const core::vector3df &scale) :
|
||||
IAnimatedMeshSceneNode(parent, mgr, id, position, rotation, scale),
|
||||
ISceneNode(parent, mgr, id, position, rotation, scale),
|
||||
Mesh(nullptr),
|
||||
StartFrame(0), EndFrame(0), FramesPerSecond(0.025f),
|
||||
CurrentFrameNr(0.f), LastTimeMs(0),
|
||||
@@ -47,14 +48,14 @@ CAnimatedMeshSceneNode::CAnimatedMeshSceneNode(IAnimatedMesh *mesh,
|
||||
}
|
||||
|
||||
//! destructor
|
||||
CAnimatedMeshSceneNode::~CAnimatedMeshSceneNode()
|
||||
AnimatedMeshSceneNode::~AnimatedMeshSceneNode()
|
||||
{
|
||||
if (Mesh)
|
||||
Mesh->drop();
|
||||
}
|
||||
|
||||
//! Sets the current frame. From now on the animation is played from this frame.
|
||||
void CAnimatedMeshSceneNode::setCurrentFrame(f32 frame)
|
||||
void AnimatedMeshSceneNode::setCurrentFrame(f32 frame)
|
||||
{
|
||||
// if you pass an out of range value, we just clamp it
|
||||
CurrentFrameNr = core::clamp(frame, (f32)StartFrame, (f32)EndFrame);
|
||||
@@ -63,13 +64,13 @@ void CAnimatedMeshSceneNode::setCurrentFrame(f32 frame)
|
||||
}
|
||||
|
||||
//! Returns the currently displayed frame number.
|
||||
f32 CAnimatedMeshSceneNode::getFrameNr() const
|
||||
f32 AnimatedMeshSceneNode::getFrameNr() const
|
||||
{
|
||||
return CurrentFrameNr;
|
||||
}
|
||||
|
||||
//! Get CurrentFrameNr and update transiting settings
|
||||
void CAnimatedMeshSceneNode::buildFrameNr(u32 timeMs)
|
||||
void AnimatedMeshSceneNode::buildFrameNr(u32 timeMs)
|
||||
{
|
||||
if (Transiting != 0.f) {
|
||||
TransitingBlend += (f32)(timeMs)*Transiting;
|
||||
@@ -106,7 +107,7 @@ void CAnimatedMeshSceneNode::buildFrameNr(u32 timeMs)
|
||||
}
|
||||
}
|
||||
|
||||
void CAnimatedMeshSceneNode::OnRegisterSceneNode()
|
||||
void AnimatedMeshSceneNode::OnRegisterSceneNode()
|
||||
{
|
||||
if (IsVisible && Mesh) {
|
||||
// because this node supports rendering of mixed mode meshes consisting of
|
||||
@@ -146,7 +147,7 @@ void CAnimatedMeshSceneNode::OnRegisterSceneNode()
|
||||
}
|
||||
}
|
||||
|
||||
IMesh *CAnimatedMeshSceneNode::getMeshForCurrentFrame()
|
||||
IMesh *AnimatedMeshSceneNode::getMeshForCurrentFrame()
|
||||
{
|
||||
if (Mesh->getMeshType() != EAMT_SKINNED) {
|
||||
return Mesh;
|
||||
@@ -164,7 +165,7 @@ IMesh *CAnimatedMeshSceneNode::getMeshForCurrentFrame()
|
||||
}
|
||||
|
||||
//! OnAnimate() is called just before rendering the whole scene.
|
||||
void CAnimatedMeshSceneNode::OnAnimate(u32 timeMs)
|
||||
void AnimatedMeshSceneNode::OnAnimate(u32 timeMs)
|
||||
{
|
||||
if (LastTimeMs == 0) { // first frame
|
||||
LastTimeMs = timeMs;
|
||||
@@ -186,7 +187,7 @@ void CAnimatedMeshSceneNode::OnAnimate(u32 timeMs)
|
||||
if (OnAnimateCallback)
|
||||
OnAnimateCallback(dtimeMs / 1000.0f);
|
||||
|
||||
IAnimatedMeshSceneNode::OnAnimate(timeMs);
|
||||
ISceneNode::OnAnimate(timeMs);
|
||||
|
||||
if (auto *skinnedMesh = dynamic_cast<SkinnedMesh*>(Mesh)) {
|
||||
for (u16 i = 0; i < PerJoint.SceneNodes.size(); ++i)
|
||||
@@ -200,7 +201,7 @@ void CAnimatedMeshSceneNode::OnAnimate(u32 timeMs)
|
||||
}
|
||||
|
||||
//! renders the node.
|
||||
void CAnimatedMeshSceneNode::render()
|
||||
void AnimatedMeshSceneNode::render()
|
||||
{
|
||||
video::IVideoDriver *driver = SceneManager->getVideoDriver();
|
||||
|
||||
@@ -312,20 +313,20 @@ void CAnimatedMeshSceneNode::render()
|
||||
}
|
||||
|
||||
//! Returns the current start frame number.
|
||||
f32 CAnimatedMeshSceneNode::getStartFrame() const
|
||||
f32 AnimatedMeshSceneNode::getStartFrame() const
|
||||
{
|
||||
return StartFrame;
|
||||
}
|
||||
|
||||
//! Returns the current start frame number.
|
||||
f32 CAnimatedMeshSceneNode::getEndFrame() const
|
||||
f32 AnimatedMeshSceneNode::getEndFrame() const
|
||||
{
|
||||
return EndFrame;
|
||||
}
|
||||
|
||||
//! sets the frames between the animation is looped.
|
||||
//! the default is 0 - MaximalFrameCount of the mesh.
|
||||
bool CAnimatedMeshSceneNode::setFrameLoop(f32 begin, f32 end)
|
||||
bool AnimatedMeshSceneNode::setFrameLoop(f32 begin, f32 end)
|
||||
{
|
||||
const f32 maxFrame = Mesh->getMaxFrameNumber();
|
||||
if (end < begin) {
|
||||
@@ -344,24 +345,24 @@ bool CAnimatedMeshSceneNode::setFrameLoop(f32 begin, f32 end)
|
||||
}
|
||||
|
||||
//! sets the speed with witch the animation is played
|
||||
void CAnimatedMeshSceneNode::setAnimationSpeed(f32 framesPerSecond)
|
||||
void AnimatedMeshSceneNode::setAnimationSpeed(f32 framesPerSecond)
|
||||
{
|
||||
FramesPerSecond = framesPerSecond * 0.001f;
|
||||
}
|
||||
|
||||
f32 CAnimatedMeshSceneNode::getAnimationSpeed() const
|
||||
f32 AnimatedMeshSceneNode::getAnimationSpeed() const
|
||||
{
|
||||
return FramesPerSecond * 1000.f;
|
||||
}
|
||||
|
||||
//! returns the axis aligned bounding box of this node
|
||||
const core::aabbox3d<f32> &CAnimatedMeshSceneNode::getBoundingBox() const
|
||||
const core::aabbox3d<f32> &AnimatedMeshSceneNode::getBoundingBox() const
|
||||
{
|
||||
return Box;
|
||||
}
|
||||
|
||||
//! returns the material based on the zero based index i.
|
||||
video::SMaterial &CAnimatedMeshSceneNode::getMaterial(u32 i)
|
||||
video::SMaterial &AnimatedMeshSceneNode::getMaterial(u32 i)
|
||||
{
|
||||
if (i >= Materials.size())
|
||||
return ISceneNode::getMaterial(i);
|
||||
@@ -370,14 +371,14 @@ video::SMaterial &CAnimatedMeshSceneNode::getMaterial(u32 i)
|
||||
}
|
||||
|
||||
//! returns amount of materials used by this scene node.
|
||||
u32 CAnimatedMeshSceneNode::getMaterialCount() const
|
||||
u32 AnimatedMeshSceneNode::getMaterialCount() const
|
||||
{
|
||||
return Materials.size();
|
||||
}
|
||||
|
||||
//! Returns a pointer to a child node, which has the same transformation as
|
||||
//! the corresponding joint, if the mesh in this scene node is a skinned mesh.
|
||||
IBoneSceneNode *CAnimatedMeshSceneNode::getJointNode(const c8 *jointName)
|
||||
IBoneSceneNode *AnimatedMeshSceneNode::getJointNode(const c8 *jointName)
|
||||
{
|
||||
if (!Mesh || Mesh->getMeshType() != EAMT_SKINNED) {
|
||||
os::Printer::log("No mesh, or mesh not of skinned mesh type", ELL_WARNING);
|
||||
@@ -405,7 +406,7 @@ IBoneSceneNode *CAnimatedMeshSceneNode::getJointNode(const c8 *jointName)
|
||||
|
||||
//! Returns a pointer to a child node, which has the same transformation as
|
||||
//! the corresponding joint, if the mesh in this scene node is a skinned mesh.
|
||||
IBoneSceneNode *CAnimatedMeshSceneNode::getJointNode(u32 jointID)
|
||||
IBoneSceneNode *AnimatedMeshSceneNode::getJointNode(u32 jointID)
|
||||
{
|
||||
if (!Mesh || Mesh->getMeshType() != EAMT_SKINNED) {
|
||||
os::Printer::log("No mesh, or mesh not of skinned mesh type", ELL_WARNING);
|
||||
@@ -423,7 +424,7 @@ IBoneSceneNode *CAnimatedMeshSceneNode::getJointNode(u32 jointID)
|
||||
}
|
||||
|
||||
//! Gets joint count.
|
||||
u32 CAnimatedMeshSceneNode::getJointCount() const
|
||||
u32 AnimatedMeshSceneNode::getJointCount() const
|
||||
{
|
||||
if (!Mesh || Mesh->getMeshType() != EAMT_SKINNED)
|
||||
return 0;
|
||||
@@ -436,7 +437,7 @@ u32 CAnimatedMeshSceneNode::getJointCount() const
|
||||
//! Removes a child from this scene node.
|
||||
//! Implemented here, to be able to remove the shadow properly, if there is one,
|
||||
//! or to remove attached childs.
|
||||
bool CAnimatedMeshSceneNode::removeChild(ISceneNode *child)
|
||||
bool AnimatedMeshSceneNode::removeChild(ISceneNode *child)
|
||||
{
|
||||
if (ISceneNode::removeChild(child)) {
|
||||
if (JointsUsed) { // stop weird bugs caused while changing parents as the joints are being created
|
||||
@@ -455,31 +456,31 @@ bool CAnimatedMeshSceneNode::removeChild(ISceneNode *child)
|
||||
|
||||
//! Sets looping mode which is on by default. If set to false,
|
||||
//! animations will not be looped.
|
||||
void CAnimatedMeshSceneNode::setLoopMode(bool playAnimationLooped)
|
||||
void AnimatedMeshSceneNode::setLoopMode(bool playAnimationLooped)
|
||||
{
|
||||
Looping = playAnimationLooped;
|
||||
}
|
||||
|
||||
//! returns the current loop mode
|
||||
bool CAnimatedMeshSceneNode::getLoopMode() const
|
||||
bool AnimatedMeshSceneNode::getLoopMode() const
|
||||
{
|
||||
return Looping;
|
||||
}
|
||||
|
||||
//! Sets if the scene node should not copy the materials of the mesh but use them in a read only style.
|
||||
void CAnimatedMeshSceneNode::setReadOnlyMaterials(bool readonly)
|
||||
void AnimatedMeshSceneNode::setReadOnlyMaterials(bool readonly)
|
||||
{
|
||||
ReadOnlyMaterials = readonly;
|
||||
}
|
||||
|
||||
//! Returns if the scene node should not copy the materials of the mesh but use them in a read only style
|
||||
bool CAnimatedMeshSceneNode::isReadOnlyMaterials() const
|
||||
bool AnimatedMeshSceneNode::isReadOnlyMaterials() const
|
||||
{
|
||||
return ReadOnlyMaterials;
|
||||
}
|
||||
|
||||
//! Sets a new mesh
|
||||
void CAnimatedMeshSceneNode::setMesh(IAnimatedMesh *mesh)
|
||||
void AnimatedMeshSceneNode::setMesh(IAnimatedMesh *mesh)
|
||||
{
|
||||
if (!mesh)
|
||||
return; // won't set null mesh
|
||||
@@ -520,14 +521,14 @@ void CAnimatedMeshSceneNode::setMesh(IAnimatedMesh *mesh)
|
||||
}
|
||||
|
||||
//! updates the absolute position based on the relative and the parents position
|
||||
void CAnimatedMeshSceneNode::updateAbsolutePosition()
|
||||
void AnimatedMeshSceneNode::updateAbsolutePosition()
|
||||
{
|
||||
IAnimatedMeshSceneNode::updateAbsolutePosition();
|
||||
ISceneNode::updateAbsolutePosition();
|
||||
}
|
||||
|
||||
//! Sets the transition time in seconds (note: This needs to enable joints)
|
||||
//! you must call animateJoints(), or the mesh will not animate
|
||||
void CAnimatedMeshSceneNode::setTransitionTime(f32 time)
|
||||
void AnimatedMeshSceneNode::setTransitionTime(f32 time)
|
||||
{
|
||||
const u32 ttime = (u32)core::floor32(time * 1000.0f);
|
||||
if (TransitionTime == ttime)
|
||||
@@ -536,12 +537,12 @@ void CAnimatedMeshSceneNode::setTransitionTime(f32 time)
|
||||
}
|
||||
|
||||
//! render mesh ignoring its transformation. Used with ragdolls. (culling is unaffected)
|
||||
void CAnimatedMeshSceneNode::setRenderFromIdentity(bool enable)
|
||||
void AnimatedMeshSceneNode::setRenderFromIdentity(bool enable)
|
||||
{
|
||||
RenderFromIdentity = enable;
|
||||
}
|
||||
|
||||
void CAnimatedMeshSceneNode::addJoints()
|
||||
void AnimatedMeshSceneNode::addJoints()
|
||||
{
|
||||
const auto &joints = static_cast<SkinnedMesh*>(Mesh)->getAllJoints();
|
||||
PerJoint.setN(joints.size());
|
||||
@@ -561,7 +562,7 @@ void CAnimatedMeshSceneNode::addJoints()
|
||||
}
|
||||
}
|
||||
|
||||
void CAnimatedMeshSceneNode::updateJointSceneNodes(
|
||||
void AnimatedMeshSceneNode::updateJointSceneNodes(
|
||||
const std::vector<SkinnedMesh::SJoint::VariantTransform> &transforms)
|
||||
{
|
||||
for (size_t i = 0; i < transforms.size(); ++i) {
|
||||
@@ -578,7 +579,7 @@ void CAnimatedMeshSceneNode::updateJointSceneNodes(
|
||||
}
|
||||
|
||||
//! updates the joint positions of this mesh
|
||||
void CAnimatedMeshSceneNode::animateJoints()
|
||||
void AnimatedMeshSceneNode::animateJoints()
|
||||
{
|
||||
if (!Mesh || Mesh->getMeshType() != EAMT_SKINNED)
|
||||
return;
|
||||
@@ -603,7 +604,7 @@ void CAnimatedMeshSceneNode::animateJoints()
|
||||
}
|
||||
}
|
||||
|
||||
void CAnimatedMeshSceneNode::checkJoints()
|
||||
void AnimatedMeshSceneNode::checkJoints()
|
||||
{
|
||||
if (!Mesh || Mesh->getMeshType() != EAMT_SKINNED)
|
||||
return;
|
||||
@@ -617,7 +618,7 @@ void CAnimatedMeshSceneNode::checkJoints()
|
||||
}
|
||||
}
|
||||
|
||||
void CAnimatedMeshSceneNode::copyOldTransforms()
|
||||
void AnimatedMeshSceneNode::copyOldTransforms()
|
||||
{
|
||||
for (u32 i = 0; i < PerJoint.SceneNodes.size(); ++i) {
|
||||
if (!PerJoint.SceneNodes[i]->Matrix) {
|
||||
@@ -628,7 +629,7 @@ void CAnimatedMeshSceneNode::copyOldTransforms()
|
||||
}
|
||||
}
|
||||
|
||||
void CAnimatedMeshSceneNode::beginTransition()
|
||||
void AnimatedMeshSceneNode::beginTransition()
|
||||
{
|
||||
if (!JointsUsed)
|
||||
return;
|
||||
@@ -639,15 +640,15 @@ void CAnimatedMeshSceneNode::beginTransition()
|
||||
TransitingBlend = 0.f;
|
||||
}
|
||||
|
||||
ISceneNode *CAnimatedMeshSceneNode::clone(ISceneNode *newParent, ISceneManager *newManager)
|
||||
ISceneNode *AnimatedMeshSceneNode::clone(ISceneNode *newParent, ISceneManager *newManager)
|
||||
{
|
||||
if (!newParent)
|
||||
newParent = Parent;
|
||||
if (!newManager)
|
||||
newManager = SceneManager;
|
||||
|
||||
CAnimatedMeshSceneNode *newNode =
|
||||
new CAnimatedMeshSceneNode(Mesh, NULL, newManager, ID, RelativeTranslation,
|
||||
AnimatedMeshSceneNode *newNode =
|
||||
new AnimatedMeshSceneNode(Mesh, NULL, newManager, ID, RelativeTranslation,
|
||||
RelativeRotation, RelativeScale);
|
||||
|
||||
if (newParent) {
|
||||
@@ -1,192 +0,0 @@
|
||||
// Copyright (C) 2002-2012 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CBoneSceneNode.h"
|
||||
#include "IAnimatedMeshSceneNode.h"
|
||||
#include "IAnimatedMesh.h"
|
||||
|
||||
#include "SkinnedMesh.h"
|
||||
#include "Transform.h"
|
||||
#include "irr_ptr.h"
|
||||
#include "matrix4.h"
|
||||
|
||||
namespace scene
|
||||
{
|
||||
|
||||
class CAnimatedMeshSceneNode : public IAnimatedMeshSceneNode
|
||||
{
|
||||
public:
|
||||
//! constructor
|
||||
CAnimatedMeshSceneNode(IAnimatedMesh *mesh, ISceneNode *parent, ISceneManager *mgr, s32 id,
|
||||
const core::vector3df &position = core::vector3df(0, 0, 0),
|
||||
const core::vector3df &rotation = core::vector3df(0, 0, 0),
|
||||
const core::vector3df &scale = core::vector3df(1.0f, 1.0f, 1.0f));
|
||||
|
||||
//! destructor
|
||||
virtual ~CAnimatedMeshSceneNode();
|
||||
|
||||
//! sets the current frame. from now on the animation is played from this frame.
|
||||
void setCurrentFrame(f32 frame) override;
|
||||
|
||||
//! frame
|
||||
void OnRegisterSceneNode() override;
|
||||
|
||||
//! OnAnimate() is called just before rendering the whole scene.
|
||||
void OnAnimate(u32 timeMs) override;
|
||||
|
||||
//! renders the node.
|
||||
void render() override;
|
||||
|
||||
//! returns the axis aligned bounding box of this node
|
||||
const core::aabbox3d<f32> &getBoundingBox() const override;
|
||||
|
||||
//! sets the frames between the animation is looped.
|
||||
//! the default is 0 - MaximalFrameCount of the mesh.
|
||||
//! NOTE: setMesh will also change this value and set it to the full range of animations of the mesh
|
||||
bool setFrameLoop(f32 begin, f32 end) override;
|
||||
|
||||
//! Sets looping mode which is on by default. If set to false,
|
||||
//! animations will not be looped.
|
||||
void setLoopMode(bool playAnimationLooped) override;
|
||||
|
||||
//! returns the current loop mode
|
||||
bool getLoopMode() const override;
|
||||
|
||||
void setOnAnimateCallback(
|
||||
const std::function<void(f32 dtime)> &cb) override
|
||||
{
|
||||
OnAnimateCallback = cb;
|
||||
}
|
||||
|
||||
//! sets the speed with which the animation is played
|
||||
//! NOTE: setMesh will also change this value and set it to the default speed of the mesh
|
||||
void setAnimationSpeed(f32 framesPerSecond) override;
|
||||
|
||||
//! gets the speed with which the animation is played
|
||||
f32 getAnimationSpeed() const override;
|
||||
|
||||
//! returns the material based on the zero based index i. To get the amount
|
||||
//! of materials used by this scene node, use getMaterialCount().
|
||||
//! This function is needed for inserting the node into the scene hierarchy on a
|
||||
//! optimal position for minimizing renderstate changes, but can also be used
|
||||
//! to directly modify the material of a scene node.
|
||||
video::SMaterial &getMaterial(u32 i) override;
|
||||
|
||||
//! returns amount of materials used by this scene node.
|
||||
u32 getMaterialCount() const override;
|
||||
|
||||
//! Returns a pointer to a child node, which has the same transformation as
|
||||
//! the corresponding joint, if the mesh in this scene node is a skinned mesh.
|
||||
IBoneSceneNode *getJointNode(const c8 *jointName) override;
|
||||
|
||||
//! same as getJointNode(const c8* jointName), but based on id
|
||||
IBoneSceneNode *getJointNode(u32 jointID) override;
|
||||
|
||||
//! Gets joint count.
|
||||
u32 getJointCount() const override;
|
||||
|
||||
//! Removes a child from this scene node.
|
||||
//! Implemented here, to be able to remove the shadow properly, if there is one,
|
||||
//! or to remove attached child.
|
||||
bool removeChild(ISceneNode *child) override;
|
||||
|
||||
//! Returns the current displayed frame number.
|
||||
f32 getFrameNr() const override;
|
||||
//! Returns the current start frame number.
|
||||
f32 getStartFrame() const override;
|
||||
//! Returns the current end frame number.
|
||||
f32 getEndFrame() const override;
|
||||
|
||||
//! Sets if the scene node should not copy the materials of the mesh but use them in a read only style.
|
||||
/* In this way it is possible to change the materials a mesh causing all mesh scene nodes
|
||||
referencing this mesh to change too. */
|
||||
void setReadOnlyMaterials(bool readonly) override;
|
||||
|
||||
//! Returns if the scene node should not copy the materials of the mesh but use them in a read only style
|
||||
bool isReadOnlyMaterials() const override;
|
||||
|
||||
//! Sets a new mesh
|
||||
void setMesh(IAnimatedMesh *mesh) override;
|
||||
|
||||
//! Returns the current mesh
|
||||
IAnimatedMesh *getMesh(void) override { return Mesh; }
|
||||
|
||||
//! Returns type of the scene node
|
||||
ESCENE_NODE_TYPE getType() const override { return ESNT_ANIMATED_MESH; }
|
||||
|
||||
//! updates the absolute position based on the relative and the parents position
|
||||
void updateAbsolutePosition() override;
|
||||
|
||||
//! Sets the transition time in seconds (note: This needs to enable joints)
|
||||
//! you must call animateJoints(), or the mesh will not animate
|
||||
void setTransitionTime(f32 Time) override;
|
||||
|
||||
void updateJointSceneNodes(const std::vector<SkinnedMesh::SJoint::VariantTransform> &transforms);
|
||||
|
||||
//! updates the joint positions of this mesh
|
||||
void animateJoints() override;
|
||||
|
||||
void addJoints();
|
||||
|
||||
//! render mesh ignoring its transformation. Used with ragdolls. (culling is unaffected)
|
||||
void setRenderFromIdentity(bool On) override;
|
||||
|
||||
//! Creates a clone of this scene node and its children.
|
||||
/** \param newParent An optional new parent.
|
||||
\param newManager An optional new scene manager.
|
||||
\return The newly created clone of this node. */
|
||||
ISceneNode *clone(ISceneNode *newParent = 0, ISceneManager *newManager = 0) override;
|
||||
|
||||
private:
|
||||
//! Get a static mesh for the current frame of this animated mesh
|
||||
IMesh *getMeshForCurrentFrame();
|
||||
|
||||
void buildFrameNr(u32 timeMs);
|
||||
void checkJoints();
|
||||
void copyOldTransforms();
|
||||
void beginTransition();
|
||||
|
||||
core::array<video::SMaterial> Materials;
|
||||
core::aabbox3d<f32> Box{{0.0f, 0.0f, 0.0f}};
|
||||
IAnimatedMesh *Mesh;
|
||||
|
||||
f32 StartFrame;
|
||||
f32 EndFrame;
|
||||
f32 FramesPerSecond;
|
||||
f32 CurrentFrameNr;
|
||||
|
||||
u32 LastTimeMs;
|
||||
u32 TransitionTime; // Transition time in millisecs
|
||||
f32 Transiting; // is mesh transiting (plus cache of TransitionTime)
|
||||
f32 TransitingBlend; // 0-1, calculated on buildFrameNr
|
||||
|
||||
bool JointsUsed;
|
||||
|
||||
bool Looping;
|
||||
bool ReadOnlyMaterials;
|
||||
bool RenderFromIdentity;
|
||||
|
||||
s32 PassCount;
|
||||
std::function<void(f32)> OnAnimateCallback;
|
||||
|
||||
struct PerJointData {
|
||||
std::vector<irr_ptr<CBoneSceneNode>> SceneNodes;
|
||||
std::vector<core::matrix4> GlobalMatrices;
|
||||
std::vector<std::optional<core::Transform>> PreTransSaves;
|
||||
void setN(u16 n) {
|
||||
SceneNodes.clear();
|
||||
SceneNodes.resize(n);
|
||||
GlobalMatrices.clear();
|
||||
GlobalMatrices.resize(n);
|
||||
PreTransSaves.clear();
|
||||
PreTransSaves.resize(n);
|
||||
}
|
||||
};
|
||||
|
||||
PerJointData PerJoint;
|
||||
};
|
||||
|
||||
} // end namespace scene
|
||||
@@ -1,68 +0,0 @@
|
||||
// Copyright (C) 2002-2012 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#pragma once
|
||||
|
||||
// Used with SkinnedMesh and IAnimatedMeshSceneNode, for boned meshes
|
||||
|
||||
#include "IBoneSceneNode.h"
|
||||
#include "Transform.h"
|
||||
#include "matrix4.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace scene
|
||||
{
|
||||
|
||||
class CBoneSceneNode : public IBoneSceneNode
|
||||
{
|
||||
public:
|
||||
//! constructor
|
||||
CBoneSceneNode(ISceneNode *parent, ISceneManager *mgr,
|
||||
s32 id = -1, u32 boneIndex = 0,
|
||||
const std::optional<std::string> &boneName = std::nullopt,
|
||||
const core::Transform &transform = {},
|
||||
const std::optional<core::matrix4> &matrix = std::nullopt) :
|
||||
IBoneSceneNode(parent, mgr, id, boneIndex, boneName),
|
||||
Matrix(matrix)
|
||||
{
|
||||
setTransform(transform);
|
||||
}
|
||||
|
||||
void setTransform(const core::Transform &transform)
|
||||
{
|
||||
setPosition(transform.translation);
|
||||
{
|
||||
core::vector3df euler;
|
||||
auto rot = transform.rotation;
|
||||
// Invert to be consistent with setRotationDegrees
|
||||
rot.makeInverse();
|
||||
rot.toEuler(euler);
|
||||
setRotation(euler * core::RADTODEG);
|
||||
}
|
||||
setScale(transform.scale);
|
||||
}
|
||||
|
||||
core::Transform getTransform() const
|
||||
{
|
||||
return {
|
||||
getPosition(),
|
||||
core::quaternion(getRotation() * core::DEGTORAD).makeInverse(),
|
||||
getScale()
|
||||
};
|
||||
}
|
||||
|
||||
core::matrix4 getRelativeTransformation() const override
|
||||
{
|
||||
if (Matrix)
|
||||
return *Matrix;
|
||||
return IBoneSceneNode::getRelativeTransformation();
|
||||
}
|
||||
|
||||
//! Some file formats alternatively let bones specify a transformation matrix.
|
||||
//! If this is set, it overrides the TRS properties.
|
||||
std::optional<core::matrix4> Matrix;
|
||||
};
|
||||
|
||||
} // end namespace scene
|
||||
@@ -251,11 +251,10 @@ set(IRRMESHLOADER
|
||||
|
||||
add_library(IRRMESHOBJ OBJECT
|
||||
CMeshSceneNode.h
|
||||
CAnimatedMeshSceneNode.h
|
||||
|
||||
SkinnedMesh.cpp
|
||||
CMeshSceneNode.cpp
|
||||
CAnimatedMeshSceneNode.cpp
|
||||
AnimatedMeshSceneNode.cpp
|
||||
|
||||
${IRRMESHLOADER}
|
||||
)
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "IImageLoader.h"
|
||||
#include "IImageWriter.h"
|
||||
#include "IMaterialRenderer.h"
|
||||
#include "IAnimatedMeshSceneNode.h"
|
||||
#include "AnimatedMeshSceneNode.h"
|
||||
#include "CMeshManipulator.h"
|
||||
#include "CColorConverter.h"
|
||||
#include "IReferenceCounted.h"
|
||||
@@ -1244,7 +1244,7 @@ void CNullDriver::addOcclusionQuery(scene::ISceneNode *node, const scene::IMesh
|
||||
else if (node->getType() == scene::ESNT_MESH)
|
||||
mesh = static_cast<scene::IMeshSceneNode *>(node)->getMesh();
|
||||
else
|
||||
mesh = static_cast<scene::IAnimatedMeshSceneNode *>(node)->getMesh();
|
||||
mesh = static_cast<scene::AnimatedMeshSceneNode *>(node)->getMesh();
|
||||
if (!mesh)
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "CB3DMeshFileLoader.h"
|
||||
#include "CGLTFMeshFileLoader.h"
|
||||
#include "CBillboardSceneNode.h"
|
||||
#include "CAnimatedMeshSceneNode.h"
|
||||
#include "AnimatedMeshSceneNode.h"
|
||||
#include "CCameraSceneNode.h"
|
||||
#include "CMeshSceneNode.h"
|
||||
#include "CDummyTransformationSceneNode.h"
|
||||
@@ -177,7 +177,7 @@ IMeshSceneNode *CSceneManager::addMeshSceneNode(IMesh *mesh, ISceneNode *parent,
|
||||
}
|
||||
|
||||
//! adds a scene node for rendering an animated mesh model
|
||||
IAnimatedMeshSceneNode *CSceneManager::addAnimatedMeshSceneNode(IAnimatedMesh *mesh, ISceneNode *parent, s32 id,
|
||||
AnimatedMeshSceneNode *CSceneManager::addAnimatedMeshSceneNode(IAnimatedMesh *mesh, ISceneNode *parent, s32 id,
|
||||
const core::vector3df &position, const core::vector3df &rotation,
|
||||
const core::vector3df &scale, bool alsoAddIfMeshPointerZero)
|
||||
{
|
||||
@@ -187,8 +187,8 @@ IAnimatedMeshSceneNode *CSceneManager::addAnimatedMeshSceneNode(IAnimatedMesh *m
|
||||
if (!parent)
|
||||
parent = this;
|
||||
|
||||
IAnimatedMeshSceneNode *node =
|
||||
new CAnimatedMeshSceneNode(mesh, parent, this, id, position, rotation, scale);
|
||||
auto *node =
|
||||
new AnimatedMeshSceneNode(mesh, parent, this, id, position, rotation, scale);
|
||||
node->drop();
|
||||
|
||||
return node;
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
video::IVideoDriver *getVideoDriver() override;
|
||||
|
||||
//! adds a scene node for rendering an animated mesh model
|
||||
virtual IAnimatedMeshSceneNode *addAnimatedMeshSceneNode(IAnimatedMesh *mesh, ISceneNode *parent = 0, s32 id = -1,
|
||||
virtual AnimatedMeshSceneNode *addAnimatedMeshSceneNode(IAnimatedMesh *mesh, ISceneNode *parent = 0, s32 id = -1,
|
||||
const core::vector3df &position = core::vector3df(0, 0, 0),
|
||||
const core::vector3df &rotation = core::vector3df(0, 0, 0),
|
||||
const core::vector3df &scale = core::vector3df(1.0f, 1.0f, 1.0f),
|
||||
|
||||
@@ -3,13 +3,9 @@
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#include "SkinnedMesh.h"
|
||||
#include "IBoneSceneNode.h"
|
||||
#include "CBoneSceneNode.h"
|
||||
#include "IAnimatedMeshSceneNode.h"
|
||||
#include "SSkinMeshBuffer.h"
|
||||
#include "Transform.h"
|
||||
#include "aabbox3d.h"
|
||||
#include "irrMath.h"
|
||||
#include "matrix4.h"
|
||||
#include "os.h"
|
||||
#include "vector3d.h"
|
||||
|
||||
Reference in New Issue
Block a user