D3DVIEW0.CPP

Go to the documentation of this file.
00001 /* --
00002 OpenFX version 1.6 - Modelling, Animation and Rendering Package
00003 Copyright (C) 2000 - 2006 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 // d3dview0.cpp
00025 
00026 static PSTR FileInPath(PSTR pstrPath){
00027  PSTR pstr;
00028  pstr = pstrPath + strlen(pstrPath);
00029  while (pstr > pstrPath) {
00030      pstr = (AnsiPrev(pstrPath, pstr));
00031      if (*pstr == '\\' || *pstr == ':' || *pstr == '/') {
00032          pstr = (AnsiNext(pstr));
00033          break;
00034      }
00035  }
00036  return pstr;
00037 }
00038 
00039 static char szFile[256]="*.x";
00040 static char szDir[256]="c:\\openfx";
00041 
00042 static void LocalCommands(WORD cmd,HWND hWnd){
00043  switch (cmd){
00044    case IDM_GLVIEW_PREFS:
00045      DialogBox(d3dInstance,MAKEINTRESOURCE(DLG_PREFS),hWnd,
00046                (DLGPROC)PrefsDlgProc);
00047 //     if(mapped)BuildMapList();
00048      PostMessage(D3dWnd,WM_UPDATE,0,0);
00049      break;
00050    case IDM_GLVIEW_HELP:{
00051        if(ChooseFile(0,szFile,szDir,"Load X File","(X files)|*.x|",hWnd)){
00052          DeleteObject(active_window);
00053          InvalidateRect(hWnd,NULL,FALSE);
00054          UpdateWindow(hWnd);
00055          OpenNewModel(szFile,active_window);
00056          InvalidateRect(hWnd,NULL,FALSE);
00057        }
00058      }
00059      break;
00060    case IDM_GLVIEW_MAP:
00061      break;
00062    case IDM_GLVIEW_ABOUT:
00063      MessageBox(hWnd,ABOUT_VERSION,"About OpenFX ViewDx",MB_OK);
00064      break;
00065    case IDM_GLVIEW_SCROLLBARS:
00066      if(ChooseFile(1,szFile,szDir,"Save as X File","(X files)|*.x|",hWnd)){
00067        SaveModel(szFile,active_window);
00068      }
00069      break;
00070      ScrollBars ^= 1;
00071      if(ScrollBars){
00072        SetScrollRange(hWnd, SB_VERT, -89,89,TRUE);
00073        SetScrollRange(hWnd, SB_HORZ, -179,179,TRUE);
00074        SetScrollPos(hWnd,SB_HORZ,(int)round_angle,TRUE);
00075        SetScrollPos(hWnd,SB_VERT,(int)up_angle,TRUE);
00076      }
00077      else{
00078        SetScrollRange(hWnd, SB_VERT, 0,0,TRUE);
00079        SetScrollRange(hWnd, SB_HORZ, 0,0,TRUE);
00080        SetScrollPos(hWnd,SB_HORZ,0,TRUE);
00081        SetScrollPos(hWnd,SB_VERT,0,TRUE);
00082      }
00083      if(ScrollBars)CheckMenuItem(D3dMenu,IDM_GLVIEW_SCROLLBARS,MF_CHECKED);
00084      else          CheckMenuItem(D3dMenu,IDM_GLVIEW_SCROLLBARS,MF_UNCHECKED);
00085      PostMessage(D3dWnd,WM_UPDATE,0,0);
00086      break;
00087    case IDM_GLVIEW_TWOSIDE:
00088      DeleteObject(active_window);
00089      MakeD3dModel(active_window);
00090      InvalidateRect(hWnd,NULL,FALSE);
00091      UpdateWindow(hWnd);
00092      break;
00093    default:
00094      break;
00095  }
00096 }
00097 
00098 static void LoadPrefs(void){
00099  double R,G,B;
00100  char pref_id[64];
00101  GetPrivateProfileString("D3DPREFERENCES","FLAT","$$$",
00102                    pref_id,sizeof(pref_id),IniFilename);
00103  if(strncmp(pref_id,"NO",2)  == 0)flat=0;
00104  if(strncmp(pref_id,"YES",3) == 0)flat=1;
00105  GetPrivateProfileString("D3DPREFERENCES","WIREB","$$$",
00106                    pref_id,sizeof(pref_id),IniFilename);
00107  if(strncmp(pref_id,"YES",3) == 0)bounding_box=1;
00108  if(strncmp(pref_id,"NO",2)  == 0)bounding_box=0;
00109  GetPrivateProfileString("D3DPREFERENCES","COLOUR","$$$",
00110                    pref_id,sizeof(pref_id),IniFilename);
00111  if(strncmp(pref_id,"$$$",3) != 0){
00112    sscanf(pref_id,"%lf %lf %lf",&R,&G,&B);
00113    gbRed=(float)R;  gbGreen=(float)G;  gbBlue=(float)B;
00114  }
00115  GetPrivateProfileString("D3DPREFERENCES","MAPPED","$$$",
00116                    pref_id,sizeof(pref_id),IniFilename);
00117  if(strncmp(pref_id,"YES",3) == 0)Mapped=TRUE;
00118  if(strncmp(pref_id,"NO",2)  == 0)Mapped=FALSE;
00119  GetPrivateProfileString("D3DPREFERENCES","UPDATE","$$$",
00120                    pref_id,sizeof(pref_id),IniFilename);
00121  if(strncmp(pref_id,"YES",3) == 0)Update=TRUE;
00122  if(strncmp(pref_id,"NO",2)  == 0)Update=FALSE;
00123  GetPrivateProfileString("D3DPREFERENCES","FASTEST","$$$",
00124                    pref_id,sizeof(pref_id),IniFilename);
00125  if(strncmp(pref_id,"YES",3) == 0)Fastest=TRUE;
00126  if(strncmp(pref_id,"NO",2)  == 0)Fastest=FALSE;
00127  GetPrivateProfileString("D3DPREFERENCES","CLAMPED","$$$",
00128                    pref_id,sizeof(pref_id),IniFilename);
00129  if(strncmp(pref_id,"YES",3) == 0)Clamped=TRUE;
00130  if(strncmp(pref_id,"NO",2)  == 0)Clamped=FALSE;
00131  GetPrivateProfileString("D3DPREFERENCES","DEPTHCUE","$$$",
00132                    pref_id,sizeof(pref_id),IniFilename);
00133  if(strncmp(pref_id,"YES",3) == 0)AttenuateLight=TRUE;
00134  if(strncmp(pref_id,"NO",2)  == 0)AttenuateLight=FALSE;
00135  GetPrivateProfileString("D3DPREFERENCES","SCROLLBARS","$$$",
00136                    pref_id,sizeof(pref_id),IniFilename);
00137  if(strncmp(pref_id,"YES",3) == 0)ScrollBars=TRUE;
00138  if(strncmp(pref_id,"NO",2)  == 0)ScrollBars=FALSE;
00139 }
00140 
00141 static BOOL CALLBACK PrefsDlgProc(HWND hdlg,UINT msg,
00142                            WPARAM wparam,LPARAM lparam){
00143  BOOL state;
00144  static double R,G,B;
00145  char *w, yesyes[]="YES", nono[]="NO",str[64];
00146  unsigned char uColour[3];
00147  switch( msg ) {
00148    case WM_INITDIALOG:
00149      CentreDlgOnC(hdlg);
00150      if(flat)state=TRUE; else state=FALSE;
00151      SendDlgItemMessage(hdlg,DLG_PREFS_FLAT,BM_SETCHECK,state,0);
00152      if(0)state=TRUE; else state=FALSE;
00153      SendDlgItemMessage(hdlg,DLG_PREFS_WIRE,BM_SETCHECK,state,0);
00154      if(bounding_box == 1)state=TRUE; else state=FALSE;
00155      SendDlgItemMessage(hdlg,DLG_PREFS_WIREB,BM_SETCHECK,state,0);
00156      if(Mapped == TRUE)state=TRUE; else state=FALSE;
00157      SendDlgItemMessage(hdlg,DLG_PREFS_MAPS,BM_SETCHECK,state,0);
00158      if(Update == TRUE)state=TRUE; else state=FALSE;
00159      SendDlgItemMessage(hdlg,DLG_PREFS_UPDATE,BM_SETCHECK,state,0);
00160      if(Fastest == TRUE)state=TRUE; else state=FALSE;
00161      SendDlgItemMessage(hdlg,DLG_PREFS_FASTEST,BM_SETCHECK,state,0);
00162      if(Clamped == TRUE)state=TRUE; else state=FALSE;
00163      SendDlgItemMessage(hdlg,DLG_PREFS_CLAMPED,BM_SETCHECK,state,0);
00164      if(AttenuateLight == TRUE)state=TRUE; else state=FALSE;
00165      SendDlgItemMessage(hdlg,DLG_PREFS_DEPTHC,BM_SETCHECK,state,0);
00166      R=(double)gbRed; G=(double)gbGreen; B=(double)gbBlue;
00167      return (TRUE);
00168    case WM_COMMAND:
00169       switch(LOWORD(wparam)){
00170         case DLG_PREFS_COLOUR:
00171           uColour[0]=(unsigned char)(R*255.0);
00172           uColour[1]=(unsigned char)(G*255.0);
00173           uColour[2]=(unsigned char)(B*255.0);
00174           ChooseColour(uColour,"Background Color",hdlg);
00175           R=(double)uColour[0]/255.0;
00176           G=(double)uColour[1]/255.0;
00177           B=(double)uColour[2]/255.0;
00178           break;
00179         case IDOK:
00180           if(SendDlgItemMessage(hdlg,DLG_PREFS_FLAT,BM_GETCHECK,0,0))
00181             flat=1; else flat=0;
00182           if(flat == 1)w=yesyes; else w=nono;
00183           WritePrivateProfileString("D3DPREFERENCES","FLAT",w,IniFilename);
00184           if(SendDlgItemMessage(hdlg,DLG_PREFS_WIREB,BM_GETCHECK,0,0))
00185             bounding_box=1; else bounding_box=0;
00186           if(bounding_box == 1)w=yesyes; else w=nono;
00187           WritePrivateProfileString("D3DPREFERENCES","WIREB",w,IniFilename);
00188           if(SendDlgItemMessage(hdlg,DLG_PREFS_MAPS,BM_GETCHECK,0,0))
00189             Mapped=TRUE; else Mapped=FALSE;
00190           if(Mapped == TRUE)w=yesyes; else w=nono;
00191           WritePrivateProfileString("D3DPREFERENCES","MAPPED",w,IniFilename);
00192           if(SendDlgItemMessage(hdlg,DLG_PREFS_UPDATE,BM_GETCHECK,0,0))
00193             Update=TRUE; else Update=FALSE;
00194           if(Update == TRUE)w=yesyes; else w=nono;
00195           WritePrivateProfileString("D3DPREFERENCES","UPDATE",w,IniFilename);
00196           if(SendDlgItemMessage(hdlg,DLG_PREFS_FASTEST,BM_GETCHECK,0,0))
00197             Fastest=TRUE; else Fastest=FALSE;
00198           if(Fastest == TRUE)w=yesyes; else w=nono;
00199           WritePrivateProfileString("D3DPREFERENCES","FASTEST",w,IniFilename);
00200           if(SendDlgItemMessage(hdlg,DLG_PREFS_CLAMPED,BM_GETCHECK,0,0))
00201             Clamped=TRUE; else Clamped=FALSE;
00202           if(Clamped == TRUE)w=yesyes; else w=nono;
00203           WritePrivateProfileString("D3DPREFERENCES","CLAMPED",w,IniFilename);
00204           if(SendDlgItemMessage(hdlg,DLG_PREFS_DEPTHC,BM_GETCHECK,0,0))
00205             AttenuateLight=TRUE; else AttenuateLight=FALSE;
00206           if(AttenuateLight == TRUE)w=yesyes; else w=nono;
00207           WritePrivateProfileString("D3DPREFERENCES","DEPTHCUE",w,IniFilename);
00208           gbRed=(float)R; gbGreen=(float)G; gbBlue=(float)B;
00209           InvalidateRect(GetParent(hdlg),NULL,FALSE);
00210           sprintf(str,"%lf %lf %lf",R,G,B);
00211           WritePrivateProfileString("D3DPREFERENCES","COLOUR",str,IniFilename);
00212           EndDialog(hdlg,TRUE);
00213           return(TRUE);
00214           break;
00215         case IDCANCEL:
00216           EndDialog(hdlg,FALSE);
00217           return(TRUE);
00218           break;
00219         default:  break;
00220       }
00221       break;
00222     default: break;
00223  }
00224  return(FALSE);
00225 }

Generated on Sun Apr 27 14:20:10 2014 for OpenFX by  doxygen 1.5.6