88 lines
1.7 KiB
C++
88 lines
1.7 KiB
C++
/**
|
|
* @file dl_actor.h
|
|
* @brief 3d绘图元素,翻译为角色
|
|
*
|
|
*
|
|
* @version 1.0
|
|
* @author lveyou
|
|
* @date 22-01-16
|
|
*
|
|
* @note 引用模型id,可以拥有独立的3d变换
|
|
* @note 如果存在骨骼,则拥有独立的骨骼变换
|
|
*/
|
|
#pragma once
|
|
|
|
#include <string>
|
|
|
|
#include "dl_type.h"
|
|
#include "memory/dl_memory_pool.h"
|
|
#include "math/dl_transform.h"
|
|
#include "render/dl_rigid_body.h"
|
|
|
|
namespace dl
|
|
{
|
|
|
|
class BoneAnimation;
|
|
|
|
//! 3D绘图对象
|
|
class Actor
|
|
{
|
|
friend class Factory;
|
|
public:
|
|
/**
|
|
* @brief 更新动画,没有动画不用调用
|
|
* @param[in] dt 动画步进,为0则使用帧间隔
|
|
*/
|
|
void Update(Float dt = 0);
|
|
|
|
void Render();
|
|
|
|
//-----------------------------animation---------------------------
|
|
/**
|
|
* @brief 是否含有动画
|
|
*/
|
|
bool HasAni() { return _boneAnimation; }
|
|
/**
|
|
* @brief 返回动画数量
|
|
*/
|
|
size_t GetAniSize();
|
|
/**
|
|
* @brief 返回动画名字
|
|
* @retval 失败返回空
|
|
*/
|
|
std::string GetAniName(size_t i);
|
|
/**
|
|
* @brief 切换动画(从头播放)
|
|
*/
|
|
void SwitchAni(std::string_view name);
|
|
/**
|
|
* @brief 返回当前动画
|
|
* @retval 失败返回空(没有骨骼动画时)
|
|
*/
|
|
std::string GetAniCurrent();
|
|
|
|
Transform* GetTrans() { return _trans; }
|
|
|
|
void SetTrans(Transform* tsf) { _trans = tsf; }
|
|
|
|
//-----------------------------rigidBody---------------------------
|
|
/**
|
|
* @brief 创建刚体
|
|
*/
|
|
void CreateRigidBody();
|
|
|
|
~Actor();
|
|
private:
|
|
size_t _idModel;
|
|
Transform* _trans;//变换,必然存在
|
|
Color* _color;//没有代表白色
|
|
BoneAnimation* _boneAnimation;//蒙皮骨骼动画
|
|
RigidBody* _rigidBody;//刚体
|
|
|
|
bool _no_bone_animation();
|
|
};
|
|
|
|
|
|
using gcActor = GC<Actor>;
|
|
|
|
}
|