123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698 |
- //
- // RedSlotBakeModel.cpp
- // empty2dx-desktop
- //
- // Created by Liang zhong on 2022/11/5.
- //
- #include "RedSlotBakeModel.h"
- static GLubyte byteMap[8] = {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
- RedSlotBakeModel::RedSlotBakeModel(std::string aSlotName,int aSlotIndex){
- slotName = aSlotName;
- slotIndex = aSlotIndex;
- }
- void RedSlotBakeModel::finishBake(){
- isSpineBakeFinish = true;
- if(textureArray.size()==0){
- //如果没有纹理就不需要被绘制了
- shoudBeDrawSlot = false;
- }else{
- }
- initBakeFrameInfos();
- }
- void RedSlotBakeModel::initBKAE_FRAME_PLAY(BKAE_FRAME_PLAY& aFrameInfo){
- aFrameInfo.slotName = slotName;
- aFrameInfo.texture = 0;
- aFrameInfo.blend = 0;
- aFrameInfo.alpha = 0;
- aFrameInfo.color = 0;
- aFrameInfo.indices = 0;
- aFrameInfo.uv = 0;
- aFrameInfo.vert = 0;
- aFrameInfo.skipFrameCount = 0;
- aFrameInfo.hasOnceUpdate = false;
- aFrameInfo.hasAttachNode = false;
- aFrameInfo.vertMapIndex = -1;
- if (colorArray.size()==0) {
- aFrameInfo.currentFrameColor = Color4B(255,255,255,255);
- }else{
- Color3B& color = colorArray.at(0);
- aFrameInfo.currentFrameColor.r = color.r;
- aFrameInfo.currentFrameColor.g = color.g;
- aFrameInfo.currentFrameColor.b = color.b;
- }
- if (alphaArray.size()!=0) {
- aFrameInfo.currentFrameColor.a = alphaArray.at(0);
- }
- if(uvArray.size()!=0){
- std::vector<Tex2F> ¤tFrameUV = uvArray[0];
- aFrameInfo.currentFrameUV = ¤tFrameUV;
- }
- if(indicesArray.size()!=0){
- std::vector<unsigned short>& indicesVect = indicesArray.at(0);
- aFrameInfo.triangles.indexCount = (int)indicesVect.size();
- aFrameInfo.triangles.indices = indicesVect.data();
- }
- aFrameInfo.triangles.vertCount = 0;
- if (aFrameInfo.triangles.verts!=nullptr) {
- delete[] aFrameInfo.triangles.verts;
- }
- aFrameInfo.triangles.verts = nullptr;
-
-
- }
- bool RedSlotBakeModel::isBakeFinish(){
- return isSpineBakeFinish;
- }
- bool RedSlotBakeModel::slotShoudBeDrawSlot(){
- return shoudBeDrawSlot;
- }
- void RedSlotBakeModel::initBakeFrameInfos(){
- for (int i =0; i<frameChangeArr.size(); i++) {
- BKAE_FRAME_INFO info = {0};
- BKAE_FRAME_INFO preInfo = {0};
- if (i>0) {
- preInfo = bakeFrameInfos[i-1];
- }
- GLubyte frameInit = frameChangeArr.at(i);
- GLubyte tmp1 = (frameInit>>frameType::frame_skip)&0x01;
- if (tmp1==0x01) {
- info.skipFrameCount = preInfo.skipFrameCount + 1;
- }else{
- info.skipFrameCount = preInfo.skipFrameCount;
- }
- tmp1 = (frameInit>>frameType::frame_texture)&0x01;
- if (tmp1==0x01) {
- info.texture = preInfo.texture + 1;
- }else{
- info.texture = preInfo.texture;
- }
- tmp1 = (frameInit>>frameType::frame_blend)&0x01;
- if (tmp1==0x01) {
- info.blend = preInfo.blend + 1;
- }else{
- info.blend = preInfo.blend;
- }
- tmp1 = (frameInit>>frameType::frame_Color)&0x01;
- if (tmp1==0x01) {
- info.color = preInfo.color + 1;
- }else{
- info.color = preInfo.color;
- }
- tmp1 = (frameInit>>frameType::frame_alpha)&0x01;
- if (tmp1==0x01) {
- info.alpha = preInfo.alpha + 1;
- }else{
- info.alpha = preInfo.alpha;
- }
- tmp1 = (frameInit>>frameType::frame_uv)&0x01;
- if (tmp1==0x01) {
- info.uv = preInfo.uv + 1;
- }else{
- info.uv = preInfo.uv;
- }
- tmp1 = (frameInit>>frameType::frame_indices)&0x01;
- if (tmp1==0x01) {
- info.indices = preInfo.indices + 1;
- }else{
- info.indices = preInfo.indices;
- }
- tmp1 = (frameInit>>frameType::frame_vert)&0x01;
- if (tmp1==0x01) {
- info.vert = preInfo.vert + 1;
- }else{
- info.vert = preInfo.vert;
- }
- bakeFrameInfos.push_back(info);
- }
- //加快性能用,这样不需要反复计算Size,同时对于始终没变的东西不需要反复更新
- colorArraySize = (int)colorArray.size();
- alphaArraySize = (int)alphaArray.size();
- uvArraySize = (int)uvArray.size();
- posArraySize = (int)posArray.size();
- blendFuncArraySize = (int)blendFuncArray.size();
- indicesArraySize = (int)indicesArray.size();
- textureArraySize = (int)textureArray.size();
-
- if (colorArraySize==1&&alphaArraySize==1&&uvArraySize==1&&blendFuncArraySize==1&&indicesArraySize==1) {
- isPosArrayChangeOnlySlot = true;
- }
- if(textureArraySize>0){
- firstTexture = textureArray[0];
- }
- if (blendFuncArraySize>0) {
- firstBlendFunc = blendFuncArray[0];
- }
-
- }
- bool RedSlotBakeModel::isUVChange(int aCurrentFrame){
- if (uvArraySize==1) {
- return false;
- }
- if (aCurrentFrame<2) {
- return false;
- }
- if (bakeFrameInfos[aCurrentFrame-2].uv!=bakeFrameInfos[aCurrentFrame-1].uv) {
- return true;
- }
- return false;
- }
- bool RedSlotBakeModel::getFrameSkip(int aCurrentFrame){
- GLubyte frameInit = frameChangeArr[aCurrentFrame-1];
- GLubyte tmp1 = (frameInit>>frameType::frame_skip)&0x01;
- if (tmp1==0x01) {
- return true;
- }
- return false;
- }
- void RedSlotBakeModel::setFrameSkip(int aCurrentFrame,BKAE_FRAME_PLAY& aFrameInfo){
- GLubyte frameInit = frameChangeArr.at(aCurrentFrame-1);
- GLubyte tmp1 = (frameInit>>frameType::frame_skip)&0x01;
- if (tmp1==0x01) {
- aFrameInfo.skipFrameCount = MIN(aFrameInfo.skipFrameCount+1, frameChangeArr.size()-1);
- }
- }
- cocos2d::Texture2D* RedSlotBakeModel::getTexture(int aCurrentFrame){
- if (textureArraySize) {
- return firstTexture;
- }
- cocos2d::Texture2D* aTexture = textureArray[bakeFrameInfos[aCurrentFrame-1].texture];
- return aTexture;
- }
- BlendFunc& RedSlotBakeModel::getBlendFunc(int aCurrentFrame){
- if (blendFuncArraySize==1) {
- return firstBlendFunc;
- }
- return blendFuncArray[bakeFrameInfos[aCurrentFrame-1].blend];
- }
- void RedSlotBakeModel::getTriangles(int aCurrentFrame,BKAE_FRAME_PLAY& aFrameInfo){
- BKAE_FRAME_INFO &bInfo = bakeFrameInfos[aCurrentFrame-1];
-
- //读取烘培的顶点偏移量
- std::vector<BAKE_POS_INT> &bpi_Arr = posArray[bInfo.vert];
-
- int bpiSize = (int)bpi_Arr.size();
- if (aFrameInfo.triangles.vertCount!=bpiSize) {
- if (aFrameInfo.triangles.verts != nullptr) {
- delete[] aFrameInfo.triangles.verts;
- }
- aFrameInfo.triangles.verts = new V3F_C4B_T2F[bpiSize];
- aFrameInfo.triangles.vertCount = bpiSize;//改这个地方,如果顶线数遍了,再申请数据
- aFrameInfo.hasOnceUpdate = false;
- }
-
-
- for (int aa = 0; aa<bpiSize; aa++) {
- V3F_C4B_T2F &tpv = aFrameInfo.triangles.verts[aa];
- BAKE_POS_INT &bpi = bpi_Arr[aa];
- tpv.vertices.x = bpi.xPos;
- tpv.vertices.y = bpi.yPos;
- }
-
- //如果uvArraySize只需要更新一次就好
- if (aFrameInfo.hasOnceUpdate==false||uvArraySize>1) {
- //读取烘培的UV
- std::vector<Tex2F> ¤tFrameUV = uvArray[bInfo.uv];
- aFrameInfo.currentFrameUV = ¤tFrameUV;
- // aFrameInfo.currentFrameUV = uvArray[bInfo.uv];
-
- for (int aa = 0; aa<bpiSize; aa++) {
- aFrameInfo.triangles.verts[aa].texCoords = (*aFrameInfo.currentFrameUV)[aa];
- }
- }
- if (aFrameInfo.hasOnceUpdate==false||indicesArraySize>1) {
- //读取烘培的Indices
- std::vector<unsigned short>& indicesVect = indicesArray[bInfo.indices];
- aFrameInfo.triangles.indexCount = (int)indicesVect.size();
- aFrameInfo.triangles.indices = indicesVect.data();
- }
-
- if (aFrameInfo.hasOnceUpdate==false||alphaArraySize>1||colorArraySize>1) {
- //读取烘培的Color
- Color3B& color = colorArray[bInfo.color];
- aFrameInfo.currentFrameColor.r = color.r;
- aFrameInfo.currentFrameColor.g = color.g;
- aFrameInfo.currentFrameColor.b = color.b;
- //读取烘培的Aphla
- aFrameInfo.currentFrameColor.a = alphaArray[bInfo.alpha];
-
- for (int aa = 0; aa<bpiSize; aa++) {
- aFrameInfo.triangles.verts[aa].colors = aFrameInfo.currentFrameColor;
- }
- }
- aFrameInfo.hasOnceUpdate = true;
- }
- void RedSlotBakeModel::startBakeOneFrame(){
- GLubyte frameInit = 0x00;
- if(frameChangeArr.size()==0){
- // frameInit = 0xFF;//第一帧所有都要变,除了下面这个frameSkip,如果需要变也应该由之后调用的bakeFrameSkip来调用
- GLubyte tt =~byteMap[frameType::frame_skip];
- frameInit = frameInit&tt;
- }
- frameChangeArr.push_back(frameInit);
- }
- void RedSlotBakeModel::bakeFrameSkip(){
- GLubyte& lastframe = frameChangeArr.at(frameChangeArr.size()-1);
- lastframe = lastframe|byteMap[frameType::frame_skip];
- }
- void RedSlotBakeModel::bakeFrameInfo(std::string& aAttachmentName,cocos2d::Texture2D* aTexture,BlendFunc aBlendFunc,cocos2d::TrianglesCommand::Triangles aTriangles){
- hasChangeAttachmentName = false;
- if(aAttachmentName!=currentBakeAttachmentName){
- hasChangeAttachmentName = true;
- currentBakeAttachmentName = aAttachmentName;
- }
- if (hasChangeAttachmentName) {
- _setTexture(aTexture);
- }
- _setBlendFunc(aBlendFunc);
- _setTriangles(aTriangles);
-
- }
- void RedSlotBakeModel::_setTexture(cocos2d::Texture2D* aTexture){
- if(aTexture == nullptr) {
- CCASSERT(false, "不要设置空纹理!");
- }
- if (textureArray.size()==0) {
- textureArray.push_back(aTexture);
- }else{
- cocos2d::Texture2D* lastTexture = textureArray.at(textureArray.size()-1);
- if (lastTexture!=aTexture) {
- textureArray.push_back(aTexture);
- GLubyte& lastframe = frameChangeArr.at(frameChangeArr.size()-1);
- lastframe = lastframe|byteMap[frameType::frame_texture];
- }
- }
- }
- void RedSlotBakeModel::_setBlendFunc(BlendFunc aBlendFunc){
- if (blendFuncArray.size()==0) {
- blendFuncArray.push_back(aBlendFunc);
- }else{
- BlendFunc lastBlend = blendFuncArray.at(blendFuncArray.size()-1);
- if (lastBlend!=aBlendFunc) {
- blendFuncArray.push_back(aBlendFunc);
- GLubyte& lastframe = frameChangeArr.at(frameChangeArr.size()-1);
- lastframe = lastframe|byteMap[frameType::frame_blend];
- }
- }
- }
- void RedSlotBakeModel::_setTriangles(cocos2d::TrianglesCommand::Triangles aTriangles){
- //烘培顶点位移
- std::vector<BAKE_POS_INT> posVect;
- for (int i = 0; i<aTriangles.vertCount; i++) {
- BAKE_POS_INT bp;
- bp.xPos = aTriangles.verts[i].vertices.x;
- bp.yPos = aTriangles.verts[i].vertices.y;
- maxXPos = MAX(maxXPos, bp.xPos);
- maxYPos = MAX(maxYPos, bp.yPos);
- minXPos = MIN(minXPos, bp.xPos);
- minYPos = MIN(minYPos, bp.yPos);
- posVect.push_back(bp);
- }
- if (posArray.size()==0) {
- posArray.push_back(posVect);
- }else{
- std::vector<BAKE_POS_INT> pre = posArray[posArray.size()-1];
- if (_vertVectIsEqual(posVect, pre)==false) {
- posArray.push_back(posVect);
- GLubyte& lastframe = frameChangeArr.at(frameChangeArr.size()-1);
- lastframe = lastframe|byteMap[frameType::frame_vert];
- }
-
- }
-
-
- //烘培颜色变化
- if (colorArray.size()==0) {
- Color4B colors = aTriangles.verts[0].colors;
- colorArray.push_back(Color3B(colors.r, colors.g, colors.b));
- }else{
- Color4B colors = aTriangles.verts[0].colors;
- Color3B currentColor = Color3B(colors.r, colors.g, colors.b);
- Color3B lastColor = colorArray.at(colorArray.size()-1);
- if (lastColor.r!=currentColor.r||lastColor.g!=currentColor.g||lastColor.b!=currentColor.b) {
- colorArray.push_back(currentColor);
- GLubyte& lastframe = frameChangeArr.at(frameChangeArr.size()-1);
- lastframe = lastframe|byteMap[frameType::frame_Color];
- }
- }
-
- //烘培alpha变化
- if (alphaArray.size()==0) {
- Color4B colors = aTriangles.verts[0].colors;
- alphaArray.push_back(colors.a);
- }else{
- GLubyte currentAlpha = aTriangles.verts[0].colors.a;
- GLubyte lastAlpha = alphaArray.at(alphaArray.size()-1);
- if (currentAlpha!=lastAlpha) {
- alphaArray.push_back(currentAlpha);
- GLubyte& lastframe = frameChangeArr.at(frameChangeArr.size()-1);
- lastframe = lastframe|byteMap[frameType::frame_alpha];
- }
- }
-
- if (hasChangeAttachmentName) {
- //UV和顶点的变化必然伴随AttachmentName变化
- //烘培UV变化
- std::vector<Tex2F> uvVect;
- for (int i = 0; i<aTriangles.vertCount; i++) {
- Tex2F bp = aTriangles.verts[i].texCoords;
- uvVect.push_back(bp);
- }
- if (uvArray.size()==0) {
- uvArray.push_back(uvVect);
- }else{
- std::vector<Tex2F> lastUV = uvArray.at(uvArray.size()-1);
- if (_uvVectIsEqual(uvVect, lastUV)==false) {
- uvArray.push_back(uvVect);
- GLubyte& lastframe = frameChangeArr.at(frameChangeArr.size()-1);
- lastframe = lastframe|byteMap[frameType::frame_uv];
- }
- }
-
- //烘培顶点顺序数组
- if (indicesArray.size()==0) {
- std::vector<unsigned short> indicesVect;
- for (int i = 0; i<aTriangles.indexCount; i++) {
- unsigned short ind = aTriangles.indices[i];
- indicesVect.push_back(ind);
- }
- indicesArray.push_back(indicesVect);
- }else{
- std::vector<unsigned short> lastIndices = indicesArray.at(indicesArray.size()-1);
- if (_indicesVectIsEqual(aTriangles.indices,aTriangles.indexCount, lastIndices)==false) {
- std::vector<unsigned short> indicesVect;
- for (int i = 0; i<aTriangles.indexCount; i++) {
- unsigned short ind = aTriangles.indices[i];
- indicesVect.push_back(ind);
- }
- indicesArray.push_back(indicesVect);
- GLubyte& lastframe = frameChangeArr.at(frameChangeArr.size()-1);
- lastframe = lastframe|byteMap[frameType::frame_indices];
- }
- }
- }
-
- }
- bool RedSlotBakeModel::_uvVectIsEqual(std::vector<Tex2F> a,std::vector<Tex2F> b){
- if (a.size()!=b.size()) {
- return false;
- }
- if (a.size()==0||b.size()==0) {
- if (a.size()==0&&b.size()==0) {
- return true;
- }
- return false;
- }
- Tex2F& a1 = a.at(0);
- Tex2F& b1 = b.at(0);
- if (a1.u!=b1.u||a1.v!=b1.v) {
- return false;
- }
- a1 = a.at(a.size()-1);
- b1 = b.at(b.size()-1);
- if (a1.u!=b1.u||a1.v!=b1.v) {
- return false;
- }
-
- a1 = a.at((int)(a.size()/2));
- b1 = b.at((int)(b.size()/2));
- if (a1.u!=b1.u||a1.v!=b1.v) {
- return false;
- }
-
- return true;
- }
- bool RedSlotBakeModel::_indicesVectIsEqual(unsigned short *a,int aCount,std::vector<unsigned short> b){
- if (aCount!=b.size()) {
- return false;
- }
- if (aCount==0||b.size()==0) {
- if (aCount==0&&b.size()==0) {
- return true;
- }
- return false;
- }
- short a1 = a[0];
- short b1 = b.at(0);
- if (a1!=b1||a1!=b1) {
- return false;
- }
- a1 = a[aCount-1];
- b1 = b.at(b.size()-1);
- if (a1!=b1||a1!=b1) {
- return false;
- }
-
- a1 = a[(int)(aCount/2)];
- b1 = b.at((int)(b.size()/2));
- if (a1!=b1||a1!=b1) {
- return false;
- }
-
- return true;
- }
- bool RedSlotBakeModel::_vertVectIsEqual(std::vector<BAKE_POS_INT> &a,std::vector<BAKE_POS_INT> &b){
- if (a.size()!=b.size()) {
- return false;
- }
- if (a.size()==0||b.size()==0) {
- if (a.size()==0&&b.size()==0) {
- return true;
- }
- return false;
- }
- for (int i = 0; i<a.size(); i++) {
- BAKE_POS_INT bpi_A = a.at(i);
- BAKE_POS_INT bpi_B = b.at(i);
- if (bpi_A.xPos!=bpi_B.xPos||bpi_A.yPos!=bpi_B.yPos) {
- return false;
- }
- }
- return true;
- }
- const std::string& RedSlotBakeModel::getSlotName(){
- return slotName;
- }
- const int RedSlotBakeModel::getSlotIndex(){
- return slotIndex;
- }
- void RedSlotBakeModel::setSlotName(const std::string& aSlotName){
- slotName = aSlotName;
- }
- void RedSlotBakeModel::setSlotIndex(int aSlotIndex){
- slotIndex = aSlotIndex;
- }
- int RedSlotBakeModel::getVertCount(){
- if (posArraySize>0) {
- return (int)posArray[0].size();
- }
- return 0;
- }
- int RedSlotBakeModel::getMaxXPos(){
- return maxXPos;
- }
- int RedSlotBakeModel::getMaxYPos(){
- return maxYPos;
- }
- int RedSlotBakeModel::getMinXPos(){
- return minXPos;
- }
- int RedSlotBakeModel::getMinYPos(){
- return minYPos;
- }
- void RedSlotBakeModel::setMaxXPos(int pos){
- maxXPos = pos;
- }
- void RedSlotBakeModel::setMaxYPos(int pos){
- maxYPos = pos;
- }
- void RedSlotBakeModel::setMinXPos(int pos){
- minXPos = pos;
- }
- void RedSlotBakeModel::setMinYPos(int pos){
- minYPos = pos;
- }
- const std::vector<std::vector<BAKE_POS_INT>>& RedSlotBakeModel::getPosArray(){
- return posArray;
- }
- void RedSlotBakeModel::addPosArray(const std::vector<BAKE_POS_INT>& aPosArray){
- posArray.push_back(aPosArray);
- }
- const std::vector<BlendFunc>& RedSlotBakeModel::getBlendFuncArray(){
- return blendFuncArray;
- }
- void RedSlotBakeModel::addBlendFuncToArray(const BlendFunc& blendFunc){
- blendFuncArray.push_back(blendFunc);
- }
- const std::vector<Color3B>& RedSlotBakeModel::getColorArray(){
- return colorArray;
- }
- void RedSlotBakeModel::addColorToArray(const Color3B& color){
- colorArray.push_back(color);
- }
- const std::vector<GLubyte>& RedSlotBakeModel::getAlphaArray(){
- return alphaArray;
- }
- void RedSlotBakeModel::addAlphaToArray(GLubyte Alpha) {
- alphaArray.push_back(Alpha);
- }
- const std::vector<std::vector<Tex2F>>& RedSlotBakeModel::getUvArray(){
- return uvArray;
- }
- void RedSlotBakeModel::addUvArray(const std::vector<Tex2F>& aUvArray){
- uvArray.push_back(aUvArray);
- }
- const std::vector<std::vector<unsigned short>>& RedSlotBakeModel::getIndicesArray(){
- return indicesArray;
- }
- void RedSlotBakeModel::addIndicesArray(const std::vector<unsigned short>& aIndicesArray){
- indicesArray.push_back(aIndicesArray);
- }
- const std::vector<GLubyte>& RedSlotBakeModel::getFrameChangeArr(){
- return frameChangeArr;
- }
- void RedSlotBakeModel::addFrameChangeToArr(GLubyte aFrameChange){
- frameChangeArr.push_back(aFrameChange);
- }
- const std::vector<cocos2d::Texture2D*>& RedSlotBakeModel::getTextureArray(){
- return textureArray;
- }
- void RedSlotBakeModel::addTextureToArray(cocos2d::Texture2D* texture){
- textureArray.push_back(texture);
- }
- void RedSlotBakeModel::getTriangles(int aCurrentFrame,BKAE_FRAME_PLAY& aFrameInfo,const Point& offSet,float dis,V3F_C4B_T2F *beginVert,bool merge){
- BKAE_FRAME_INFO &bInfo = bakeFrameInfos[aCurrentFrame-1];
-
- //读取烘培的顶点偏移量
- std::vector<BAKE_POS_INT> &bpi_Arr = posArray[bInfo.vert];
- int bpiSize = (int)bpi_Arr.size();
- aFrameInfo.triangles.vertCount = bpiSize;
- if (aCurrentFrame<2||dis==0) {
- for (int aa = 0; aa<bpiSize; aa++) {
- BAKE_POS_INT &bpi = bpi_Arr[aa];
- beginVert[aa].vertices.x = bpi.xPos+offSet.x;
- beginVert[aa].vertices.y = bpi.yPos+offSet.y;
- }
- }else{
- BKAE_FRAME_INFO &prebInfo = bakeFrameInfos[aCurrentFrame-2];
- if (prebInfo.vert!=bInfo.vert&&merge) {
- std::vector<BAKE_POS_INT> &preBpi_Arr = posArray[prebInfo.vert];
- for (int aa = 0; aa<bpiSize; aa++) {
- BAKE_POS_INT &bpi = bpi_Arr[aa];
- BAKE_POS_INT &prebpi = preBpi_Arr[aa];
- beginVert[aa].vertices.x = prebpi.xPos + dis*(bpi.xPos - prebpi.xPos)+offSet.x;
- beginVert[aa].vertices.y = prebpi.yPos + dis*(bpi.yPos - prebpi.yPos)+offSet.y;
- }
- }else{
- for (int aa = 0; aa<bpiSize; aa++) {
- BAKE_POS_INT &bpi = bpi_Arr[aa];
- beginVert[aa].vertices.x = bpi.xPos+offSet.x;
- beginVert[aa].vertices.y = bpi.yPos+offSet.y;
- }
- }
- }
-
- //如果uvArraySize只需要更新一次就好
- if (aFrameInfo.hasOnceUpdate==false||uvArraySize>1) {
- //读取烘培的UV
- std::vector<Tex2F> ¤tFrameUV = uvArray[bInfo.uv];
- aFrameInfo.currentFrameUV = ¤tFrameUV;
- // aFrameInfo.currentFrameUV = uvArray[bInfo.uv];
-
- for (int aa = 0; aa<bpiSize; aa++) {
- beginVert[aa].texCoords = (*aFrameInfo.currentFrameUV)[aa];
- }
- }
- if (aFrameInfo.hasOnceUpdate==false||indicesArraySize>1) {
- //读取烘培的Indices
- std::vector<unsigned short>& indicesVect = indicesArray[bInfo.indices];
- aFrameInfo.triangles.indexCount = (int)indicesVect.size();
- aFrameInfo.triangles.indices = indicesVect.data();
- }
-
- if (aFrameInfo.hasOnceUpdate==false||alphaArraySize>1||colorArraySize>1) {
- //读取烘培的Color
- Color3B& color = colorArray[bInfo.color];
- aFrameInfo.currentFrameColor.r = color.r;
- aFrameInfo.currentFrameColor.g = color.g;
- aFrameInfo.currentFrameColor.b = color.b;
- //读取烘培的Aphla
- aFrameInfo.currentFrameColor.a = alphaArray[bInfo.alpha];
-
- for (int aa = 0; aa<bpiSize; aa++) {
- beginVert[aa].colors = aFrameInfo.currentFrameColor;
- }
- }
- aFrameInfo.hasOnceUpdate = true;
- }
|