first commit

This commit is contained in:
2026-06-22 11:49:35 +02:00
commit d805f2ba86
619 changed files with 126873 additions and 0 deletions

View File

@ -0,0 +1,35 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __IAUTOMATEDPROPERTYPROVIDER__
#define __IAUTOMATEDPROPERTYPROVIDER__
#include "motion/motion_channel.h"
namespace GS {
struct Quaternion;
namespace Automation {
/// Automated property provider interface.
struct IPropertyProvider
{
virtual bool GetProperty(Core::MotionChannel::Type, float &);
virtual bool SetProperty(Core::MotionChannel::Type, float);
virtual Quaternion GetRotation() const;
virtual bool SetRotation(const Quaternion &);
virtual ~IPropertyProvider() {}
};
} // Automation
} // GS
#endif // __IAUTOMATEDPROPERTYPROVIDER__

View File

@ -0,0 +1,112 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NAUTOMATIONPLAYER__
#define __NAUTOMATIONPLAYER__
#include "automation/automation_source.h"
#include "automation/automated_property_provider.h"
#include "motion/motion.h" // FIXME move to motion_group
#include "math/vector.h"
#include "memory/bit_field.h"
#include "memory/nauto_ptr.h"
#include "memory/nshared_ptr.h"
namespace GS {
namespace Automation {
struct SourceGroup;
using Core::Motion;
using Core::MotionChannel;
/*!
@short Automation player.
@author Emmanuel Julien (ejulien@gsworks.fr)
*/
class Player
{
public:
enum AddSourceMode
{
SourceSet = 0, ///< Stop all current animation sources.
SourceAdd ///< Add a new animation source.
};
enum
{
FlagRelativeMotion = 1 ///< Motion sources should be evaluated in relative mode (not absolute)
};
protected:
bool active;
SharedList <Motion *> motions;
SharedList <Source *> sources;
/// Only valid during evaluation.
float *weight_table;
public:
AutoPtr <IPropertyProvider> property_provider;
/*!
@name Automation player.
@{
*/
BitField flags;
/// Start an automation source.
Source *StartAutomation(Source *, float blend = Units::Sec(0.1), AddSourceMode = SourceSet, float weight = 1);
/// Dispose of all sources.
void DisposeAutomationSources();
bool IsAutomated() const;
bool IsAutomationDone() const;
bool GetAutomationActive() const;
void SetAutomationActive(bool active);
void Evaluate(const Time &dt_time);
void BlendAutomatedProperty(MotionChannel::Type, float, float);
/// Get animation sources.
const SharedList <Source *> &GetSourceList() const { return sources; }
/// @}
/*!
@name Motion container.
@{
*/
// FIXME move to motion_group
const SharedList <Motion *> &GetMotionList() const { return motions; }
Motion *GetMotion(const char *id) const;
Motion *GetMotionFromIndex(uint index) const;
bool AddMotion(Motion *motion);
void RemoveMotion(Motion *motion);
/// @}
bool FromMetaTag(NML::Tag &);
NML::Tag *AsMetaTag();
Player();
~Player();
};
} // Automation
} // GS
#endif // __NAUTOMATIONPLAYER__

View File

@ -0,0 +1,86 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NAUTOMATIONSOURCE__
#define __NAUTOMATIONSOURCE__
#include "geometry/curve.h"
#include "math/quaternion.h"
#include "math/vector.h"
#include "memory/nshared_ptr.h"
namespace GS {
namespace Automation {
class Player;
/*!
@short Base automation source.
@author Emmanuel Julien (ejulien@gsworks.fr)
*/
class Source : public SharedObject
{
public:
enum Type
{
TypeMotion = 0
};
protected:
Type type;
Vector4 p_pos,
p_euler;
Quaternion p_quat;
float weight,
weight_target,
weight_step;
bool dispose;
public:
NPLACEMENT_NEW(AnimationSource)
Time time;
float time_scale;
bool relative;
Type GetType() const { return type; }
virtual void Update(const Time &dt_time);
virtual void Evaluate(Player &target) = 0;
virtual bool EvaluateRotation(Quaternion &q) = 0;
virtual void SetLoopMode(Curve::LoopMode = Curve::Reset) {}
virtual void SetLoop(const Time &start = Time::Inf, const Time &end = Time::Inf) {}
/// Is animation source done.
virtual bool IsDone() const = 0;
/// Mark the source as disposable.
void Dispose(float blend = Units::Sec(0.1));
/// Can the source be disposed of.
bool CanDispose() const;
void SetWeight(float _weight = 1, float _blend = Units::Sec(1));
float GetWeight() const { return weight; }
explicit Source();
~Source();
};
} // Automation
} // GS
#endif // __NAUTOMATIONSOURCE__

View File

@ -0,0 +1,62 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NAUTOMATIONSOURCEGROUP__
#define __NAUTOMATIONSOURCEGROUP__
#include "automation/automation_source.h"
namespace GS {
namespace Automation {
/*!
@short Automation source group.
This is the structure holding automation sources created when starting
automations on a group of items like a hierarchy, a scene or a group of
items.
@author Emmanuel Julien (ejulien@gsworks.fr)
*/
struct SourceGroup
{
NPLACEMENT_NEW(AnimationSource)
SharedList <Source *> source_list;
/*!
@short Blend group sources weight to 0 then dispose of them.
@note The group can be deleted before the sources are disposed of.
*/
void Dispose(float blend = Units::Sec(1));
void SetLoopMode(Curve::LoopMode = Curve::Reset);
void SetLoop(const Time &loop_start = Time::Inf, const Time &loop_end = Time::Inf);
void SetTime(const Time &t);
void SetTimeScale(float scale = 1);
void SetWeight(float weight, float blend = Units::Sec(0.1));
void SetRelative(bool relative);
bool IsDone() const;
/*!
@short Get time.
Get group time using the root source.
Returns 0 if there is no source in the group.
*/
Time GetTime() const;
};
} // Automation
} // GS
#endif // __NAUTOMATIONSOURCEGROUP__