[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39963] trunk/blender/source/blender/ makesrna/intern: texture evaluation function (like we had in 2.4x api), requested by Lee.

Campbell Barton ideasman42 at gmail.com
Tue Sep 6 12:49:56 CEST 2011


Revision: 39963
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39963
Author:   campbellbarton
Date:     2011-09-06 10:49:55 +0000 (Tue, 06 Sep 2011)
Log Message:
-----------
texture evaluation function (like we had in 2.4x api), requested by Lee.

eg:
 red, green, blue, intensity = texture.evaluate(vec)

Modified Paths:
--------------
    trunk/blender/source/blender/makesrna/intern/rna_internal.h
    trunk/blender/source/blender/makesrna/intern/rna_texture.c
    trunk/blender/source/blender/makesrna/intern/rna_texture_api.c

Modified: trunk/blender/source/blender/makesrna/intern/rna_internal.h
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_internal.h	2011-09-06 08:30:17 UTC (rev 39962)
+++ trunk/blender/source/blender/makesrna/intern/rna_internal.h	2011-09-06 10:49:55 UTC (rev 39963)
@@ -261,6 +261,7 @@
 void RNA_api_sensor(struct StructRNA *srna);
 void RNA_api_controller(struct StructRNA *srna);
 void RNA_api_actuator(struct StructRNA *srna);
+void RNA_api_texture(struct StructRNA *srna);
 void RNA_api_environment_map(struct StructRNA *srna);
 
 /* main collection functions */

Modified: trunk/blender/source/blender/makesrna/intern/rna_texture.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_texture.c	2011-09-06 08:30:17 UTC (rev 39962)
+++ trunk/blender/source/blender/makesrna/intern/rna_texture.c	2011-09-06 10:49:55 UTC (rev 39963)
@@ -1820,6 +1820,8 @@
 	rna_def_texture_pointdensity(brna);
 	rna_def_texture_voxeldata(brna);
 	/* XXX add more types here .. */
+
+	RNA_api_texture(srna);
 }
 
 void RNA_def_texture(BlenderRNA *brna)

Modified: trunk/blender/source/blender/makesrna/intern/rna_texture_api.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_texture_api.c	2011-09-06 08:30:17 UTC (rev 39962)
+++ trunk/blender/source/blender/makesrna/intern/rna_texture_api.c	2011-09-06 10:49:55 UTC (rev 39963)
@@ -43,6 +43,7 @@
 #include "BKE_context.h"
 #include "BKE_global.h"
 #include "RE_pipeline.h"
+#include "RE_shader_ext.h"
 
 void save_envmap(struct EnvMap *env, bContext *C, ReportList *reports, const char* filepath, struct Scene *scene, float layout[12])
 {
@@ -67,30 +68,59 @@
 		}
 }
 
+void texture_evaluate(struct Tex *tex, float value[3], float color_r[3])
+{
+	TexResult texres= {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL};
+	multitex_ext(tex, value, NULL, NULL, 1, &texres);
+
+	color_r[0] = texres.tr;
+	color_r[1] = texres.tg;
+	color_r[2] = texres.tb;
+	color_r[3] = texres.tin;
+}
+
 #else
 
+void RNA_api_texture(StructRNA *srna)
+{
+	FunctionRNA *func;
+	PropertyRNA *parm;
+
+	func= RNA_def_function(srna, "evaluate", "texture_evaluate");
+	RNA_def_function_ui_description(func, "Evaluate the texture at the coordinates given");
+
+	parm= RNA_def_float_vector(func, "value", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4);
+	RNA_def_property_flag(parm, PROP_REQUIRED);
+
+	/* return location and normal */
+	parm= RNA_def_float_vector(func, "result", 4, NULL, -FLT_MAX, FLT_MAX, "Result", NULL, -1e4, 1e4);
+	RNA_def_property_flag(parm, PROP_THICK_WRAP);
+	RNA_def_function_output(func, parm);
+
+}
+
 void RNA_api_environment_map(StructRNA *srna)
 {
 	FunctionRNA *func;
 	PropertyRNA *parm;
-	
+
 	static const float default_layout[] = { 0,0, 1,0, 2,0, 0,1, 1,1, 2,1 };
-	
+
 	func= RNA_def_function(srna, "clear", "clear_envmap");
-		RNA_def_function_ui_description(func, "Discard the environment map and free it from memory.");
-		RNA_def_function_flag(func, FUNC_USE_CONTEXT);
+	RNA_def_function_ui_description(func, "Discard the environment map and free it from memory.");
+	RNA_def_function_flag(func, FUNC_USE_CONTEXT);
 
 
 	func= RNA_def_function(srna,"save", "save_envmap");
-		RNA_def_function_ui_description(func, "Save the environment map to disc using the scene render settings.");
-		RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
-	
-		parm= RNA_def_string_file_name(func,"filepath","",FILE_MAX,"File path","Location of the output file");
-			RNA_def_property_flag(parm, PROP_REQUIRED);
-	
-		RNA_def_pointer(func, "scene", "Scene", "", "Overrides the scene from which image parameters are taken.");
+	RNA_def_function_ui_description(func, "Save the environment map to disc using the scene render settings.");
+	RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
 
-		parm = RNA_def_float_array(func, "layout", 12, default_layout, 0.0f, 0.0f, "File layout", "Flat array describing the X,Y position of each cube face in the output image, where 1 is the size of a face. Order is [+Z -Z +Y -X -Y +X]. Use -1 to skip a face.", 0.0f, 0.0f);
+	parm= RNA_def_string_file_name(func,"filepath","",FILE_MAX,"File path","Location of the output file");
+	RNA_def_property_flag(parm, PROP_REQUIRED);
+
+	RNA_def_pointer(func, "scene", "Scene", "", "Overrides the scene from which image parameters are taken.");
+
+	parm = RNA_def_float_array(func, "layout", 12, default_layout, 0.0f, 0.0f, "File layout", "Flat array describing the X,Y position of each cube face in the output image, where 1 is the size of a face. Order is [+Z -Z +Y -X -Y +X]. Use -1 to skip a face.", 0.0f, 0.0f);
 }
 
 #endif




More information about the Bf-blender-cvs mailing list