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>2007-03-02 12:48:04 +0300
committerCampbell Barton <ideasman42@gmail.com>2007-03-02 12:48:04 +0300
commitb2acdd69b037b8363dd2c214ccc0a2af691ab017 (patch)
tree5a6333eb58c7d762b5b4d7ce3673a22192d9b832 /source/blender/python/api2_2x/Texture.c
parentb5343551acd7069c5ba9bd028b42a11fab2f8e5e (diff)
vector.c - bugfix, vec.w accessed vec[4] not vec[3]! (probably my fault)
Texture.c - added "val = tex.evaluate(vec)" so you can find the color/intensity at a given loaction for a texture.
Diffstat (limited to 'source/blender/python/api2_2x/Texture.c')
-rw-r--r--source/blender/python/api2_2x/Texture.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/source/blender/python/api2_2x/Texture.c b/source/blender/python/api2_2x/Texture.c
index 2a0f4af45aa..12caa55fce5 100644
--- a/source/blender/python/api2_2x/Texture.c
+++ b/source/blender/python/api2_2x/Texture.c
@@ -53,6 +53,9 @@
#include "blendef.h"
#include "gen_utils.h"
+#include "vector.h" /* for Texture_evaluate(vec) */
+#include "RE_shader_ext.h"
+
/*****************************************************************************/
/* Blender.Texture constants */
/*****************************************************************************/
@@ -487,6 +490,8 @@ static int Texture_setImageFlags( BPy_Texture *self, PyObject *args,
void *type );
static int Texture_setNoiseBasis2( BPy_Texture *self, PyObject *args,
void *type );
+
+static PyObject *Texture_evaluate( BPy_Texture *self, PyObject *args );
/*****************************************************************************/
/* Python BPy_Texture methods table: */
@@ -529,6 +534,8 @@ static PyMethodDef BPy_Texture_methods[] = {
"(s) - Set Dist Noise"},
{"setDistMetric", ( PyCFunction ) Texture_oldsetDistMetric, METH_VARARGS,
"(s) - Set Dist Metric"},
+ {"evaluate", ( PyCFunction ) Texture_evaluate, METH_VARARGS,
+ "(vector) - evaluate the texture at this position"},
{NULL, NULL, 0, NULL}
};
@@ -2644,3 +2651,25 @@ static PyObject *Texture_oldsetImageFlags( BPy_Texture * self, PyObject * args )
Py_RETURN_NONE;
}
+static PyObject *Texture_evaluate( BPy_Texture * self, PyObject * args )
+{
+ VectorObject *vec_in = NULL;
+ TexResult texres= {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL};
+ float vec[4];
+ /* int rgbnor; dont use now */
+
+ if(!PyArg_ParseTuple(args, "O!", &vector_Type, &vec_in) || vec_in->size < 3)
+ return EXPP_ReturnPyObjError(PyExc_TypeError,
+ "expects a 3D vector object\n");
+
+ /* rgbnor = .. we dont need this now */
+ multitex_ext(self->texture, vec_in->vec, 1, 1, 1, &texres);
+
+ vec[0] = texres.tr;
+ vec[1] = texres.tg;
+ vec[2] = texres.tb;
+ vec[3] = texres.tin;
+
+ return newVectorObject(vec, 4, Py_NEW);
+}
+