Particles effector type #define

Different draw mode for Vortex effector ( http://www.clubinfo.bdeb.qc.ca/~theeth/Temp/vortex.jpg )
Use row buts for effector type (only one effector at a time per object).
Forcefield circle transparency in 3D view is controlled by falloff value (for coolness factor).

Please note that those only draws in the 3D view for Empty objects. I've tested with all other object types through a global call, but lamps (and only those) give problems. Since we go in release status soon, I prefer commiting something that works all the time.
This commit is contained in:
2004-07-18 22:23:50 +00:00
parent f6a6a5a279
commit b57167d3e4
4 changed files with 137 additions and 17 deletions

View File

@@ -3075,6 +3075,98 @@ static void tekentextcurs(void)
glEnd();
}
void drawspiral(float *cent, float rad, float tmat[][4], int start)
{
float vec[3], vx[3], vy[3];
int a, tot=32;
/* 32 values of sin function (still same result!) */
static float si[32] = {0.00000000,
0.20129852,
0.39435585,
0.57126821,
0.72479278,
0.84864425,
0.93775213,
0.98846832,
0.99871650,
0.96807711,
0.89780453,
0.79077573,
0.65137248,
0.48530196,
0.29936312,
0.10116832,
-0.10116832,
-0.29936312,
-0.48530196,
-0.65137248,
-0.79077573,
-0.89780453,
-0.96807711,
-0.99871650,
-0.98846832,
-0.93775213,
-0.84864425,
-0.72479278,
-0.57126821,
-0.39435585,
-0.20129852,
0.00000000};
/* 32 values of cos function (still same result!) */
static float co[32] ={1.00000000,
0.97952994,
0.91895781,
0.82076344,
0.68896691,
0.52896401,
0.34730525,
0.15142777,
-0.05064916,
-0.25065253,
-0.44039415,
-0.61210598,
-0.75875812,
-0.87434661,
-0.95413925,
-0.99486932,
-0.99486932,
-0.95413925,
-0.87434661,
-0.75875812,
-0.61210598,
-0.44039415,
-0.25065253,
-0.05064916,
0.15142777,
0.34730525,
0.52896401,
0.68896691,
0.82076344,
0.91895781,
0.97952994,
1.00000000};
VECCOPY(vx, tmat[0]);
VECCOPY(vy, tmat[1]);
VecMulf(vx, rad);
VecMulf(vy, rad);
VECCOPY(vec, cent);
for(a=0; a<tot; a++) {
if (a+start>31)
start=-a + 1;
glBegin(GL_LINES);
glVertex3fv(vec);
vec[0]= cent[0] + *(si+a+start) * (vx[0] * (float)a/(float)tot) + *(co+a+start) * (vy[0] * (float)a/(float)tot);
vec[1]= cent[1] + *(si+a+start) * (vx[1] * (float)a/(float)tot) + *(co+a+start) * (vy[1] * (float)a/(float)tot);
vec[2]= cent[2] + *(si+a+start) * (vx[2] * (float)a/(float)tot) + *(co+a+start) * (vy[2] * (float)a/(float)tot);
glVertex3fv(vec);
glEnd();
}
}
void drawcircball(float *cent, float rad, float tmat[][4])
{
float vec[3], vx[3], vy[3];
@@ -3220,12 +3312,34 @@ static void draw_forcefield(Object *ob)
Normalise(imat[0]);
Normalise(imat[1]);
BIF_ThemeColorBlend(TH_WIRE, TH_BACK, 0.4);
drawcircball(vec, 0.5, imat);
BIF_ThemeColorBlend(TH_WIRE, TH_BACK, 0.65);
drawcircball(vec, 1.0, imat);
BIF_ThemeColorBlend(TH_WIRE, TH_BACK, 0.8);
drawcircball(vec, 1.5, imat);
if (ob->pd->forcefield == PFIELD_FORCE) {
float ffall_val;
if (has_ipo_code(ob->ipo, OB_PD_FFALL))
ffall_val = IPO_GetFloatValue(ob->ipo, OB_PD_FFALL, G.scene->r.cfra);
else
ffall_val = ob->pd->f_power;
BIF_ThemeColorBlend(TH_WIRE, TH_BACK, 0.5);
drawcircball(vec, 1.0, imat);
BIF_ThemeColorBlend(TH_WIRE, TH_BACK, 0.9 - 0.4 / pow(1.5, (double)ffall_val));
drawcircball(vec, 1.5, imat);
BIF_ThemeColorBlend(TH_WIRE, TH_BACK, 0.9 - 0.4 / pow(2.0, (double)ffall_val));
drawcircball(vec, 2.0, imat);
}
else if (ob->pd->forcefield == PFIELD_VORTEX) {
float ffall_val;
if (has_ipo_code(ob->ipo, OB_PD_FFALL))
ffall_val = IPO_GetFloatValue(ob->ipo, OB_PD_FFALL, G.scene->r.cfra);
else
ffall_val = ob->pd->f_power;
BIF_ThemeColorBlend(TH_WIRE, TH_BACK, 0.7);
drawspiral(vec, 1.0, imat, 0);
drawspiral(vec, 1.0, imat, 15);
}
}
static void draw_bb_box(BoundBox *bb)
@@ -3815,7 +3929,6 @@ void draw_object(Base *base)
break;
case OB_EMPTY:
drawaxes(1.0);
if(ob->pd && ob->pd->forcefield) draw_forcefield(ob);
break;
case OB_LAMP:
/* does a myloadmatrix */
@@ -3835,6 +3948,7 @@ void draw_object(Base *base)
default:
drawaxes(1.0);
}
if(ob->pd && ob->pd->forcefield) draw_forcefield(ob);
/* draw extra: after normal draw because of makeDispList */