From 96897d567493964c2280b5069b7f70363c388185 Mon Sep 17 00:00:00 2001 From: Chris Want Date: Wed, 1 Jan 2003 15:06:10 +0000 Subject: Initial commit of the 'release' directory (splash screen/icon junkies will be happy to find the datatoc.c program in the datafiles directory). Some quick notes: * 'datafiles' has the version 2.21 splash.jpg and blenderbuttons (e.g., so no NLA icon). Someone should at least get the 2.25 blenderbuttons from somewhere and commit them. * 'text' has obsolete content/license * I did not include the python scripts as they have copyright Jan Walter and no license specified. * I changed to unix line terminators everywhere with the exeption of the 'windows' directory. Chris --- release/plugins/Makefile | 42 ++++++ release/plugins/bmake | 130 +++++++++++++++++++ release/plugins/include/floatpatch.h | 92 +++++++++++++ release/plugins/include/iff.h | 180 ++++++++++++++++++++++++++ release/plugins/include/plugin.h | 95 ++++++++++++++ release/plugins/include/util.h | 95 ++++++++++++++ release/plugins/sequence/Makefile | 38 ++++++ release/plugins/sequence/blur.c | 243 +++++++++++++++++++++++++++++++++++ release/plugins/sequence/scatter.c | 235 +++++++++++++++++++++++++++++++++ release/plugins/sequence/showzbuf.c | 126 ++++++++++++++++++ release/plugins/texture/Makefile | 38 ++++++ release/plugins/texture/clouds2.c | 177 +++++++++++++++++++++++++ release/plugins/texture/tiles.c | 176 +++++++++++++++++++++++++ 13 files changed, 1667 insertions(+) create mode 100644 release/plugins/Makefile create mode 100644 release/plugins/bmake create mode 100644 release/plugins/include/floatpatch.h create mode 100644 release/plugins/include/iff.h create mode 100644 release/plugins/include/plugin.h create mode 100644 release/plugins/include/util.h create mode 100644 release/plugins/sequence/Makefile create mode 100644 release/plugins/sequence/blur.c create mode 100644 release/plugins/sequence/scatter.c create mode 100644 release/plugins/sequence/showzbuf.c create mode 100644 release/plugins/texture/Makefile create mode 100644 release/plugins/texture/clouds2.c create mode 100644 release/plugins/texture/tiles.c (limited to 'release/plugins') diff --git a/release/plugins/Makefile b/release/plugins/Makefile new file mode 100644 index 00000000000..bef7c7b5e17 --- /dev/null +++ b/release/plugins/Makefile @@ -0,0 +1,42 @@ +# +# $Id$ +# +# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. The Blender +# Foundation also sells licenses for use in proprietary software under +# the Blender License. See http://www.blender.org/BL/ for information +# about this. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. +# All rights reserved. +# +# The Original Code is: all of this file. +# +# Contributor(s): none yet. +# +# ***** END GPL/BL DUAL LICENSE BLOCK ***** + +all: textures sequences + +textures: + cd texture; make; + +sequences: + cd sequence; make; + +clean: + cd texture; make clean; + cd sequence; make clean; diff --git a/release/plugins/bmake b/release/plugins/bmake new file mode 100644 index 00000000000..f7d1404a808 --- /dev/null +++ b/release/plugins/bmake @@ -0,0 +1,130 @@ +#!/bin/sh +# +# $Id$ +# +# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. The Blender +# Foundation also sells licenses for use in proprietary software under +# the Blender License. See http://www.blender.org/BL/ for information +# about this. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. +# All rights reserved. +# +# The Original Code is: all of this file. +# +# Contributor(s): none yet. +# +# ***** END GPL/BL DUAL LICENSE BLOCK ***** + +# detect the system + +UNAME=`uname` +if ( test $UNAME = "IRIX64" -o $UNAME = "IRIX" ) then + CC="cc"; + CFLAGS="-KPIC -O2 -mips3"; + + LD="ld"; + LDFLAGS="-shared -U"; +elif ( test $UNAME = "FreeBSD" ) then + CC="gcc"; + CFLAGS="-fPIC -funsigned-char -O2"; + + LD="ld"; + LDFLAGS="-Bshareable"; +elif ( test $UNAME = "OpenBSD" ) then + CC="gcc"; + CFLAGS="-fPIC -funsigned-char -O2"; + + LD="ld"; + LDFLAGS="-Bshareable"; +elif ( test $UNAME = "Linux" ) then + CC="gcc"; + CFLAGS="-fPIC -funsigned-char -O2"; + + LD="ld"; + LDFLAGS="-Bshareable"; +elif ( test $UNAME = "SunOS" ) then + CC="cc"; + CFLAGS="-O2"; + + LD="ld"; + LDFLAGS="-r"; +fi + +if ( test "$#" = "1" ) then + if ( test -f $1 ) then + BASE_FILE=`echo $1 | sed -e "1 s/\.c//g"`; + else + BASE_FILE=$1; + fi + + CFILE="$BASE_FILE.c" + OFILE="$BASE_FILE.o" + SOFILE="$BASE_FILE.so" +else + if ( test -f $1$2 ) then + BASE_FILE=`echo $2 | sed -e "1 s/\.c//g"`; + else + BASE_FILE=$2; + fi + + CFILE="$1$BASE_FILE.c" + OFILE="$BASE_FILE.o" + SOFILE="$BASE_FILE.so" +fi + +INCLUDES= +if ( test -f plugin.h ) then + INCLUDES=-I.; +elif ( test -f "include/plugin.h" ) then + INCLUDES=-Iinclude/ +elif ( test -f "../plugin.h" ) then + INCLUDES=-I..; +elif ( test -f "../include/plugin.h" ) then + INCLUDES=-I../include +else + echo "Couldn't find plugin.h"; + exit; +fi + +LIBM=`fgrep "#include " $CFILE` +LIBC=`fgrep "#include +#include "util.h" + +#define IB_rect (1 << 0) +#define IB_planes (1 << 1) +#define IB_cmap (1 << 2) +#define IB_test (1 << 7) + +#define IB_fields (1 << 11) +#define IB_yuv (1 << 12) +#define IB_zbuf (1 << 13) +#define IB_rgba (1 << 14) + +#define AMI (1 << 31) +#define Anim (1 << 29) +#define TGA (1 << 28) +#define JPG (1 << 27) + +#define RAWTGA (TGA | 1) + +#define JPG_STD (JPG | (0 << 8)) +#define JPG_VID (JPG | (1 << 8)) +#define JPG_JST (JPG | (2 << 8)) +#define JPG_MAX (JPG | (3 << 8)) +#define JPG_MSK (0xffffff00) + +#define AM_ham (0x0800 | AMI) +#define AM_hbrite (0x0080 | AMI) +#define AM_lace (0x0004 | AMI) +#define AM_hires (0x8000 | AMI) +#define AM_hblace (AM_hbrite | AM_lace) +#define AM_hilace (AM_hires | AM_lace) +#define AM_hamlace (AM_ham | AM_lace) + +#define RGB888 1 +#define RGB555 2 +#define DYUV 3 +#define CLUT8 4 +#define CLUT7 5 +#define CLUT4 6 +#define CLUT3 7 +#define RL7 8 +#define RL3 9 +#define MPLTE 10 + +#define DYUV1 0 +#define C233 1 +#define YUVX 2 +#define HAMX 3 +#define TANX 4 + +#define AN_c233 (Anim | C233) +#define AN_yuvx (Anim | YUVX) +#define AN_hamx (Anim | HAMX) +#define AN_tanx (Anim | TANX) + +#define IS_amiga(x) (x->ftype & AMI) +#define IS_ham(x) ((x->ftype & AM_ham) == AM_ham) +#define IS_hbrite(x) ((x->ftype & AM_hbrite) == AM_hbrite) +#define IS_lace(x) ((x->ftype & AM_lace) == AM_lace) +#define IS_hires(x) ((x->ftype & AM_hires) == AM_hires) +#define IS_hblace(x) ((x->ftype & AM_hblace) == AM_hblace) +#define IS_hilace(x) ((x->ftype & AM_hilace) == AM_hilace) +#define IS_hamlace(x) ((x->ftype & AM_hamlace) == AM_hamlace) + +#define IS_anim(x) (x->ftype & Anim) +#define IS_hamx(x) (x->ftype == AN_hamx) + +#define IS_tga(x) (x->ftype & TGA) +#define IS_tim(x) (x->ftype & TIM) + +#define IMAGIC 0732 +#define IS_iris(x) (x->ftype == IMAGIC) + +#define IS_jpg(x) (x->ftype & JPG) +#define IS_stdjpg(x) ((x->ftype & JPG_MSK) == JPG_STD) +#define IS_vidjpg(x) ((x->ftype & JPG_MSK) == JPG_VID) +#define IS_jstjpg(x) ((x->ftype & JPG_MSK) == JPG_JST) +#define IS_maxjpg(x) ((x->ftype & JPG_MSK) == JPG_MAX) + +#define AN_INIT an_stringdec = stringdec; an_stringenc = stringenc; + +typedef struct ImBuf{ + short x,y; /* breedte in pixels, hoogte in scanlines */ + short skipx; /* breedte in ints om bij volgende scanline te komen */ + uchar depth; /* actieve aantal bits/bitplanes */ + uchar cbits; /* aantal active bits in cmap */ + ushort mincol; + ushort maxcol; + int type; /* 0=abgr, 1=bitplanes */ + int ftype; + uint *cmap; /* int array van kleuren */ + uint *rect; /* databuffer */ + uint **planes; /* bitplanes */ + uchar *chardata; /* voor cdi-compressie */ + int flags; + int mall; /* wat is er intern gemalloced en mag weer vrijgegeven worden */ + short xorig, yorig; + char name[127]; + char namenull; + int userflags; + int *zbuf; + void *userdata; +} ImBuf; + +extern struct ImBuf *allocImBuf(short,short,uchar,uint,uchar); +extern struct ImBuf *dupImBuf(struct ImBuf *); +extern void freeImBuf(struct ImBuf*); + +extern short converttocmap(struct ImBuf* ibuf); + +extern short saveiff(struct ImBuf *,char *,int); + +extern struct ImBuf *loadiffmem(int *,int); +extern struct ImBuf *loadifffile(int,int); +extern struct ImBuf *loadiffname(char *,int); +extern struct ImBuf *testiffname(char *,int); + +extern struct ImBuf *onehalf(struct ImBuf *); +extern struct ImBuf *onethird(struct ImBuf *); +extern struct ImBuf *halflace(struct ImBuf *); +extern struct ImBuf *half_x(struct ImBuf *); +extern struct ImBuf *half_y(struct ImBuf *); +extern struct ImBuf *double_x(struct ImBuf *); +extern struct ImBuf *double_y(struct ImBuf *); +extern struct ImBuf *double_fast_x(struct ImBuf *); +extern struct ImBuf *double_fast_y(struct ImBuf *); + +extern int ispic(char *); + +extern void floyd(struct ImBuf *, short, short); +extern void dit2(struct ImBuf *, short, short); +extern void dit3(struct ImBuf *, short, short); +extern void dit4(struct ImBuf *, short, short); +extern void dit0(struct ImBuf *, short, short); +extern void (*ditherfunc)(struct ImBuf *, short, short); + +extern struct ImBuf *scaleImBuf(struct ImBuf *, short, short); +extern struct ImBuf *scalefastImBuf(struct ImBuf *, short, short); +extern struct ImBuf *scalefieldImBuf(struct ImBuf *, short, short); +extern struct ImBuf *scalefastfieldImBuf(struct ImBuf *, short, short); + +extern long getdither(); + +#endif /* IFF_H */ diff --git a/release/plugins/include/plugin.h b/release/plugins/include/plugin.h new file mode 100644 index 00000000000..d09959c54ab --- /dev/null +++ b/release/plugins/include/plugin.h @@ -0,0 +1,95 @@ +/** + * $Id$ + * + * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** + */ + +#ifndef PLUGIN_H +#define PLUGIN_H + +#include "iff.h" +#include "util.h" +#include "floatpatch.h" + +#define B_PLUGIN_VERSION 3 + +typedef int (*TexDoit)(int, void*, float*, float*, float*); +typedef void (*SeqDoit)(void*, float, float, int, int, ImBuf*, ImBuf*, ImBuf*, ImBuf*); + +typedef struct VarStruct { + int type; + char name[16]; + float def, min, max; + char tip[80]; +} VarStruct; + +typedef struct _PluginInfo { + char *name; + char *snames; + + int stypes; + int nvars; + VarStruct *varstr; + float *result; + float *cfra; + + void (*init)(void); + void (*callback)(int); + TexDoit tex_doit; + SeqDoit seq_doit; +} PluginInfo; + +int plugin_tex_getversion(void); +int plugin_seq_getversion(void); +void plugin_getinfo(PluginInfo *); + +/* *************** defines for button types ************** */ + +#define INT 96 +#define FLO 128 + +#define TOG (3<<9) +#define NUM (5<<9) +#define LABEL (10<<9) +#define NUMSLI (14<<9) + + +/* *************** API functions ******************** */ + + /* derived from the famous Perlin noise */ +extern float hnoise(float noisesize, float x, float y, float z); + /* the original Perlin noise */ +extern float hnoisep(float noisesize, float x, float y, float z); + + /* soft turbulence */ +extern float turbulence(float noisesize, float x, float y, float z, int depth); + /* hard turbulence */ +extern float turbulence1(float noisesize, float x, float y, float z, int depth); + +#endif /* PLUGIN_H */ diff --git a/release/plugins/include/util.h b/release/plugins/include/util.h new file mode 100644 index 00000000000..19b51b1fce3 --- /dev/null +++ b/release/plugins/include/util.h @@ -0,0 +1,95 @@ +/** + * $Id$ + * + * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** + */ + +#ifndef UTIL_H +#define UTIL_H + +#include +#include +#include + +#ifndef NULL +#define NULL 0 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef ulong +#define ulong unsigned long +#endif + +#ifndef ushort +#define ushort unsigned short +#endif + +#ifndef uchar +#define uchar unsigned char +#endif + +#ifndef uint +#define uint unsigned int +#endif + +#define MIN2(x,y) ( (x)<(y) ? (x) : (y) ) +#define MIN3(x,y,z) MIN2( MIN2((x),(y)) , (z) ) +#define MIN4(x,y,z,a) MIN2( MIN2((x),(y)) , MIN2((z),(a)) ) + +#define MAX2(x,y) ( (x)>(y) ? (x) : (y) ) +#define MAX3(x,y,z) MAX2( MAX2((x),(y)) , (z) ) +#define MAX4(x,y,z,a) MAX2( MAX2((x),(y)) , MAX2((z),(a)) ) + +#define SWAP(type, a, b) { type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; } + +#ifndef ABS +#define ABS(x) ((x) < 0 ? -(x) : (x)) +#endif + +#ifndef CLAMP +#define CLAMP(val, low, high) ((val>high)?high:((valname= name; + info->nvars= sizeof(varstr)/sizeof(VarStruct); + info->cfra= &cfra; + + info->varstr= varstr; + + info->init= plugin_init; + info->seq_doit= (SeqDoit) plugin_seq_doit; + info->callback= plugin_but_changed; +} + + +void blurbuf(struct ImBuf *ibuf, int nr, Cast *cast) +{ + /* nr = number of blurs */ + /* the ibuf->rect is replaced */ + struct ImBuf *tbuf, *ttbuf; + int i, x4; + + tbuf= dupImBuf(ibuf); + x4= ibuf->x/4; + + if(cast->gamma != 1.0) gamwarp(tbuf, cast->gamma); + + /* reduce */ + for(i=0; ix<4 || tbuf->y<4) break; + } + + /* enlarge */ + for(i=0; ix > x4) { + scaleImBuf(tbuf, ibuf->x, ibuf->y); + break; + } + } + + if(cast->gamma != 1.0) gamwarp(tbuf, 1.0 / cast->gamma); + + freeN(ibuf->rect); + ibuf->rect= tbuf->rect; + freeN(tbuf); + +} + +void doblur(struct ImBuf *mbuf, float fac, Cast *cast) +{ + /* make two filtered images, like a mipmap structure + * fac is filtersize in pixels + */ + struct ImBuf *ibuf, *pbuf; + float ifac, pfac; + int n, b1, b2; + char *irect, *prect, *mrect; + + /* wich buffers ? */ + + if(fac>7.0) fac= 7.0; + if(fac<=1.0) return; + + pfac= 2.0; + + pbuf= dupImBuf(mbuf); + n= 1; + while(pfac < fac) { + blurbuf(pbuf, n, cast); + blurbuf(pbuf, n, cast); + + n++; + pfac+= 1.0; + } + + ifac= pfac; + pfac-= 1.0; + + ibuf= dupImBuf(pbuf); + blurbuf(ibuf, n, cast); + blurbuf(ibuf, n, cast); + + fac= 255.0*(fac-pfac)/(ifac-pfac); + b1= fac; + if(b1>255) b1= 255; + b2= 255-b1; + + if(b1==255) { + memcpy(mbuf->rect, ibuf->rect, 4*ibuf->x*ibuf->y); + } + else if(b1==0) { + memcpy(mbuf->rect, pbuf->rect, 4*pbuf->x*pbuf->y); + } + else { /* interpolate */ + n= ibuf->x*ibuf->y; + irect= (char *)ibuf->rect; + prect= (char *)pbuf->rect; + mrect= (char *)mbuf->rect; + while(n--) { + mrect[0]= (irect[0]*b1+ prect[0]*b2)>>8; + mrect[1]= (irect[1]*b1+ prect[1]*b2)>>8; + mrect[2]= (irect[2]*b1+ prect[2]*b2)>>8; + mrect[3]= (irect[3]*b1+ prect[3]*b2)>>8; + mrect+= 4; + irect+= 4; + prect+= 4; + } + } + freeImBuf(ibuf); + freeImBuf(pbuf); +} + + +void plugin_seq_doit(Cast *cast, float facf0, float facf1, int x, int y, ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *out, ImBuf *use) +{ + float bfacf0, bfacf1; + + if(cast->use_ipo==0) { + bfacf0= bfacf1= cast->blur+1.0; + } + else { + bfacf0 = (facf0 * 6.0) + 1.0; + bfacf1 = (facf1 * 6.0) + 1.0; + } + + memcpy(out->rect, ibuf1->rect, 4*out->x*out->y); + + /* it blurs interlaced, only tested with even fields */ + de_interlace(out); + + /* otherwise scaling goes wrong */ + out->flags &= ~IB_fields; + + doblur(out, bfacf0, cast); /*fieldA*/ + + out->rect += out->x * out->y; + + doblur(out, bfacf1, cast); /*fieldB*/ + + out->rect -= out->x * out->y; + out->flags |= IB_fields; + + interlace(out); + +} + diff --git a/release/plugins/sequence/scatter.c b/release/plugins/sequence/scatter.c new file mode 100644 index 00000000000..cba8aeab5a8 --- /dev/null +++ b/release/plugins/sequence/scatter.c @@ -0,0 +1,235 @@ +/** + * $Id$ + * + * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** + */ + +#include "plugin.h" + +/* ******************** GLOBAL VARIABLES ***************** */ + + +char name[24]= "scatter"; + +/* structure for buttons, + * butcode name default min max 0 + */ + +VarStruct varstr[]= { + LABEL, "Input: 1 strip", 0.0, 0.0, 0.0, "", + NUM|INT, "seed: ", 1.0, 0.0, 10.0, "Offset in random table", + NUMSLI|FLO, "swing: ", 1.0, 0.0, 3.0, "The amplitude, width of the effect", + TOG|INT, "wrap", 0.0, 0.0, 1.0, "Cyclic wrap around the left/right edges", + NUM|INT, "type: ", 1.0, 0.0, 1.0, "Type 1 is random for each frame", +}; + +/* The cast struct is for input in the main doit function + Varstr and Cast must have the same variables in the same order */ + +typedef struct Cast { + int dummy; /* because of the 'label' button */ + int seed; + float swing; + int wrap; + int type; +} Cast; + +/* cfra: the current frame */ + +float cfra; + +void plugin_seq_doit(Cast *, float, float, int, int, ImBuf *, ImBuf *, ImBuf *, ImBuf *); + + +/* ******************** Fixed functions ***************** */ + +int plugin_seq_getversion(void) +{ + return B_PLUGIN_VERSION; +} + +void plugin_but_changed(int but) +{ +} + +void plugin_init() +{ +} + +void plugin_getinfo(PluginInfo *info) +{ + info->name= name; + info->nvars= sizeof(varstr)/sizeof(VarStruct); + info->cfra= &cfra; + + info->varstr= varstr; + + info->init= plugin_init; + info->seq_doit= (SeqDoit) plugin_seq_doit; + info->callback= plugin_but_changed; +} + + +/* ************************************************************ + Scatter + + with usage of ImBuf rect operation. + + ************************************************************ */ + +static void ibufrectop(ImBuf *dbuf, ImBuf *sbuf, + int destx, int desty, + int srcx, int srcy, int width, int height, + void (*operation)(), + int value) +{ + uint *drect,*srect; + + if (dbuf == 0) return; + if (operation == 0) return; + + if (destx < 0){ + srcx -= destx ; + width += destx ; + destx = 0; + } + if (srcx < 0){ + destx -= srcx ; + width += destx ; + srcx = 0; + } + if (desty < 0){ + srcy -= desty ; + height += desty ; + desty = 0; + } + if (srcy < 0){ + desty -= srcy ; + height += desty ; + srcy = 0; + } + + if (width > dbuf->x - destx) width = dbuf->x - destx; + if (height > dbuf->y - desty) height = dbuf->y - desty; + if (sbuf){ + if (width > sbuf->x - srcx) width = sbuf->x - srcx; + if (height > sbuf->y - srcy) height = sbuf->y - srcy; + } + + if (width <= 0) return; + if (height <= 0) return; + + drect = dbuf->rect; + if (sbuf) srect = sbuf->rect; + + drect += desty * dbuf->x; + drect += destx; + destx = dbuf->x; + + if (sbuf) { + srect += srcy * sbuf->x; + srect += srcx; + srcx = sbuf->x; + } else{ + srect = drect; + srcx = destx; + } + + for (;height > 0; height--){ + operation(drect, srect, width, value); + drect += destx; + srect += srcx; + } +} + +static void rectcpy(uint *drect, uint *srect, int x) { + memcpy(drect,srect, x * sizeof(int)); +} + +static void rectfill(uint *drect, uint *srect, int x, int value) +{ + for (;x > 0; x--) *drect++ = value; +} + + +void plugin_seq_doit(Cast *cast, float facf0, float facf1, int sx, int sy, ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *out, ImBuf *use) +{ + float f1, f2, t1, t2, t3; + int x, y, lr; + + /* fill imbuf 'out' with black */ + rectop(out, 0,0,0,0,0,32767,32767,rectfill, 0); + + switch (cast->type) { + case 0: + srand48(cast->seed); + break; + case 1: + srand48(cast->seed + facf0 * 1000); + break; + } + + for (y = 0; y < sy; y++) { + switch (cast->type) { + case 0: + if ((y & 1) == 0) { + f1 = drand48() - 0.5; + f2 = drand48() - 0.5; + f1 = cast->swing * f1; + f2 = cast->swing * f2; + if (cast->wrap) f2 += 1.0; + lr = drand48()>0.5; + t1 = facf0; + } else t1 = facf1; + + t2 = 1.0 - t1; + t3 = 3.0 * (f1 * t1 * t1 * t2 + f2 * t1 * t2 * t2); + if (cast->wrap) t3 += t2 * t2 * t2; + x = sx * t3; + if (lr) x = -x; + break; + case 1: + f1 = drand48() - 0.5; + f1 = f1 * cast->swing; + if ((y & 1) == 0) f1 *= facf0; + else f1 *= facf1; + x = f1 * sx; + break; + } + + rectop(out, ibuf1, 0, y, x, y, 32767, 1, rectcpy, 0); + if (cast->wrap) { + rectop(out, ibuf1, 0, y, x + sx, y, 32767, 1, rectcpy, 0); + rectop(out, ibuf1, 0, y, x + sx + sx, y, 32767, 1, rectcpy, 0); + rectop(out, ibuf1, 0, y, x - sx, y, 32767, 1, rectcpy, 0); + rectop(out, ibuf1, 0, y, x - sx - sx, y, 32767, 1, rectcpy, 0); + } + } +} + diff --git a/release/plugins/sequence/showzbuf.c b/release/plugins/sequence/showzbuf.c new file mode 100644 index 00000000000..403e526a1cd --- /dev/null +++ b/release/plugins/sequence/showzbuf.c @@ -0,0 +1,126 @@ +/** + * $Id$ + * + * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** + */ + +#include "plugin.h" + +/* ******************** GLOBAL VARIABLES ***************** */ + + +char name[24]= "showzbuf"; + +/* structure for buttons, + * butcode name default min max 0 + */ + +VarStruct varstr[]= { + {NUMSLI|FLO, "width ", 1.0, 0.0, 10.0, "This button is obsolete!"} +}; + +/* The cast struct is for input in the main doit function + Varstr and Cast must have the same variables in the same order */ + +typedef struct Cast { + float width; +} Cast; + +/* cfra: the current frame */ + +float cfra; + +void plugin_seq_doit(Cast *, float, float, int, int, ImBuf *, ImBuf *, ImBuf *, ImBuf *); + +/* ******************** Fixed functions ***************** */ + +int plugin_seq_getversion(void) +{ + return B_PLUGIN_VERSION; +} + +void plugin_but_changed(int but) +{ +} + +void plugin_init() +{ +} + +void plugin_getinfo(PluginInfo *info) +{ + info->name= name; + info->nvars= sizeof(varstr)/sizeof(VarStruct); + info->cfra= &cfra; + + info->varstr= varstr; + + info->init= plugin_init; + info->seq_doit= (SeqDoit) plugin_seq_doit; + info->callback= plugin_but_changed; +} + +/* ************************************************************ + Show Zbuffer + + Demonstration of usage of the 32 bits zbuffer input. + remember: z-values are not linear... + + Z values are only displayed when the input is a Scene-strip + or when images were saved in IRIZ format. + + ************************************************************ */ + + +void plugin_seq_doit(Cast *cast, float facf0, float facf1, int sx, int sy, ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *out, ImBuf *use) +{ + int a; + int *rectz; + char *rectc; + + if(ibuf1) { + if(ibuf1->zbuf==0) { + printf("no zbuf\n"); + return; + } + + a= ibuf1->x*ibuf1->y; + rectz= ibuf1->zbuf; + rectc= (char *)out->rect; + + while(a--) { + rectc[0]= 255; + rectc[1]= rectc[2]= rectc[3]= (rectz[0]>>18); + rectc+= 4; + rectz++; + } + } + +} + diff --git a/release/plugins/texture/Makefile b/release/plugins/texture/Makefile new file mode 100644 index 00000000000..dc632c5d2e7 --- /dev/null +++ b/release/plugins/texture/Makefile @@ -0,0 +1,38 @@ +# +# $Id$ +# +# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. The Blender +# Foundation also sells licenses for use in proprietary software under +# the Blender License. See http://www.blender.org/BL/ for information +# about this. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. +# All rights reserved. +# +# The Original Code is: all of this file. +# +# Contributor(s): none yet. +# +# ***** END GPL/BL DUAL LICENSE BLOCK ***** + +all: plugins + +plugins: + @/bin/sh -c 'for i in *.c; do ../bmake $$i; done;' + +clean: + rm -rf *.o *.so diff --git a/release/plugins/texture/clouds2.c b/release/plugins/texture/clouds2.c new file mode 100644 index 00000000000..6511b7f68b6 --- /dev/null +++ b/release/plugins/texture/clouds2.c @@ -0,0 +1,177 @@ +/** + * $Id$ + * + * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** + */ + +#include "math.h" +#include "plugin.h" + +/* ******************** GLOBAL VARIABLES ***************** */ + +/* Texture name */ + +char name[24]= "Clouds2"; + +/* Subtype names must be less than 15 characters */ + +#define NR_TYPES 3 +char stnames[NR_TYPES][16]= {"Intens", "Col", "Bump" }; + +/* Structure for buttons, + * butcode name default min max 0 + */ + +VarStruct varstr[]= { +{ NUM|FLO, "Offset", -0.5, -20.0, 20.0, ""}, +{ NUM|INT, "Depth", 8.0, 1.0, 12.0, ""}, +{ NUM|FLO, "Scale", 2.2, -20.0, 20.0, ""}, +{ NUM|FLO, "Falloff", 1.0, -20.0, 20.0, ""} +}; + +/* The cast struct is for input in the main doit function + Varstr and Cast must have the same variables in the same order, + INCLUDING dummy variables for label fields. */ + +typedef struct Cast { + float offset; + int depth; + float txtscale; + float falloff; +} Cast; + +/* result: + Intensity, R, G, B, Alpha, nor.x, nor.y, nor.z + */ + +float result[8]; + +/* cfra: the current frame */ + +float cfra; + +int plugin_tex_doit(int, Cast*, float*, float*, float*); + +/* ******************** Fixed functions ***************** */ + +int plugin_tex_getversion(void) +{ + return B_PLUGIN_VERSION; +} + +void plugin_but_changed(int but) +{ +} + +void plugin_init(void) +{ + +} + +/* this function should not be changed: */ + +void plugin_getinfo(PluginInfo *info) +{ + info->name= name; + info->stypes= NR_TYPES; + info->nvars= sizeof(varstr)/sizeof(VarStruct); + + info->snames= stnames[0]; + info->result= result; + info->cfra= &cfra; + info->varstr= varstr; + + info->init= plugin_init; + info->tex_doit= (TexDoit) plugin_tex_doit; + info->callback= plugin_but_changed; +} + +/* ********************* the texture ******************** */ + + +/* return 0: One channel texture + return 1: RGB texture + return 2: Normals texture */ + +int plugin_tex_doit(int stype, Cast *cast, float *texvec, float *dxt, float *dyt) +{ + float val = 0.0; + float a = 1.0; + float p[3]; + float tv[3]; + int i; + + tv[0]=(texvec[0]+1.0)/2.0; + tv[1]=(texvec[1]+1.0)/2.0; + tv[2]=(texvec[2]+1.0)/2.0; + + p[0] = cast->txtscale * tv[0]; + p[1] = cast->txtscale * tv[1]; + p[2] = cast->txtscale * tv[2]; + + for (i=0; idepth; i++) { + val += a * hnoise(1.0, p[0], p[1], p[2]); + + p[0] *= 2.0; + p[1] *= 2.0; + p[2] *= 2.0; + a *= 0.5; + } + + /* always return this value */ + result[0] = CLAMP (val+cast->offset, 0.0, 1.0) * pow (fabs(sqrt(tv[0]*tv[0]+tv[1]*tv[1]+tv[2]*tv[2])), cast->falloff); + + if(stype==1) { + /* color? then return 1; + * + * this is r, g, b, a: + */ + result[1]= 0.5*result[0]; + result[2]= 1.0-val; + result[3]= fsqrt(fabs(result[0])); + result[4]= 1.0; + + return 1; + } + if(stype==2) { + /* normal? then return 2 + * + * This value is the displacement of the actual normal in + * the Material calculation. + */ + result[5]+= val; + result[6]+= 1.0-val; + result[7]= 0.0; + + return 2; + } + + return 0; +} + diff --git a/release/plugins/texture/tiles.c b/release/plugins/texture/tiles.c new file mode 100644 index 00000000000..9977675c389 --- /dev/null +++ b/release/plugins/texture/tiles.c @@ -0,0 +1,176 @@ + /** + * $Id$ + * + * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** + */ + +#include "math.h" +#include "plugin.h" + +/* ******************** GLOBAL VARIABLES ***************** */ + +char name[]= "tiles"; + +/* Subtype names must be less than 15 characters */ + +#define NR_TYPES 2 +char stnames[NR_TYPES][16]= {"Square", "Deformed"}; + +VarStruct varstr[]= { + NUM|FLO, "size", 1.0, 0.0, 1.0, "The size of each tile", + NUM|FLO, "Noise", 1.0, 0.01, 10.0, "" +}; + +/* The cast struct is for input in the main doit function + Varstr and Cast must have the same variables in the same order */ + +typedef struct Cast { + float size; + float noise; +} Cast; + +/* result: + Intensity, R, G, B, Alpha, nor.x, nor.y, nor.z + */ + +float result[8]; + +/* cfra: the current frame */ + +float cfra; + +int plugin_tex_doit(int, Cast *, float *, float *, float *); + + +/* ******************** Fixed functions ***************** */ + +int plugin_tex_getversion(void) +{ + return B_PLUGIN_VERSION; +} + +void plugin_but_changed(int but) +{ +} + +void plugin_init(void) +{ +} + +/* this function should not be changed: */ + +void plugin_getinfo(PluginInfo *info) +{ + info->name= name; + info->stypes= NR_TYPES; + info->nvars= sizeof(varstr)/sizeof(VarStruct); + + info->snames= stnames[0]; + info->result= result; + info->cfra= &cfra; + info->varstr= varstr; + + info->init= plugin_init; + info->tex_doit= (TexDoit) plugin_tex_doit; + info->callback= plugin_but_changed; +} + +/* ************************************************************ + Tiles + + Demonstration of a simple square wave function sampled + with anti-aliasing. + It is not mipmapped yet... + + ************************************************************ */ + + +/* square wave, antialiased, no mipmap! */ + +float sample_wave(float freq, float coord, float pixsize) +{ + float fac, frac, retval; + int part1, part2; + + if(pixsize > freq) return 0.5; + + pixsize/= freq; + + fac= coord/freq; + part1= ffloor(fac); + frac= fac - part1; + + if(part1 & 1) retval= 0.0; + else retval= 1.0; + + if(pixsize != 0.0) { + + /* is coord+pixsize another value? */ + + part2= ffloor(fac + pixsize); + if(part1==part2) return retval; + + /* antialias */ + if(retval==1.0) retval= (1.0-frac)/pixsize; + else retval= 1.0-(1.0-frac)/pixsize; + } + return retval; +} + +/* return 0: One channel texture + return 1: RGB texture + return 2: Normals texture */ + + +int plugin_tex_doit(int stype, Cast *cast, float *texvec, float *dxt, float *dyt) +{ + float xwave, ywave; + + if(stype==1) { + texvec[0]+= hnoise(cast->noise, texvec[0], texvec[1], texvec[2]); + texvec[1]+= hnoise(cast->noise, texvec[1], texvec[2], texvec[0]); + } + + if(dxt && dyt) { + xwave= sample_wave(cast->size, texvec[0], fabs(dxt[0]) + fabs(dyt[0]) ); + ywave= sample_wave(cast->size, texvec[1], fabs(dxt[1]) + fabs(dyt[1]) ); + + if(xwave > ywave) result[0]= xwave-ywave; + else result[0]= ywave-xwave; + } + else { + xwave= sample_wave(cast->size, texvec[0], 0.0 ); + ywave= sample_wave(cast->size, texvec[1], 0.0 ); + + if(xwave > ywave) result[0]= xwave-ywave; + else result[0]= ywave-xwave; + } + + return 0; +} -- cgit v1.2.3