// // RedSpineBakeModel.hpp // empty2dx-desktop // // Created by Liang zhong on 2022/11/5. // #ifndef RedAnimationBakeModel_h #define RedAnimationBakeModel_h #include #include "cocos2d.h" #include "RedSlotBakeModel.h" #include struct DrawOrderMD { int frame; int arrIndex; }; struct EventMD{ int frame; std::vector eventNames; }; class RedAnimationBakeModel { public: RedAnimationBakeModel(); virtual ~RedAnimationBakeModel(); RedAnimationBakeModel(const std::string aFileName,const std::string& aAnimateName); RedSlotBakeModel* getSlotFromKey(int akey);//快速查询 RedSlotBakeModel* findSlotFromKey(int akey);//慢速查询,在绘制的时候千万别用,主要用来mix的时候判断合法性的 RedSlotBakeModel* getSlotByDrawOrder(int aIndex,int aFrameNum,int &aCurrentDrawOrderIndex); void handleEventByFrame(Node* target, std::function cb); //处理当前帧的事件 目前只是wwise事件 void addSlotByName(RedSlotBakeModel *aSlot); virtual int getSlotCount(); const std::vector& getAllSlotKey(); void setFileName(const std::string& aFileName); const std::string& getFileName(); int getTotalBakeFrame(); void setTotalBakeFrame(int atotalBakeFrame); void setLastDrawOverTime(float aLastDrawOverTime); float getLastDrawOverTime(); void setCurrentFrameRate(int aRate); int getCurrentFrameRate(); void setAimationName(const std::string& animName); const std::string& getAimationName(); virtual bool isMixAnimation(); //bounds void setMaxXPos(int aMaxXPos); int getMaxXPos(); void setMaxYPos(int aMaxYPos); int getMaxYPos(); void setMinXPos(int aMinXPos); int getMinXPos(); void setMinYPos(int aMinYPos); int getMinYPos(); void setLeftBottom(const Vec2& pos); const Vec2& getLeftBottom(); void setRightTopPos(const Vec2& pos); const Vec2& getRightTopPos(); void setLeftBottomSubSizePos(const Vec2& pos); const Vec2& getLeftBottomSubSizePos(); void setRightTopSubSizePos(const Vec2& pos); const Vec2& getRightTopSubSizePos(); //SlotArr void setSlotArr(const std::map& aSlotArr); const std::map& getSlotArr(); //DrawOrderArr void setDrawOrderArr(std::vector>& aDrawOrderArr); const std::vector>& getDrawOrderArr(); //DrawOrderArrIndex void setDrawOrderArrIndex(const std::vector& aDrawOrderArrIndex); const std::vector& getDrawOrderArrIndex(); //EventArr void setEventArr(const std::vector& aEventArr); const std::vector& getEventArr(); //boneAttachs void setBoneAttachs(std::map>& aBoneAttachs); const std::map>& getBoneAttachs(); std::vector getAllgetBoneAttachs(); //bake时候专用的 void setBeginLastDraw(); bool isBeginLastDraw(); void setBakeFinish(float alastDrawOverTime); bool isBakeFinish(); void drawOneFrame(); void updateDrawOrder(spine::Vector &aDrawList); void addEventData(std::string eventName);//增加一个需要被记录的事件 void addboneAttachNames(std::string aName);//增加一个需要被记录的外接连动bone的名字 const std::vector& getAllboneAttachNames(); void bakeAModePointBeginPos(std::string aName,Point aPoint); void bakeAModePoint(std::string aName,Point aPoint); virtual const Point& getABakeModePoint(std::string aName,int aFrame); const Point& getABakeModePoint(int aIndex,int aFrame); int getBoneAttachsSearchIndex(std::string aKey);//获取指定Key的BoneAttachs在数组的什么位置 protected: bool isSpineBakeFinish = false; bool beginLastDraw = false; //update会先于draw调用,最后一个update后还有一个draw需要记录下来。 std::vector boneAttachNames;//所有需要被记录的外接bone的名字 std::map boneAttachsBeginPos;//所有需要被记录的外接bone的初始位置 std::vector slotArrVector; //提高查询性能专用,slotArr的Vector版 int slotArrSize = 0; //提高查询性能专用,减少slotArr.size的调用 int drawOrderArrIndexSize = 0; std::vector> boneAttachsVector;//记录外接连动BakeNode的位子偏移,因为我们是用bone来代替外接模块的联动,加快性能用 //*******************************************需要protolBuffer存************************************** std::string fileName; std::string animateName; std::map> boneAttachs;//记录外接连动BakeNode的位子偏移,因为我们是用bone来代替外接模块的联动 std::map slotArr;//记录所有Slot std::vector> drawOrderArr;//记录slot所有Draworder变化 std::vector drawOrderArrIndex; //记录哪帧Draworder发生了变化 std::vector eventArr; //记录哪帧有事件信息 主要用来播放wwise事件的 int totalBakeFrame = 0; float lastDrawOverTime = 0.0; //最后一个draw的实际长度,因为烘培的帧率和spine帧率不一定相等,所以最后一帧不一定能对齐 int maxXPos = 0; int maxYPos = 0; int minXPos = 0; int minYPos = 0; cocos2d::Vec2 leftBottom; cocos2d::Vec2 rightTopPos; cocos2d::Vec2 leftBottomSubSizePos; //方便出屏幕判断,预先将leftBottom里面去加上Size,因为leftBottom出界需要判断自己右上角,减少之后的计算 cocos2d::Vec2 rightTopSubSizePos; //方便出屏幕判断,预先将Rightop里面去减去Size,因为Righttop出界需要判断自己左下角,减少之后的计算 int currentFrameRate = 30; //当前帧率,默认30 //*********************************************************************************************** }; #endif /* RedSpineBakeModel_h */