home *** CD-ROM | disk | FTP | other *** search
/ Game Audio Programming / GameAudioProgramming.iso / Extras / Sensaura / SDK1.0 / data1.cab / Example_Files / ZoomFX / buffrdlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-13  |  34.5 KB  |  995 lines

  1. /*
  2.     Company:            Sensaura Ltd
  3.     Copyright:          (C) 1999
  4.  
  5.     File Name:            buffrdlg.cpp
  6.     File Description:    Source file for implementation of BufferDlg class which creates a 
  7.                         DirectSound3D buffer with ZoomFX support controlled by a dialog box 
  8.                         interface
  9.     Author:                Adam Philp
  10.     Last Update:        04-JAN-00
  11.  
  12.     Target Compiler:    Microsoft Visual C++ Version 5.0
  13. */
  14.  
  15. /////////////////////// Included files ////////////////////////////////////////////////////////////
  16.  
  17. #include <windows.h>
  18. #include <commctrl.h>
  19. #include <stdio.h>
  20.  
  21. #include "buffrdlg.h"
  22. #include "debug.h"
  23. #include "resource.h"
  24.  
  25. /////////////////////// Definitions ///////////////////////////////////////////////////////////////
  26.  
  27. #define XYZ_SLIDER_MAX        100
  28. #define XYZ_SLIDER_MIN        (-XYZ_SLIDER_MAX)
  29. #define DS3D_MAXDISTANCE    100.0f
  30.  
  31. ///////////////////////    Constants /////////////////////////////////////////////////////////////////
  32.  
  33. DS3DBUFFER Default3DBuffer =    // Default DirectSound3D buffer parameters
  34. {
  35.     sizeof(DS3DBUFFER),
  36.     { 0.0f, 0.0f, 0.0f },
  37.     { 0.0f, 0.0f, 0.0f },
  38.     DS3D_DEFAULTCONEANGLE, DS3D_DEFAULTCONEANGLE,
  39.     { 0.0f, 0.0f, 1.0f }, 
  40.     DS3D_DEFAULTCONEOUTSIDEVOLUME,
  41.     DS3D_DEFAULTMINDISTANCE, DS3D_MAXDISTANCE,
  42.     DS3DMODE_NORMAL
  43. };
  44.  
  45. ZOOMFX_BOX DefaultExtent =    // Default ZoomFX extent 
  46. {
  47.     { 0.0f, 0.0f, 0.0f },
  48.     { 0.0f, 0.0f, 0.0f }
  49. };
  50.                                 // Default ZoomFX orientation
  51. ZOOMFX_ORIENTATION DefaultOrientation = 
  52. {
  53.     { 0.0f, 0.0f, 1.0f },
  54.     { 0.0f, 1.0f, 0.0f }
  55. };
  56.  
  57. /////////////////////// BufferDlg class implementation ////////////////////////////////////////////
  58.  
  59. BufferDlg::BufferDlg():Buffer()
  60. {
  61.     PTRACE("BufferDlg::BufferDlg()");
  62.  
  63.     m_hWnd = NULL;
  64.     m_pParent = NULL;
  65.     m_bZoomFXEnabled = false;
  66.     m_bZoomFXSymmetrical = true;
  67.  
  68.     m_hPlayBtn = NULL;
  69.     m_hLoopedBtn = NULL;
  70.     m_hDefaultBtn = NULL;
  71.     m_hEnableZoomFXBtn = NULL;
  72.     m_hFormatStatic = NULL;
  73.     m_hPlayCursorStatic = NULL;
  74.     m_hWriteCursorStatic = NULL; 
  75.     m_hFrequencySlider = NULL;
  76.     m_hVolumeSlider = NULL;
  77.     m_hFrequencyStatic = NULL;
  78.     m_hVolumeStatic = NULL;
  79.     m_hNormalBtn = NULL;
  80.     m_hHeadRelativeBtn = NULL;
  81.     m_hDisabledBtn = NULL;
  82.     m_hMinDistanceSlider = NULL;
  83.     m_hMaxDistanceSlider = NULL;
  84.     m_hMinDistanceStatic = NULL;
  85.     m_hMaxDistanceStatic = NULL;
  86.     m_hPositionXSlider = NULL;
  87.     m_hPositionYSlider = NULL;
  88.     m_hPositionZSlider = NULL;
  89.     m_hPositionXStatic = NULL;
  90.     m_hPositionYStatic = NULL;
  91.     m_hPositionZStatic = NULL;
  92.     m_hVelocityXSlider = NULL;
  93.     m_hVelocityYSlider = NULL;
  94.     m_hVelocityZSlider = NULL;
  95.     m_hVelocityXStatic = NULL;
  96.     m_hVelocityYStatic = NULL;
  97.     m_hVelocityZStatic = NULL;
  98.     m_hInnerConeAngleSlider = NULL;
  99.     m_hOuterConeAngleSlider = NULL;
  100.     m_hInnerConeAngleStatic = NULL;
  101.     m_hOuterConeAngleStatic = NULL;
  102.     m_hOuterVolumeSlider = NULL;
  103.     m_hOuterVolumeStatic = NULL;
  104.     m_hZoomFXMaxXSlider = NULL;
  105.     m_hZoomFXMaxYSlider = NULL;
  106.     m_hZoomFXMaxZSlider = NULL;
  107.     m_hZoomFXMaxXStatic = NULL;
  108.     m_hZoomFXMaxYStatic = NULL;
  109.     m_hZoomFXMaxZStatic = NULL;
  110.     m_hZoomFXMinXSlider = NULL;
  111.     m_hZoomFXMinYSlider = NULL;
  112.     m_hZoomFXMinZSlider = NULL;
  113.     m_hZoomFXMinXStatic = NULL;
  114.     m_hZoomFXMinYStatic = NULL;
  115.     m_hZoomFXMinZStatic = NULL;
  116.     m_hZoomFXSymmetricalBtn = NULL;
  117.     m_hZoomFXFrontXSlider = NULL;
  118.     m_hZoomFXFrontYSlider = NULL;
  119.     m_hZoomFXFrontZSlider = NULL;
  120.     m_hZoomFXFrontXStatic = NULL;
  121.     m_hZoomFXFrontYStatic = NULL;
  122.     m_hZoomFXFrontZStatic = NULL;
  123.     m_hZoomFXTopXSlider = NULL;
  124.     m_hZoomFXTopYSlider = NULL;
  125.     m_hZoomFXTopZSlider = NULL;
  126.     m_hZoomFXTopXStatic = NULL;
  127.     m_hZoomFXTopYStatic = NULL;
  128.     m_hZoomFXTopZStatic = NULL;
  129.     m_hZoomFXCommitOrientationBtn = NULL;
  130. }
  131.  
  132. BufferDlg::~BufferDlg()
  133. {
  134.     PTRACE("BufferDlg::~BufferDlg()");
  135.  
  136.     Destroy();
  137. }
  138.  
  139. /////////////////////// BufferDlg public member functions /////////////////////////////////////////
  140.  
  141. bool BufferDlg::Create(Application* pApp, const char* pFileName, LPDIRECTSOUND pDirectSound)
  142. {
  143.     ASSERT(m_hWnd == NULL);
  144.     if(m_hWnd != NULL)
  145.     {
  146.         MessageBox(NULL, "Buffer dialog already created", pApp->GetName(), MB_OK|MB_ICONSTOP);
  147.         return false;
  148.     }
  149.  
  150.     m_pParent = pApp->GetMainWindow();
  151.     if(m_pParent == NULL)
  152.         return false;
  153.     
  154.     if(!Buffer::Create(pFileName, pDirectSound))
  155.         return false;
  156.     if(!SetAllParameters(&Default3DBuffer, DS3D_IMMEDIATE))
  157.         return false;
  158.     m_bZoomFXEnabled = CanDoZoomFX();
  159.  
  160.     m_hWnd = CreateDialogParam(pApp->GetInstance(), MAKEINTRESOURCE(IDD_BUFFER),
  161.                                m_pParent->m_hWnd,
  162.                                (DLGPROC)BufferDlgProc, (LPARAM)this);
  163.     if(m_hWnd == NULL)
  164.     {
  165.         MessageBox(NULL, "Cannot create buffer dialog", pApp->GetName(), MB_OK|MB_ICONSTOP);
  166.         return false;
  167.     }
  168.  
  169.     InitControlRanges(pDirectSound);
  170.     if(!InitControls())
  171.         return false;
  172.  
  173.     SetWindowText(m_hWnd, pFileName);
  174.     m_pParent->CascadeWindow(m_hWnd);
  175.     ::ShowWindow(m_hWnd, SW_SHOW);
  176.  
  177.     return true;
  178. }
  179.  
  180. void BufferDlg::Destroy()
  181. {
  182.     if(m_hWnd)
  183.     {
  184.         DestroyWindow(m_hWnd);
  185.         m_hWnd = NULL;
  186.     }
  187.     Buffer::Destroy();
  188. }
  189.  
  190. bool BufferDlg::Update()
  191. {
  192.     static bool bWasPlaying = false;
  193.     bool bIsPlaying;
  194.     DWORD dwPlayCursor = 0, dwWriteCursor = 0;
  195.     char str[100];
  196.  
  197.     bIsPlaying = IsPlaying();
  198.     if(bIsPlaying != bWasPlaying)
  199.     {
  200.         if(!bIsPlaying)
  201.             Rewind();
  202.  
  203.         SetWindowText(m_hPlayBtn, bIsPlaying ? "Stop" : "Play");
  204.         bWasPlaying = bIsPlaying;
  205.     }
  206.     GetCurrentPosition(&dwPlayCursor, &dwWriteCursor);
  207.     sprintf(str, "%d", dwPlayCursor);
  208.     SetWindowText(m_hPlayCursorStatic, str);
  209.     sprintf(str, "%d", dwWriteCursor);
  210.     SetWindowText(m_hWriteCursorStatic, str);
  211.  
  212.     return true;
  213. }
  214.  
  215. BOOL CALLBACK BufferDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  216. {
  217.     BufferDlg* pDlg;
  218.  
  219.     switch(message)
  220.     {
  221.     case WM_INITDIALOG:
  222.         ASSERT(lParam != NULL);
  223.         pDlg = (BufferDlg*)lParam;
  224.         SetWindowLong(hDlg, DWL_USER, (LONG)pDlg);
  225.  
  226.         if(!pDlg->OnInitDialog(hDlg, wParam, lParam))
  227.             DestroyWindow(hDlg);
  228.         return TRUE;
  229.  
  230.     case WM_HSCROLL:
  231.         pDlg = (BufferDlg*)GetWindowLong(hDlg, DWL_USER);
  232.         ASSERT(pDlg != NULL);
  233.         return !pDlg->OnHScroll(LOWORD(wParam), (LONG)HIWORD(wParam), (HWND)lParam);
  234.  
  235.     case WM_COMMAND:
  236.         pDlg = (BufferDlg*)GetWindowLong(hDlg, DWL_USER);
  237.         // It's possible to get child notifications before the
  238.         // INITDIALOG message, so we'll handle a NULL class item
  239.         // here a less stringently
  240.         if(!pDlg)
  241.             return FALSE;
  242.         return !pDlg->OnCommand(wParam, lParam);
  243.  
  244.     case WM_DESTROY:
  245.         pDlg = (BufferDlg*)GetWindowLong(hDlg, DWL_USER);
  246.         ASSERT(pDlg != NULL);
  247.         pDlg->OnDestroy();
  248.         return TRUE;
  249.  
  250.     default:
  251.         return FALSE;
  252.     }
  253. }
  254.  
  255. /////////////////////// BufferDlg protected member functions //////////////////////////////////////
  256.  
  257. BOOL BufferDlg::OnInitDialog(HWND hDlg, WPARAM, LPARAM lParam)
  258. {
  259.     m_hPlayBtn = GetDlgItem(hDlg, IDC_PLAY);
  260.     m_hLoopedBtn = GetDlgItem(hDlg, IDC_LOOPED);
  261.     m_hDefaultBtn = GetDlgItem(hDlg, IDC_DEFAULT);
  262.     m_hEnableZoomFXBtn = GetDlgItem(hDlg, IDC_ENABLEZOOMFX);
  263.     m_hFormatStatic = GetDlgItem(hDlg, IDC_FORMATSTATIC);
  264.     m_hPlayCursorStatic = GetDlgItem(hDlg, IDC_PLAYCURSORSTATIC);
  265.     m_hWriteCursorStatic = GetDlgItem(hDlg, IDC_WRITECURSORSTATIC); 
  266.     m_hFrequencySlider = GetDlgItem(hDlg, IDC_FREQUENCY);
  267.     m_hVolumeSlider = GetDlgItem(hDlg, IDC_VOLUME);
  268.     m_hFrequencyStatic = GetDlgItem(hDlg, IDC_FREQUENCYSTATIC);
  269.     m_hVolumeStatic = GetDlgItem(hDlg, IDC_VOLUMESTATIC);
  270.     m_hNormalBtn = GetDlgItem(hDlg, IDC_NORMAL);
  271.     m_hHeadRelativeBtn = GetDlgItem(hDlg, IDC_HEADRELATIVE);
  272.     m_hDisabledBtn = GetDlgItem(hDlg, IDC_DISABLED);
  273.     m_hMinDistanceSlider = GetDlgItem(hDlg, IDC_MINDISTANCE);
  274.     m_hMaxDistanceSlider = GetDlgItem(hDlg, IDC_MAXDISTANCE);
  275.     m_hMinDistanceStatic = GetDlgItem(hDlg, IDC_MINDISTANCESTATIC);
  276.     m_hMaxDistanceStatic = GetDlgItem(hDlg, IDC_MAXDISTANCESTATIC);
  277.     m_hPositionXSlider = GetDlgItem(hDlg, IDC_POSITIONX);
  278.     m_hPositionYSlider = GetDlgItem(hDlg, IDC_POSITIONY);
  279.     m_hPositionZSlider = GetDlgItem(hDlg, IDC_POSITIONZ);
  280.     m_hPositionXStatic = GetDlgItem(hDlg, IDC_POSITIONXSTATIC);
  281.     m_hPositionYStatic = GetDlgItem(hDlg, IDC_POSITIONYSTATIC);
  282.     m_hPositionZStatic = GetDlgItem(hDlg, IDC_POSITIONZSTATIC);
  283.     m_hVelocityXSlider = GetDlgItem(hDlg, IDC_VELOCITYX);
  284.     m_hVelocityYSlider = GetDlgItem(hDlg, IDC_VELOCITYY);
  285.     m_hVelocityZSlider = GetDlgItem(hDlg, IDC_VELOCITYZ);
  286.     m_hVelocityXStatic = GetDlgItem(hDlg, IDC_VELOCITYXSTATIC);
  287.     m_hVelocityYStatic = GetDlgItem(hDlg, IDC_VELOCITYYSTATIC);
  288.     m_hVelocityZStatic = GetDlgItem(hDlg, IDC_VELOCITYZSTATIC);
  289.     m_hInnerConeAngleSlider = GetDlgItem(hDlg, IDC_INNERCONEANGLE);
  290.     m_hOuterConeAngleSlider = GetDlgItem(hDlg, IDC_OUTERCONEANGLE);
  291.     m_hInnerConeAngleStatic = GetDlgItem(hDlg, IDC_INNERCONEANGLESTATIC);
  292.     m_hOuterConeAngleStatic = GetDlgItem(hDlg, IDC_OUTERCONEANGLESTATIC);
  293.     m_hOuterVolumeSlider = GetDlgItem(hDlg, IDC_OUTERVOLUME);
  294.     m_hOuterVolumeStatic = GetDlgItem(hDlg, IDC_OUTERVOLUMESTATIC);
  295.     m_hZoomFXMaxXSlider = GetDlgItem(hDlg, IDC_ZOOMFXMAXX);
  296.     m_hZoomFXMaxYSlider = GetDlgItem(hDlg, IDC_ZOOMFXMAXY);
  297.     m_hZoomFXMaxZSlider = GetDlgItem(hDlg, IDC_ZOOMFXMAXZ);
  298.     m_hZoomFXMaxXStatic = GetDlgItem(hDlg, IDC_ZOOMFXMAXXSTATIC);
  299.     m_hZoomFXMaxYStatic = GetDlgItem(hDlg, IDC_ZOOMFXMAXYSTATIC);
  300.     m_hZoomFXMaxZStatic = GetDlgItem(hDlg, IDC_ZOOMFXMAXZSTATIC);
  301.     m_hZoomFXMinXSlider = GetDlgItem(hDlg, IDC_ZOOMFXMINX);
  302.     m_hZoomFXMinYSlider = GetDlgItem(hDlg, IDC_ZOOMFXMINY);
  303.     m_hZoomFXMinZSlider = GetDlgItem(hDlg, IDC_ZOOMFXMINZ);
  304.     m_hZoomFXMinXStatic = GetDlgItem(hDlg, IDC_ZOOMFXMINXSTATIC);
  305.     m_hZoomFXMinYStatic = GetDlgItem(hDlg, IDC_ZOOMFXMINYSTATIC);
  306.     m_hZoomFXMinZStatic = GetDlgItem(hDlg, IDC_ZOOMFXMINZSTATIC);
  307.     m_hZoomFXSymmetricalBtn = GetDlgItem(hDlg, IDC_ZOOMFXSYMMETRICAL);
  308.     m_hZoomFXFrontXSlider = GetDlgItem(hDlg, IDC_ZOOMFXFRONTX);
  309.     m_hZoomFXFrontYSlider = GetDlgItem(hDlg, IDC_ZOOMFXFRONTY);
  310.     m_hZoomFXFrontZSlider = GetDlgItem(hDlg, IDC_ZOOMFXFRONTZ);
  311.     m_hZoomFXFrontXStatic = GetDlgItem(hDlg, IDC_ZOOMFXFRONTXSTATIC);
  312.     m_hZoomFXFrontYStatic = GetDlgItem(hDlg, IDC_ZOOMFXFRONTYSTATIC);
  313.     m_hZoomFXFrontZStatic = GetDlgItem(hDlg, IDC_ZOOMFXFRONTZSTATIC);
  314.     m_hZoomFXTopXSlider = GetDlgItem(hDlg, IDC_ZOOMFXTOPX);
  315.     m_hZoomFXTopYSlider = GetDlgItem(hDlg, IDC_ZOOMFXTOPY);
  316.     m_hZoomFXTopZSlider = GetDlgItem(hDlg, IDC_ZOOMFXTOPZ);
  317.     m_hZoomFXTopXStatic = GetDlgItem(hDlg, IDC_ZOOMFXTOPXSTATIC);
  318.     m_hZoomFXTopYStatic = GetDlgItem(hDlg, IDC_ZOOMFXTOPYSTATIC);
  319.     m_hZoomFXTopZStatic = GetDlgItem(hDlg, IDC_ZOOMFXTOPZSTATIC);
  320.     m_hZoomFXCommitOrientationBtn = GetDlgItem(hDlg, IDC_COMMITZOOMFXORIENTATION);
  321.  
  322.     return TRUE;
  323. }
  324.  
  325. BOOL BufferDlg::OnCommand(WPARAM wParam, LPARAM/* lParam*/)
  326. {
  327.     if(HIWORD(wParam) == BN_CLICKED)
  328.     {
  329.         switch(LOWORD(wParam))
  330.         {
  331.         case IDCANCEL:
  332.             DestroyWindow(m_hWnd);
  333.             m_hWnd = NULL;
  334.             break;
  335.  
  336.         case IDC_PLAY:
  337.             if(IsPlaying())
  338.             {
  339.                 Stop();
  340.                 Rewind();
  341.             }
  342.             else
  343.                 Play(IsDlgButtonChecked(m_hWnd, IDC_LOOPED) ? true : false);
  344.  
  345.         case IDC_DEFAULT:
  346.             RestoreDefaults();
  347.             break;
  348.  
  349.         case IDC_ENABLEZOOMFX:
  350.             EnableZoomFX(!m_bZoomFXEnabled);
  351.             break;
  352.  
  353.         case IDC_NORMAL:
  354.         case IDC_HEADRELATIVE:
  355.         case IDC_DISABLED:
  356.             UpdateMode(LOWORD(wParam));
  357.             break;
  358.  
  359.         case IDC_ZOOMFXSYMMETRICAL:
  360.             UpdateZoomFXExtentSymmetrical(IsDlgButtonChecked(m_hWnd, IDC_ZOOMFXSYMMETRICAL) ? true : false);
  361.             break;
  362.  
  363.         case IDC_COMMITZOOMFXORIENTATION:
  364.             CommitZoomFXOrientation();
  365.             break;
  366.  
  367.         }
  368.     }
  369.     return TRUE;
  370. }
  371.  
  372. BOOL BufferDlg::OnHScroll(WORD wNotifyCode, LONG lPos, HWND hwndCtl)
  373. {
  374.     int id;
  375.  
  376.     ASSERT(hwndCtl);
  377.     id = GetDlgCtrlID(hwndCtl);
  378.     switch(id)
  379.     {
  380.     case IDC_FREQUENCY:
  381.         UpdateFrequency();
  382.         break;
  383.  
  384.     case IDC_VOLUME:
  385.         UpdateVolume();
  386.         break;
  387.  
  388.     case IDC_MINDISTANCE:
  389.         UpdateMinDistance();
  390.         break;
  391.  
  392.     case IDC_MAXDISTANCE:
  393.         UpdateMaxDistance();
  394.         break;
  395.  
  396.     case IDC_POSITIONX:
  397.     case IDC_POSITIONY:
  398.     case IDC_POSITIONZ:
  399.         UpdatePosition();
  400.         break;
  401.  
  402.     case IDC_VELOCITYX:
  403.     case IDC_VELOCITYY:
  404.     case IDC_VELOCITYZ:
  405.         UpdateVelocity();
  406.         break;
  407.  
  408.     case IDC_INNERCONEANGLE:
  409.         UpdateInnerConeAngle();
  410.         break;
  411.  
  412.     case IDC_OUTERCONEANGLE:
  413.         UpdateOuterConeAngle();
  414.         break;
  415.  
  416.     case IDC_OUTERVOLUME:
  417.         UpdateOuterVolume();
  418.         break;
  419.  
  420.     case IDC_ZOOMFXMAXX:
  421.     case IDC_ZOOMFXMAXY:
  422.     case IDC_ZOOMFXMAXZ:
  423.     case IDC_ZOOMFXMINX:
  424.     case IDC_ZOOMFXMINY:
  425.     case IDC_ZOOMFXMINZ:
  426.         UpdateZoomFXExtent();
  427.         break;
  428.  
  429.     case IDC_ZOOMFXFRONTX:
  430.     case IDC_ZOOMFXFRONTY:
  431.     case IDC_ZOOMFXFRONTZ:
  432.     case IDC_ZOOMFXTOPX:
  433.     case IDC_ZOOMFXTOPY:
  434.     case IDC_ZOOMFXTOPZ:
  435.         UpdateZoomFXOrientation();
  436.         break;
  437.     }
  438.     return TRUE;
  439. }
  440.  
  441. void BufferDlg::OnDestroy()
  442. {
  443.     m_pParent->DestroyChild(m_hWnd);
  444. }
  445.  
  446. BOOL BufferDlg::InitControlRanges(LPDIRECTSOUND pDirectSound)
  447. {
  448.     DSCAPS    dsc;
  449.  
  450.     dsc.dwSize = sizeof(DSCAPS);
  451.     if(pDirectSound->GetCaps(&dsc) != DS_OK)
  452.         return FALSE;
  453.  
  454.     SendMessage(m_hFrequencySlider, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(dsc.dwMinSecondarySampleRate/10, dsc.dwMaxSecondarySampleRate/10));
  455.     SendMessage(m_hVolumeSlider, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(0, DSBVOLUME_MAX-(DSBVOLUME_MIN)));
  456.     SendMessage(m_hMinDistanceSlider, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(DS3D_DEFAULTMINDISTANCE, DS3D_MAXDISTANCE));
  457.     SendMessage(m_hMaxDistanceSlider, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(DS3D_DEFAULTMINDISTANCE, DS3D_MAXDISTANCE));
  458.     SendMessage(m_hPositionXSlider, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(XYZ_SLIDER_MIN, XYZ_SLIDER_MAX));
  459.     SendMessage(m_hPositionXSlider, TBM_SETTICFREQ, (WPARAM)XYZ_SLIDER_MAX, 0);
  460.     SendMessage(m_hPositionYSlider, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(XYZ_SLIDER_MIN, XYZ_SLIDER_MAX));
  461.     SendMessage(m_hPositionYSlider, TBM_SETTICFREQ, (WPARAM)XYZ_SLIDER_MAX, 0);
  462.     SendMessage(m_hPositionZSlider, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(XYZ_SLIDER_MIN, XYZ_SLIDER_MAX));
  463.     SendMessage(m_hPositionZSlider, TBM_SETTICFREQ, (WPARAM)XYZ_SLIDER_MAX, 0);
  464.     SendMessage(m_hVelocityXSlider, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(XYZ_SLIDER_MIN, XYZ_SLIDER_MAX));
  465.     SendMessage(m_hVelocityXSlider, TBM_SETTICFREQ, (WPARAM)XYZ_SLIDER_MAX, 0);
  466.     SendMessage(m_hVelocityYSlider, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(XYZ_SLIDER_MIN, XYZ_SLIDER_MAX));
  467.     SendMessage(m_hVelocityYSlider, TBM_SETTICFREQ, (WPARAM)XYZ_SLIDER_MAX, 0);
  468.     SendMessage(m_hVelocityZSlider, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(XYZ_SLIDER_MIN, XYZ_SLIDER_MAX));
  469.     SendMessage(m_hVelocityZSlider, TBM_SETTICFREQ, (WPARAM)XYZ_SLIDER_MAX, 0);
  470.     SendMessage(m_hInnerConeAngleSlider, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(0, 360));
  471.     SendMessage(m_hOuterConeAngleSlider, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(0, 360));
  472.     SendMessage(m_hOuterVolumeSlider, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(0, DSBVOLUME_MAX-(DSBVOLUME_MIN)));
  473.  
  474.     SendMessage(m_hZoomFXMaxXSlider, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(0, XYZ_SLIDER_MAX));
  475.     SendMessage(m_hZoomFXMaxYSlider, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(0, XYZ_SLIDER_MAX));
  476.     SendMessage(m_hZoomFXMaxZSlider, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(0, XYZ_SLIDER_MAX));
  477.     SendMessage(m_hZoomFXMinXSlider, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(0, XYZ_SLIDER_MAX));
  478.     SendMessage(m_hZoomFXMinYSlider, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(0, XYZ_SLIDER_MAX));
  479.     SendMessage(m_hZoomFXMinZSlider, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(0, XYZ_SLIDER_MAX));
  480.     SendMessage(m_hZoomFXFrontXSlider, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(XYZ_SLIDER_MIN, XYZ_SLIDER_MAX));
  481.     SendMessage(m_hZoomFXFrontXSlider, TBM_SETTICFREQ, (WPARAM)XYZ_SLIDER_MAX, 0);
  482.     SendMessage(m_hZoomFXFrontYSlider, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(XYZ_SLIDER_MIN, XYZ_SLIDER_MAX));
  483.     SendMessage(m_hZoomFXFrontYSlider, TBM_SETTICFREQ, (WPARAM)XYZ_SLIDER_MAX, 0);
  484.     SendMessage(m_hZoomFXFrontZSlider, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(XYZ_SLIDER_MIN, XYZ_SLIDER_MAX));
  485.     SendMessage(m_hZoomFXFrontZSlider, TBM_SETTICFREQ, (WPARAM)XYZ_SLIDER_MAX, 0);
  486.  
  487.     SendMessage(m_hZoomFXTopXSlider, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(XYZ_SLIDER_MIN, XYZ_SLIDER_MAX));
  488.     SendMessage(m_hZoomFXTopXSlider, TBM_SETTICFREQ, (WPARAM)XYZ_SLIDER_MAX, 0);
  489.     SendMessage(m_hZoomFXTopYSlider, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(XYZ_SLIDER_MIN, XYZ_SLIDER_MAX));
  490.     SendMessage(m_hZoomFXTopYSlider, TBM_SETTICFREQ, (WPARAM)XYZ_SLIDER_MAX, 0);
  491.     SendMessage(m_hZoomFXTopZSlider, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(XYZ_SLIDER_MIN, XYZ_SLIDER_MAX));
  492.     SendMessage(m_hZoomFXTopZSlider, TBM_SETTICFREQ, (WPARAM)XYZ_SLIDER_MAX, 0);
  493.  
  494.     return TRUE;
  495. }
  496.  
  497. bool BufferDlg::InitControls()
  498. {
  499.     WAVEFORMATEX    wfx;
  500.     DWORD            dwFrequency;
  501.     long            lVolume;
  502.     DS3DBUFFER        params;
  503.     char            str[100];
  504.     ZOOMFX_BUFFERPROPERTIES    zoomfx;
  505.  
  506.     if(!GetFormat(&wfx) || !GetFrequency(&dwFrequency) || !GetVolume(&lVolume) || !GetAllParameters(¶ms))
  507.         return false;
  508.  
  509.     sprintf(str, "%d Hz, %d-bit, %s", wfx.nSamplesPerSec, wfx.wBitsPerSample, wfx.nChannels == 1 ? "Mono" : wfx.nChannels == 2 ? "Stereo" : "");
  510.     SetWindowText(m_hFormatStatic, str);
  511.     SendMessage(m_hFrequencySlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)dwFrequency/10);
  512.     sprintf(str, "%d Hz", dwFrequency);
  513.     SetWindowText(m_hFrequencyStatic, str);
  514.     SendMessage(m_hVolumeSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)lVolume-DSBVOLUME_MIN);
  515.     sprintf(str, "%.2f dB", ((float)lVolume)/100.0f);
  516.     SetWindowText(m_hVolumeStatic, str);
  517.  
  518.     CheckRadioButton(m_hWnd, IDC_NORMAL, IDC_DISABLED, params.dwMode == DS3DMODE_NORMAL ? IDC_NORMAL :
  519.         params.dwMode == DS3DMODE_HEADRELATIVE ? IDC_HEADRELATIVE : IDC_DISABLED);
  520.  
  521.     SendMessage(m_hMinDistanceSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)params.flMinDistance);
  522.     SendMessage(m_hMaxDistanceSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)params.flMaxDistance);
  523.     UpdateDistanceStatics(params.flMinDistance, params.flMaxDistance);
  524.     
  525.     SendMessage(m_hPositionXSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)params.vPosition.x);
  526.     SendMessage(m_hPositionYSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)params.vPosition.y);
  527.     SendMessage(m_hPositionZSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)params.vPosition.z);
  528.     UpdatePositionStatics(¶ms.vPosition);
  529.  
  530.     SendMessage(m_hVelocityXSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)params.vVelocity.x);
  531.     SendMessage(m_hVelocityYSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)params.vVelocity.y);
  532.     SendMessage(m_hVelocityZSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)params.vVelocity.z);
  533.     UpdateVelocityStatics(¶ms.vVelocity);
  534.  
  535.     SendMessage(m_hInnerConeAngleSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)params.dwInsideConeAngle);
  536.     SendMessage(m_hOuterConeAngleSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)params.dwOutsideConeAngle);
  537.     UpdateConeAngleStatics(params.dwInsideConeAngle, params.dwOutsideConeAngle);
  538.     SendMessage(m_hOuterVolumeSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(params.lConeOutsideVolume-(DSBVOLUME_MIN)));
  539.     sprintf(str, "%d", params.lConeOutsideVolume);
  540.     SetWindowText(m_hOuterVolumeStatic, str);
  541.  
  542.     EnableZoomFXControls();
  543.     if(CanDoZoomFX())
  544.     {
  545.         EnableWindow(m_hEnableZoomFXBtn, TRUE);
  546.         GetAllZoomFX(&zoomfx);
  547.         m_Orientation = zoomfx.orientation;
  548.         SendMessage(m_hZoomFXMaxXSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)zoomfx.box.vMax.x);
  549.         SendMessage(m_hZoomFXMaxYSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)zoomfx.box.vMax.y);
  550.         SendMessage(m_hZoomFXMaxZSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)zoomfx.box.vMax.z);
  551.         SendMessage(m_hZoomFXMinXSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)-zoomfx.box.vMin.x);
  552.         SendMessage(m_hZoomFXMinYSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)-zoomfx.box.vMin.y);
  553.         SendMessage(m_hZoomFXMinZSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)-zoomfx.box.vMin.z);
  554.         sprintf(str, "X:%d", zoomfx.box.vMax.x);
  555.         SetWindowText(m_hZoomFXMaxXStatic, str);
  556.         sprintf(str, "Y:%d", zoomfx.box.vMax.y);
  557.         SetWindowText(m_hZoomFXMaxYStatic, str);
  558.         sprintf(str, "Z:%d", zoomfx.box.vMax.z);
  559.         SetWindowText(m_hZoomFXMaxZStatic, str);
  560.         sprintf(str, "X:%d", zoomfx.box.vMin.x);
  561.         SetWindowText(m_hZoomFXMinXStatic, str);
  562.         sprintf(str, "Y:%d", zoomfx.box.vMin.y);
  563.         SetWindowText(m_hZoomFXMinYStatic, str);
  564.         sprintf(str, "Z:%d", zoomfx.box.vMin.z);
  565.         SetWindowText(m_hZoomFXMinZStatic, str);
  566.  
  567.         CheckDlgButton(m_hWnd, IDC_ZOOMFXSYMMETRICAL, m_bZoomFXSymmetrical);
  568.  
  569.         SendMessage(m_hZoomFXFrontXSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(zoomfx.orientation.vFront.x*XYZ_SLIDER_MAX));
  570.         SendMessage(m_hZoomFXFrontYSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(zoomfx.orientation.vFront.y*XYZ_SLIDER_MAX));
  571.         SendMessage(m_hZoomFXFrontZSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(zoomfx.orientation.vFront.z*XYZ_SLIDER_MAX));
  572.         SendMessage(m_hZoomFXTopXSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(zoomfx.orientation.vTop.x*XYZ_SLIDER_MAX));
  573.         SendMessage(m_hZoomFXTopYSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(zoomfx.orientation.vTop.y*XYZ_SLIDER_MAX));
  574.         SendMessage(m_hZoomFXTopZSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(zoomfx.orientation.vTop.z*XYZ_SLIDER_MAX));
  575.         sprintf(str, "X:%.2f", zoomfx.orientation.vFront.x);
  576.         SetWindowText(m_hZoomFXFrontXStatic, str);
  577.         sprintf(str, "Y:%.2f", zoomfx.orientation.vFront.y);
  578.         SetWindowText(m_hZoomFXFrontYStatic, str);
  579.         sprintf(str, "Z:%.2f", zoomfx.orientation.vFront.z);
  580.         SetWindowText(m_hZoomFXFrontZStatic, str);
  581.         sprintf(str, "X:%.2f", zoomfx.orientation.vTop.x);
  582.         SetWindowText(m_hZoomFXTopXStatic, str);
  583.         sprintf(str, "Y:%.2f", zoomfx.orientation.vTop.y);
  584.         SetWindowText(m_hZoomFXTopYStatic, str);
  585.         sprintf(str, "Z:%.2f", zoomfx.orientation.vTop.z);
  586.         SetWindowText(m_hZoomFXTopZStatic, str);
  587.     }
  588.     else
  589.         EnableWindow(m_hEnableZoomFXBtn, FALSE);
  590.     return Update();
  591. }
  592.  
  593. void BufferDlg::EnableZoomFXControls()
  594. {
  595.     HWND hCtl;
  596.  
  597.     SetWindowText(m_hEnableZoomFXBtn, m_bZoomFXEnabled ? "Disable ZoomFX" : "Enable ZoomFX");
  598.     hCtl = GetDlgItem(m_hWnd, IDC_ZOOMFXPROPERTIES);
  599.     EnableWindow(hCtl, m_bZoomFXEnabled);
  600.     hCtl = GetDlgItem(m_hWnd, IDC_ZOOMFXEXTENT);
  601.     EnableWindow(hCtl, m_bZoomFXEnabled);
  602.     hCtl = GetDlgItem(m_hWnd, IDC_ZOOMFXMAX);
  603.     EnableWindow(hCtl, m_bZoomFXEnabled);
  604.     hCtl = GetDlgItem(m_hWnd, IDC_ZOOMFXMIN);
  605.     EnableWindow(hCtl, m_bZoomFXEnabled);
  606.     hCtl = GetDlgItem(m_hWnd, IDC_ZOOMFXORIENTATION);
  607.     EnableWindow(hCtl, m_bZoomFXEnabled);
  608.     hCtl = GetDlgItem(m_hWnd, IDC_ZOOMFXFRONT);
  609.     EnableWindow(hCtl, m_bZoomFXEnabled);
  610.     hCtl = GetDlgItem(m_hWnd, IDC_ZOOMFXTOP);
  611.     EnableWindow(hCtl, m_bZoomFXEnabled);
  612.  
  613.     EnableWindow(m_hZoomFXMaxXSlider, m_bZoomFXEnabled);
  614.     EnableWindow(m_hZoomFXMaxYSlider, m_bZoomFXEnabled);
  615.     EnableWindow(m_hZoomFXMaxZSlider, m_bZoomFXEnabled);
  616.     EnableWindow(m_hZoomFXMaxXStatic, m_bZoomFXEnabled);
  617.     EnableWindow(m_hZoomFXMaxYStatic, m_bZoomFXEnabled);
  618.     EnableWindow(m_hZoomFXMaxZStatic, m_bZoomFXEnabled);
  619.     EnableWindow(m_hZoomFXMinXSlider, m_bZoomFXEnabled);
  620.     EnableWindow(m_hZoomFXMinYSlider, m_bZoomFXEnabled);
  621.     EnableWindow(m_hZoomFXMinZSlider, m_bZoomFXEnabled);
  622.     EnableWindow(m_hZoomFXMinXStatic, m_bZoomFXEnabled);
  623.     EnableWindow(m_hZoomFXMinYStatic, m_bZoomFXEnabled);
  624.     EnableWindow(m_hZoomFXMinZStatic, m_bZoomFXEnabled);
  625.     EnableWindow(m_hZoomFXSymmetricalBtn, m_bZoomFXEnabled);
  626.     EnableWindow(m_hZoomFXFrontXSlider, m_bZoomFXEnabled);
  627.     EnableWindow(m_hZoomFXFrontYSlider, m_bZoomFXEnabled);
  628.     EnableWindow(m_hZoomFXFrontZSlider, m_bZoomFXEnabled);
  629.     EnableWindow(m_hZoomFXFrontXStatic, m_bZoomFXEnabled);
  630.     EnableWindow(m_hZoomFXFrontYStatic, m_bZoomFXEnabled);
  631.     EnableWindow(m_hZoomFXFrontZStatic, m_bZoomFXEnabled);
  632.     EnableWindow(m_hZoomFXTopXSlider, m_bZoomFXEnabled);
  633.     EnableWindow(m_hZoomFXTopYSlider, m_bZoomFXEnabled);
  634.     EnableWindow(m_hZoomFXTopZSlider, m_bZoomFXEnabled);
  635.     EnableWindow(m_hZoomFXTopXStatic, m_bZoomFXEnabled);
  636.     EnableWindow(m_hZoomFXTopYStatic, m_bZoomFXEnabled);
  637.     EnableWindow(m_hZoomFXTopZStatic, m_bZoomFXEnabled);
  638.     EnableWindow(m_hZoomFXCommitOrientationBtn, m_bZoomFXEnabled);
  639. }
  640.  
  641. bool BufferDlg::UpdateFrequency()
  642. {
  643.     DWORD    dwFrequency;
  644.     char    str[20];
  645.  
  646.     dwFrequency = SendMessage(m_hFrequencySlider, TBM_GETPOS, 0, 0)*10;
  647.     sprintf(str, "%d Hz", dwFrequency);
  648.     SetWindowText(m_hFrequencyStatic, str);
  649.     return SetFrequency(dwFrequency);
  650. }
  651.  
  652. bool BufferDlg::UpdateVolume()
  653. {
  654.     long    lVolume;
  655.     char    str[20];
  656.  
  657.     lVolume = SendMessage(m_hVolumeSlider, TBM_GETPOS, 0, 0)+DSBVOLUME_MIN;
  658.     sprintf(str, "%.2f dB", ((float)lVolume)/100.0f);
  659.     SetWindowText(m_hVolumeStatic, str);
  660.     return SetVolume(lVolume);
  661. }
  662.  
  663. bool BufferDlg::RestoreDefaults()
  664. {
  665.     WAVEFORMATEX wfx;
  666.  
  667.     GetFormat(&wfx);
  668.     SetFrequency(wfx.nSamplesPerSec);
  669.     SetVolume(0);
  670.     SetAllParameters(&Default3DBuffer, DS3D_IMMEDIATE);
  671.  
  672.     if(CanDoZoomFX())
  673.     {
  674.         m_Extent = DefaultExtent;
  675.         m_Orientation = DefaultOrientation;
  676.  
  677.         if(!SetZoomFXExtent(&m_Extent))
  678.             return false;
  679.         if(!SetZoomFXOrientation(&m_Orientation))
  680.             return false;
  681.     }
  682.     m_bZoomFXSymmetrical = true;
  683.  
  684.     return InitControls();
  685. }
  686.  
  687. bool BufferDlg::EnableZoomFX(bool bEnable)
  688. {
  689.     if(!CanDoZoomFX())
  690.         return false;
  691.  
  692.     if(bEnable)
  693.     {
  694.         if(SetZoomFXExtent(&m_Extent))
  695.             m_bZoomFXEnabled = true;
  696.     }
  697.     else
  698.     {
  699.         SetZoomFXExtent(&DefaultExtent);
  700.         m_bZoomFXEnabled = false;
  701.     }
  702.     EnableZoomFXControls();
  703.     return true;
  704. }
  705.  
  706. bool BufferDlg::UpdateMode(WORD wMode)
  707. {
  708.     DWORD dwMode = wMode == IDC_NORMAL ? DS3DMODE_NORMAL : 
  709.                    wMode == IDC_HEADRELATIVE ? DS3DMODE_HEADRELATIVE : 
  710.                    DS3DMODE_DISABLE;
  711.     return SetMode(dwMode, DS3D_IMMEDIATE);
  712. }
  713.  
  714. bool BufferDlg::UpdateMinDistance()
  715. {
  716.     D3DVALUE    flMinDistance;
  717.     D3DVALUE    flMaxDistance;
  718.  
  719.     flMinDistance = (D3DVALUE)SendMessage(m_hMinDistanceSlider, TBM_GETPOS, 0, 0);
  720.     flMaxDistance = (D3DVALUE)SendMessage(m_hMaxDistanceSlider, TBM_GETPOS, 0, 0);
  721.     if(!SetMinDistance(flMinDistance, DS3D_IMMEDIATE))
  722.         return false;
  723.  
  724.     if(flMinDistance > flMaxDistance)
  725.     {
  726.         flMaxDistance = flMinDistance;
  727.         SendMessage(m_hMaxDistanceSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)flMaxDistance);
  728.         if(!SetMaxDistance(flMaxDistance, DS3D_IMMEDIATE))
  729.             return false;
  730.     }
  731.     UpdateDistanceStatics(flMinDistance, flMaxDistance);
  732.  
  733.     return true;
  734. }
  735.  
  736. bool BufferDlg::UpdateMaxDistance()
  737. {
  738.     D3DVALUE    flMinDistance;
  739.     D3DVALUE    flMaxDistance;
  740.  
  741.     flMaxDistance = (D3DVALUE)SendMessage(m_hMaxDistanceSlider, TBM_GETPOS, 0, 0);
  742.     flMinDistance = (D3DVALUE)SendMessage(m_hMinDistanceSlider, TBM_GETPOS, 0, 0);
  743.     if(!SetMaxDistance(flMaxDistance, DS3D_IMMEDIATE))
  744.         return false;
  745.  
  746.     if(flMinDistance > flMaxDistance)
  747.     {
  748.         flMinDistance = flMaxDistance;
  749.         SendMessage(m_hMinDistanceSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)flMinDistance);
  750.         if(!SetMinDistance(flMinDistance, DS3D_IMMEDIATE))
  751.             return false;
  752.     }
  753.     UpdateDistanceStatics(flMinDistance, flMaxDistance);
  754.  
  755.     return true;
  756. }
  757.  
  758. bool BufferDlg::UpdatePosition()
  759. {
  760.     D3DVECTOR p;
  761.  
  762.     p.x = (D3DVALUE)SendMessage(m_hPositionXSlider, TBM_GETPOS, 0, 0);
  763.     p.y = (D3DVALUE)SendMessage(m_hPositionYSlider, TBM_GETPOS, 0, 0);
  764.     p.z = (D3DVALUE)SendMessage(m_hPositionZSlider, TBM_GETPOS, 0, 0);
  765.     UpdatePositionStatics(&p);
  766.  
  767.     return SetPosition(p.x, p.y, p.z, DS3D_IMMEDIATE);
  768. }
  769.  
  770. bool BufferDlg::UpdateVelocity()
  771. {
  772.     D3DVECTOR v;
  773.  
  774.     v.x = (D3DVALUE)SendMessage(m_hVelocityXSlider, TBM_GETPOS, 0, 0);
  775.     v.y = (D3DVALUE)SendMessage(m_hVelocityYSlider, TBM_GETPOS, 0, 0);
  776.     v.z = (D3DVALUE)SendMessage(m_hVelocityZSlider, TBM_GETPOS, 0, 0);
  777.     UpdateVelocityStatics(&v);
  778.  
  779.     return SetVelocity(v.x, v.y, v.z, DS3D_IMMEDIATE);
  780. }
  781.  
  782. bool BufferDlg::UpdateInnerConeAngle()
  783. {
  784.     DWORD    dwInsideConeAngle;
  785.     DWORD    dwOutsideConeAngle;
  786.  
  787.     dwInsideConeAngle = SendMessage(m_hInnerConeAngleSlider, TBM_GETPOS, 0, 0);
  788.     dwOutsideConeAngle = SendMessage(m_hOuterConeAngleSlider, TBM_GETPOS, 0, 0);
  789.     if(dwInsideConeAngle > dwOutsideConeAngle)
  790.     {
  791.         dwOutsideConeAngle = dwInsideConeAngle;
  792.         SendMessage(m_hOuterConeAngleSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)dwOutsideConeAngle);
  793.     }
  794.     UpdateConeAngleStatics(dwInsideConeAngle, dwOutsideConeAngle);
  795.  
  796.     return SetConeAngles(dwInsideConeAngle, dwOutsideConeAngle, DS3D_IMMEDIATE);
  797. }
  798.  
  799. bool BufferDlg::UpdateOuterConeAngle()
  800. {
  801.     DWORD    dwInsideConeAngle;
  802.     DWORD    dwOutsideConeAngle;
  803.  
  804.     dwOutsideConeAngle = SendMessage(m_hOuterConeAngleSlider, TBM_GETPOS, 0, 0);
  805.     dwInsideConeAngle = SendMessage(m_hInnerConeAngleSlider, TBM_GETPOS, 0, 0);
  806.     if(dwInsideConeAngle > dwOutsideConeAngle)
  807.     {
  808.         dwInsideConeAngle = dwOutsideConeAngle;
  809.         SendMessage(m_hInnerConeAngleSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)dwInsideConeAngle);
  810.     }
  811.     UpdateConeAngleStatics(dwInsideConeAngle, dwOutsideConeAngle);
  812.  
  813.     return SetConeAngles(dwInsideConeAngle, dwOutsideConeAngle, DS3D_IMMEDIATE);
  814. }
  815.  
  816. bool BufferDlg::UpdateOuterVolume()
  817. {
  818.     long    lVolume;
  819.     char    str[20];
  820.  
  821.     lVolume = SendMessage(m_hOuterVolumeSlider, TBM_GETPOS, 0, 0)+DSBVOLUME_MIN;
  822.     sprintf(str, "%.2f dB", ((float)lVolume)/100.0f);
  823.     SetWindowText(m_hOuterVolumeStatic, str);
  824.     return SetConeOutsideVolume(lVolume, DS3D_IMMEDIATE);
  825. }
  826.  
  827. bool BufferDlg::UpdateZoomFXExtent()
  828. {
  829.     ZOOMFX_BOX extent;
  830.     char str[20];
  831.  
  832.     extent.vMax.x = (D3DVALUE)SendMessage(m_hZoomFXMaxXSlider, TBM_GETPOS, 0, 0);
  833.     extent.vMax.y = (D3DVALUE)SendMessage(m_hZoomFXMaxYSlider, TBM_GETPOS, 0, 0);
  834.     extent.vMax.z = (D3DVALUE)SendMessage(m_hZoomFXMaxZSlider, TBM_GETPOS, 0, 0);
  835.     if(m_bZoomFXSymmetrical)
  836.     {
  837.         extent.vMin.x = -extent.vMax.x;
  838.         extent.vMin.y = -extent.vMax.y;
  839.         extent.vMin.z = -extent.vMax.z;
  840.         SendMessage(m_hZoomFXMinXSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)-extent.vMin.x);
  841.         SendMessage(m_hZoomFXMinYSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)-extent.vMin.y);
  842.         SendMessage(m_hZoomFXMinZSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)-extent.vMin.z);
  843.     }
  844.     else
  845.     {
  846.         extent.vMin.x = -(D3DVALUE)SendMessage(m_hZoomFXMinXSlider, TBM_GETPOS, 0, 0);
  847.         extent.vMin.y = -(D3DVALUE)SendMessage(m_hZoomFXMinYSlider, TBM_GETPOS, 0, 0);
  848.         extent.vMin.z = -(D3DVALUE)SendMessage(m_hZoomFXMinZSlider, TBM_GETPOS, 0, 0);
  849.     }
  850.     sprintf(str, "X:%.0f", extent.vMax.x);
  851.     SetWindowText(m_hZoomFXMaxXStatic, str);
  852.     sprintf(str, "Y:%.0f", extent.vMax.y);
  853.     SetWindowText(m_hZoomFXMaxYStatic, str);
  854.     sprintf(str, "Z:%.0f", extent.vMax.z);
  855.     SetWindowText(m_hZoomFXMaxZStatic, str);
  856.     sprintf(str, "X:%.0f", extent.vMin.x);
  857.     SetWindowText(m_hZoomFXMinXStatic, str);
  858.     sprintf(str, "Y:%.0f", extent.vMin.y);
  859.     SetWindowText(m_hZoomFXMinYStatic, str);
  860.     sprintf(str, "Z:%.0f", extent.vMin.z);
  861.     SetWindowText(m_hZoomFXMinZStatic, str);
  862.  
  863.     return SetZoomFXExtent(&extent);
  864. }
  865.  
  866. bool BufferDlg::UpdateZoomFXExtentSymmetrical(bool bSymmetrical)
  867. {
  868.     ZOOMFX_BOX extent;
  869.     char str[20];
  870.  
  871.     m_bZoomFXSymmetrical = bSymmetrical;
  872.     
  873.     if(m_bZoomFXSymmetrical)
  874.     {
  875.         extent.vMax.x = (D3DVALUE)SendMessage(m_hZoomFXMaxXSlider, TBM_GETPOS, 0, 0);
  876.         extent.vMax.y = (D3DVALUE)SendMessage(m_hZoomFXMaxYSlider, TBM_GETPOS, 0, 0);
  877.         extent.vMax.z = (D3DVALUE)SendMessage(m_hZoomFXMaxZSlider, TBM_GETPOS, 0, 0);
  878.         extent.vMin.x = -extent.vMax.x;
  879.         extent.vMin.y = -extent.vMax.y;
  880.         extent.vMin.z = -extent.vMax.z;
  881.         SendMessage(m_hZoomFXMinXSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)-extent.vMin.x);
  882.         SendMessage(m_hZoomFXMinYSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)-extent.vMin.y);
  883.         SendMessage(m_hZoomFXMinZSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)-extent.vMin.z);
  884.         sprintf(str, "X:%.0f", extent.vMin.x);
  885.         SetWindowText(m_hZoomFXMinXStatic, str);
  886.         sprintf(str, "Y:%.0f", extent.vMin.y);
  887.         SetWindowText(m_hZoomFXMinYStatic, str);
  888.         sprintf(str, "Z:%.0f", extent.vMin.z);
  889.         SetWindowText(m_hZoomFXMinZStatic, str);
  890.         return SetZoomFXExtent(&extent);
  891.     }
  892.     return true;
  893. }
  894.  
  895. void BufferDlg::UpdateZoomFXOrientation()
  896. {
  897.     char str[20];
  898.  
  899.     m_Orientation.vFront.x = (D3DVALUE)SendMessage(m_hZoomFXFrontXSlider, TBM_GETPOS, 0, 0)/100.0f;
  900.     m_Orientation.vFront.y = (D3DVALUE)SendMessage(m_hZoomFXFrontYSlider, TBM_GETPOS, 0, 0)/100.0f;
  901.     m_Orientation.vFront.z = (D3DVALUE)SendMessage(m_hZoomFXFrontZSlider, TBM_GETPOS, 0, 0)/100.0f;
  902.     m_Orientation.vTop.x = (D3DVALUE)SendMessage(m_hZoomFXTopXSlider, TBM_GETPOS, 0, 0)/100.0f;
  903.     m_Orientation.vTop.y = (D3DVALUE)SendMessage(m_hZoomFXTopYSlider, TBM_GETPOS, 0, 0)/100.0f;
  904.     m_Orientation.vTop.z = (D3DVALUE)SendMessage(m_hZoomFXTopZSlider, TBM_GETPOS, 0, 0)/100.0f;
  905.     sprintf(str, "X:%.2f", m_Orientation.vFront.x);
  906.     SetWindowText(m_hZoomFXFrontXStatic, str);
  907.     sprintf(str, "Y:%.2f", m_Orientation.vFront.y);
  908.     SetWindowText(m_hZoomFXFrontYStatic, str);
  909.     sprintf(str, "Z:%.2f", m_Orientation.vFront.z);
  910.     SetWindowText(m_hZoomFXFrontZStatic, str);
  911.     sprintf(str, "X:%.2f", m_Orientation.vTop.x);
  912.     SetWindowText(m_hZoomFXTopXStatic, str);
  913.     sprintf(str, "Y:%.2f", m_Orientation.vTop.y);
  914.     SetWindowText(m_hZoomFXTopYStatic, str);
  915.     sprintf(str, "Z:%.2f", m_Orientation.vTop.z);
  916.     SetWindowText(m_hZoomFXTopZStatic, str);
  917. }
  918.  
  919. bool BufferDlg::CommitZoomFXOrientation()
  920. {
  921.     char str[20];
  922.  
  923.     if(!SetZoomFXOrientation(&m_Orientation))
  924.         return false;
  925.  
  926.     if(!GetZoomFXOrientation(&m_Orientation))
  927.         return false;
  928.  
  929.     SendMessage(m_hZoomFXFrontXSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(m_Orientation.vFront.x*100.0f));
  930.     SendMessage(m_hZoomFXFrontYSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(m_Orientation.vFront.y*100.0f));
  931.     SendMessage(m_hZoomFXFrontZSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(m_Orientation.vFront.z*100.0f));
  932.     SendMessage(m_hZoomFXTopXSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(m_Orientation.vTop.x*100.0f));
  933.     SendMessage(m_hZoomFXTopYSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(m_Orientation.vTop.y*100.0f));
  934.     SendMessage(m_hZoomFXTopZSlider, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(m_Orientation.vTop.z*100.0f));
  935.     sprintf(str, "X:%.2f", m_Orientation.vFront.x);
  936.     SetWindowText(m_hZoomFXFrontXStatic, str);
  937.     sprintf(str, "Y:%.2f", m_Orientation.vFront.y);
  938.     SetWindowText(m_hZoomFXFrontYStatic, str);
  939.     sprintf(str, "Z:%.2f", m_Orientation.vFront.z);
  940.     SetWindowText(m_hZoomFXFrontZStatic, str);
  941.     sprintf(str, "X:%.2f", m_Orientation.vTop.x);
  942.     SetWindowText(m_hZoomFXTopXStatic, str);
  943.     sprintf(str, "Y:%.2f", m_Orientation.vTop.y);
  944.     SetWindowText(m_hZoomFXTopYStatic, str);
  945.     sprintf(str, "Z:%.2f", m_Orientation.vTop.z);
  946.     SetWindowText(m_hZoomFXTopZStatic, str);
  947.  
  948.     return true;
  949. }
  950.  
  951. void BufferDlg::UpdateDistanceStatics(D3DVALUE flMinDistance, D3DVALUE flMaxDistance)
  952. {
  953.     char str[20];
  954.  
  955.     sprintf(str, "%.0f", flMinDistance);
  956.     SetWindowText(m_hMinDistanceStatic, str);
  957.     sprintf(str, "%.0f", flMaxDistance);
  958.     SetWindowText(m_hMaxDistanceStatic, str);
  959. }
  960.  
  961. void BufferDlg::UpdatePositionStatics(LPD3DVECTOR p)
  962. {
  963.     char str[20];
  964.  
  965.     sprintf(str, "X:%.0f", p->x);
  966.     SetWindowText(m_hPositionXStatic, str);
  967.     sprintf(str, "Y:%.0f", p->y);
  968.     SetWindowText(m_hPositionYStatic, str);
  969.     sprintf(str, "Z:%.0f", p->z);
  970.     SetWindowText(m_hPositionZStatic, str);
  971. }
  972.  
  973. void BufferDlg::UpdateVelocityStatics(LPD3DVECTOR v)
  974. {
  975.     char str[20];
  976.  
  977.     sprintf(str, "X:%.0f", v->x);
  978.     SetWindowText(m_hVelocityXStatic, str);
  979.     sprintf(str, "Y:%.0f", v->y);
  980.     SetWindowText(m_hVelocityYStatic, str);
  981.     sprintf(str, "Z:%.0f", v->z);
  982.     SetWindowText(m_hVelocityZStatic, str);
  983. }
  984.  
  985. void BufferDlg::UpdateConeAngleStatics(DWORD dwInsideConeAngle, DWORD dwOutsideConeAngle)
  986. {
  987.     char    str[20];
  988.  
  989.     sprintf(str, "%d", dwInsideConeAngle);
  990.     SetWindowText(m_hInnerConeAngleStatic, str);
  991.     sprintf(str, "%d", dwOutsideConeAngle);
  992.     SetWindowText(m_hOuterConeAngleStatic, str);
  993. }
  994.  
  995.