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:
-rw-r--r--source/blender/python/api2_2x/Texture.c29
-rw-r--r--source/blender/python/api2_2x/doc/Texture.py9
-rw-r--r--source/blender/python/api2_2x/vector.c2
3 files changed, 39 insertions, 1 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);
+}
+
diff --git a/source/blender/python/api2_2x/doc/Texture.py b/source/blender/python/api2_2x/doc/Texture.py
index 34093bef6c7..d8fb3255b4a 100644
--- a/source/blender/python/api2_2x/doc/Texture.py
+++ b/source/blender/python/api2_2x/doc/Texture.py
@@ -469,6 +469,15 @@ class Texture:
and 'DistNoise'
@type type: string
"""
+ def evaluate(coord):
+ """
+ Evaluates the texture at this location and returns the result.
+
+ The return value is a 4D vector where (x,y,z,w) are (red, green, blue, intensity)
+ For greyscale textures, often intensity only will be used.
+ @type coord: vector
+ """
+
import id_generics
Texture.__doc__ += id_generics.attributes
diff --git a/source/blender/python/api2_2x/vector.c b/source/blender/python/api2_2x/vector.c
index 537a82c0a86..f969a5d1bcf 100644
--- a/source/blender/python/api2_2x/vector.c
+++ b/source/blender/python/api2_2x/vector.c
@@ -959,7 +959,7 @@ static PyObject *Vector_getAxis( VectorObject * self, void *type )
return EXPP_ReturnPyObjError(PyExc_AttributeError,
"vector.w: error, cannot get this axis for a 3D vector\n");
- return PyFloat_FromDouble(self->vec[4]);
+ return PyFloat_FromDouble(self->vec[3]);
default:
{
char errstr[1024];