added no-xtile and no-ytile to the images realtime properties and python api.
authorCampbell Barton <ideasman42@gmail.com>
Mon, 12 Mar 2007 01:43:11 +0000 (01:43 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 12 Mar 2007 01:43:11 +0000 (01:43 +0000)
source/blender/makesdna/DNA_image_types.h
source/blender/python/api2_2x/Image.c
source/blender/python/api2_2x/doc/Image.py
source/blender/src/drawimage.c
source/blender/src/drawmesh.c

index d99e19ce456aadbbbc9ba0d7b043290f319296f4..78672d7cde82f95bd4f8b3a3b9945088e97eeb78 100644 (file)
@@ -117,6 +117,8 @@ typedef struct Image {
 #define IMA_TWINANIM           2
 #define IMA_COLCYCLE           4       /* Depreciated */
 #define IMA_MIPMAP_COMPLETE 8   /* all mipmap levels in OpenGL texture set? */
+#define IMA_NOREPEAT_U         16
+#define IMA_NOREPEAT_V         32
 
 /* ima->type and ima->source moved to BKE_image.h, for API */
 
index 41714e2cdf7c2d310a5cd2871f119feb0e05602b..7cd22afff7dd63d9e7a164d62d1a6c125be8e52d 100644 (file)
@@ -1131,6 +1131,15 @@ static PyObject *Image_getFlag(BPy_Image *self, void *flag)
                
 }
 
+static PyObject *Image_getFlagTpage(BPy_Image *self, void *flag)
+{
+       if (self->image->tpageflag & (int)flag)
+               Py_RETURN_TRUE;
+       else
+               Py_RETURN_FALSE;
+               
+}
+
 static int Image_setSource( BPy_Image *self, PyObject *args)
 {
     PyObject* integer = PyNumber_Int( args );
@@ -1160,6 +1169,14 @@ static int Image_setFlag(BPy_Image *self, PyObject *value, void *flag)
        return 0;
 }
 
+static int Image_setFlagTpage(BPy_Image *self, PyObject *value, void *flag)
+{
+       if ( PyObject_IsTrue(value) )
+               self->image->tpageflag |= (int)flag;
+       else
+               self->image->tpageflag &= ~(int)flag;
+       return 0;
+}
 
 /*
  * get integer attributes
@@ -1295,7 +1312,10 @@ static PyGetSetDef BPy_Image_getseters[] = {
         "image antialiasing toggle", (void *)IMA_ANTIALI },
        {"reflect", (getter)Image_getFlag, (setter)Image_setFlag,
         "image reflect toggle", (void *)IMA_REFLECT },
-
+       {"noXTile", (getter)Image_getFlagTpage, (setter)Image_setFlagTpage,
+        "image reflect toggle", (void *)IMA_REFLECT },
+       {"noYTile", (getter)Image_getFlagTpage, (setter)Image_setFlagTpage,
+        "image reflect toggle", (void *)IMA_REFLECT },
        {NULL,NULL,NULL,NULL,NULL}  /* Sentinel */
 };
 
index 9212180613085ed348965196b172b83cada1d517..2adfdfb5d40a83621d44e5150065da6d02093d77 100644 (file)
@@ -111,6 +111,10 @@ class Image:
        @type bindcode: int
        @ivar source: Image source type.  See L{the Sources dictionary<Sources>} .
        @type source: int
+       @ivar noXTile: When true the image will not tile horizontally.
+       @type noXTile: bool
+       @ivar noYTile: When true the image will not tile vertically.
+       @type noYTile: bool
        """
 
        def getName():
index 119beb8981c6352bb604c033c920a4871fa979e5..0a1046f384af24f27154dd52f101305eec0a3af2 100644 (file)
@@ -948,6 +948,11 @@ static void image_panel_game_properties(short cntrl)       // IMAGE_HANDLER_GAME_PROPE
                uiDefButS(block, NUM, B_SIMAGEDRAW, "X:",               160,130,70,19, &G.sima->image->xrep, 1.0, 16.0, 0, 0, "Sets the degree of repetition in the X direction");
                uiDefButS(block, NUM, B_SIMAGEDRAW, "Y:",               230,130,70,19, &G.sima->image->yrep, 1.0, 16.0, 0, 0, "Sets the degree of repetition in the Y direction");
                uiBlockBeginAlign(block);
+               
+               uiBlockBeginAlign(block);
+               uiDefButBitS(block, TOG, IMA_NOREPEAT_U, B_SIMAGEDRAW, "No XRep",       160,100,70,19, &G.sima->image->tpageflag, 0, 0, 0, 0, "Disable texture repeating horizontaly");
+               uiDefButBitS(block, TOG, IMA_NOREPEAT_V, B_SIMAGEDRAW, "No YRep",       230,100,70,19, &G.sima->image->tpageflag, 0, 0, 0, 0, "Disable texture repeating vertically");
+               uiBlockEndAlign(block);         
        }
 }
 
index c8c07748d6a13dde5cbd6d081a75903526f4872a..2a22451f2f67816d5895d32756e11de800e78b20 100644 (file)
@@ -417,6 +417,18 @@ int set_tpage(MTFace *tface)
        }
        else glBindTexture( GL_TEXTURE_2D, *bind);
        
+       /* dont tile x/y as set the the game properties */
+       if (ima->tpageflag & IMA_NOREPEAT_U)
+          glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+       else
+               glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+       if (ima->tpageflag & IMA_NOREPEAT_V)
+               glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+       else
+               glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+       
+       /* tag_image_time(ima);*/  /* Did this get lost in the image recode? */
+       
        glEnable(GL_TEXTURE_2D);
 
        fCurpage= ima;