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:
authorCampbell Barton <ideasman42@gmail.com>2011-09-06 14:49:55 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-09-06 14:49:55 +0400
commit7062788017cfb2841596d15f7c37612312692195 (patch)
treebbb55860b05e7ea9df70ce91da7573e866107a71
parent32287bebe82615b8500ef0196b7b780745147835 (diff)
texture evaluation function (like we had in 2.4x api), requested by Lee.
eg: red, green, blue, intensity = texture.evaluate(vec)
-rw-r--r--source/blender/makesrna/intern/rna_internal.h1
-rw-r--r--source/blender/makesrna/intern/rna_texture.c2
-rw-r--r--source/blender/makesrna/intern/rna_texture_api.c54
3 files changed, 45 insertions, 12 deletions
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index 9e98f166875..78b8c67d92c 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -261,6 +261,7 @@ void RNA_api_wm(struct StructRNA *srna);
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 */
diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c
index 503212201c4..890be76c49a 100644
--- a/source/blender/makesrna/intern/rna_texture.c
+++ b/source/blender/makesrna/intern/rna_texture.c
@@ -1820,6 +1820,8 @@ static void rna_def_texture(BlenderRNA *brna)
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)
diff --git a/source/blender/makesrna/intern/rna_texture_api.c b/source/blender/makesrna/intern/rna_texture_api.c
index 8d4b73f1f0c..8c63d5da8fd 100644
--- a/source/blender/makesrna/intern/rna_texture_api.c
+++ b/source/blender/makesrna/intern/rna_texture_api.c
@@ -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 clear_envmap(struct EnvMap *env, bContext *C)
}
}
+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_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);
+ 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