Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJanne Karhu <jhkarh@gmail.com>2011-02-13 02:25:03 +0300
committerJanne Karhu <jhkarh@gmail.com>2011-02-13 02:25:03 +0300
commit373fea66620eb11a07640699f0d702521d4e55c3 (patch)
tree9ab67c81dea947c1fd2c4e2fa68f02c457d275fa /source/blender/render
parent54b2127fadd53ccabeeee6b7bc75a10495643255 (diff)
Small update for billboards:
* Renamed the old split uv's animate option "time" to "age" and added a new option to change the used split frame by frame. These are good changes were suggested/implied by Hannu Hoffren over 3 years ago in his tutorial video! (oh my how time flies) * Also cleaned up the billboard ui quite a bit. For example now the uv channels can be properly chosen from the existing channels.
Diffstat (limited to 'source/blender/render')
-rw-r--r--source/blender/render/intern/source/convertblender.c41
1 files changed, 20 insertions, 21 deletions
diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c
index b5cfc123c15..1dc709d27df 100644
--- a/source/blender/render/intern/source/convertblender.c
+++ b/source/blender/render/intern/source/convertblender.c
@@ -1269,6 +1269,7 @@ static void particle_billboard(Render *re, ObjectRen *obr, Material *ma, Particl
VlakRen *vlr;
MTFace *mtf;
float xvec[3], yvec[3], zvec[3], bb_center[3];
+ int totsplit = bb->uv_split * bb->uv_split;
float uvx = 0.0f, uvy = 0.0f, uvdx = 1.0f, uvdy = 1.0f, time = 0.0f;
vlr= RE_findOrAddVlak(obr, obr->totvlak++);
@@ -1306,49 +1307,46 @@ static void particle_billboard(Render *re, ObjectRen *obr, Material *ma, Particl
if(bb->uv_split > 1){
uvdx = uvdy = 1.0f / (float)bb->uv_split;
- if(bb->anim == PART_BB_ANIM_TIME) {
- if(bb->split_offset == PART_BB_OFF_NONE)
- time = bb->time;
- else if(bb->split_offset == PART_BB_OFF_LINEAR)
- time = (float)fmod(bb->time + (float)bb->num / (float)(bb->uv_split * bb->uv_split), 1.0f);
- else /* split_offset==PART_BB_OFF_RANDOM */
- time = (float)fmod(bb->time + bb->random, 1.0f);
+ if(ELEM(bb->anim, PART_BB_ANIM_AGE, PART_BB_ANIM_FRAME)) {
+ if(bb->anim == PART_BB_ANIM_FRAME)
+ time = ((int)(bb->time * bb->lifetime) % totsplit)/(float)totsplit;
+ else
+ time = bb->time;
}
else if(bb->anim == PART_BB_ANIM_ANGLE) {
if(bb->align == PART_BB_VIEW) {
time = (float)fmod((bb->tilt + 1.0f) / 2.0f, 1.0);
}
- else{
+ else {
float axis1[3] = {0.0f,0.0f,0.0f};
float axis2[3] = {0.0f,0.0f,0.0f};
+
axis1[(bb->align + 1) % 3] = 1.0f;
axis2[(bb->align + 2) % 3] = 1.0f;
+
if(bb->lock == 0) {
zvec[bb->align] = 0.0f;
normalize_v3(zvec);
}
+
time = saacos(dot_v3v3(zvec, axis1)) / (float)M_PI;
+
if(dot_v3v3(zvec, axis2) < 0.0f)
time = 1.0f - time / 2.0f;
else
- time = time / 2.0f;
+ time /= 2.0f;
}
- if(bb->split_offset == PART_BB_OFF_LINEAR)
- time = (float)fmod(bb->time + (float)bb->num / (float)(bb->uv_split * bb->uv_split), 1.0f);
- else if(bb->split_offset == PART_BB_OFF_RANDOM)
- time = (float)fmod(bb->time + bb->random, 1.0f);
- }
- else{
- if(bb->split_offset == PART_BB_OFF_NONE)
- time = 0.0f;
- else if(bb->split_offset == PART_BB_OFF_LINEAR)
- time = (float)fmod((float)bb->num /(float)(bb->uv_split * bb->uv_split) , 1.0f);
- else /* split_offset==PART_BB_OFF_RANDOM */
- time = bb->random;
}
+
+ if(bb->split_offset == PART_BB_OFF_LINEAR)
+ time = (float)fmod(time + (float)bb->num / (float)totsplit, 1.0f);
+ else if(bb->split_offset==PART_BB_OFF_RANDOM)
+ time = (float)fmod(time + bb->random, 1.0f);
+
uvx = uvdx * floor((float)(bb->uv_split * bb->uv_split) * (float)fmod((double)time, (double)uvdx));
uvy = uvdy * floor((1.0f - time) * (float)bb->uv_split);
+
if(fmod(time, 1.0f / bb->uv_split) == 0.0f)
uvy -= uvdy;
}
@@ -1989,6 +1987,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
bb.tilt = part->bb_tilt * (1.0f - part->bb_rand_tilt * r_tilt);
bb.time = pa_time;
bb.num = a;
+ bb.lifetime = pa_dietime-pa_birthtime;
}
particle_normal_ren(part->ren_as, part, re, obr, psmd->dm, ma, &sd, &bb, &state, seed, hasize, pa_co);