testdll.c

Go to the documentation of this file.
00001 /* --
00002 OpenFX version 1.0 - Modelling, Animation and Rendering Package
00003 Copyright (C) 2000 OpenFX Development Team
00004 
00005 This program is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU General Public License
00007 as published by the Free Software Foundation; either version 2
00008 of the License, or (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License
00016 along with this program; if not, write to the Free Software
00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 
00019 You may contact the OpenFX development team via elecronic mail
00020 at core@openfx.org, or visit our website at http://openfx.org for
00021 further information and support details.
00022 -- */
00023 
00024 /* OLD OLD !!! Template for building EXTERNAL animation effect for */
00025 
00026 #include <math.h>
00027 #include <windows.h>
00028 
00029 #if __ZTC__ || __SC__
00030 #ifndef max
00031 #define max(a,b)  ( ((a) > (b)) ? (a) : (b) )
00032 #endif
00033 #endif
00034 
00035 #if __WATCOMC__
00036 #define PI 3.1415926
00037 #endif
00038 
00039 /************** Structures that may be addressed externally ********/
00040 
00041 #define double float    /* renderer uses FLOAT real numbers */
00042 typedef double vector[3];
00043 
00044 typedef struct VERTEX { /* structure for each vertex   */
00045  vector p;              /* real position  3D space     */
00046  double x,y;            /* screen location pixel space - NOT used in effect */
00047 } vertex;
00048 
00049 typedef struct TVERTEX {
00050  double x,y;            /* texture coordinates - for future expansion       */
00051 } tvertex;
00052 
00053 typedef struct {
00054  long nvert;            /* number of vertices that apply to the model       */
00055  long ltime;
00056  long vmin[3];
00057  long vmax[3];
00058  long origin[3];
00059  double time;
00060 } sfxinfo;
00061 
00062 /************** Function that is called  ****************/
00063 
00064 long CALLBACK DLL_ExternalEffect(char *PrmList, sfxinfo *SFXinfo,
00065                                  vertex *Vlist);
00066 
00067 /************************** DLL entry point ********************************/
00068 
00069 int APIENTRY LibMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00070 #define BUFSIZE 80
00071   HANDLE ghMod;
00072   switch (dwReason) {
00073     case DLL_PROCESS_ATTACH: {
00074       char buf[BUFSIZE+1];
00075 //      ghMod = hDLL;
00076 //      GetModuleFileName (NULL, (LPTSTR) buf, BUFSIZE);
00077 //      MessageBox ( GetFocus(),
00078 //                  (LPCTSTR) buf,
00079 //                  (LPCTSTR) "External effect: Process attaching",
00080 //                  MB_OK | MB_SYSTEMMODAL);
00081       break;
00082     }
00083     case DLL_PROCESS_DETACH:
00084 //      MessageBox ( GetFocus(),
00085 //                  (LPCTSTR) "External effect: Process detaching",
00086 //                  (LPCTSTR) "",
00087 //                  MB_OK | MB_SYSTEMMODAL );
00088       break;
00089   }
00090 return (int)TRUE;
00091 }
00092 
00093 #if __SC__
00094 #pragma startaddress(LibMain)
00095 #endif
00096 
00097 /*******************************************************************\
00098 |                Code that define the effects                       |
00099 \*******************************************************************/
00100 
00101 long CALLBACK DLL_ExternalEffect(char *PrmList, sfxinfo *SFXinfo,
00102                                  vertex *Vlist){
00103  double amplitude,wavelength,displacement,distance;
00104  long i;
00105  double PRMfreq, PRMwavelength;
00106  char axis, *cp;
00107  wavelength=max((double)(SFXinfo->vmax[1]-SFXinfo->vmin[1]),1.0) / 12.0;
00108  amplitude=wavelength/24;
00109  for(i=0L; i < SFXinfo->nvert; i++){
00110   distance=sqrt((double)Vlist[i].p[0]*(double)Vlist[i].p[0] +
00111                 (double)Vlist[i].p[1]*(double)Vlist[i].p[1]);
00112   displacement=amplitude*cos(PI*2*(SFXinfo->time-distance/wavelength));
00113   Vlist[i].p[2] += (long)displacement;
00114  }
00115  return 1;
00116 }
00117 
Generated on Tue Jan 28 06:18:29 2014 for OpenFX by  doxygen 1.6.3