save code
This commit is contained in:
+34
-20
@@ -12,13 +12,20 @@
|
||||
using namespace std;
|
||||
using json = nlohmann::json;
|
||||
|
||||
struct Frame {
|
||||
string name;
|
||||
float x;
|
||||
float y;
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(Frame, name, x, y)
|
||||
};
|
||||
|
||||
struct Motion {
|
||||
string type;
|
||||
vector<string> png_names;
|
||||
string name;
|
||||
vector< Frame> frames;
|
||||
string getMotionId() {
|
||||
return type;
|
||||
return name;
|
||||
}
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(Motion, type, png_names)
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(Motion, name, frames)
|
||||
};
|
||||
|
||||
struct InitArg
|
||||
@@ -34,7 +41,7 @@ struct PushConstants {
|
||||
float myValue;
|
||||
};
|
||||
|
||||
using Callback = std::function<void(const std::string&)>;
|
||||
using Callback = std::function<void()>;
|
||||
using AnimationFinishedCallback = std::function<void()>;
|
||||
|
||||
class FaceApp :public Application
|
||||
@@ -103,7 +110,7 @@ private:
|
||||
VkPipelineLayout m_pipelineLayout = VK_NULL_HANDLE;
|
||||
VkDescriptorSetLayout m_descriptorSetLayout = VK_NULL_HANDLE;
|
||||
vector<VkDescriptorSet> m_descriptor_sets;
|
||||
const uint32_t kMaxTexture = 60;
|
||||
const uint32_t kMaxTexture = 10;
|
||||
vector<Texture> m_texs;
|
||||
vector<Texture> m_texs_next;
|
||||
vector<Texture> m_texs_ex;
|
||||
@@ -139,28 +146,35 @@ private:
|
||||
|
||||
|
||||
public:
|
||||
Callback _callback;
|
||||
void loadMotionThread();
|
||||
std::thread worker_;
|
||||
bool _isLoadMotion = false;
|
||||
Callback _callback_loadfinish;
|
||||
AnimationFinishedCallback _animationFinishedCallback;
|
||||
bool _animationLoop = true;
|
||||
string preReadyMotion(const std::string& json, Callback callback);
|
||||
void changeMotion(const string motion_type, AnimationFinishedCallback callback, bool loop);
|
||||
string preLoadMotionList(const vector<string>& motions, Callback callback);
|
||||
vector<Motion>_preLoadMotions;
|
||||
vector<Motion>_curMotions;
|
||||
void changeMotionList(AnimationFinishedCallback callback, bool loop);
|
||||
|
||||
//void changeMotion(Motion& motion);
|
||||
InitArg _initArg;
|
||||
//Motion _curMotion;
|
||||
string _curMotion_type;
|
||||
int _curMotion_png_size;
|
||||
Motion _nextMotion;
|
||||
int _nextMotionIndex;
|
||||
//string _curMotion_type;
|
||||
//int _curMotion_png_size;
|
||||
//Motion _nextMotion;
|
||||
//int _nextMotionIndex;
|
||||
|
||||
enum MotionState {
|
||||
ready,
|
||||
loading_next_motion,
|
||||
load_next_motion_finished,
|
||||
};
|
||||
//enum MotionState {
|
||||
// ready,
|
||||
// loading_next_motion,
|
||||
// load_next_motion_finished,
|
||||
//};
|
||||
|
||||
MotionState _motionState = ready;
|
||||
//MotionState _motionState = ready;
|
||||
|
||||
int _curTexIndex = 0;
|
||||
int _curFrameIndex = 0;
|
||||
int _curMotionIndex = 0;
|
||||
void SetInitArg(const char* arg);
|
||||
|
||||
void drawFrame(long long frameTime)override;
|
||||
|
||||
Reference in New Issue
Block a user