X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FPerson.cpp;h=330dd40fb9f0e415bd9fe9f58defb676b6ffeb82;hb=ff29f47f799d99cec7c2a6aa2cf818da2b931fc5;hp=3e0f52807d6cbbc60397baa42a0fec7d1da92368;hpb=bf99f4428d07954f6586112f211ac4fb63946331;p=lugaru.git diff --git a/Source/Person.cpp b/Source/Person.cpp index 3e0f528..330dd40 100644 --- a/Source/Person.cpp +++ b/Source/Person.cpp @@ -160,14 +160,13 @@ void Person::CatchFire() int howmany; for (int i = 0; i < 10; i++) { howmany = abs(Random() % (skeleton.num_joints)); - if (!skeleton.free) - flatvelocity = velocity; - if (skeleton.free) + if (skeleton.free) { flatvelocity = skeleton.joints[howmany].velocity; - if (!skeleton.free) - flatfacing = DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0) * scale + coords; - if (skeleton.free) flatfacing = skeleton.joints[howmany].position * scale + coords; + } else { + flatvelocity = velocity; + flatfacing = DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0) * scale + coords; + } Sprite::MakeSprite(flamesprite, flatfacing, flatvelocity, 1, 1, 1, 2, 1); } @@ -316,22 +315,15 @@ void Person::DoBlood(float howmuch, int which) for (int i = 0; i < 3; i++) { // emit blood particles bloodvel = 0; - if (!skeleton.free) { - bloodvel.z = 10; - bloodvel = DoRotation(bloodvel, ((float)(Random() % 100)) / 4, yaw + ((float)(Random() % 100)) / 4, 0) * scale; - } if (skeleton.free) { bloodvel -= DoRotation(skeleton.forward * 10 * scale, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0); - } - if (skeleton.free) bloodvel += DoRotation(jointVel(head), ((float)(Random() % 100)) / 4, yaw + ((float)(Random() % 100)) / 4, 0) * scale; - if (!skeleton.free) - bloodvel += DoRotation(velocity, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0) * scale; - if (skeleton.free) { Sprite::MakeSprite(bloodsprite, jointPos(head) * scale + coords, bloodvel, 1, 1, 1, .05, 1); Sprite::MakeSprite(bloodflamesprite, jointPos(head) * scale + coords, bloodvel, 1, 1, 1, .3, 1); - } - if (!skeleton.free) { + } else { + bloodvel.z = 10; + bloodvel = DoRotation(bloodvel, ((float)(Random() % 100)) / 4, yaw + ((float)(Random() % 100)) / 4, 0) * scale; + bloodvel += DoRotation(velocity, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0) * scale; Sprite::MakeSprite(bloodsprite, DoRotation((jointPos(head) + jointPos(neck)) / 2, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .05, 1); Sprite::MakeSprite(bloodflamesprite, DoRotation((jointPos(head) + jointPos(neck)) / 2, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .3, 1); } @@ -446,22 +438,15 @@ void Person::DoBloodBig(float howmuch, int which) // emit blood particles // FIXME: copypaste from above bloodvel = 0; - if (!skeleton.free) { - bloodvel.z = 10; - bloodvel = DoRotation(bloodvel, ((float)(Random() % 100)) / 4, yaw + ((float)(Random() % 100)) / 4, 0) * scale; - } if (skeleton.free) { bloodvel -= DoRotation(skeleton.forward * 10 * scale, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0); - } - if (skeleton.free) bloodvel += DoRotation(jointVel(head), ((float)(Random() % 100)) / 4, yaw + ((float)(Random() % 100)) / 4, 0) * scale; - if (!skeleton.free) - bloodvel += DoRotation(velocity, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0) * scale; - if (skeleton.free) { Sprite::MakeSprite(bloodsprite, jointPos(head) * scale + coords, bloodvel, 1, 1, 1, .05, 1); Sprite::MakeSprite(bloodflamesprite, jointPos(head) * scale + coords, bloodvel, 1, 1, 1, .3, 1); - } - if (!skeleton.free) { + } else { + bloodvel.z = 10; + bloodvel = DoRotation(bloodvel, ((float)(Random() % 100)) / 4, yaw + ((float)(Random() % 100)) / 4, 0) * scale; + bloodvel += DoRotation(velocity, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0) * scale; Sprite::MakeSprite(bloodsprite, DoRotation((jointPos(head) + jointPos(neck)) / 2, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .05, 1); Sprite::MakeSprite(bloodflamesprite, DoRotation((jointPos(head) + jointPos(neck)) / 2, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .3, 1); } @@ -624,7 +609,6 @@ bool Person::DoBloodBigWhere(float howmuch, int which, XYZ where) static float rotationpoint; static int whichtri; static XYZ p1, p2, p3, p0; - static XYZ N, temp; XYZ bary; XYZ gxx, gyy; float coordsx, coordsy; @@ -649,13 +633,6 @@ bool Person::DoBloodBigWhere(float howmuch, int which, XYZ where) p1 = skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[0]]; p2 = skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[1]]; p3 = skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[2]]; - /* - CrossProduct(p2-p1,p3-p1,&N); - CrossProduct(p0-p1,p3-p1,&temp); - s = dotproduct(&temp,&N)/findLength(&N); - CrossProduct(p2-p1,p1-p0,&temp); - t = dotproduct(&temp,&N)/findLength(&N); - r = 1 - (s + t);*/ bary.x = distsq(&p0, &p1); bary.y = distsq(&p0, &p2); @@ -685,31 +662,21 @@ bool Person::DoBloodBigWhere(float howmuch, int which, XYZ where) coordsx = skeleton.drawmodel.Triangles[whichtri].gx[0] * bary.x + skeleton.drawmodel.Triangles[whichtri].gx[1] * bary.y + skeleton.drawmodel.Triangles[whichtri].gx[2] * bary.z; coordsy = skeleton.drawmodel.Triangles[whichtri].gy[0] * bary.x + skeleton.drawmodel.Triangles[whichtri].gy[1] * bary.y + skeleton.drawmodel.Triangles[whichtri].gy[2] * bary.z; - //coordsx=skeleton.drawmodel.Triangles[whichtri].gx[1]; - //coordsy=skeleton.drawmodel.Triangles[whichtri].gy[1]; - if (bleeding <= 0 && spurt) { spurt = 0; for (int i = 0; i < 3; i++) { // emit blood particles // FIXME: more copypaste code bloodvel = 0; - if (!skeleton.free) { - bloodvel.z = 10; - bloodvel = DoRotation(bloodvel, ((float)(Random() % 100)) / 4, yaw + ((float)(Random() % 100)) / 4, 0) * scale; - } if (skeleton.free) { bloodvel -= DoRotation(skeleton.forward * 10 * scale, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0); - } - if (skeleton.free) bloodvel += DoRotation(jointVel(head), ((float)(Random() % 100)) / 4, yaw + ((float)(Random() % 100)) / 4, 0) * scale; - if (!skeleton.free) - bloodvel += DoRotation(velocity, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0) * scale; - if (skeleton.free) { Sprite::MakeSprite(bloodsprite, jointPos(head) * scale + coords, bloodvel, 1, 1, 1, .05, 1); Sprite::MakeSprite(bloodflamesprite, jointPos(head) * scale + coords, bloodvel, 1, 1, 1, .3, 1); - } - if (!skeleton.free) { + } else { + bloodvel.z = 10; + bloodvel = DoRotation(bloodvel, ((float)(Random() % 100)) / 4, yaw + ((float)(Random() % 100)) / 4, 0) * scale; + bloodvel += DoRotation(velocity, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0) * scale; Sprite::MakeSprite(bloodsprite, DoRotation((jointPos(head) + jointPos(neck)) / 2, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .05, 1); Sprite::MakeSprite(bloodflamesprite, DoRotation((jointPos(head) + jointPos(neck)) / 2, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .3, 1); } @@ -1205,14 +1172,13 @@ void Person::DoDamage(float howmuch) XYZ flatvelocity2; XYZ flatfacing2; for (int i = 0; i < skeleton.num_joints; i++) { - if (!skeleton.free) - flatvelocity2 = velocity; - if (skeleton.free) + if (skeleton.free) { flatvelocity2 = skeleton.joints[i].velocity; - if (!skeleton.free) - flatfacing2 = DoRotation(DoRotation(DoRotation(skeleton.joints[i].position, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0) * scale + coords; - if (skeleton.free) flatfacing2 = skeleton.joints[i].position * scale + coords; + } else { + flatvelocity2 = velocity; + flatfacing2 = DoRotation(DoRotation(DoRotation(skeleton.joints[i].position, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0) * scale + coords; + } flatvelocity2.x += (float)(abs(Random() % 100) - 50) / 10; flatvelocity2.y += (float)(abs(Random() % 100) - 50) / 10; flatvelocity2.z += (float)(abs(Random() % 100) - 50) / 10; @@ -2658,8 +2624,7 @@ void Person::DoAnimations() footvel = 0; if (skeleton.free) { footpoint = (victim->jointPos(abdomen) + victim->jointPos(neck)) / 2 * victim->scale + victim->coords; - } - if (!skeleton.free) { + } else { footpoint = DoRotation((victim->jointPos(abdomen) + victim->jointPos(neck)) / 2, 0, victim->yaw, 0) * victim->scale + victim->coords; } if (tutoriallevel != 1) { @@ -2714,8 +2679,7 @@ void Person::DoAnimations() footvel = 0; if (skeleton.free) { footpoint = (victim->jointPos(abdomen) + victim->jointPos(neck)) / 2 * victim->scale + victim->coords; - } - if (!skeleton.free) { + } else { footpoint = DoRotation((victim->jointPos(abdomen) + victim->jointPos(neck)) / 2, 0, victim->yaw, 0) * victim->scale + victim->coords; } if (bloodtoggle) @@ -4105,28 +4069,26 @@ void Person::DoStuff() while (flamedelay < 0 && onfire) { flamedelay += .006; howmany = abs(Random() % (skeleton.num_joints)); - if (!skeleton.free) - flatvelocity = (coords - oldcoords) / multiplier / 2; //velocity/2; - if (skeleton.free) + if (skeleton.free) { flatvelocity = skeleton.joints[howmany].velocity * scale / 2; - if (!skeleton.free) - flatfacing = DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0) * scale + coords; - if (skeleton.free) flatfacing = skeleton.joints[howmany].position * scale + coords; + } else { + flatfacing = DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0) * scale + coords; + flatvelocity = (coords - oldcoords) / multiplier / 2; + } Sprite::MakeSprite(flamesprite, flatfacing, flatvelocity, 1, 1, 1, .6 + (float)abs(Random() % 100) / 200 - .25, 1); } while (flamedelay < 0 && !onfire && tutoriallevel == 1 && id != 0) { flamedelay += .05; howmany = abs(Random() % (skeleton.num_joints)); - if (!skeleton.free) - flatvelocity = (coords - oldcoords) / multiplier / 2; //velocity/2; - if (skeleton.free) + if (skeleton.free) { flatvelocity = skeleton.joints[howmany].velocity * scale / 2; - if (!skeleton.free) - flatfacing = DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0) * scale + coords; - if (skeleton.free) flatfacing = skeleton.joints[howmany].position * scale + coords; + } else { + flatvelocity = (coords - oldcoords) / multiplier / 2; + flatfacing = DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0) * scale + coords; + } Sprite::MakeSprite(breathsprite, flatfacing, flatvelocity, 1, 1, 1, .6 + (float)abs(Random() % 100) / 200 - .25, .3); } @@ -4146,21 +4108,16 @@ void Person::DoStuff() if (neckspurtparticledelay < 0 && neckspurtdelay > 2) { spurt = 0; bloodvel = 0; - if (!skeleton.free) { - bloodvel.z = 5 * neckspurtamount; - bloodvel = DoRotation(bloodvel, ((float)(Random() % 100)) / 40, yaw + ((float)(Random() % 100)) / 40, 0) * scale; - } if (skeleton.free) { bloodvel -= DoRotation(skeleton.forward * 10 * scale, ((float)(Random() % 100)) / 40, ((float)(Random() % 100)) / 40, 0); - } - if (skeleton.free) bloodvel += DoRotation(jointVel(head), ((float)(Random() % 100)) / 40, yaw + ((float)(Random() % 100)) / 40, 0) * scale; - if (!skeleton.free) - bloodvel += DoRotation(velocity, ((float)(Random() % 100)) / 40, ((float)(Random() % 100)) / 40, 0) * scale; - if (skeleton.free) Sprite::MakeSprite(bloodsprite, (jointPos(neck) + (jointPos(neck) - jointPos(head)) / 5)*scale + coords, bloodvel, 1, 1, 1, .05, .9); - if (!skeleton.free) + } else { + bloodvel.z = 5 * neckspurtamount; + bloodvel = DoRotation(bloodvel, ((float)(Random() % 100)) / 40, yaw + ((float)(Random() % 100)) / 40, 0) * scale; + bloodvel += DoRotation(velocity, ((float)(Random() % 100)) / 40, ((float)(Random() % 100)) / 40, 0) * scale; Sprite::MakeSprite(bloodsprite, DoRotation(jointPos(neck) + (jointPos(neck) - jointPos(head)) / 5, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .05, .9); + } neckspurtparticledelay = .05; } if (neckspurtdelay < 0) { @@ -4178,14 +4135,13 @@ void Person::DoStuff() XYZ bloodvel; if (bloodtoggle) { bloodvel = 0; - if (skeleton.free) + if (skeleton.free) { bloodvel += DoRotation(jointVel(abdomen), ((float)(Random() % 100)) / 4, yaw + ((float)(Random() % 100)) / 4, 0) * scale; - if (!skeleton.free) - bloodvel += DoRotation(velocity, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0) * scale; - if (skeleton.free) Sprite::MakeSprite(bloodsprite, jointPos(abdomen) * scale + coords, bloodvel, 1, 1, 1, .05, 1); - if (!skeleton.free) + } else { + bloodvel += DoRotation(velocity, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0) * scale; Sprite::MakeSprite(bloodsprite, DoRotation((jointPos(abdomen) + jointPos(abdomen)) / 2, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .05, 1); + } } } bloodloss += deathbleeding * multiplier * 80; @@ -4283,19 +4239,18 @@ void Person::DoStuff() DoMipmaps(); } - if (!skeleton.free) { - bleedy -= 4 / realtexdetail; - if (detail == 2) - bleedx += (abs(Random() % 3) - 1) * 2 / realtexdetail; - else - bleedx += (abs(Random() % 3) - 1) * 4 / realtexdetail; - } if (skeleton.free) { bleedx += 4 * direction / realtexdetail; if (detail == 2) bleedy += (abs(Random() % 3) - 1) * 2 / realtexdetail; else bleedy += (abs(Random() % 3) - 1) * 4 / realtexdetail; + } else { + bleedy -= 4 / realtexdetail; + if (detail == 2) + bleedx += (abs(Random() % 3) - 1) * 2 / realtexdetail; + else + bleedx += (abs(Random() % 3) - 1) * 4 / realtexdetail; } } @@ -4390,14 +4345,13 @@ void Person::DoStuff() if (environment == snowyenvironment) { XYZ footpoint; XYZ footvel; - if (!skeleton.free) - footvel = DoRotation(skeleton.specialforward[0], 0, yaw, 0) * -1; - if (skeleton.free) + if (skeleton.free) { footvel = skeleton.specialforward[0] * -1; - if (!skeleton.free) - footpoint = DoRotation((jointPos(head) + jointPos(neck)) / 2, 0, yaw, 0) * scale + coords; - if (skeleton.free) footpoint = ((jointPos(head) + jointPos(neck)) / 2) * scale + coords; + } else { + footvel = DoRotation(skeleton.specialforward[0], 0, yaw, 0) * -1; + footpoint = DoRotation((jointPos(head) + jointPos(neck)) / 2, 0, yaw, 0) * scale + coords; + } if (animTarget == sleepanim) footvel = DoRotation(footvel, 0, 90, 0); Sprite::MakeSprite(breathsprite, footpoint + footvel * .2, footvel * .4, 1, 1, 1, .4, .3); @@ -4746,7 +4700,6 @@ void Person::DoStuff() } average /= multiplier; - //velocity=jointVel(groin)*scale; velocity = 0; for (int i = 0; i < skeleton.num_joints; i++) { velocity += skeleton.joints[i].velocity * scale; @@ -5311,7 +5264,7 @@ void Person::DoStuff() if (hasvictim) { if ((victim != this->shared_from_this()) && !victim->dead && (victim->aitype != passivetype) && (victim->aitype != searchtype) && (aitype != passivetype) && - (aitype != searchtype) && (victim->id < Person::players.size()) && (aitype != passivetype)) { + (aitype != searchtype) && (victim->id < Person::players.size())) { behind = (normaldotproduct(facing, coords - victim->coords) > 0); } } @@ -5704,7 +5657,7 @@ void Person::DoStuff() */ void IKHelper(Person *p, float interp) { - XYZ point, newpoint, change, change2; + XYZ point, change, change2; float heightleft, heightright; // TODO: implement localToWorld and worldToLocal @@ -6049,14 +6002,11 @@ int Person::DrawSkeleton() glMatrixMode(GL_MODELVIEW); glPushMatrix(); - if (!skeleton.free) - glTranslatef(coords.x, coords.y - .02, coords.z); - if (skeleton.free) - glTranslatef(coords.x, coords.y - .02, coords.z); - if (!skeleton.free) + glTranslatef(coords.x, coords.y - .02, coords.z); + if (!skeleton.free) { glTranslatef(offset.x * scale, offset.y * scale, offset.z * scale); - if (!skeleton.free) glRotatef(yaw, 0, 1, 0); + } if (showpoints) { glPointSize(5); glColor4f(.4, 1, .4, 1); @@ -6284,7 +6234,7 @@ int Person::DrawSkeleton() weapons[i].smallrotation2 = 50; } if ((animCurrent == crouchstabanim && animTarget == crouchstabanim) || (animCurrent == backhandspringanim && animTarget == backhandspringanim)) { - XYZ temppoint1, temppoint2, tempforward; + XYZ temppoint1, temppoint2; float distance; temppoint1 = jointPos(righthand); @@ -6303,7 +6253,7 @@ int Person::DrawSkeleton() weapons[i].rotation1 = 360 - weapons[i].rotation1; } if ((animCurrent == knifeslashreversalanim && animTarget == knifeslashreversalanim) || (animCurrent == knifeslashreversedanim && animTarget == knifeslashreversedanim)) { - XYZ temppoint1, temppoint2, tempforward; + XYZ temppoint1, temppoint2; float distance; temppoint1 = jointPos(righthand); @@ -6347,7 +6297,7 @@ int Person::DrawSkeleton() weapons[i].rotation3 = 0; } if ((animTarget == swordgroundstabanim && animCurrent == swordgroundstabanim) || (animTarget == swordsneakattackanim && animCurrent == swordsneakattackanim) || (animTarget == swordslashparryanim && animCurrent == swordslashparryanim) || (animTarget == swordslashparriedanim && animCurrent == swordslashparriedanim) || (animTarget == swordslashreversalanim && animCurrent == swordslashreversalanim) || (animTarget == swordslashreversedanim && animCurrent == swordslashreversedanim) || (animTarget == knifeslashreversalanim && animCurrent == knifeslashreversalanim) || (animTarget == knifeslashreversedanim && animCurrent == knifeslashreversedanim) || (animTarget == swordslashanim && animCurrent == swordslashanim) || (animTarget == drawleftanim && animCurrent == drawleftanim) || (animCurrent == backhandspringanim && animTarget == backhandspringanim)) { - XYZ temppoint1, temppoint2, tempforward; + XYZ temppoint1, temppoint2; float distance; temppoint1 = animation[animCurrent].position[skeleton.jointlabels[righthand]][frameCurrent] * (1 - target) + animation[animTarget].position[skeleton.jointlabels[righthand]][frameTarget] * (target); //jointPos(righthand); @@ -6370,7 +6320,7 @@ int Person::DrawSkeleton() weapons[i].smallrotation = 100; weapons[i].smallrotation2 = 0; if ((animTarget == staffhitanim && animCurrent == staffhitanim) || (animTarget == staffhitreversedanim && animCurrent == staffhitreversedanim) || (animTarget == staffspinhitreversedanim && animCurrent == staffspinhitreversedanim) || (animTarget == staffgroundsmashanim && animCurrent == staffgroundsmashanim) || (animTarget == staffspinhitanim && animCurrent == staffspinhitanim)) { - XYZ temppoint1, temppoint2, tempforward; + XYZ temppoint1, temppoint2; float distance; temppoint1 = animation[animCurrent].position[skeleton.jointlabels[righthand]][frameCurrent] * (1 - target) + animation[animTarget].position[skeleton.jointlabels[righthand]][frameTarget] * (target); //jointPos(righthand); @@ -6418,7 +6368,7 @@ int Person::DrawSkeleton() calcrot = 0; if (skeleton.free) calcrot = 1; - if (animation[animTarget].attack || isRun() || animTarget == staggerbackhardanim || isFlip() || animTarget == climbanim || animTarget == sneakanim || animTarget == rollanim || animTarget == walkanim || animTarget == backhandspringanim || isFlip() || isWallJump()) + if (animation[animTarget].attack || isRun() || animTarget == staggerbackhardanim || isFlip() || animTarget == climbanim || animTarget == sneakanim || animTarget == rollanim || animTarget == walkanim || animTarget == backhandspringanim || isWallJump()) calcrot = 1; if (animCurrent != animTarget) calcrot = 1; @@ -6583,3 +6533,64 @@ void Person::takeWeapon(int weaponId) weaponids[0] = weaponId; } +void Person::addClothes() +{ + if (numclothes > 0) { + for (int i = 0; i < numclothes; i++) { + addClothes(i); + } + DoMipmaps(); + } +} + +bool Person::addClothes(const int& clothesId) +{ + LOGFUNC; + const char* fileName = clothes[clothesId]; + + GLubyte* array = &skeleton.skinText[0]; + + //Load Image + ImageRec texture; + bool opened = load_image(fileName, texture); + + float alphanum; + //Is it valid? + if (opened) { + float tintr = clothestintr[clothesId]; + float tintg = clothestintg[clothesId]; + float tintb = clothestintb[clothesId]; + + if (tintr > 1) tintr = 1; + if (tintg > 1) tintg = 1; + if (tintb > 1) tintb = 1; + + if (tintr < 0) tintr = 0; + if (tintg < 0) tintg = 0; + if (tintb < 0) tintb = 0; + + int bytesPerPixel = texture.bpp / 8; + + int tempnum = 0; + alphanum = 255; + for (int i = 0; i < (int)(texture.sizeY * texture.sizeX * bytesPerPixel); i++) { + if (bytesPerPixel == 3) + alphanum = 255; + else if ((i + 1) % 4 == 0) + alphanum = texture.data[i]; + if ((i + 1) % 4 || bytesPerPixel == 3) { + if ((i % 4) == 0) + texture.data[i] *= tintr; + if ((i % 4) == 1) + texture.data[i] *= tintg; + if ((i % 4) == 2) + texture.data[i] *= tintb; + array[tempnum] = (float)array[tempnum] * (1 - alphanum / 255) + (float)texture.data[i] * (alphanum / 255); + tempnum++; + } + } + return 1; + } else { + return 0; + } +}