home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Learn 3D Graphics Programming on the PC
/
Learn_3D_Graphics_Programming_on_the_PC_Ferraro.iso
/
rwwin
/
viewdlg.c_
/
viewdlg.bin
Wrap
Text File
|
1995-11-14
|
76KB
|
1,688 lines
/**********************************************************************
*
* File : viewdlg.c
*
* Abstract : Dialogs used in rfView mostly taken from rfView
*
* This application had been written to be compatible with
* both the fixed and floating-point versions of the
* RenderWare library, i.e., it uses the macros CREAL,
* INT2REAL, RAdd, RDiv, RSub etc. If your application is
* intended for the floating-point version of the library
* only these macros are not necessary.
*
* Please note that this application is intended for
* demonstration purposes only. No support will be
* provided for this code and it comes with no warranty.
*
**********************************************************************
*
* This file is a product of Richard F. Ferraro
*
* This file is provided as is with no warranties of any kind and is
* provided without any obligation on Richard F. Ferraro. or Criterion Software or
* Canon Inc. to assist in its use or modification.
*
* Richard F. Ferraro or Criterion Software Ltd. will not, under any
* circumstances, be liable for any lost revenue or other damages arising
* from the use of this file.
*
* Copyright (c) 1995 Richard F. Ferraro
* All Rights Reserved.
*
* RenderWare is a trademark of Canon Inc.
*
**********************************************************************/
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <rwlib.h>
#include <rwwin.h>
#include "resource.h"
#include "rfview.h"
#include "booksub.h"
#include "viewsub.h"
/*
* The RenderWare search path dialog procedure.
*/
BOOL CALLBACK
SearchPathDlgProc(HWND dialog, UINT message, WPARAM wParam, LPARAM lParam)
{
char searchPath[RWMAXPATHLEN];
lParam=lParam;
switch (message)
{
case WM_INITDIALOG:
/*
* Initialize the edit control with the current RenderWare
* search path.
*/
RwGetShapePath(searchPath);
SetDlgItemText(dialog, IDC_SEARCHPATH_PATH, searchPath);
SetFocus(GetDlgItem(dialog, IDC_SEARCHPATH_PATH));
return FALSE;
case WM_COMMAND:
#ifdef WIN32
switch(LOWORD(wParam))
#else
switch (wParam)
#endif
{
case IDOK:
/*
* Set the RenderWare search path to the contents of
* the edit control.
*/
GetDlgItemText(dialog, IDC_SEARCHPATH_PATH, searchPath, sizeof(searchPath));
RwSetShapePath(searchPath, rwREPLACE);
EndDialog(dialog, IDOK);
break;
case IDCANCEL:
EndDialog(dialog, IDCANCEL);
break;
}
return TRUE;
}
return FALSE;
}
/**********************************************************************/
/*
* The about box dialog procedure.
*/
BOOL CALLBACK
AboutBoxDlgProc(HWND dialog, UINT message, WPARAM wParam, LPARAM lParam)
{
char version[80];
RwBool isFixed;
RwBool isDebug;
RwInt32 depth;
RwBool usingDIBs;
RwBool usingWinG;
lParam=lParam;
switch (message)
{
case WM_INITDIALOG:
/*
* Get information about the RenderWare library being used and
* set the appropriate fields of the dialog with these values.
*/
RwGetSystemInfo(rwVERSIONSTRING, &version, sizeof(version));
RwGetSystemInfo(rwFIXEDPOINTLIB, &isFixed, sizeof(isFixed));
RwGetSystemInfo(rwDEBUGGINGLIB, &isDebug, sizeof(isDebug));
RwGetDeviceInfo(rwRENDERDEPTH, &depth, sizeof(depth));
RwGetDeviceInfo(rwWINUSINGDIBS, &usingDIBs, sizeof(usingDIBs));
RwGetDeviceInfo(rwWINUSINGWING, &usingWinG, sizeof(usingWinG));
SetDlgItemText(dialog, IDC_ABOUT_RENDERWAREVERSION, version);
SetDlgItemText(dialog, IDC_ABOUT_RENDERWARENUMERICS,
(isFixed ? "Fixed-point" : "Floating-point"));
SetDlgItemText(dialog, IDC_ABOUT_RENDERWAREKERNEL,
(isDebug ? "Debugging" : "Retail"));
SetDlgItemText(dialog, IDC_ABOUT_RENDERWARERENDERING,
((depth == 8L) ? "8-bit (256 color)" : "16-bit (65536 color)"));
if (usingDIBs)
{
SetDlgItemText(dialog, IDC_ABOUT_RENDERWAREBITMAPS, "DIBs");
}
else if (usingWinG)
{
SetDlgItemText(dialog, IDC_ABOUT_RENDERWAREBITMAPS, "WinG");
}
else
{
#if defined(WIN32)
SetDlgItemText(dialog, IDC_ABOUT_RENDERWAREBITMAPS, "DIB Sections");
#else
SetDlgItemText(dialog, IDC_ABOUT_RENDERWAREBITMAPS, "DDBs");
#endif
}
return TRUE;
case WM_COMMAND:
#ifdef WIN32
switch(LOWORD(wParam))
#else
switch (wParam)
#endif
{
case IDOK:
EndDialog(dialog, IDOK);
break;
}
return TRUE;
}
return FALSE;
}
// *******************************************************************************************************
BOOL CALLBACK
CameraDlgProc(HWND dialog, UINT message, WPARAM wParam, LPARAM lParam)
{
char buffer[10];
HWND scrollBar=NULL;
int i,code,pos,newPos=0,channel,id=0,maxs=0;
float fvalue;
RwCamera * retcam;
switch (message)
{
case WM_INITDIALOG:
RwGetCameraPosition(CurrentCamera,&rfCam.pos);
//RwGetCameraLookAt(CurrentCamera,&rfCam.point);
RwGetCameraViewwindow(CurrentCamera,&rfCam.vw_width, &rfCam.vw_height);
// based on the view window and view size, let's find the view angle
rfViewwindowToAngle();
/* Initialize the scrollbars. */
SetScrollRange(GetDlgItem(dialog, IDC_CR_SLIDER), SB_CTL, 0, MAX_REPEAT, FALSE);
SetScrollRange(GetDlgItem(dialog, IDC_CA_SLIDER), SB_CTL, -MAX_CSCROLL/2, MAX_CSCROLL/2, FALSE);
SetScrollRange(GetDlgItem(dialog, IDC_CWX_SLIDER), SB_CTL, 0, MAX_CP_SCROLL/2, FALSE);
SetScrollRange(GetDlgItem(dialog, IDC_CWY_SLIDER), SB_CTL, 0, MAX_CP_SCROLL/2, FALSE);
SetScrollRange(GetDlgItem(dialog, IDC_CAA_SLIDER), SB_CTL, 0, 1000, FALSE);
SetScrollRange(GetDlgItem(dialog, IDC_CVA_SLIDER), SB_CTL, 0, 18000, FALSE);
SetScrollRange(GetDlgItem(dialog, IDC_CPX_SLIDER), SB_CTL, -MAX_CP_SCROLL/2, MAX_CP_SCROLL/2, FALSE);
SetScrollRange(GetDlgItem(dialog, IDC_CPY_SLIDER), SB_CTL, -MAX_CP_SCROLL/2, MAX_CP_SCROLL/2, FALSE);
SetScrollRange(GetDlgItem(dialog, IDC_CPZ_SLIDER), SB_CTL, -MAX_CP_SCROLL/2, MAX_CP_SCROLL/2, FALSE);
SetScrollRange(GetDlgItem(dialog, IDC_COX_SLIDER), SB_CTL, -MAX_CP_SCROLL/2, MAX_CP_SCROLL/2, FALSE);
SetScrollRange(GetDlgItem(dialog, IDC_COY_SLIDER), SB_CTL, -MAX_CP_SCROLL/2, MAX_CP_SCROLL/2, FALSE);
SetScrollRange(GetDlgItem(dialog, IDC_COZ_SLIDER), SB_CTL, -MAX_CP_SCROLL/2, MAX_CP_SCROLL/2, FALSE);
SetScrollPos(GetDlgItem(dialog, IDC_CR_SLIDER), SB_CTL, rfCam.repeat, FALSE);
SetScrollPos(GetDlgItem(dialog, IDC_CA_SLIDER), SB_CTL, (int)(100*rfCam.val), FALSE);
SetScrollPos(GetDlgItem(dialog, IDC_CWX_SLIDER), SB_CTL, (int)(100*rfCam.vw_width), FALSE);
SetScrollPos(GetDlgItem(dialog, IDC_CWY_SLIDER), SB_CTL, (int)(100*rfCam.vw_height), FALSE);
SetScrollPos(GetDlgItem(dialog, IDC_CAA_SLIDER), SB_CTL, (int)(100*rfCam.aspect), FALSE);
SetScrollPos(GetDlgItem(dialog, IDC_CVA_SLIDER), SB_CTL, (int)(100*rfCam.angle), FALSE);
SetScrollPos(GetDlgItem(dialog, IDC_CPX_SLIDER), SB_CTL, (int)(100*rfCam.pos.x), FALSE);
SetScrollPos(GetDlgItem(dialog, IDC_CPY_SLIDER), SB_CTL, (int)(100*rfCam.pos.y), FALSE);
SetScrollPos(GetDlgItem(dialog, IDC_CPZ_SLIDER), SB_CTL, (int)(100*rfCam.pos.z), FALSE);
SetScrollPos(GetDlgItem(dialog, IDC_COX_SLIDER), SB_CTL, (int)(100*rfCam.point.x), FALSE);
SetScrollPos(GetDlgItem(dialog, IDC_COY_SLIDER), SB_CTL, (int)(100*rfCam.point.y), FALSE);
SetScrollPos(GetDlgItem(dialog, IDC_COZ_SLIDER), SB_CTL, (int)(100*rfCam.point.z), FALSE);
/*
* Initialize the edit controls.
*/
sprintf(buffer, "%4d", rfCam.repeat);
SetDlgItemText(dialog, IDC_CR_EDIT, buffer);
sprintf(buffer, "%2.1f", rfCam.val);
SetDlgItemText(dialog, IDC_CA_EDIT, buffer);
sprintf(buffer, "%2.1f", rfCam.vw_width);
SetDlgItemText(dialog, IDC_CWX_EDIT, buffer);
sprintf(buffer, "%2.1f",rfCam.vw_height);
SetDlgItemText(dialog, IDC_CWY_EDIT, buffer);
sprintf(buffer, "%2.1f", rfCam.aspect);
SetDlgItemText(dialog, IDC_CAA_EDIT, buffer);
sprintf(buffer, "%2.1f",rfCam.angle);
SetDlgItemText(dialog, IDC_CVA_EDIT, buffer);
sprintf(buffer, "%2.1f", rfCam.pos.x);
SetDlgItemText(dialog, IDC_CPX_EDIT, buffer);
sprintf(buffer, "%2.1f",rfCam.pos.y);
SetDlgItemText(dialog, IDC_CPY_EDIT, buffer);
sprintf(buffer, "%2.1f", rfCam.pos.z);
SetDlgItemText(dialog, IDC_CPZ_EDIT, buffer);
sprintf(buffer, "%2.1f", rfCam.point.x);
SetDlgItemText(dialog, IDC_COX_EDIT, buffer);
sprintf(buffer, "%2.1f",rfCam.point.y);
SetDlgItemText(dialog, IDC_COY_EDIT, buffer);
sprintf(buffer, "%2.1f", rfCam.point.z);
SetDlgItemText(dialog, IDC_COZ_EDIT, buffer);
return FALSE;
case WM_HSCROLL:
#if defined(WIN32)
code = (int)LOWORD(wParam);
newPos = (int)HIWORD(wParam);
scrollBar = (HWND)lParam;
id = (int)GetWindowLong(scrollBar, GWL_ID);
#else
code = (int)wParam;
newPos = (int)LOWORD(lParam);
scrollBar = (HWND)HIWORD(lParam);
id = (int)GetWindowWord(scrollBar, GWW_ID);
#endif
maxs = MAX_CP_SCROLL; // assume not repeat or value
switch (id)
{
case IDC_CR_SLIDER: maxs = MAX_REPEAT; break;
case IDC_CA_SLIDER: maxs = MAX_CSCROLL; break;
case IDC_CVA_SLIDER: maxs = 32000; break;
case IDC_CAA_SLIDER: maxs = 2000; break;
}
/*
* As we preview continuously SB_ENDSCROLL is not important to us.
*/
if (code == SB_ENDSCROLL) return TRUE;
/* Update the scroll bar. */
pos = GetScrollPos(scrollBar, SB_CTL);
switch (code)
{
case SB_BOTTOM: pos = maxs; break;
case SB_LINEDOWN: pos += maxs/10; break;
case SB_LINEUP: pos -= maxs/10; break;
case SB_PAGEDOWN: pos += maxs/2; break;
case SB_PAGEUP: pos -= maxs/2; break;
case SB_THUMBTRACK: pos = newPos; break;
case SB_THUMBPOSITION: pos = newPos; break;
case SB_TOP: pos = 0; break;
}
/*
* Clamp the position to the valid range.
*/
if (pos < -maxs/2) pos = -maxs/2; else if (pos > maxs/2) pos = maxs/2;
SetScrollPos(scrollBar, SB_CTL, pos, TRUE);
/*
* Compute the new camera(depending on which channel has changed)
* and update the appropriate edit control.
*/
switch (id)
{
case IDC_CR_SLIDER:
sprintf(buffer, "%3d", pos);
SetDlgItemText(dialog, IDC_CR_EDIT, buffer);
rfCam.repeat = pos;
break;
case IDC_CA_SLIDER:
sprintf(buffer, "%2.1f",(float)pos/100);
SetDlgItemText(dialog, IDC_CA_EDIT, buffer);
rfCam.val = (float)pos/100;
break;
case IDC_CWX_SLIDER:
sprintf(buffer, "%2.1f", (float)pos/100);
SetDlgItemText(dialog, IDC_CWX_EDIT, buffer);
rfCam.vw_width = (float)pos/100;
rfViewwindowToAngle();
sprintf(buffer, "%2.1f", (float)rfCam.aspect);
SetDlgItemText(dialog, IDC_CAA_EDIT, buffer);
sprintf(buffer, "%3.1f", (float)rfCam.angle);
SetDlgItemText(dialog, IDC_CVA_EDIT, buffer);
SetScrollPos(GetDlgItem(dialog, IDC_CAA_SLIDER), SB_CTL, (int)(rfCam.aspect*100), TRUE);
SetScrollPos(GetDlgItem(dialog, IDC_CVA_SLIDER), SB_CTL, (int)(rfCam.angle*100), TRUE);
break;
case IDC_CWY_SLIDER:
sprintf(buffer, "%2.1f", (float)pos/100);
SetDlgItemText(dialog, IDC_CWY_EDIT, buffer);
rfCam.vw_height = (float)pos/100;
rfViewwindowToAngle();
sprintf(buffer, "%2.1f", (float)rfCam.aspect);
SetDlgItemText(dialog, IDC_CAA_EDIT, buffer);
sprintf(buffer, "%3.1f", (float)rfCam.angle);
SetDlgItemText(dialog, IDC_CVA_EDIT, buffer);
SetScrollPos(GetDlgItem(dialog, IDC_CAA_SLIDER), SB_CTL, (int)(rfCam.aspect*100), TRUE);
SetScrollPos(GetDlgItem(dialog, IDC_CVA_SLIDER), SB_CTL, (int)(rfCam.angle*100), TRUE);
break;
case IDC_CAA_SLIDER:
sprintf(buffer, "%2.1f", (float)pos/100);
SetDlgItemText(dialog, IDC_CAA_EDIT, buffer);
rfCam.aspect = (float)pos/100;
rfAngleToViewwindow();
sprintf(buffer, "%2.1f", (float)rfCam.vw_width);
SetDlgItemText(dialog, IDC_CWX_EDIT, buffer);
sprintf(buffer, "%2.1f", (float)rfCam.vw_height);
SetDlgItemText(dialog, IDC_CWY_EDIT, buffer);
SetScrollPos(GetDlgItem(dialog, IDC_CWX_SLIDER), SB_CTL, (int)(rfCam.vw_width*100), TRUE);
SetScrollPos(GetDlgItem(dialog, IDC_CWY_SLIDER), SB_CTL, (int)(rfCam.vw_height*100), TRUE);
break;
case IDC_CVA_SLIDER:
sprintf(buffer, "%3.1f", (float)pos/100);
SetDlgItemText(dialog, IDC_CVA_EDIT, buffer);
rfCam.angle = (float)pos/100;
rfAngleToViewwindow();
sprintf(buffer, "%2.1f", (float)rfCam.vw_width);
SetDlgItemText(dialog, IDC_CWX_EDIT, buffer);
sprintf(buffer, "%2.1f", (float)rfCam.vw_height);
SetDlgItemText(dialog, IDC_CWY_EDIT, buffer);
SetScrollPos(GetDlgItem(dialog, IDC_CWX_SLIDER), SB_CTL, (int)(rfCam.vw_width*100), TRUE);
SetScrollPos(GetDlgItem(dialog, IDC_CWY_SLIDER), SB_CTL, (int)(rfCam.vw_height*100), TRUE);
break;
case IDC_CPX_SLIDER:
sprintf(buffer, "%2.1f", (float)pos/100);
SetDlgItemText(dialog, IDC_CPX_EDIT, buffer);
rfCam.pos.x = (float)pos/100;
break;
case IDC_CPY_SLIDER:
sprintf(buffer, "%2.1f", (float)pos/100);
SetDlgItemText(dialog, IDC_CPY_EDIT, buffer);
rfCam.pos.y = (float)pos/100;
break;
case IDC_CPZ_SLIDER:
sprintf(buffer, "%2.1f", (float)pos/100);
SetDlgItemText(dialog, IDC_CPZ_EDIT, buffer);
rfCam.pos.z = (float)pos/100;
break;
case IDC_COX_SLIDER:
sprintf(buffer, "%2.1f", (float)pos/100);
SetDlgItemText(dialog, IDC_COX_EDIT, buffer);
rfCam.point.x = (float)pos/100;
break;
case IDC_COY_SLIDER:
sprintf(buffer, "%2.1f", (float)pos/100);
SetDlgItemText(dialog, IDC_COY_EDIT, buffer);
rfCam.point.y = (float)pos/100;
break;
case IDC_COZ_SLIDER:
sprintf(buffer, "%2.1f", (float)pos/100);
SetDlgItemText(dialog, IDC_COZ_EDIT, buffer);
rfCam.point.z = (float)pos/100;
break;
}
return TRUE;
case WM_COMMAND:
{
#ifdef WIN32
HWND hwndCtl = (HWND) lParam;
WORD wID = LOWORD(wParam);
WORD wNotifyCode = HIWORD(wParam);
#else
HWND hwndCtl = (HWND) LOWORD(lParam);
WORD wID = wParam;
WORD wNotifyCode = HIWORD(lParam);
#endif
switch (wID)
{
case IDC_CPX_EDIT: case IDC_CPY_EDIT: case IDC_CPZ_EDIT:
case IDC_COX_EDIT: case IDC_COY_EDIT: case IDC_COZ_EDIT:
case IDC_CA_EDIT: case IDC_CR_EDIT:
case IDC_CWX_EDIT: case IDC_CWY_EDIT: case IDC_CAA_EDIT: case IDC_CVA_EDIT:
/*
* For the edit controls we only take any notice when the
* control loses the input focus.
*/
if (wNotifyCode == EN_KILLFOCUS)
{
/* Get the edit control's text. */
GetDlgItemText(dialog, wID, buffer, sizeof(buffer));
/* Build the new current tanslation and update the appropriate slider.*/
switch (wID)
{
case IDC_CA_EDIT:
scrollBar = GetDlgItem(dialog, IDC_CA_SLIDER);
if( (sscanf(buffer, "%f", &fvalue) == 1) &&
(fvalue >= -MAX_CSCROLL/2) && (fvalue <= MAX_CSCROLL/2))
{
rfCam.val = fvalue;
SetScrollPos(scrollBar, SB_CTL, (int)(fvalue*100), TRUE);
}
else
{
channel = GetScrollPos(scrollBar, SB_CTL);
sprintf(buffer, "%2.1f", (float)channel/100);
SetDlgItemText(dialog, wID, buffer);
}
break;
case IDC_CPX_EDIT:
scrollBar = GetDlgItem(dialog, IDC_CPX_SLIDER);
if( (sscanf(buffer, "%f", &fvalue) == 1) &&
(fvalue >= -MAX_CP_SCROLL/2) && (fvalue <= MAX_CP_SCROLL/2))
{
rfCam.pos.x = fvalue;
SetScrollPos(scrollBar, SB_CTL, (int)(fvalue*100), TRUE);
}
else
{
channel = GetScrollPos(scrollBar, SB_CTL);
sprintf(buffer, "%2.1f", (float)channel/100);
SetDlgItemText(dialog, wID, buffer);
}
break;
case IDC_CPY_EDIT:
scrollBar = GetDlgItem(dialog, IDC_CPY_SLIDER);
if( (sscanf(buffer, "%f", &fvalue) == 1) &&
(fvalue >= -MAX_CP_SCROLL/2) && (fvalue <= MAX_CP_SCROLL/2))
{
rfCam.pos.y = fvalue;
SetScrollPos(scrollBar, SB_CTL, (int)(fvalue*100), TRUE);
}
else
{
channel = GetScrollPos(scrollBar, SB_CTL);
sprintf(buffer, "%2.1f", (float)channel/100);
SetDlgItemText(dialog, wID, buffer);
}
break;
case IDC_CPZ_EDIT:
scrollBar = GetDlgItem(dialog, IDC_CPZ_SLIDER);
if( (sscanf(buffer, "%f", &fvalue) == 1) &&
(fvalue >= -MAX_CP_SCROLL/2) && (fvalue <= MAX_CP_SCROLL/2))
{
rfCam.pos.z = fvalue;
SetScrollPos(scrollBar, SB_CTL, (int)(fvalue*100), TRUE);
}
else
{
channel = GetScrollPos(scrollBar, SB_CTL);
sprintf(buffer, "%2.1f", (float)channel/100);
SetDlgItemText(dialog, wID, buffer);
}
break;
case IDC_CWX_EDIT:
scrollBar = GetDlgItem(dialog, IDC_CWX_SLIDER);
if ((sscanf(buffer, "%f", &fvalue) == 1) &&
(fvalue >= 0) && (fvalue <= MAX_CP_SCROLL))
{
rfCam.vw_width = fvalue;
SetScrollPos(scrollBar, SB_CTL, (int)(fvalue*100), TRUE);
rfViewwindowToAngle();
sprintf(buffer, "%2.1f", (float)rfCam.aspect);
SetDlgItemText(dialog, IDC_CAA_EDIT, buffer);
sprintf(buffer, "%2.1f", (float)rfCam.angle);
SetDlgItemText(dialog, IDC_CVA_EDIT, buffer);
SetScrollPos(GetDlgItem(dialog, IDC_CAA_SLIDER), SB_CTL, (int)(rfCam.aspect*100), TRUE);
SetScrollPos(GetDlgItem(dialog, IDC_CVA_SLIDER), SB_CTL, (int)(rfCam.angle*100), TRUE);
}
else
{
channel = GetScrollPos(scrollBar, SB_CTL);
sprintf(buffer, "%2.1f", channel);
SetDlgItemText(dialog, wID, buffer);
}
break;
case IDC_CWY_EDIT:
scrollBar = GetDlgItem(dialog, IDC_CWY_SLIDER);
if ((sscanf(buffer, "%f", &fvalue) == 1) &&
(fvalue >= 0) && (fvalue <= MAX_CP_SCROLL))
{
rfCam.vw_height = fvalue;
SetScrollPos(scrollBar, SB_CTL, (int)(fvalue*100), TRUE);
rfViewwindowToAngle();
sprintf(buffer, "%2.1f", (float)rfCam.aspect);
SetDlgItemText(dialog, IDC_CAA_EDIT, buffer);
sprintf(buffer, "%2.1f", (float)rfCam.angle);
SetDlgItemText(dialog, IDC_CVA_EDIT, buffer);
SetScrollPos(GetDlgItem(dialog, IDC_CAA_SLIDER), SB_CTL, (int)(rfCam.aspect*100), TRUE);
SetScrollPos(GetDlgItem(dialog, IDC_CVA_SLIDER), SB_CTL, (int)(rfCam.angle*100), TRUE);
}
else
{
channel = GetScrollPos(scrollBar, SB_CTL);
sprintf(buffer, "%2.1", channel);
SetDlgItemText(dialog, wID, buffer);
}
break;
case IDC_CAA_EDIT:
scrollBar = GetDlgItem(dialog, IDC_CAA_SLIDER);
if ((sscanf(buffer, "%f", &fvalue) == 1) &&
(fvalue >= 0) && (fvalue <= 1000))
{
rfCam.aspect = fvalue;
SetScrollPos(scrollBar, SB_CTL, (int)(fvalue*100), TRUE);
rfAngleToViewwindow();
sprintf(buffer, "%2.1f", (float)rfCam.vw_width);
SetDlgItemText(dialog, IDC_CWX_EDIT, buffer);
sprintf(buffer, "%2.1f", (float)rfCam.vw_height);
SetDlgItemText(dialog, IDC_CWY_EDIT, buffer);
SetScrollPos(GetDlgItem(dialog, IDC_CWX_SLIDER), SB_CTL, (int)(rfCam.vw_width*100), TRUE);
SetScrollPos(GetDlgItem(dialog, IDC_CWY_SLIDER), SB_CTL, (int)(rfCam.vw_height*100), TRUE);
}
else
{
channel = GetScrollPos(scrollBar, SB_CTL);
sprintf(buffer, "%2.1f", channel);
SetDlgItemText(dialog, wID, buffer);
}
break;
case IDC_CVA_EDIT:
scrollBar = GetDlgItem(dialog, IDC_CVA_SLIDER);
if ((sscanf(buffer, "%f", &fvalue) == 1) &&
(fvalue >= 0) && (fvalue <= 16000))
{
rfCam.angle = fvalue;
SetScrollPos(scrollBar, SB_CTL, (int)(fvalue*100), TRUE);
rfAngleToViewwindow();
sprintf(buffer, "%2.1f", (float)rfCam.vw_width);
SetDlgItemText(dialog, IDC_CWX_EDIT, buffer);
sprintf(buffer, "%2.1f", (float)rfCam.vw_height);
SetDlgItemText(dialog, IDC_CWY_EDIT, buffer);
SetScrollPos(GetDlgItem(dialog, IDC_CWX_SLIDER), SB_CTL, (int)(rfCam.vw_width*100), TRUE);
SetScrollPos(GetDlgItem(dialog, IDC_CWY_SLIDER), SB_CTL, (int)(rfCam.vw_height*100), TRUE);
}
else
{
channel = GetScrollPos(scrollBar, SB_CTL);
sprintf(buffer, "%2.1", channel);
SetDlgItemText(dialog, wID, buffer);
}
case IDC_COX_EDIT:
scrollBar = GetDlgItem(dialog, IDC_COX_SLIDER);
if( (sscanf(buffer, "%f", &fvalue) == 1) &&
(fvalue >= -MAX_CP_SCROLL/2) && (fvalue <= MAX_CP_SCROLL/2))
{
rfCam.point.x = fvalue;
SetScrollPos(scrollBar, SB_CTL, (int)(fvalue*100), TRUE);
}
else
{
channel = GetScrollPos(scrollBar, SB_CTL);
sprintf(buffer, "%2.1f", (float)channel/100);
SetDlgItemText(dialog, wID, buffer);
}
break;
case IDC_COY_EDIT:
scrollBar = GetDlgItem(dialog, IDC_COY_SLIDER);
if( (sscanf(buffer, "%f", &fvalue) == 1) &&
(fvalue >= -MAX_CP_SCROLL/2) && (fvalue <= MAX_CP_SCROLL/2))
{
rfCam.point.y = fvalue;
SetScrollPos(scrollBar, SB_CTL, (int)(fvalue*100), TRUE);
}
else
{
channel = GetScrollPos(scrollBar, SB_CTL);
sprintf(buffer, "%2.1f", (float)channel/100);
SetDlgItemText(dialog, wID, buffer);
}
break;
case IDC_COZ_EDIT:
scrollBar = GetDlgItem(dialog, IDC_COZ_SLIDER);
if( (sscanf(buffer, "%f", &fvalue) == 1) &&
(fvalue >= -MAX_CP_SCROLL/2) && (fvalue <= MAX_CP_SCROLL/2))
{
rfCam.point.z = fvalue;
SetScrollPos(scrollBar, SB_CTL, (int)(fvalue*100), TRUE);
}
else
{
channel = GetScrollPos(scrollBar, SB_CTL);
sprintf(buffer, "%2.1f", (float)channel/100);
SetDlgItemText(dialog, wID, buffer);
}
break;
case IDC_CR_EDIT:
scrollBar = GetDlgItem(dialog, IDC_CR_SLIDER);
if ((sscanf(buffer, "%d", &channel) == 1) &&
(channel >= 0) && (channel <= 1000))
{
rfCam.repeat = channel;
SetScrollPos(scrollBar, SB_CTL, (int)(fvalue*100), TRUE);
}
else
{
channel = GetScrollPos(scrollBar, SB_CTL);
sprintf(buffer, "%d", channel);
SetDlgItemText(dialog, wID, buffer);
}
break;
} // end of case
} // end of if
break;
// ************************************** pan, revolve, and tilt *************************************
case IDC_CPAN: // about local Y UP
RwPushScratchMatrix();
RwGetCameraPosition(CurrentCamera,&rfRel.pos);
rfRel.up.x = CREAL(0.0); rfRel.up.y = CREAL(1.0); rfRel.up.z = CREAL(0.0);
RwGetCameraLTM(CurrentCamera,RwScratchMatrix());
RwTransformVector(&rfRel.up,RwScratchMatrix());
RwTranslateMatrix(RwScratchMatrix(),-rfRel.pos.x,-rfRel.pos.y,-rfRel.pos.z,rwREPLACE);
RwRotateMatrix(RwScratchMatrix(),rfRel.up.x, rfRel.up.y, rfRel.up.z, rfCam.val,rwPOSTCONCAT);
RwTranslateMatrix(RwScratchMatrix(),rfRel.pos.x,rfRel.pos.y,rfRel.pos.z,rwPOSTCONCAT);
if(rfCam.repeat!=1) rfRepeatMode = TRUE;
for (i=0; i<rfCam.repeat; i++) {
RwTransformCamera(CurrentCamera, RwScratchMatrix(), rwPOSTCONCAT);
if(i == rfCam.repeat-1) rfRepeatMode = FALSE;
RenderScene(CurrentWindow);
}
RwPopScratchMatrix();
break;
case IDC_CREVOLVE: // about local Z At
RwPushScratchMatrix();
RwGetCameraPosition(CurrentCamera,&rfRel.pos);
rfRel.at.x = CREAL(0.0); rfRel.at.y = CREAL(0.0); rfRel.at.z = CREAL(1.0);
RwGetCameraLTM(CurrentCamera,RwScratchMatrix());
RwTransformVector(&rfRel.at,RwScratchMatrix());
RwTranslateMatrix(RwScratchMatrix(),-rfRel.pos.x,-rfRel.pos.y,-rfRel.pos.z,rwREPLACE);
RwRotateMatrix(RwScratchMatrix(),rfRel.at.x, rfRel.at.y, rfRel.at.z, rfCam.val,rwPOSTCONCAT);
RwTranslateMatrix(RwScratchMatrix(),rfRel.pos.x,rfRel.pos.y,rfRel.pos.z,rwPOSTCONCAT);
if(rfCam.repeat!=1) rfRepeatMode = TRUE;
for (i=0; i<rfCam.repeat; i++) {
RwTransformCamera(CurrentCamera, RwScratchMatrix(), rwPOSTCONCAT);
if(i == rfCam.repeat-1) rfRepeatMode = FALSE;
RenderScene(CurrentWindow);
}
RwPopScratchMatrix();
break;
case IDC_CTILT: // about local X Right
RwPushScratchMatrix();
RwGetCameraPosition(CurrentCamera,&rfRel.pos);
rfRel.right.x = CREAL(1.0); rfRel.right.y = CREAL(0.0); rfRel.right.z = CREAL(0.0);
RwGetCameraLTM(CurrentCamera,RwScratchMatrix());
RwTransformVector(&rfRel.right,RwScratchMatrix());
RwTranslateMatrix(RwScratchMatrix(),-rfRel.pos.x,-rfRel.pos.y,-rfRel.pos.z,rwREPLACE);
RwRotateMatrix(RwScratchMatrix(),rfRel.right.x, rfRel.right.y, rfRel.right.z, rfCam.val, rwPOSTCONCAT);
RwTranslateMatrix(RwScratchMatrix(),rfRel.pos.x,rfRel.pos.y,rfRel.pos.z,rwPOSTCONCAT);
if(rfCam.repeat!=1) rfRepeatMode = TRUE;
for (i=0; i<rfCam.repeat; i++) {
RwTransformCamera(CurrentCamera, RwScratchMatrix(), rwPOSTCONCAT);
if(i == rfCam.repeat-1) rfRepeatMode = FALSE;
RenderScene(CurrentWindow);
}
RwPopScratchMatrix();
break;
case IDC_TRYVW:
retcam=RwSetCameraPosition(CurrentCamera, rfCam.pos.x, rfCam.pos.y, rfCam.pos.z);
if(retcam==NULL) MessageBox(CurrentWindow, "ERROR Position", WINDOWTITLE,MB_OK | MB_APPLMODAL | MB_ICONEXCLAMATION);
retcam=RwPointCamera(CurrentCamera,rfCam.point.x, rfCam.point.y, rfCam.point.z);
if(retcam==NULL) MessageBox(CurrentWindow, "ERROR Point Camera", WINDOWTITLE,MB_OK | MB_APPLMODAL | MB_ICONEXCLAMATION);
retcam = RwSetCameraViewwindow(CurrentCamera, rfCam.vw_width, rfCam.vw_height );
if(retcam==NULL) MessageBox(CurrentWindow, "ERROR ViewWindow", WINDOWTITLE,MB_OK | MB_APPLMODAL | MB_ICONEXCLAMATION);
RenderScene(CurrentWindow);
break;
case IDOK:
retcam=RwSetCameraPosition(CurrentCamera, rfCam.pos.x, rfCam.pos.y, rfCam.pos.z);
if(retcam==NULL) MessageBox(CurrentWindow, "ERROR Position", WINDOWTITLE,MB_OK | MB_APPLMODAL | MB_ICONEXCLAMATION);
retcam=RwPointCamera(CurrentCamera,rfCam.point.x, rfCam.point.y, rfCam.point.z);
if(retcam==NULL) MessageBox(CurrentWindow, "ERROR Point Camera", WINDOWTITLE,MB_OK | MB_APPLMODAL | MB_ICONEXCLAMATION);
retcam = RwSetCameraViewwindow(CurrentCamera, rfCam.vw_width, rfCam.vw_height );
if(retcam==NULL) MessageBox(CurrentWindow, "ERROR ViewWindow", WINDOWTITLE,MB_OK | MB_APPLMODAL | MB_ICONEXCLAMATION);
EndDialog(dialog, IDOK);
break;
case IDCANCEL:
EndDialog(dialog, IDCANCEL);
break;
}
return TRUE;
}
}
return FALSE;
}
BOOL CALLBACK
RotateDlgProc(HWND dialog, UINT message, WPARAM wParam, LPARAM lParam)
{
char buffer[10];
HWND scrollBar=NULL;
int code;
int pos=0;
int newPos;
int channel;
int id,maxs=0;
float fvalue;
switch (message)
{
case WM_INITDIALOG:
switch(rfRot.combine) {
case rwPRECONCAT:
CheckRadioButton(dialog,IDR_COMBINE_PRE,IDR_COMBINE_POST,IDR_COMBINE_PRE);
break;
case rwPOSTCONCAT:
CheckRadioButton(dialog,IDR_COMBINE_PRE,IDR_COMBINE_POST,IDR_COMBINE_POST);
break;
}
SetScrollRange(GetDlgItem(dialog, IDC_RR_SLIDER), SB_CTL, 0, 500, FALSE);
SetScrollRange(GetDlgItem(dialog, IDC_RX_SLIDER), SB_CTL, -MAX_RSCROLL/2, MAX_RSCROLL/2, FALSE);
SetScrollRange(GetDlgItem(dialog, IDC_RY_SLIDER), SB_CTL, -MAX_RSCROLL/2, MAX_RSCROLL/2, FALSE);
SetScrollRange(GetDlgItem(dialog, IDC_RZ_SLIDER), SB_CTL, -MAX_RSCROLL/2, MAX_RSCROLL/2, FALSE);
SetScrollRange(GetDlgItem(dialog, IDC_RT_SLIDER), SB_CTL, -180,180, FALSE);
SetScrollPos(GetDlgItem(dialog, IDC_RR_SLIDER), SB_CTL, rfRot.repeat, FALSE);
SetScrollPos(GetDlgItem(dialog, IDC_RX_SLIDER), SB_CTL, (int)(10*rfRot.x), FALSE);
SetScrollPos(GetDlgItem(dialog, IDC_RY_SLIDER), SB_CTL, (int)(10*rfRot.y), FALSE);
SetScrollPos(GetDlgItem(dialog, IDC_RZ_SLIDER), SB_CTL, (int)(10*rfRot.z), FALSE);
SetScrollPos(GetDlgItem(dialog, IDC_RT_SLIDER), SB_CTL, (int)rfRot.val, FALSE);
/*
* Initialize the edit controls.
*/
sprintf(buffer, "%4d", rfRot.repeat);
SetDlgItemText(dialog, IDC_RR_EDIT, buffer);
sprintf(buffer, "%2.1f", rfRot.x);
SetDlgItemText(dialog, IDC_RX_EDIT, buffer);
sprintf(buffer, "%2.1f", rfRot.y);
SetDlgItemText(dialog, IDC_RY_EDIT, buffer);
sprintf(buffer, "%2.1f", rfRot.z);
SetDlgItemText(dialog, IDC_RZ_EDIT, buffer);
sprintf(buffer, "%3d", rfRot.val);
SetDlgItemText(dialog, IDC_RT_EDIT, buffer);
return FALSE;
case WM_HSCROLL:
#if defined(WIN32)
code = (int)LOWORD(wParam);
newPos = (int)HIWORD(wParam);
scrollBar = (HWND)lParam;
id = (int)GetWindowLong(scrollBar, GWL_ID);
#else
code = (int)wParam;
newPos = (int)LOWORD(lParam);
scrollBar = (HWND)HIWORD(lParam);
id = (int)GetWindowWord(scrollBar, GWW_ID);
#endif
/*
* As we preview continuously SB_ENDSCROLL is not important to us.
*/
if (code == SB_ENDSCROLL) return TRUE;
/*
* Update the scroll bar.
*/
switch (id)
{
case IDC_RX_SLIDER: case IDC_RY_SLIDER:case IDC_RZ_SLIDER:
maxs = MAX_RSCROLL;
break;
case IDC_RT_SLIDER:
maxs = 1000;
break;
case IDC_RR_SLIDER:
maxs = 360;
break;
}
switch (code)
{
case SB_BOTTOM: pos = maxs; break;
case SB_LINEDOWN: pos += maxs/10; break;
case SB_LINEUP: pos -= maxs/10; break;
case SB_PAGEDOWN: pos += maxs/2; break;
case SB_PAGEUP: pos -= maxs/2; break;
case SB_THUMBTRACK: pos = newPos; break;
case SB_THUMBPOSITION: pos = newPos; break;
case SB_TOP: pos = 0; break;
}
/*
* Clamp the position to the valid range.
*/
if (pos < -maxs/2) pos = -maxs/2;
else if (pos > maxs/2) pos = maxs/2;
SetScrollPos(scrollBar, SB_CTL, pos, TRUE);
/*
* Compute the new translation(depending on which channel has changed)
* and update the appropriate edit control.
*/
switch (id)
{
case IDC_RR_SLIDER:
sprintf(buffer, "%3d", pos);
SetDlgItemText(dialog, IDC_RR_EDIT, buffer);
rfRot.repeat = pos;
break;
case IDC_RX_SLIDER:
sprintf(buffer, "%2.1f", (float)pos/10);
SetDlgItemText(dialog, IDC_RX_EDIT, buffer);
rfRot.x = (float)pos/10;
break;
case IDC_RY_SLIDER:
sprintf(buffer, "%2.1f", (float)pos/10);
SetDlgItemText(dialog, IDC_RY_EDIT, buffer);
rfRot.y = (float)pos/10;
break;
case IDC_RZ_SLIDER:
sprintf(buffer, "%2.1f", (float)pos/10);
SetDlgItemText(dialog, IDC_RZ_EDIT, buffer);
rfRot.z = (float)pos/10;
break;
case IDC_RT_SLIDER:
sprintf(buffer, "%3d", pos);
SetDlgItemText(dialog, IDC_RT_EDIT, buffer);
rfRot.val = pos;
break;
}
return TRUE;
case WM_COMMAND:
{
#ifdef WIN32
HWND hwndCtl = (HWND) lParam;
WORD wID = LOWORD(wParam);
WORD wNotifyCode = HIWORD(wParam);
#else
HWND hwndCtl = (HWND) LOWORD(lParam);
WORD wID = wParam;
WORD wNotifyCode = HIWORD(lParam);
#endif
switch (wID)
{
case IDC_RX_EDIT:
case IDC_RY_EDIT:
case IDC_RZ_EDIT:
/*
* For the edit controls we only take any notice when the
* control loses the input focus.
*/
if (wNotifyCode == EN_KILLFOCUS)
{
/*
* Get the edit control's text.
*/
GetDlgItemText(dialog, wID, buffer, sizeof(buffer));
/*
* Ensure its a valid value.
*/
if( (sscanf(buffer, "%f", &fvalue) == 1) &&
(fvalue >= -MAX_RSCROLL/2) && (fvalue <= MAX_RSCROLL/2))
{
/*
* Build the new current tanslation and update the appropriate
* slider.
*/
switch (wID)
{
case IDC_RX_EDIT:
scrollBar = GetDlgItem(dialog, IDC_RX_SLIDER);
rfRot.x = fvalue;
break;
case IDC_RY_EDIT:
scrollBar = GetDlgItem(dialog, IDC_RY_SLIDER);
rfRot.y = fvalue;
break;
case IDC_RZ_EDIT:
scrollBar = GetDlgItem(dialog, IDC_RZ_SLIDER);
rfRot.z = fvalue;
break;
}
SetScrollPos(scrollBar, SB_CTL, (int)(fvalue*10), TRUE);
}
else
{
/*
* Not valid, put the existing value back.
*/
switch (wID)
{
case IDC_RX_EDIT: scrollBar = GetDlgItem(dialog, IDC_RX_SLIDER); break;
case IDC_RY_EDIT: scrollBar = GetDlgItem(dialog, IDC_RY_SLIDER); break;
case IDC_RZ_EDIT: scrollBar = GetDlgItem(dialog, IDC_RZ_SLIDER); break;
}
channel = GetScrollPos(scrollBar, SB_CTL);
sprintf(buffer, "%2.1f", (float)channel/10);
SetDlgItemText(dialog, wID, buffer);
}
}
break;
case IDC_RT_EDIT: case IDC_RR_EDIT:
/*
* For the edit controls we only take any notice when the
* control loses the input focus.
*/
if (wNotifyCode == EN_KILLFOCUS)
{
/*
* Get the edit control's text.
*/
GetDlgItemText(dialog, wID, buffer, sizeof(buffer));
/*
* Ensure its a valid value.
*/
if ((sscanf(buffer, "%d", &channel) == 1) &&
(channel >= -180) && (channel <= 180))
{
switch(wParam) {
case IDC_RT_EDIT:
scrollBar = GetDlgItem(dialog, IDC_RT_SLIDER);
rfRot.val = channel;
break;
case IDC_RR_EDIT:
scrollBar = GetDlgItem(dialog, IDC_RR_SLIDER);
rfRot.repeat = channel;
break;
}
SetScrollPos(scrollBar, SB_CTL, channel, TRUE);
}
else
{
switch(wID) {
case IDC_RT_EDIT:
scrollBar = GetDlgItem(dialog, IDC_RT_SLIDER);
break;
case IDC_RR_EDIT:
scrollBar = GetDlgItem(dialog, IDC_RR_SLIDER);
break;
}
channel = GetScrollPos(scrollBar, SB_CTL);
sprintf(buffer, "%d", channel);
SetDlgItemText(dialog, wID, buffer);
}
}
break;
case IDOK:
if(IsDlgButtonChecked(dialog,IDR_COMBINE_PRE)) rfRot.combine=rwPRECONCAT;
else if(IsDlgButtonChecked(dialog,IDR_COMBINE_POST)) rfRot.combine=rwPOSTCONCAT;
EndDialog(dialog, IDOK);
break;
case IDCANCEL:
EndDialog(dialog, IDCANCEL);
break;
}
return TRUE;
}
}
return FALSE;
}
BOOL CALLBACK
PRTDlgProc(HWND dialog, UINT message, WPARAM wParam, LPARAM lParam)
{
char buffer[10];
HWND scrollBar=NULL;
int code,pos=0,newPos,channel,id,maxs=0;
switch (message)
{
case WM_INITDIALOG:
SetScrollRange(GetDlgItem(dialog, IDC_RPRT_SLIDER), SB_CTL, 0, 500, FALSE);
SetScrollRange(GetDlgItem(dialog, IDC_APRT_SLIDER), SB_CTL, -180,180, FALSE);
SetScrollPos(GetDlgItem(dialog, IDC_RPRT_SLIDER), SB_CTL, rfLoc.repeat, FALSE);
SetScrollPos(GetDlgItem(dialog, IDC_APRT_SLIDER), SB_CTL, (int)rfLoc.val, FALSE);
/* Initialize the edit controls. */
sprintf(buffer, "%4d", rfLoc.repeat);
SetDlgItemText(dialog, IDC_RPRT_EDIT, buffer);
sprintf(buffer, "%3d", rfLoc.val);
SetDlgItemText(dialog, IDC_APRT_EDIT, buffer);
return FALSE;
case WM_HSCROLL:
#if defined(WIN32)
code = (int)LOWORD(wParam);
newPos = (int)HIWORD(wParam);
scrollBar = (HWND)lParam;
id = (int)GetWindowLong(scrollBar, GWL_ID);
#else
code = (int)wParam;
newPos = (int)LOWORD(lParam);
scrollBar = (HWND)HIWORD(lParam);
id = (int)GetWindowWord(scrollBar, GWW_ID);
#endif
/* As we preview continuously SB_ENDSCROLL is not important to us. */
if (code == SB_ENDSCROLL) return TRUE;
/* Update the scroll bar. */
switch (id)
{
case IDC_RPRT_SLIDER:
maxs = 1000;
break;
case IDC_APRT_SLIDER:
maxs = 360;
break;
}
switch (code)
{
case SB_BOTTOM: pos = maxs; break;
case SB_LINEDOWN: pos += maxs/10; break;
case SB_LINEUP: pos -= maxs/10; break;
case SB_PAGEDOWN: pos += maxs/2; break;
case SB_PAGEUP: pos -= maxs/2; break;
case SB_THUMBTRACK: pos = newPos; break;
case SB_THUMBPOSITION: pos = newPos; break;
case SB_TOP: pos = 0; break;
}
/*
* Clamp the position to the valid range.
*/
if (pos < -maxs/2) pos = -maxs/2;
else if (pos > maxs/2) pos = maxs/2;
SetScrollPos(scrollBar, SB_CTL, pos, TRUE);
/*
* Compute the new translation(depending on which channel has changed)
* and update the appropriate edit control.
*/
switch (id)
{
case IDC_RPRT_SLIDER:
sprintf(buffer, "%3d", pos);
SetDlgItemText(dialog, IDC_RPRT_EDIT, buffer);
rfLoc.repeat = pos;
break;
case IDC_APRT_SLIDER:
sprintf(buffer, "%3d", pos);
SetDlgItemText(dialog, IDC_APRT_EDIT, buffer);
rfLoc.val = pos;
break;
}
return TRUE;
case WM_COMMAND:
{
#ifdef WIN32
HWND hwndCtl = (HWND) lParam;
WORD wID = LOWORD(wParam);
WORD wNotifyCode = HIWORD(wParam);
#else
HWND hwndCtl = (HWND) LOWORD(lParam);
WORD wID = wParam;
WORD wNotifyCode = HIWORD(lParam);
#endif
switch (wID)
{
case IDC_RPRT_EDIT: case IDC_APRT_EDIT:
/* For the edit controls we only take any notice when the
* control loses the input focus. */
if (wNotifyCode == EN_KILLFOCUS)
{
/* Get the edit control's text. */
GetDlgItemText(dialog, wID, buffer, sizeof(buffer));
/* Ensure its a valid value. */
if ((sscanf(buffer, "%d", &channel) == 1) &&
(channel >= -180) && (channel <= 180))
{
switch(wParam) {
case IDC_RPRT_EDIT:
scrollBar = GetDlgItem(dialog, IDC_RPRT_SLIDER);
rfLoc.repeat = channel;
break;
case IDC_APRT_EDIT:
scrollBar = GetDlgItem(dialog, IDC_APRT_SLIDER);
rfLoc.val = channel;
break;
}
SetScrollPos(scrollBar, SB_CTL, channel, TRUE);
}
else
{
switch(wParam) {
case IDC_RPRT_EDIT:
scrollBar = GetDlgItem(dialog, IDC_RPRT_SLIDER);
break;
case IDC_APRT_EDIT:
scrollBar = GetDlgItem(dialog, IDC_APRT_SLIDER);
break;
}
channel = GetScrollPos(scrollBar, SB_CTL);
sprintf(buffer, "%d", channel);
SetDlgItemText(dialog, wID, buffer);
}
}
break;
case IDOK:
EndDialog(dialog, IDOK);
break;
case IDCANCEL:
EndDialog(dialog, IDCANCEL);
break;
}
return TRUE;
}
}
return FALSE;
}
BOOL CALLBACK
TranslateDlgProc(HWND dialog, UINT message, WPARAM wParam, LPARAM lParam)
{
char buffer[10];
HWND scrollBar=NULL;
int code;
int pos;
int newPos;
int channel;
int id;
float fvalue;
switch (message)
{
case WM_INITDIALOG:
switch(rfTran.combine) {
case rwPRECONCAT:
CheckRadioButton(dialog,IDT_COMBINE_PRE,IDT_COMBINE_POST,IDT_COMBINE_PRE);
break;
case rwPOSTCONCAT:
CheckRadioButton(dialog,IDT_COMBINE_PRE,IDT_COMBINE_POST,IDT_COMBINE_POST);
break;
}
/*
* Initialize the scrollbars.
*/
SetScrollRange(GetDlgItem(dialog, IDC_TX_SLIDER), SB_CTL, -MAX_SCROLL/2, MAX_SCROLL/2, FALSE);
SetScrollRange(GetDlgItem(dialog, IDC_TY_SLIDER), SB_CTL, -MAX_SCROLL/2, MAX_SCROLL/2, FALSE);
SetScrollRange(GetDlgItem(dialog, IDC_TZ_SLIDER), SB_CTL, -MAX_SCROLL/2, MAX_SCROLL/2, FALSE);
SetScrollPos(GetDlgItem(dialog, IDC_TX_SLIDER), SB_CTL, (int)(100*rfTran.x), FALSE);
SetScrollPos(GetDlgItem(dialog, IDC_TY_SLIDER), SB_CTL, (int)(100*rfTran.y), FALSE);
SetScrollPos(GetDlgItem(dialog, IDC_TZ_SLIDER), SB_CTL, (int)(100*rfTran.z), FALSE);
/*
* Initialize the edit controls.
*/
sprintf(buffer, "%2.1f", rfTran.x);
SetDlgItemText(dialog, IDC_TX_EDIT, buffer);
sprintf(buffer, "%2.1f",rfTran.y);
SetDlgItemText(dialog, IDC_TY_EDIT, buffer);
sprintf(buffer, "%2.1f", rfTran.z);
SetDlgItemText(dialog, IDC_TZ_EDIT, buffer);
return FALSE;
case WM_HSCROLL:
#if defined(WIN32)
code = (int)LOWORD(wParam);
newPos = (int)HIWORD(wParam);
scrollBar = (HWND)lParam;
id = (int)GetWindowLong(scrollBar, GWL_ID);
#else
code = (int)wParam;
newPos = (int)LOWORD(lParam);
scrollBar = (HWND)HIWORD(lParam);
id = (int)GetWindowWord(scrollBar, GWW_ID);
#endif
/*
* As we preview continuously SB_ENDSCROLL is not important to us.
*/
if (code == SB_ENDSCROLL) return TRUE;
/*
* Update the scroll bar.
*/
pos = GetScrollPos(scrollBar, SB_CTL);
switch (code)
{
case SB_BOTTOM: pos = MAX_SCROLL; break;
case SB_LINEDOWN: pos += MAX_SCROLL/10; break;
case SB_LINEUP: pos -= MAX_SCROLL/10; break;
case SB_PAGEDOWN: pos += MAX_SCROLL/2; break;
case SB_PAGEUP: pos -= MAX_SCROLL/2; break;
case SB_THUMBTRACK: pos = newPos; break;
case SB_THUMBPOSITION: pos = newPos; break;
case SB_TOP: pos = 0; break;
}
/*
* Clamp the position to the valid range.
*/
if (pos < -MAX_SCROLL/2) pos = -MAX_SCROLL/2;
else if (pos > MAX_SCROLL/2) pos = MAX_SCROLL/2;
SetScrollPos(scrollBar, SB_CTL, pos, TRUE);
/*
* Compute the new translation(depending on which channel has changed)
* and update the appropriate edit control.
*/
switch (id)
{
case IDC_TX_SLIDER:
sprintf(buffer, "%2.1f", (float)pos/100);
SetDlgItemText(dialog, IDC_TX_EDIT, buffer);
rfTran.x = (float)pos/100;
break;
case IDC_TY_SLIDER:
sprintf(buffer, "%2.1f", (float)pos/100);
SetDlgItemText(dialog, IDC_TY_EDIT, buffer);
rfTran.y = (float)pos/100;
break;
case IDC_TZ_SLIDER:
sprintf(buffer, "%2.1f", (float)pos/100);
SetDlgItemText(dialog, IDC_TZ_EDIT, buffer);
rfTran.z = (float)pos/100;
break;
}
return TRUE;
case WM_COMMAND:
{
#ifdef WIN32
HWND hwndCtl = (HWND) lParam;
WORD wID = LOWORD(wParam);
WORD wNotifyCode = HIWORD(wParam);
#else
HWND hwndCtl = (HWND) LOWORD(lParam);
WORD wID = wParam;
WORD wNotifyCode = HIWORD(lParam);
#endif
switch (wID)
{
case IDC_TX_EDIT:
case IDC_TY_EDIT:
case IDC_TZ_EDIT:
/*
* For the edit controls we only take any notice when the
* control loses the input focus.
*/
if (wNotifyCode == EN_KILLFOCUS)
{
/*
* Get the edit control's text.
*/
GetDlgItemText(dialog, wID, buffer, sizeof(buffer));
/*
* Ensure its a valid value.
*/
if( (sscanf(buffer, "%f", &fvalue) == 1) &&
(fvalue >= -MAX_SCROLL/2) && (fvalue <= MAX_SCROLL/2))
{
/*
* Build the new current tanslation and update the appropriate
* slider.
*/
switch (wID)
{
case IDC_TX_EDIT:
scrollBar = GetDlgItem(dialog, IDC_TX_SLIDER);
rfTran.x = fvalue;
break;
case IDC_TY_EDIT:
scrollBar = GetDlgItem(dialog, IDC_TY_SLIDER);
rfTran.y = fvalue;
break;
case IDC_TZ_EDIT:
scrollBar = GetDlgItem(dialog, IDC_TZ_SLIDER);
rfTran.z = fvalue;
break;
}
SetScrollPos(scrollBar, SB_CTL, (int)(fvalue*100), TRUE);
}
else
{
/*
* Not valid, put the existing value back.
*/
switch (wID)
{
case IDC_TX_EDIT: scrollBar = GetDlgItem(dialog, IDC_TX_SLIDER); break;
case IDC_TY_EDIT: scrollBar = GetDlgItem(dialog, IDC_TY_SLIDER); break;
case IDC_TZ_EDIT: scrollBar = GetDlgItem(dialog, IDC_TZ_SLIDER); break;
}
channel = GetScrollPos(scrollBar, SB_CTL);
sprintf(buffer, "%2.1f", (float)channel/100);
SetDlgItemText(dialog, wID, buffer);
}
}
break;
case IDOK:
if(IsDlgButtonChecked(dialog,IDT_COMBINE_PRE)) rfTran.combine=rwPRECONCAT;
else if(IsDlgButtonChecked(dialog,IDT_COMBINE_POST)) rfTran.combine=rwPOSTCONCAT;
EndDialog(dialog, IDOK);
break;
case IDCANCEL:
EndDialog(dialog, IDCANCEL);
break;
}
return TRUE;
}
}
return FALSE;
}
BOOL CALLBACK
ScaleDlgProc(HWND dialog, UINT message, WPARAM wParam, LPARAM lParam)
{
char buffer[10];
HWND scrollBar=NULL;
int code;
int pos;
int newPos;
int channel;
int id;
float fvalue;
switch (message)
{
case WM_INITDIALOG:
switch(rfScale.combine) {
case rwPRECONCAT:
CheckRadioButton(dialog,IDS_COMBINE_PRE,IDS_COMBINE_POST,IDS_COMBINE_PRE);
break;
case rwPOSTCONCAT:
CheckRadioButton(dialog,IDS_COMBINE_PRE,IDS_COMBINE_POST,IDS_COMBINE_POST);
break;
}
/*
* Initialize the scrollbars.
*/
SetScrollRange(GetDlgItem(dialog, IDC_SX_SLIDER), SB_CTL, -MAX_SCROLLS/2, MAX_SCROLLS/2, FALSE);
SetScrollRange(GetDlgItem(dialog, IDC_SY_SLIDER), SB_CTL, -MAX_SCROLLS/2, MAX_SCROLLS/2, FALSE);
SetScrollRange(GetDlgItem(dialog, IDC_SZ_SLIDER), SB_CTL, -MAX_SCROLLS/2, MAX_SCROLLS/2, FALSE);
SetScrollPos(GetDlgItem(dialog, IDC_SX_SLIDER), SB_CTL, (int)(100*rfScale.x), FALSE);
SetScrollPos(GetDlgItem(dialog, IDC_SY_SLIDER), SB_CTL, (int)(100*rfScale.y), FALSE);
SetScrollPos(GetDlgItem(dialog, IDC_SZ_SLIDER), SB_CTL, (int)(100*rfScale.z), FALSE);
/*
* Initialize the edit controls.
*/
sprintf(buffer, "%3.2f", rfScale.x);
SetDlgItemText(dialog, IDC_SX_EDIT, buffer);
sprintf(buffer, "%3.2f",rfScale.y);
SetDlgItemText(dialog, IDC_SY_EDIT, buffer);
sprintf(buffer, "%3.2f", rfScale.z);
SetDlgItemText(dialog, IDC_SZ_EDIT, buffer);
return FALSE;
case WM_HSCROLL:
#if defined(WIN32)
code = (int)LOWORD(wParam);
newPos = (int)HIWORD(wParam);
scrollBar = (HWND)lParam;
id = (int)GetWindowLong(scrollBar, GWL_ID);
#else
code = (int)wParam;
newPos = (int)LOWORD(lParam);
scrollBar = (HWND)HIWORD(lParam);
id = (int)GetWindowWord(scrollBar, GWW_ID);
#endif
/*
* As we preview continuously SB_ENDSCROLL is not important to us.
*/
if (code == SB_ENDSCROLL) return TRUE;
/*
* Update the scroll bar.
*/
pos = GetScrollPos(scrollBar, SB_CTL);
switch (code)
{
case SB_BOTTOM: pos = MAX_SCROLLS; break;
case SB_LINEDOWN: pos += MAX_SCROLLS/10; break;
case SB_LINEUP: pos -= MAX_SCROLLS/10; break;
case SB_PAGEDOWN: pos += MAX_SCROLLS/2; break;
case SB_PAGEUP: pos -= MAX_SCROLLS/2; break;
case SB_THUMBTRACK: pos = newPos; break;
case SB_THUMBPOSITION: pos = newPos; break;
case SB_TOP: pos = 0; break;
}
/*
* Clamp the position to the valid range.
*/
if (pos < -MAX_SCROLLS/2) pos = -MAX_SCROLLS/2;
else if (pos > MAX_SCROLLS/2) pos = MAX_SCROLLS/2;
SetScrollPos(scrollBar, SB_CTL, pos, TRUE);
/*
* Compute the new scale depending on which channel has changed)
* and update the appropriate edit control.
*/
switch (id)
{
case IDC_SX_SLIDER:
sprintf(buffer, "%3.2f", (float)pos/100);
SetDlgItemText(dialog, IDC_SX_EDIT, buffer);
rfScale.x = (float)pos/100;
break;
case IDC_SY_SLIDER:
sprintf(buffer, "%3.2f", (float)pos/100);
SetDlgItemText(dialog, IDC_SY_EDIT, buffer);
rfScale.y = (float)pos/100;
break;
case IDC_SZ_SLIDER:
sprintf(buffer, "%3.2f", (float)pos/100);
SetDlgItemText(dialog, IDC_SZ_EDIT, buffer);
rfScale.z = (float)pos/100;
break;
}
return TRUE;
case WM_COMMAND:
{
#ifdef WIN32
HWND hwndCtl = (HWND) lParam;
WORD wID = LOWORD(wParam);
WORD wNotifyCode = HIWORD(wParam);
#else
HWND hwndCtl = (HWND) LOWORD(lParam);
WORD wID = wParam;
WORD wNotifyCode = HIWORD(lParam);
#endif
switch (wID)
{
case IDC_SX_EDIT:
case IDC_SY_EDIT:
case IDC_SZ_EDIT:
/*
* For the edit controls we only take any notice when the
* control loses the input focus.
*/
if (wNotifyCode == EN_KILLFOCUS)
{
/*
* Get the edit control's text.
*/
GetDlgItemText(dialog, wID, buffer, sizeof(buffer));
/*
* Ensure its a valid value.
*/
if( (sscanf(buffer, "%f", &fvalue) == 1) &&
(fvalue*100 >= -MAX_SCROLLS/2) && (fvalue*100 <= MAX_SCROLLS/2))
{
/*
* Build the new current tanslation and update the appropriate
* slider.
*/
switch (wID)
{
case IDC_SX_EDIT:
scrollBar = GetDlgItem(dialog, IDC_SX_SLIDER);
rfScale.x = fvalue;
break;
case IDC_SY_EDIT:
scrollBar = GetDlgItem(dialog, IDC_SY_SLIDER);
rfScale.y = fvalue;
break;
case IDC_SZ_EDIT:
scrollBar = GetDlgItem(dialog, IDC_SZ_SLIDER);
rfScale.z = fvalue;
break;
}
SetScrollPos(scrollBar, SB_CTL, (int)(fvalue*100), TRUE);
}
else
{
/*
* Not valid, put the existing value back.
*/
switch (wID)
{
case IDC_SX_EDIT: scrollBar = GetDlgItem(dialog, IDC_SX_SLIDER); break;
case IDC_SY_EDIT: scrollBar = GetDlgItem(dialog, IDC_SY_SLIDER); break;
case IDC_SZ_EDIT: scrollBar = GetDlgItem(dialog, IDC_SZ_SLIDER); break;
}
channel = GetScrollPos(scrollBar, SB_CTL);
sprintf(buffer, "%3.2f", (float)channel/100);
SetDlgItemText(dialog, wParam, buffer);
}
}
break;
case IDOK:
if(IsDlgButtonChecked(dialog,IDS_COMBINE_PRE)) rfScale.combine=rwPRECONCAT;
else if(IsDlgButtonChecked(dialog,IDS_COMBINE_POST)) rfScale.combine=rwPOSTCONCAT;
EndDialog(dialog, IDOK);
break;
case IDCANCEL:
EndDialog(dialog, IDCANCEL);
break;
}
return TRUE;
}
}
return FALSE;
}
/*
* The debug box dialog procedure.
*/
BOOL CALLBACK
DebugDlgProc(HWND dialog, UINT message, WPARAM wParam, LPARAM lParam)
{
lParam = lParam;
switch (message)
{
case WM_INITDIALOG:
switch(rfDebug.Severity) {
case rwINFORM:
CheckRadioButton(dialog,IDC_SEVERITY_INFORM,IDC_SEVERITY_ERROR,IDC_SEVERITY_INFORM);
break;
case rwWARNING:
CheckRadioButton(dialog,IDC_SEVERITY_INFORM,IDC_SEVERITY_ERROR,IDC_SEVERITY_WARNING);
break;
case rwERROR:
CheckRadioButton(dialog,IDC_SEVERITY_INFORM,IDC_SEVERITY_ERROR,IDC_SEVERITY_ERROR);
break;
}
if(rfDebug.Message == rwDISABLE) CheckDlgButton(dialog,IDC_DEBUG_MESSAGE, 0);
else CheckDlgButton(dialog,IDC_DEBUG_MESSAGE, 1);
if(rfDebug.Assertion == rwDISABLE) CheckDlgButton(dialog,IDC_DEBUG_ASSERTION, 0);
else CheckDlgButton(dialog,IDC_DEBUG_ASSERTION, 1);
if(rfDebug.Script == rwDISABLE) CheckDlgButton(dialog,IDC_DEBUG_SCRIPT, 0);
else CheckDlgButton(dialog,IDC_DEBUG_SCRIPT, 1);
if(rfDebug.Trace == rwDISABLE) CheckDlgButton(dialog,IDC_DEBUG_TRACE, 0);
else CheckDlgButton(dialog,IDC_DEBUG_TRACE, 1);
if(rfDebug.Output == rwDISABLE) CheckDlgButton(dialog,IDC_DEBUG_OUTPUT, 0);
else CheckDlgButton(dialog,IDC_DEBUG_OUTPUT, 1);
return TRUE;
case WM_COMMAND:
#ifdef WIN32
switch (LOWORD(wParam))
#else
switch (wParam)
#endif
{
case IDOK:
if(IsDlgButtonChecked(dialog,IDC_SEVERITY_INFORM)) rfDebug.Severity=rwINFORM;
else if(IsDlgButtonChecked(dialog,IDC_SEVERITY_WARNING)) rfDebug.Severity=rwWARNING;
else if(IsDlgButtonChecked(dialog,IDC_SEVERITY_ERROR)) rfDebug.Severity=rwERROR;
RwSetDebugSeverity(rfDebug.Severity);
if(IsDlgButtonChecked(dialog,IDC_DEBUG_MESSAGE)) {
rfDebug.Message=rwENABLE;
RwSetDebugMessageState(rwON);
}
else {
rfDebug.Message=rwDISABLE;
RwSetDebugMessageState(rwOFF);
}
if(IsDlgButtonChecked(dialog,IDC_DEBUG_ASSERTION)) {
rfDebug.Assertion=rwENABLE;
RwSetDebugAssertionState(rwON);
}
else {
rfDebug.Assertion=rwDISABLE;
RwSetDebugAssertionState(rwOFF);
}
if(IsDlgButtonChecked(dialog,IDC_DEBUG_SCRIPT)) {
rfDebug.Script=rwENABLE;
RwSetDebugScriptState(rwON);
}
else {
rfDebug.Script=rwDISABLE;
RwSetDebugScriptState(rwOFF);
}
if(IsDlgButtonChecked(dialog,IDC_DEBUG_TRACE)) {
rfDebug.Trace=rwENABLE;
RwSetDebugTraceState(rwON);
}
else {
rfDebug.Trace=rwDISABLE;
RwSetDebugTraceState(rwOFF);
}
if(IsDlgButtonChecked(dialog,IDC_DEBUG_OUTPUT)) {
rfDebug.Output=rwENABLE;
RwSetDebugOutputState(rwON);
}
else {
rfDebug.Output=rwDISABLE;
RwSetDebugOutputState(rwOFF);
}
EndDialog(dialog, IDOK);
break;
case IDCANCEL:
EndDialog(dialog, IDCANCEL);
break; }
return TRUE;
}
return FALSE;
}