00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <math.h>
00027 #include <windows.h>
00028
00029 #include "3dview.h"
00030
00031 #if __X__MIPS__
00032 BOOL WINAPI _CRT_INIT(HINSTANCE ,DWORD , LPVOID );
00033 #endif
00034
00035 static HINSTANCE hDLLinstance=NULL;
00036
00037 #include "..\animate\astruct.h"
00038 #include "..\animate\dstruct.h"
00039
00040 #ifndef min
00041 #define min(a,b) ( ((a) < (b)) ? (a) : (b) )
00042 #endif
00043 #ifndef max
00044 #define max(a,b) ( ((a) > (b)) ? (a) : (b) )
00045 #endif
00046
00047 #if __WATCOMC__
00048 int APIENTRY LibMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00049 #else
00050 BOOL WINAPI DllMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00051 #endif
00052 switch (dwReason) {
00053 case DLL_PROCESS_ATTACH:
00054 #if __X__MIPS__
00055 if(!_CRT_INIT(hDLL,dwReason,lpReserved))return(int)FALSE;
00056 #endif
00057 hDLLinstance = hDLL;
00058 break;
00059 case DLL_PROCESS_DETACH:
00060 #if __X__MIPS__
00061 if(!_CRT_INIT(hDLL,dwReason,lpReserved))return(int)FALSE;
00062 #endif
00063 break;
00064 }
00065 return (int)TRUE;
00066 }
00067
00068 #if __SC__
00069 #pragma startaddress(LibMain)
00070 #endif
00071
00072
00073 BOOL _ExternalPreset(HWND parent, ANI_STRUCTURE *lpevi){
00074 object *Op;
00075 position *Pp,*Pc,*Pl;
00076 align *Ap;
00077 char f_name[256],f_dir[256];
00078 int i,j,k,nfi,nalpha,nf;
00079 double fi,alpha,dfi,dalpha;
00080 long xmax,ymax,zmax,size,xmin,ymin,zmin;
00081 lpEVI=lpevi;
00082 LoadString(hDLLinstance,IDS_TITLE,f_name,256);
00083 MessageBox(parent,f_name,"3D View",MB_OK);
00084 nfi=18;
00085 nalpha=11;
00086 nf=nfi*nalpha;
00087 fi = -180.0; alpha = -75.0;
00088 dfi=fabs(2.0*fi/(double)nfi);
00089 dalpha=2.0*fabs(alpha/(double)nalpha);
00090 SetNumberOfFrames((short)nf);
00091
00092 if(CreatePosition(FirstNp,1,(short)Nframes) == NULL)return FALSE;
00093 Pc=FirstNp->fpos;
00094 FirstNp->fpos->finish[0]=0;
00095 FirstNp->fpos->finish[1]=TVpointY+TVsizeY*2;
00096 FirstNp->fpos->finish[2]=0;
00097
00098 if(CreateNode() == NULL)return FALSE;
00099 strcpy(MainNp->actorname,"Target");
00100 MainNp->type=TARGET;
00101 if((Op=CreateCostume(MainNp,1,(short)Nframes)) == NULL)return FALSE;
00102 Op->type=MainNp->type;
00103
00104 if(CreateAlign(FirstNp,1,(short)Nframes) == NULL)return FALSE;
00105 FirstNp->fali->type=TRACK; FirstNp->fali->topath=MainNp;
00106
00107 if(CreateNode() == NULL)return FALSE;
00108 strcpy(MainNp->actorname,"Light");
00109 MainNp->type=LIGHT;
00110 if((Op=CreateCostume(MainNp,1,Nframes)) == NULL)return FALSE;
00111 Op->type=MainNp->type;
00112 Op->lighttype=SPHERE; Op->colour[0]=Op->colour[1]=Op->colour[2]=255;
00113
00114 if((Pp=CreatePosition(MainNp,1,(short)Nframes)) == NULL)return FALSE;
00115 Pl=Pp;
00116 Pp->finish[0]=0;
00117 Pp->finish[1]=FirstNp->fpos->finish[1]+TVsizeY;
00118 Pp->finish[2]=0;
00119
00120 if(CreateNode() == NULL)return FALSE;
00121 strcpy(MainNp->actorname,"Actor");
00122 MainNp->type=NORMAL;
00123 if((Op=CreateCostume(MainNp,1,(short)Nframes)) == NULL)return FALSE;
00124 Op->type=MainNp->type;
00125 strcpy(f_dir,gszHomeDir); strcat(f_dir,"objects"); strcpy(f_name,"*.mfx");
00126 if(SelectFileName(0,f_name,f_dir,"Choose Model To View",
00127 "(*.MFX)|*.mfx|",parent) == TRUE){
00128 strcpy(Op->name,f_name);
00129 Op->morph=NO;
00130 if(LoadMeshObject(f_name,Op,YES,YES,NO) == FAIL)DeleteCostume(MainNp,1);
00131 }
00132 else return FALSE;
00133
00134 if(Op->npoints > 0 && Op->points != NULL){
00135 xmax=ymax=zmax=size= -MAXUNIT;
00136 xmin=ymin=zmin=MAXUNIT;
00137 for(i=0;i<Op->npoints;i++){
00138 if(Op->points[i][0] > xmax)xmax=Op->points[i][0];
00139 if(Op->points[i][1] > ymax)ymax=Op->points[i][1];
00140 if(Op->points[i][2] > zmax)zmax=Op->points[i][2];
00141 if(Op->points[i][0] < xmin)xmin=Op->points[i][0];
00142 if(Op->points[i][1] < ymin)ymin=Op->points[i][1];
00143 if(Op->points[i][2] < zmin)zmin=Op->points[i][2];
00144 }
00145 size=max(xmax-xmin,ymax-ymin);
00146 size=max(size,zmax-zmin);
00147 Pc->finish[1]=TVpointY+max(size*3,TVsizeY*2);
00148 Pl->finish[1]=Pc->finish[1]+TVsizeY*2;
00149 }
00150 k=1;
00151 for(j=0;j<nalpha;j++){
00152 if((Ap=CreateAlign(MainNp,k,k+nfi-1)) == NULL)return FALSE;
00153 Ap->type=TWEEN;
00154 Ap->im=1; Ap->ima=1.0;
00155 Ap->alpha=(alpha+(double)j*dalpha);
00156 k += nfi;
00157 }
00158 return TRUE;
00159 }