void CStarburstProjectile::Draw(void) { float3 interPos=pos+speed*gu->timeOffset; inArray=true; float age2=(age&7)+gu->timeOffset; float color=0.7; unsigned char col[4]; unsigned char col2[4]; if(drawTrail){ //draw the trail as a single quad float3 dif(interPos-camera->pos); dif.Normalize(); float3 dir1(dif.cross(dir)); dir1.Normalize(); float3 dif2(oldSmoke-camera->pos); dif2.Normalize(); float3 dir2(dif2.cross(oldSmokeDir)); dir2.Normalize(); float a1=(1-float(0)/(Smoke_Time))*255; a1*=0.7+fabs(dif.dot(dir)); int alpha=min(255,(int)max(0.f,a1)); col[0]=(unsigned char) (color*alpha); col[1]=(unsigned char) (color*alpha); col[2]=(unsigned char) (color*alpha); col[3]=(unsigned char)alpha; float a2=(1-float(age2)/(Smoke_Time))*255; a2*=0.7+fabs(dif2.dot(oldSmokeDir)); if(age<8) a2=0; alpha=min(255,(int)max(0.f,a2)); col2[0]=(unsigned char) (color*alpha); col2[1]=(unsigned char) (color*alpha); col2[2]=(unsigned char) (color*alpha); col2[3]=(unsigned char)alpha; float xmod=0; float ymod=0.25; float size=1; float size2=(1+age2*(1/Smoke_Time)*7); float txs=(1-age2/8.0); va->AddVertexTC(interPos-dir1*size, txs/4+1.0/32, 2.0/16, col); va->AddVertexTC(interPos+dir1*size, txs/4+1.0/32, 3.0/16, col); va->AddVertexTC(oldSmoke+dir2*size2, 0.25+1.0/32, 3.0/16, col2); va->AddVertexTC(oldSmoke-dir2*size2, 0.25+1.0/32, 2.0/16, col2); } else { //draw the trail as particles float dist=pos.distance(oldSmoke); float3 dirpos1=pos-dir*dist*0.33; float3 dirpos2=oldSmoke+oldSmokeDir*dist*0.33; for(int a=0;a<numParts;++a){ float a1=1-float(a)/Smoke_Time; col[0]=(unsigned char) (color*255); col[1]=(unsigned char) (color*255); col[2]=(unsigned char) (color*255); col[3]=255;//min(255,max(0,a1*255)); float size=(1+(a)*(1/Smoke_Time)*7); float3 pos1=CalcBeizer(float(a)/(numParts),pos,dirpos1,dirpos2,oldSmoke); va->AddVertexTC(pos1+( camera->up+camera->right)*size, 4.0/16, 0.0/16, col); va->AddVertexTC(pos1+( camera->up-camera->right)*size, 5.0/16, 0.0/16, col); va->AddVertexTC(pos1+(-camera->up-camera->right)*size, 5.0/16, 1.0/16, col); va->AddVertexTC(pos1+(-camera->up+camera->right)*size, 4.0/16, 1.0/16, col); } } DrawCallback(); if(curCallback==0) DrawCallback(); }
void CStarburstProjectile::Draw(void) { inArray = true; float age2 = (age & 7) + globalRendering->timeOffset; unsigned char col[4]; unsigned char col2[4]; if (weaponDef->visuals.smokeTrail) { #if defined(USE_GML) && GML_ENABLE_SIM const int curNumParts = *(volatile int *)&numParts; #else const int curNumParts = numParts; #endif va->EnlargeArrays(4+4*curNumParts,0,VA_SIZE_TC); const float color = 0.7f; if(drawTrail){ //draw the trail as a single quad float3 dif(drawPos-camera->pos); dif.Normalize(); float3 dir1(dif.cross(dir)); dir1.Normalize(); float3 dif2(oldSmoke-camera->pos); dif2.Normalize(); float3 dir2(dif2.cross(oldSmokeDir)); dir2.Normalize(); float a1=(1-float(0)/(Smoke_Time))*255; a1*=0.7f+fabs(dif.dot(dir)); const int alpha1 = std::min(255, (int) std::max(0.f,a1)); col[0]=(unsigned char) (color*alpha1); col[1]=(unsigned char) (color*alpha1); col[2]=(unsigned char) (color*alpha1); col[3]=(unsigned char)alpha1; float a2=(1-float(age2)/(Smoke_Time))*255; a2*=0.7f+fabs(dif2.dot(oldSmokeDir)); if(age<8) a2=0; const int alpha2 = std::min(255, (int) std::max(0.f,a2)); col2[0]=(unsigned char) (color*alpha2); col2[1]=(unsigned char) (color*alpha2); col2[2]=(unsigned char) (color*alpha2); col2[3]=(unsigned char)alpha2; const float size = 1.0f; const float size2 = (1.0f + age2 * (1.0f / Smoke_Time) * 7.0f); const float txs = weaponDef->visuals.texture2->xend - (weaponDef->visuals.texture2->xend - weaponDef->visuals.texture2->xstart) * (age2 / 8.0f); // (1.0f - age2 / 8.0f); va->AddVertexQTC(drawPos - dir1 * size, txs, weaponDef->visuals.texture2->ystart, col); va->AddVertexQTC(drawPos + dir1 * size, txs, weaponDef->visuals.texture2->yend, col); va->AddVertexQTC(oldSmoke + dir2 * size2, weaponDef->visuals.texture2->xend, weaponDef->visuals.texture2->yend, col2); va->AddVertexQTC(oldSmoke - dir2 * size2, weaponDef->visuals.texture2->xend, weaponDef->visuals.texture2->ystart, col2); } else { //draw the trail as particles const float dist = pos.distance(oldSmoke); const float3 dirpos1 = pos-dir * dist * 0.33f; const float3 dirpos2 = oldSmoke + oldSmokeDir * dist * 0.33f; for (int a = 0; a < curNumParts; ++a) { //! CAUTION: loop count must match EnlargeArrays above //float a1=1-float(a)/Smoke_Time; col[0]=(unsigned char) (color*255); col[1]=(unsigned char) (color*255); col[2]=(unsigned char) (color*255); col[3]=255;//min(255,max(0,a1*255)); const float size=(1+(a)*(1/Smoke_Time)*7); const float3 pos1=CalcBeizer(float(a)/(curNumParts),pos,dirpos1,dirpos2,oldSmoke); #define st projectileDrawer->smoketex[0] va->AddVertexQTC(pos1 + ( camera->up + camera->right) * size, st->xstart, st->ystart, col); va->AddVertexQTC(pos1 + ( camera->up - camera->right) * size, st->xend, st->ystart, col); va->AddVertexQTC(pos1 + (-camera->up - camera->right) * size, st->xend, st->ystart, col); va->AddVertexQTC(pos1 + (-camera->up + camera->right) * size, st->xstart, st->ystart, col); #undef st } } } DrawCallback(); if(curCallback==0) DrawCallback(); }
void CPieceProjectile::Draw() { if (flags & PF_NoCEGTrail) { if (flags & PF_Smoke) { // this piece leaves a default (non-CEG) smoketrail inArray = true; float age2 = (age & 7) + globalRendering->timeOffset; float color = 0.5f; unsigned char col[4]; float3 dir = speed; dir.Normalize(); int numParts = age & 7; va->EnlargeArrays(4+4*numParts,0,VA_SIZE_TC); if (drawTrail) { // draw the trail as a single quad if camera close enough float3 dif(drawPos - camera->pos); dif.Normalize(); float3 dir1(dif.cross(dir)); dir1.Normalize(); float3 dif2(oldSmoke - camera->pos); dif2.Normalize(); float3 dir2(dif2.cross(oldSmokeDir)); dir2.Normalize(); float a1 = ((1 - 0.0f / (Smoke_Time)) * 255) * (0.7f + fabs(dif.dot(dir))); float alpha = std::min(255.0f, std::max(0.f, a1)); col[0] = (unsigned char) (color * alpha); col[1] = (unsigned char) (color * alpha); col[2] = (unsigned char) (color * alpha); col[3] = (unsigned char) (alpha); unsigned char col2[4]; float a2 = ((1 - float(age2) / (Smoke_Time)) * 255) * (0.7f + fabs(dif2.dot(oldSmokeDir))); if (age < 8) a2 = 0; alpha = std::min(255.0f, std::max(0.f, a2)); col2[0] = (unsigned char) (color * alpha); col2[1] = (unsigned char) (color * alpha); col2[2] = (unsigned char) (color * alpha); col2[3] = (unsigned char) (alpha); const float size = 1.0f; const float size2 = 1 + (age2 * (1 / Smoke_Time)) * 14; const float txs = projectileDrawer->smoketrailtex->xstart - (projectileDrawer->smoketrailtex->xend - projectileDrawer->smoketrailtex->xstart) * (age2 / 8.0f); va->AddVertexQTC(drawPos - dir1 * size, txs, projectileDrawer->smoketrailtex->ystart, col); va->AddVertexQTC(drawPos + dir1 * size, txs, projectileDrawer->smoketrailtex->yend, col); va->AddVertexQTC(oldSmoke + dir2 * size2, projectileDrawer->smoketrailtex->xend, projectileDrawer->smoketrailtex->yend, col2); va->AddVertexQTC(oldSmoke - dir2 * size2, projectileDrawer->smoketrailtex->xend, projectileDrawer->smoketrailtex->ystart, col2); } else { // draw the trail as particles const float dist = pos.distance(oldSmoke); const float3 dirpos1 = pos - dir * dist * 0.33f; const float3 dirpos2 = oldSmoke + oldSmokeDir * dist * 0.33f; for (int a = 0; a < numParts; ++a) { //! CAUTION: loop count must match EnlargeArrays above float alpha = 255.0f; col[0] = (unsigned char) (color * alpha); col[1] = (unsigned char) (color * alpha); col[2] = (unsigned char) (color * alpha); col[3] = (unsigned char) (alpha); const float size = 1.0f + ((a) * (1.0f / Smoke_Time)) * 14.0f; const float3 pos1 = CalcBeizer(float(a) / (numParts), pos, dirpos1, dirpos2, oldSmoke); #define st projectileDrawer->smoketex[0] va->AddVertexQTC(pos1 + ( camera->up+camera->right) * size, st->xstart, st->ystart, col); va->AddVertexQTC(pos1 + ( camera->up-camera->right) * size, st->xend, st->ystart, col); va->AddVertexQTC(pos1 + (-camera->up-camera->right) * size, st->xend, st->ystart, col); va->AddVertexQTC(pos1 + (-camera->up+camera->right) * size, st->xstart, st->ystart, col); #undef st } } } } DrawCallback(); if (curCallback == 0) { DrawCallback(); } }
void CStarburstProjectile::Draw() { inArray = true; if (weaponDef->visuals.smokeTrail) { const int curNumParts = GML::SimEnabled() ? *(volatile int*) &numParts : numParts; va->EnlargeArrays(4 + (4 * curNumParts), 0, VA_SIZE_TC); const float age2 = (age & 7) + globalRendering->timeOffset; const float color = 0.7f; if (drawTrail) { // draw the trail as a single quad const float3 dif1 = (drawPos - camera->pos).ANormalize(); const float3 dir1 = (dif1.cross(dir)).ANormalize(); const float3 dif2 = (oldSmoke - camera->pos).ANormalize(); const float3 dir2 = (dif2.cross(oldSmokeDir)).ANormalize(); const float a1 = ((1.0f - (0.0f / SMOKE_TIME))) * (0.7f + math::fabs(dif1.dot(dir))); const float a2 = (age < 8)? 0.0f: ((1.0f - (age2 / SMOKE_TIME))) * (0.7f + math::fabs(dif2.dot(oldSmokeDir))); const float alpha1 = Clamp(a1, 0.0f, 1.0f); const float alpha2 = Clamp(a2, 0.0f, 1.0f); const float size1 = 1.0f; const float size2 = (1.0f + age2 * (1.0f / SMOKE_TIME) * 7.0f); const float txs = weaponDef->visuals.texture2->xend - (weaponDef->visuals.texture2->xend - weaponDef->visuals.texture2->xstart) * (age2 / 8.0f); SColor col (color * alpha1, color * alpha1, color * alpha1, alpha1); SColor col2(color * alpha2, color * alpha2, color * alpha2, alpha2); va->AddVertexQTC(drawPos - dir1 * size1, txs, weaponDef->visuals.texture2->ystart, col); va->AddVertexQTC(drawPos + dir1 * size1, txs, weaponDef->visuals.texture2->yend, col); va->AddVertexQTC(oldSmoke + dir2 * size2, weaponDef->visuals.texture2->xend, weaponDef->visuals.texture2->yend, col2); va->AddVertexQTC(oldSmoke - dir2 * size2, weaponDef->visuals.texture2->xend, weaponDef->visuals.texture2->ystart, col2); } else { // draw the trail as particles const float dist = pos.distance(oldSmoke); const float3 dirpos1 = pos - dir * dist * 0.33f; const float3 dirpos2 = oldSmoke + oldSmokeDir * dist * 0.33f; const SColor col(color, color, color); for (int a = 0; a < curNumParts; ++a) { // CAUTION: loop count must match EnlargeArrays above const float size = 1 + (a * (1.0f / SMOKE_TIME) * 7.0f); const float3 pos1 = CalcBeizer((float)a / curNumParts, pos, dirpos1, dirpos2, oldSmoke); #define st projectileDrawer->smoketex[0] va->AddVertexQTC(pos1 + ( camera->up + camera->right) * size, st->xstart, st->ystart, col); va->AddVertexQTC(pos1 + ( camera->up - camera->right) * size, st->xend, st->ystart, col); va->AddVertexQTC(pos1 + (-camera->up - camera->right) * size, st->xend, st->ystart, col); va->AddVertexQTC(pos1 + (-camera->up + camera->right) * size, st->xstart, st->ystart, col); #undef st } } } DrawCallback(); }
void CPieceProjectile::Draw() { if(flags & PP_Smoke){ float3 interPos=pos+speed*gu->timeOffset; inArray=true; float age2=(age&7)+gu->timeOffset; float color=0.5f; unsigned char col[4]; float3 dir=speed; dir.Normalize(); if(drawTrail){ //draw the trail as a single quad float3 dif(interPos-camera->pos); dif.Normalize(); float3 dir1(dif.cross(dir)); dir1.Normalize(); float3 dif2(oldSmoke-camera->pos); dif2.Normalize(); float3 dir2(dif2.cross(oldSmokeDir)); dir2.Normalize(); float a1=(1-float(0)/(Smoke_Time))*255; a1*=0.7f+fabs(dif.dot(dir)); float alpha=min(255.f,max(0.f,a1)); col[0]=(unsigned char) (color*alpha); col[1]=(unsigned char) (color*alpha); col[2]=(unsigned char) (color*alpha); col[3]=(unsigned char) (alpha); unsigned char col2[4]; float a2=(1-float(age2)/(Smoke_Time))*255; a2*=0.7f+fabs(dif2.dot(oldSmokeDir)); if(age<8) a2=0; alpha=min(255.f,max(0.f,a2)); col2[0]=(unsigned char) (color*alpha); col2[1]=(unsigned char) (color*alpha); col2[2]=(unsigned char) (color*alpha); col2[3]=(unsigned char) (alpha); float size=(1); float size2=1+(age2*(1/Smoke_Time))*14; float txs=ph->smoketrailtex.xstart - (ph->smoketrailtex.xend-ph->smoketrailtex.xstart)*(age2/8.0f);//(1-age2/8.0f); va->AddVertexTC(interPos-dir1*size, txs, ph->smoketrailtex.ystart, col); va->AddVertexTC(interPos+dir1*size, txs, ph->smoketrailtex.yend, col); va->AddVertexTC(oldSmoke+dir2*size2, ph->smoketrailtex.xend, ph->smoketrailtex.yend, col2); va->AddVertexTC(oldSmoke-dir2*size2, ph->smoketrailtex.xend, ph->smoketrailtex.ystart, col2); } else { //draw the trail as particles float dist=pos.distance(oldSmoke); float3 dirpos1=pos-dir*dist*0.33f; float3 dirpos2=oldSmoke+oldSmokeDir*dist*0.33f; int numParts=age&7; for(int a=0;a<numParts;++a){ //float a1=1-float(a)/Smoke_Time; float alpha=255; col[0]=(unsigned char) (color*alpha); col[1]=(unsigned char) (color*alpha); col[2]=(unsigned char) (color*alpha); col[3]=(unsigned char) (alpha);//min(255,max(0,a1*255)); float size=1+((a)*(1/Smoke_Time))*14; float3 pos1=CalcBeizer(float(a)/(numParts),pos,dirpos1,dirpos2,oldSmoke); va->AddVertexTC(pos1+( camera->up+camera->right)*size, ph->smoketex[0].xstart, ph->smoketex[0].ystart, col); va->AddVertexTC(pos1+( camera->up-camera->right)*size, ph->smoketex[0].xend, ph->smoketex[0].ystart, col); va->AddVertexTC(pos1+(-camera->up-camera->right)*size, ph->smoketex[0].xend, ph->smoketex[0].ystart, col); va->AddVertexTC(pos1+(-camera->up+camera->right)*size, ph->smoketex[0].xstart, ph->smoketex[0].ystart, col); } } } DrawCallback(); if(curCallback==0) DrawCallback(); }