diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-09-06 14:49:55 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-09-06 14:49:55 +0400 |
commit | 7062788017cfb2841596d15f7c37612312692195 (patch) | |
tree | bbb55860b05e7ea9df70ce91da7573e866107a71 /source/blender/makesrna/intern/rna_texture_api.c | |
parent | 32287bebe82615b8500ef0196b7b780745147835 (diff) |
texture evaluation function (like we had in 2.4x api), requested by Lee.
eg:
red, green, blue, intensity = texture.evaluate(vec)
Diffstat (limited to 'source/blender/makesrna/intern/rna_texture_api.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_texture_api.c | 54 |
1 files changed, 42 insertions, 12 deletions
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 |