[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34806] trunk/blender: Small update for billboards:

Janne Karhu jhkarh at gmail.com
Sun Feb 13 00:25:05 CET 2011


Revision: 34806
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34806
Author:   jhk
Date:     2011-02-12 23:25:03 +0000 (Sat, 12 Feb 2011)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/properties_particle.py
    trunk/blender/source/blender/blenkernel/BKE_particle.h
    trunk/blender/source/blender/makesdna/DNA_particle_types.h
    trunk/blender/source/blender/makesrna/intern/rna_particle.c
    trunk/blender/source/blender/render/intern/source/convertblender.c

Modified: trunk/blender/release/scripts/ui/properties_particle.py
===================================================================
--- trunk/blender/release/scripts/ui/properties_particle.py	2011-02-12 21:54:50 UTC (rev 34805)
+++ trunk/blender/release/scripts/ui/properties_particle.py	2011-02-12 23:25:03 UTC (rev 34806)
@@ -821,6 +821,8 @@
                     row.prop(weight, "count")
 
         elif part.render_type == 'BILLBOARD':
+            ob = context.object
+            
             sub.label(text="Align:")
 
             row = layout.row()
@@ -833,21 +835,22 @@
             col = row.column(align=True)
             col.label(text="Tilt:")
             col.prop(part, "billboard_tilt", text="Angle", slider=True)
-            col.prop(part, "billboard_tilt_random", slider=True)
+            col.prop(part, "billboard_tilt_random", text="Random", slider=True)
             col = row.column()
             col.prop(part, "billboard_offset")
 
-            row = layout.row()
-            row.prop(psys, "billboard_normal_uv")
-            row = layout.row()
-            row.prop(psys, "billboard_time_index_uv")
+            col = layout.column()
+            col.prop_search(psys, "billboard_normal_uv", ob.data, "uv_textures")
+            col.prop_search(psys, "billboard_time_index_uv", ob.data, "uv_textures")
 
-            row = layout.row()
-            row.label(text="Split uv's:")
-            row.prop(part, "billboard_uv_split", text="Number of splits")
-            row = layout.row()
-            row.prop(psys, "billboard_split_uv")
-            row = layout.row()
+            split = layout.split(percentage=0.33)
+            split.label(text="Split uv's:")
+            split.prop(part, "billboard_uv_split", text="Number of splits")
+            col = layout.column()
+            col.active = part.billboard_uv_split > 1
+            col.prop_search(psys, "billboard_split_uv", ob.data, "uv_textures")
+            
+            row = col.row()
             row.label(text="Animate:")
             row.prop(part, "billboard_animation", text="")
             row.label(text="Offset:")

Modified: trunk/blender/source/blender/blenkernel/BKE_particle.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_particle.h	2011-02-12 21:54:50 UTC (rev 34805)
+++ trunk/blender/source/blender/blenkernel/BKE_particle.h	2011-02-12 23:25:03 UTC (rev 34806)
@@ -149,6 +149,7 @@
 	int uv[3];
 	int lock, num;
 	int totnum;
+	int lifetime;
 	short align, uv_split, anim, split_offset;
 } ParticleBillboardData;
 

Modified: trunk/blender/source/blender/makesdna/DNA_particle_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_particle_types.h	2011-02-12 21:54:50 UTC (rev 34805)
+++ trunk/blender/source/blender/makesdna/DNA_particle_types.h	2011-02-12 23:25:03 UTC (rev 34806)
@@ -390,10 +390,9 @@
 
 /* part->bb_anim */
 #define PART_BB_ANIM_NONE	0
-#define PART_BB_ANIM_TIME	1
+#define PART_BB_ANIM_AGE	1
 #define PART_BB_ANIM_ANGLE	2
-#define PART_BB_ANIM_OFF_TIME	3
-#define PART_BB_ANIM_OFF_ANGLE	4
+#define PART_BB_ANIM_FRAME	3
 
 /* part->bb_split_offset */
 #define PART_BB_OFF_NONE	0

Modified: trunk/blender/source/blender/makesrna/intern/rna_particle.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_particle.c	2011-02-12 21:54:50 UTC (rev 34805)
+++ trunk/blender/source/blender/makesrna/intern/rna_particle.c	2011-02-12 23:25:03 UTC (rev 34806)
@@ -1450,10 +1450,9 @@
 
 	static EnumPropertyItem bb_anim_items[] = {
 		{PART_BB_ANIM_NONE, "NONE", 0, "None", ""},
-		{PART_BB_ANIM_TIME, "TIME", 0, "Time", ""},
+		{PART_BB_ANIM_AGE, "AGE", 0, "Age", ""},
+		{PART_BB_ANIM_FRAME, "FRAME", 0, "Frame", ""},
 		{PART_BB_ANIM_ANGLE, "ANGLE", 0, "Angle", ""},
-		//{PART_BB_ANIM_OFF_TIME, "OFF_TIME", 0, "off_time", ""},
-		//{PART_BB_ANIM_OFF_ANGLE, "OFF_ANGLE", 0, "off_angle", ""},
 		{0, NULL, 0, NULL, NULL}
 	};
 

Modified: trunk/blender/source/blender/render/intern/source/convertblender.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/convertblender.c	2011-02-12 21:54:50 UTC (rev 34805)
+++ trunk/blender/source/blender/render/intern/source/convertblender.c	2011-02-12 23:25:03 UTC (rev 34806)
@@ -1269,6 +1269,7 @@
 	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 @@
 
 	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 @@
 					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);




More information about the Bf-blender-cvs mailing list