home *** CD-ROM | disk | FTP | other *** search
- /*------------------------------------------------------------------\
- | Name: NOISE.H |
- | Author: Charles Congdon |
- | Created: 09/23/92 |
- | Last Updated: 10/29/92 |
- | |
- | Purpose: |
- | This module contains the includes for 3D noise functions. |
- \------------------------------------------------------------------*/
-
- #ifndef NOISEH
-
- #define NOISEH 1
-
- /*---------------------------\
- | Pull in main includes. |
- \---------------------------*/
-
- #include <stdlib.h>
- #include <math.h>
-
- /*-------------------------------------------------------\
- | I suggest use the following two lines only with -f8 |
- | (floating point accelerator, optimized code). |
- \-------------------------------------------------------*/
- #ifdef _M68881
- #include <m68881.h>
- #endif
- #define FLOOR_ERROR 0 /* The Lattice 5.10a 68881 library incorrectly sets
- floor -4.5 to -4. This inserts code to correct
- for this sin */
-
- #undef CONSUME_MY_CPU
- /*---------------------------------------- ------------------------------\
- | Uncomment the following line if you wish to use Hermit interpolation |
- | for the vector direction as well as the vector magnitude (overkill |
- | unless you really need all 4 of these values smooth - the vector |
- | directions, although usually linearly interpolated, add to a pretty |
- | smooth direction change, and the vector magnitude is always |
- | interpolated with care. |
- \-----------------------------------------------------------------------*/
- /* #define CONSUME_MY_CPU 1 */
-
- /*---------------------------------------\
- | Define matrix and vector datatypes |
- \---------------------------------------*/
- /* #ifdef INITNOISE */
- #define MATRIXSIZE 4
- #define COORD double
-
- /*-----------------------------------------------------------\
- | It may make sense to externalize these type definitions |
- \-----------------------------------------------------------*/
- typedef double matrix[MATRIXSIZE][MATRIXSIZE];
- typedef COORD vector[3];
- /* #endif */
-
-
- /*-------------------\
- | Noise defaults |
- \-------------------*/
- #define IINIT_SCALE 10.0
- #define INUM_SCALES 5.0
- #define ISCALE_RATIO 0.4
- #define IAMP_RATIO 0.4
- #define ITIME_RATIO 0.4
- #define ITIME 0.0
- #define IMAX_SCALES 20.0
- #define IIMAX_SCALES 20
-
- #ifdef INITNOISE
- /*----------------------------\
- | Initialization variables. |
- \----------------------------*/
- # define EI
- # define II(x) = { (x) }
-
- #else /* INITNOISE */
-
- /*-----------------------------\
- | External reference macros. |
- \-----------------------------*/
- # define EI extern
- # define II(x)
-
- #endif /* INITNOISE */
-
- #define SLONG signed long int
- #define ULNG unsigned long int
-
- /*---------------------------\
- | Noise function globals |
- \---------------------------*/
- EI SLONG xlim[3][2]; /* Global variable for the cube containing the point */
- EI double xarg[3]; /* Global variable for the fractional parts for each
- coord - always positive (critical!) */
- EI short int Noiseinit; /* Have we set up the noise function yet? */
- EI double Frame; /* The frame number - use as needed */
-
- /*-------------------------------\
- | Noise function prototypes. |
- \-------------------------------*/
-
- #ifdef __STDC__
- #define P8(a,b,c,d,e,f,g,h) a,b,c,d,e,f,g,h
- #else
- #define P8(a,b,c,d,e,f,g,h)
- #endif
-
- void ninterp(P3(double f[4],
- short int i,
- register short int n)
- );
- void normalze(P3(double scale,
- vector in,
- vector out)
- );
-
- double frand( P1(SLONG s) );
- double Noise3D(P2(vector point,
- vector noisev)
- );
- double wfractalval3(P8(vector in,
- double Initial_scale,
- double NumScales,
- double Scale_Ratio,
- double Amplitude_Ratio,
- double Time_Ratio,
- double Time,
- vector out)
- );
- void NiceN3D(P4(vector point,
- vector noisev,
- double scale,
- double NumScales)
- );
-
- #endif /* Not NOISEH */
-
-
-