diff options
Diffstat (limited to 'utils/qc_eyes')
22 files changed, 1440 insertions, 0 deletions
diff --git a/utils/qc_eyes/QC_Eyes.cpp b/utils/qc_eyes/QC_Eyes.cpp new file mode 100644 index 0000000..179391d --- /dev/null +++ b/utils/qc_eyes/QC_Eyes.cpp @@ -0,0 +1,73 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// QC_Eyes.cpp : Defines the class behaviors for the application. +// + +#include "stdafx.h" +#include "QC_Eyes.h" +#include "QC_EyesDlg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CQC_EyesApp + +BEGIN_MESSAGE_MAP(CQC_EyesApp, CWinApp) + //{{AFX_MSG_MAP(CQC_EyesApp) + // NOTE - the ClassWizard will add and remove mapping macros here. + // DO NOT EDIT what you see in these blocks of generated code! + //}}AFX_MSG + ON_COMMAND(ID_HELP, CWinApp::OnHelp) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CQC_EyesApp construction + +CQC_EyesApp::CQC_EyesApp() +{ + // TODO: add construction code here, + // Place all significant initialization in InitInstance +} + +///////////////////////////////////////////////////////////////////////////// +// The one and only CQC_EyesApp object + +CQC_EyesApp theApp; + +///////////////////////////////////////////////////////////////////////////// +// CQC_EyesApp initialization + +BOOL CQC_EyesApp::InitInstance() +{ + AfxEnableControlContainer(); + + // Standard initialization + // If you are not using these features and wish to reduce the size + // of your final executable, you should remove from the following + // the specific initialization routines you do not need. + +#ifdef _AFXDLL + Enable3dControls(); // Call this when using MFC in a shared DLL +#endif + + CQC_EyesDlg dlg; + m_pMainWnd = &dlg; + INT_PTR nResponse = dlg.DoModal(); + if (nResponse == IDOK) + { + // TODO: Place code here to handle when the dialog is + // dismissed with OK + } + else if (nResponse == IDCANCEL) + { + // TODO: Place code here to handle when the dialog is + // dismissed with Cancel + } + + // Since the dialog has been closed, return FALSE so that we exit the + // application, rather than start the application's message pump. + return FALSE; +} diff --git a/utils/qc_eyes/QC_Eyes.h b/utils/qc_eyes/QC_Eyes.h new file mode 100644 index 0000000..e1068d6 --- /dev/null +++ b/utils/qc_eyes/QC_Eyes.h @@ -0,0 +1,50 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// QC_Eyes.h : main header file for the QC_EYES application +// + +#if !defined(AFX_QC_EYES_H__398BAF8D_D3C0_4326_BEF0_5129884EE1A3__INCLUDED_) +#define AFX_QC_EYES_H__398BAF8D_D3C0_4326_BEF0_5129884EE1A3__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#ifndef __AFXWIN_H__ + #error include 'stdafx.h' before including this file for PCH +#endif + +#include "resource.h" // main symbols + +///////////////////////////////////////////////////////////////////////////// +// CQC_EyesApp: +// See QC_Eyes.cpp for the implementation of this class +// + +class CQC_EyesApp : public CWinApp +{ +public: + CQC_EyesApp(); + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CQC_EyesApp) + public: + virtual BOOL InitInstance(); + //}}AFX_VIRTUAL + +// Implementation + + //{{AFX_MSG(CQC_EyesApp) + // NOTE - the ClassWizard will add and remove member functions here. + // DO NOT EDIT what you see in these blocks of generated code ! + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_QC_EYES_H__398BAF8D_D3C0_4326_BEF0_5129884EE1A3__INCLUDED_) diff --git a/utils/qc_eyes/QC_Eyes.rc b/utils/qc_eyes/QC_Eyes.rc new file mode 100644 index 0000000..487ac39 --- /dev/null +++ b/utils/qc_eyes/QC_Eyes.rc @@ -0,0 +1,276 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "#define _AFX_NO_SPLITTER_RESOURCES\r\n" + "#define _AFX_NO_OLE_RESOURCES\r\n" + "#define _AFX_NO_TRACKER_RESOURCES\r\n" + "#define _AFX_NO_PROPERTY_RESOURCES\r\n" + "\r\n" + "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" + "#ifdef _WIN32\r\n" + "LANGUAGE 9, 1\r\n" + "#pragma code_page(1252)\r\n" + "#endif //_WIN32\r\n" + "#include ""res\\QC_Eyes.rc2"" // non-Microsoft Visual C++ edited resources\r\n" + "#include ""afxres.rc"" // Standard components\r\n" + "#endif\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDR_MAINFRAME ICON "res\\QC_Eyes.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_QC_EYES_DIALOG DIALOGEX 0, 0, 695, 510 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | + WS_SYSMENU +EXSTYLE WS_EX_APPWINDOW +CAPTION "QC Eyes" +FONT 8, "MS Sans Serif", 0, 0, 0x1 +BEGIN + EDITTEXT IDC_REFERENCE_FILENAME,87,24,93,14,ES_AUTOHSCROLL + EDITTEXT IDC_EXPRESSIONS_FILENAME,87,42,93,14,ES_AUTOHSCROLL + EDITTEXT IDC_MODEL_FILENAME,87,60,93,14,ES_AUTOHSCROLL + EDITTEXT IDC_RIGHT_EYE_X,19,140,40,14,ES_AUTOHSCROLL + EDITTEXT IDC_RIGHT_EYE_Y,83,140,40,14,ES_AUTOHSCROLL + EDITTEXT IDC_RIGHT_EYE_Z,147,140,40,14,ES_AUTOHSCROLL + EDITTEXT IDC_LEFT_EYE_X,19,205,40,14,ES_AUTOHSCROLL + EDITTEXT IDC_LEFT_EYE_Y,83,205,40,14,ES_AUTOHSCROLL + EDITTEXT IDC_LEFT_EYE_Z,147,205,40,14,ES_AUTOHSCROLL + GROUPBOX "3D Platform",IDC_STATIC,219,7,126,47 + GROUPBOX "Options",IDC_STATIC,219,58,126,47 + GROUPBOX "Upper Lid Positions",IDC_STATIC,219,109,126,60 + EDITTEXT IDC_UPPER_LID_RAISED,264,118,74,14,ES_AUTOHSCROLL + EDITTEXT IDC_UPPER_LID_NEUTRAL,264,134,74,14,ES_AUTOHSCROLL + EDITTEXT IDC_UPPER_LID_LOWERED,264,150,74,14,ES_AUTOHSCROLL + EDITTEXT IDC_LOWER_LID_RAISED,264,184,74,14,ES_AUTOHSCROLL + EDITTEXT IDC_LOWER_LID_NEUTRAL,264,200,74,14,ES_AUTOHSCROLL + EDITTEXT IDC_LOWER_LID_LOWERED,264,216,74,14,ES_AUTOHSCROLL + GROUPBOX "Iris Color",IDC_STATIC,351,175,75,60 + GROUPBOX "Eye White Color",IDC_STATIC,431,175,126,60 + EDITTEXT IDC_IRIS_SIZE,469,21,59,14,ES_AUTOHSCROLL + EDITTEXT IDC_EYEBALL_SIZE,469,43,59,14,ES_AUTOHSCROLL + PUSHBUTTON "Create QC Text",IDC_CREATE_QC_TEXT,7,243,93,19 + PUSHBUTTON "Copy Text To Clipboard",IDC_COPY_TEXT_TO_CLIPBOARD,109, + 243,93,19 + EDITTEXT IDC_OUTPUT_TEXT,7,271,681,232,ES_MULTILINE | + ES_AUTOHSCROLL + CONTROL "Y Axis Up (XSI, Maya)",IDC_Y_AXIS_UP,"Button", + BS_AUTORADIOBUTTON | WS_GROUP,228,21,92,10 + CONTROL "Z Axis Up (MAX)",IDC_Z_AXIS_UP,"Button", + BS_AUTORADIOBUTTON,228,36,94,10 + CONTROL "Default Controls",IDC_DEFAULT_CONTROLS,"Button", + BS_AUTORADIOBUTTON | WS_GROUP,228,72,92,10 + CONTROL "Advanced Controls",IDC_ADVANCED_CONTROLS,"Button", + BS_AUTORADIOBUTTON,228,88,94,10 + RADIOBUTTON "Brown Irises",IDC_IRIS_COLOR_BROWN,360,188,55,10, + WS_GROUP + RADIOBUTTON "Green Irises",IDC_IRIS_COLOR_GREEN,360,203,54,10 + RADIOBUTTON "Blue Irises",IDC_IRIS_COLOR_BLUE,360,218,54,10 + RADIOBUTTON "Light Whites (paler skin tones)",IDC_EYE_COLOR_LIGHT, + 438,193,108,10,WS_GROUP + RADIOBUTTON "Dark Whites (darker skin tones)",IDC_EYE_COLOR_DARK,438, + 214,112,10 + RTEXT "Reference Filename:",IDC_STATIC,13,27,70,8 + RTEXT "Expressions Filename:",IDC_STATIC,13,45,70,8 + RTEXT "Model Filename:",IDC_STATIC,13,64,70,8 + LTEXT ".SMD",IDC_STATIC,184,29,19,8 + LTEXT ".VTA",IDC_STATIC,184,47,17,8 + LTEXT ".MDL",IDC_STATIC,184,65,18,8 + GROUPBOX "Eye Positions",IDC_STATIC,7,95,200,140 + GROUPBOX "Right Eye",IDC_STATIC,14,108,185,56 + LTEXT "Y Position",IDC_STATIC,85,126,32,8 + LTEXT "X Position",IDC_STATIC,21,126,32,8 + LTEXT "Z Position",IDC_STATIC,149,126,32,8 + GROUPBOX "Left Eye",IDC_STATIC,14,173,185,56 + LTEXT "Y Position",IDC_STATIC,85,191,32,8 + LTEXT "X Position",IDC_STATIC,21,191,32,8 + LTEXT "Z Position",IDC_STATIC,149,191,32,8 + GROUPBOX "Filenames",IDC_STATIC,7,7,200,78 + CONTROL "",IDC_PICTURES,"Static",SS_BITMAP,352,7,336,162 + RTEXT "Raised:",IDC_STATIC,228,122,32,8 + RTEXT "Neutral:",IDC_STATIC,227,137,32,8 + RTEXT "Lowered:",IDC_STATIC,227,153,32,8 + GROUPBOX "Lowered Lid Positions",IDC_STATIC,219,175,126,60 + RTEXT "Raised:",IDC_STATIC,228,188,32,8 + RTEXT "Neutral:",IDC_STATIC,227,204,32,8 + RTEXT "Lowered:",IDC_STATIC,227,220,32,8 + GROUPBOX "Eye Detail Control",IDC_EYE_DETAIL_CONTROL_FRAME,414,7, + 140,73 + RTEXT "Iris Size:",IDC_IRIS_SIZE_LABEL,417,25,48,8 + RTEXT "Eyeball Size:",IDC_EYEBALL_SIZE_LABEL,417,47,48,8 + CTEXT "",IDC_PICTURE_LABEL,375,162,285,8 + CONTROL "Enable Independent Left Lid Control", + IDC_LEFT_LID_CONTROL,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,421,62,128,10 + GROUPBOX "Upper Left Lid Positions",IDC_UPPER_LEFT_LID_PANEL,562, + 7,126,60 + EDITTEXT IDC_UPPER_LEFT_LID_RAISED,607,16,74,14,ES_AUTOHSCROLL + EDITTEXT IDC_UPPER_LEFT_LID_NEUTRAL,607,32,74,14,ES_AUTOHSCROLL + EDITTEXT IDC_UPPER_LEFT_LID_LOWERED,607,48,74,14,ES_AUTOHSCROLL + EDITTEXT IDC_LOWER_LEFT_LID_RAISED,607,82,74,14,ES_AUTOHSCROLL + EDITTEXT IDC_LOWER_LEFT_LID_NEUTRAL,607,98,74,14,ES_AUTOHSCROLL + EDITTEXT IDC_LOWER_LEFT_LID_LOWERED,607,114,74,14,ES_AUTOHSCROLL + RTEXT "Raised:",IDC_UPPER_LEFT_LID_RAISED_LABEL,571,20,32,8 + RTEXT "Neutral:",IDC_UPPER_LEFT_LID_NEUTRAL_LABEL,570,35,32,8 + RTEXT "Lowered:",IDC_UPPER_LEFT_LID_LOWERED_LABEL,570,51,32,8 + GROUPBOX "Lowered Left Lid Positions",IDC_LOWER_LEFT_LID_PANEL, + 562,73,126,60 + RTEXT "Raised:",IDC_LOWER_LEFT_LID_RAISED_LABEL,571,86,32,8 + RTEXT "Neutral:",IDC_LOWER_LEFT_LID_NEUTRAL_LABEL,570,102,32,8 + RTEXT "Lowered:",IDC_LOWER_LEFT_LID_LOWERED_LABEL,570,118,32,8 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904B0" + BEGIN + VALUE "FileDescription", "QC_Eyes MFC Application" + VALUE "FileVersion", "1, 0, 0, 1" + VALUE "InternalName", "QC_Eyes" + VALUE "LegalCopyright", "Copyright (C) 2005" + VALUE "OriginalFilename", "QC_Eyes.EXE" + VALUE "ProductName", "QC_Eyes Application" + VALUE "ProductVersion", "1, 0, 0, 1" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_QC_EYES_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 688 + TOPMARGIN, 7 + BOTTOMMARGIN, 503 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Bitmap +// + +IDB_EYE_DEFAULT BITMAP "res\\eye_default.bmp" +IDB_EYE_LOWER_HI BITMAP "res\\eye_lower_hi.bmp" +IDB_EYE_LOWER_LO BITMAP "res\\eye_lower_lo.bmp" +IDB_EYE_LOWER_MID BITMAP "res\\eye_lower_mid.bmp" +IDB_EYE_UPPER_HI BITMAP "res\\eye_upper_hi.bmp" +IDB_EYE_UPPER_LO BITMAP "res\\eye_upper_lo.bmp" +IDB_EYE_UPPER_MID BITMAP "res\\eye_upper_mid.bmp" +IDB_EYE_XY_L BITMAP "res\\eye_xy_l.bmp" +IDB_EYE_XY_R BITMAP "res\\eye_xy_r.bmp" +IDB_EYE_Z_L BITMAP "res\\eye_z_l.bmp" +IDB_EYE_Z_R BITMAP "res\\eye_z_r.bmp" +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// +#define _AFX_NO_SPLITTER_RESOURCES +#define _AFX_NO_OLE_RESOURCES +#define _AFX_NO_TRACKER_RESOURCES +#define _AFX_NO_PROPERTY_RESOURCES + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE 9, 1 +#pragma code_page(1252) +#endif //_WIN32 +#include "res\QC_Eyes.rc2" // non-Microsoft Visual C++ edited resources +#include "afxres.rc" // Standard components +#endif + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/utils/qc_eyes/QC_EyesDlg.cpp b/utils/qc_eyes/QC_EyesDlg.cpp new file mode 100644 index 0000000..d76d916 --- /dev/null +++ b/utils/qc_eyes/QC_EyesDlg.cpp @@ -0,0 +1,705 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// QC_EyesDlg.cpp : implementation file +// + +#include "stdafx.h" +#include <math.h> +#include "QC_Eyes.h" +#include "QC_EyesDlg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CQC_EyesDlg dialog + +CQC_EyesDlg::CQC_EyesDlg(CWnd* pParent /*=NULL*/) + : CDialog(CQC_EyesDlg::IDD, pParent) +{ + //{{AFX_DATA_INIT(CQC_EyesDlg) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 + m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); + m_pBitmapHead = NULL; +} + +void CQC_EyesDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CQC_EyesDlg) + DDX_Control(pDX, IDC_LEFT_LID_CONTROL, m_IndependentLeftLidControl); + DDX_Control(pDX, IDC_PICTURES, m_PictureControl); + //}}AFX_DATA_MAP +} + +BEGIN_MESSAGE_MAP(CQC_EyesDlg, CDialog) + //{{AFX_MSG_MAP(CQC_EyesDlg) + ON_WM_PAINT() + ON_WM_QUERYDRAGICON() + ON_BN_CLICKED(IDC_CREATE_QC_TEXT, OnCreateQcText) + ON_BN_CLICKED(IDC_IRIS_COLOR_BROWN, OnIrisColorBrown) + ON_BN_CLICKED(IDC_IRIS_COLOR_GREEN, OnIrisColorGreen) + ON_BN_CLICKED(IDC_IRIS_COLOR_BLUE, OnIrisColorBlue) + ON_BN_CLICKED(IDC_EYE_COLOR_DARK, OnEyeColorDark) + ON_BN_CLICKED(IDC_EYE_COLOR_LIGHT, OnEyeColorLight) + ON_EN_SETFOCUS(IDC_RIGHT_EYE_X, OnSetfocusRightEyeX) + ON_EN_SETFOCUS(IDC_RIGHT_EYE_Y, OnSetfocusRightEyeY) + ON_EN_SETFOCUS(IDC_RIGHT_EYE_Z, OnSetfocusRightEyeZ) + ON_EN_SETFOCUS(IDC_LEFT_EYE_X, OnSetfocusLeftEyeX) + ON_EN_SETFOCUS(IDC_LEFT_EYE_Y, OnSetfocusLeftEyeY) + ON_EN_SETFOCUS(IDC_LEFT_EYE_Z, OnSetfocusLeftEyeZ) + ON_EN_SETFOCUS(IDC_UPPER_LID_LOWERED, OnSetfocusUpperLidLowered) + ON_EN_SETFOCUS(IDC_UPPER_LID_NEUTRAL, OnSetfocusUpperLidNeutral) + ON_EN_SETFOCUS(IDC_UPPER_LID_RAISED, OnSetfocusUpperLidRaised) + ON_EN_SETFOCUS(IDC_LOWER_LID_LOWERED, OnSetfocusLowerLidLowered) + ON_EN_SETFOCUS(IDC_LOWER_LID_NEUTRAL, OnSetfocusLowerLidNeutral) + ON_EN_SETFOCUS(IDC_LOWER_LID_RAISED, OnSetfocusLowerLidRaised) + ON_BN_CLICKED(IDC_COPY_TEXT_TO_CLIPBOARD, OnCopyTextToClipboard) + ON_BN_CLICKED(IDC_DEFAULT_CONTROLS, OnDefaultControls) + ON_BN_CLICKED(IDC_ADVANCED_CONTROLS, OnAdvancedControls) + ON_BN_CLICKED(IDC_LEFT_LID_CONTROL, OnLeftLidControl) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + + +void CQC_EyesDlg::AddText( const char *pFormat, ... ) +{ + char tempMsg[4096]; + va_list marker; + va_start( marker, pFormat ); + _vsnprintf( tempMsg, sizeof( tempMsg ), pFormat, marker ); + tempMsg[ ARRAYSIZE(tempMsg) - 1 ] = 0; + va_end( marker ); + + size_t nCharsInBuf = strlen( m_Buf ); + size_t nCharsInMsg = strlen( tempMsg ); + + if ( nCharsInBuf + nCharsInMsg + 1 > m_BufSize ) + { + m_BufSize = nCharsInBuf + nCharsInMsg + 4096; + char *newbuf = new char[m_BufSize]; + memcpy( newbuf, m_Buf, nCharsInBuf + 1 ); + delete [] m_Buf; + m_Buf = newbuf; + } + + strcat( m_Buf, tempMsg ); +} + + +void SendToEditControl( HWND hEditControl, const char *pText ) +{ + LRESULT nLen = SendMessage( hEditControl, EM_GETLIMITTEXT, 0, 0 ); + SendMessage( hEditControl, EM_SETSEL, nLen, nLen ); + SendMessage( hEditControl, EM_REPLACESEL, FALSE, (LPARAM)pText ); +} + + +void FormatAndSendToEditControl( void *hWnd, const char *pText ) +{ + HWND hEditControl = (HWND)hWnd; + + // Translate \n to \r\n. + char outMsg[1024]; + const char *pIn = pText; + char *pOut = outMsg; + while ( *pIn ) + { + if ( *pIn == '\n' ) + { + *pOut = '\r'; + pOut++; + } + *pOut = *pIn; + + ++pIn; + ++pOut; + + if ( pOut - outMsg >= 1020 ) + { + *pOut = 0; + SendToEditControl( hEditControl, outMsg ); + pOut = outMsg; + } + } + *pOut = 0; + SendToEditControl( hEditControl, outMsg ); +} + + +HBITMAP CQC_EyesDlg::GetCachedBitmap( UINT id ) +{ + for ( CBitmapRef *pCur=m_pBitmapHead; pCur; pCur=pCur->m_pNext ) + { + if ( pCur->m_iResource == id ) + return pCur->m_hBitmap; + } + + CBitmapRef *pNew = new CBitmapRef; + pNew->m_iResource = id; + pNew->m_hBitmap = ::LoadBitmap( AfxGetInstanceHandle(), MAKEINTRESOURCE(id) ); + pNew->m_pNext = m_pBitmapHead; + m_pBitmapHead = pNew; + + return pNew->m_hBitmap; +} + + +///////////////////////////////////////////////////////////////////////////// +// CQC_EyesDlg message handlers + +BOOL CQC_EyesDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + // Set the icon for this dialog. The framework does this automatically + // when the application's main window is not a dialog + SetIcon(m_hIcon, TRUE); // Set big icon + SetIcon(m_hIcon, FALSE); // Set small icon + + // TODO: Add extra initialization here + GetDlgItem( IDC_REFERENCE_FILENAME )->SetWindowText( "filename_reference" ); + GetDlgItem( IDC_EXPRESSIONS_FILENAME )->SetWindowText( "filename_expressions" ); + GetDlgItem( IDC_MODEL_FILENAME )->SetWindowText( "filename_model" ); + GetDlgItem( IDC_IRIS_SIZE )->SetWindowText( "0.63" ); + GetDlgItem( IDC_EYEBALL_SIZE )->SetWindowText( "1.0" ); + + ::SendMessage( ::GetDlgItem( m_hWnd, IDC_Y_AXIS_UP ), BM_SETCHECK, BST_CHECKED, 0 ); + ::SendMessage( ::GetDlgItem( m_hWnd, IDC_DEFAULT_CONTROLS ), BM_SETCHECK, BST_CHECKED, 0 ); + ::SendMessage( ::GetDlgItem( m_hWnd, IDC_IRIS_COLOR_BROWN ), BM_SETCHECK, BST_CHECKED, 0 ); + ::SendMessage( ::GetDlgItem( m_hWnd, IDC_EYE_COLOR_LIGHT ), BM_SETCHECK, BST_CHECKED, 0 ); + + m_hOutputText = ::GetDlgItem( m_hWnd, IDC_OUTPUT_TEXT ); + + m_PictureControl.SetBitmap( GetCachedBitmap( IDB_EYE_DEFAULT ) ); + OnDefaultControls(); // Hide the advanced controls. + + return TRUE; // return TRUE unless you set the focus to a control +} + +// If you add a minimize button to your dialog, you will need the code below +// to draw the icon. For MFC applications using the document/view model, +// this is automatically done for you by the framework. + +void CQC_EyesDlg::OnPaint() +{ + if (IsIconic()) + { + CPaintDC dc(this); // device context for painting + + SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); + + // Center icon in client rectangle + int cxIcon = GetSystemMetrics(SM_CXICON); + int cyIcon = GetSystemMetrics(SM_CYICON); + CRect rect; + GetClientRect(&rect); + int x = (rect.Width() - cxIcon + 1) / 2; + int y = (rect.Height() - cyIcon + 1) / 2; + + // Draw the icon + dc.DrawIcon(x, y, m_hIcon); + } + else + { + CDialog::OnPaint(); + } +} + +// The system calls this to obtain the cursor to display while the user drags +// the minimized window. +HCURSOR CQC_EyesDlg::OnQueryDragIcon() +{ + return (HCURSOR) m_hIcon; +} + + +void HandleYAxisUp( float &yVal, float &zVal ) +{ + float flTemp = yVal; + yVal = -zVal; + zVal = flTemp; +} + + +float CQC_EyesDlg::GetDlgItemFloat( UINT id ) +{ + char text[4096]; + GetDlgItemText( id, text, sizeof( text ) ); + return (float)atof( text ); +} + + +bool CQC_EyesDlg::IsOptionChecked( UINT option ) +{ + return (::SendMessage( ::GetDlgItem( m_hWnd, option ), BM_GETCHECK, 0, 0 ) == BST_CHECKED); +} + + +void CQC_EyesDlg::GetDialogParams( CDialogParams &p ) +{ + p.m_flLeftEye[0] = GetDlgItemFloat( IDC_LEFT_EYE_X ); + p.m_flLeftEye[1] = GetDlgItemFloat( IDC_LEFT_EYE_Y ); + p.m_flLeftEye[2] = GetDlgItemFloat( IDC_LEFT_EYE_Z ); + + p.m_flRightEye[0] = GetDlgItemFloat( IDC_RIGHT_EYE_X ); + p.m_flRightEye[1] = GetDlgItemFloat( IDC_RIGHT_EYE_Y ); + p.m_flRightEye[2] = GetDlgItemFloat( IDC_RIGHT_EYE_Z ); + + bool bYAxisUp = IsOptionChecked( IDC_Y_AXIS_UP ); + if ( bYAxisUp ) + { + HandleYAxisUp( p.m_flLeftEye[1], p.m_flLeftEye[2] ); + HandleYAxisUp( p.m_flRightEye[1], p.m_flRightEye[2] ); + } + + GetDlgItemText( IDC_REFERENCE_FILENAME, p.m_ReferenceFilename, sizeof( p.m_ReferenceFilename ) ); + GetDlgItemText( IDC_EXPRESSIONS_FILENAME, p.m_ExpressionsFilename, sizeof( p.m_ExpressionsFilename ) ); + GetDlgItemText( IDC_MODEL_FILENAME, p.m_ModelFilename, sizeof( p.m_ModelFilename ) ); + + p.m_flIrisSize = GetDlgItemFloat( IDC_IRIS_SIZE ); + p.m_flEyeballSize = GetDlgItemFloat( IDC_EYEBALL_SIZE ); + + p.m_flRightUpperLidRaised = GetDlgItemFloat( IDC_UPPER_LID_RAISED ); + p.m_flRightUpperLidNeutral = GetDlgItemFloat( IDC_UPPER_LID_NEUTRAL ); + p.m_flRightUpperLidLowered = GetDlgItemFloat( IDC_UPPER_LID_LOWERED ); + + p.m_flRightLowerLidRaised = GetDlgItemFloat( IDC_LOWER_LID_RAISED ); + p.m_flRightLowerLidNeutral = GetDlgItemFloat( IDC_LOWER_LID_NEUTRAL ); + p.m_flRightLowerLidLowered = GetDlgItemFloat( IDC_LOWER_LID_LOWERED ); + + if ( IsIndependentLeftLidControlEnabled() ) + { + p.m_flLeftUpperLidRaised = GetDlgItemFloat( IDC_UPPER_LEFT_LID_RAISED ); + p.m_flLeftUpperLidNeutral = GetDlgItemFloat( IDC_UPPER_LEFT_LID_NEUTRAL ); + p.m_flLeftUpperLidLowered = GetDlgItemFloat( IDC_UPPER_LEFT_LID_LOWERED ); + + p.m_flLeftLowerLidRaised = GetDlgItemFloat( IDC_LOWER_LEFT_LID_RAISED ); + p.m_flLeftLowerLidNeutral = GetDlgItemFloat( IDC_LOWER_LEFT_LID_NEUTRAL ); + p.m_flLeftLowerLidLowered = GetDlgItemFloat( IDC_LOWER_LEFT_LID_LOWERED ); + } + else + { + // Left lids follow the right lids. + p.m_flLeftUpperLidRaised = p.m_flRightUpperLidRaised; + p.m_flLeftUpperLidNeutral = p.m_flRightUpperLidNeutral; + p.m_flLeftUpperLidLowered = p.m_flRightUpperLidLowered; + + p.m_flLeftLowerLidRaised = p.m_flRightLowerLidRaised; + p.m_flLeftLowerLidNeutral = p.m_flRightLowerLidNeutral; + p.m_flLeftLowerLidLowered = p.m_flRightLowerLidLowered; + } + + // Figure out the eyeball prefix. + if ( IsOptionChecked( IDC_EYE_COLOR_LIGHT ) ) + strcpy( p.m_EyeballPrefix, "eyeball" ); + else + strcpy( p.m_EyeballPrefix, "dark_eyeball" ); + + // Figure out the pupil prefix. + if ( IsOptionChecked( IDC_IRIS_COLOR_BROWN ) ) + strcpy( p.m_PupilPrefix, "pupil" ); + else if ( IsOptionChecked( IDC_IRIS_COLOR_GREEN ) ) + strcpy( p.m_PupilPrefix, "grn_pupil" ); + else + strcpy( p.m_PupilPrefix, "bl_pupil" ); +} + + +void CQC_EyesDlg::GenerateQCText() +{ + CDialogParams p; + GetDialogParams( p ); + + + m_BufSize = 16 * 1024; + m_Buf = new char[m_BufSize]; + m_Buf[0] = 0; + + AddText( "//start eye/face data\n" ); + AddText( "$eyeposition 0 0 70\n\n" ); + + AddText( "//head controllers\n" ); + AddText( "$attachment \"eyes\" \"ValveBiped.Bip01_Head1\" %.2f %.2f %.2f absolute\n", + p.m_flLeftEye[0] - ((fabs( p.m_flRightEye[0] ) + p.m_flLeftEye[0]) * 0.5), + (p.m_flLeftEye[1] + p.m_flRightEye[1]) * 0.5, + (p.m_flLeftEye[2] + p.m_flRightEye[2]) * 0.5 ); + + AddText( "$attachment \"mouth\" \"ValveBiped.Bip01_Head1\" 0.80 -5.80 -0.15 rotate 0 -80 -90\n\n" ); + + AddText( "$model %s \"%s.smd\" {\n", + p.m_ModelFilename, p.m_ReferenceFilename ); + + AddText( "\teyeball righteye \"ValveBiped.Bip01_Head1\" %.2f %.2f %.2f \"%s_r\" %.2f 4 \"%s_r\" %.2f\n", + p.m_flRightEye[0], + p.m_flRightEye[1], + p.m_flRightEye[2], + p.m_EyeballPrefix, + p.m_flEyeballSize, + p.m_PupilPrefix, + p.m_flIrisSize ); + + AddText( "\teyeball lefteye \"ValveBiped.Bip01_Head1\" %.2f %.2f %.2f \"%s_l\" %.2f -4 \"%s_l\" %.2f\n\n", + p.m_flLeftEye[0], + p.m_flLeftEye[1], + p.m_flLeftEye[2], + p.m_EyeballPrefix, + p.m_flEyeballSize, + p.m_PupilPrefix, + p.m_flIrisSize ); + + AddText( "\teyelid upper_right \"%s\" lowerer 1 %.2f neutral 0 %.2f raiser 2 %.2f split 0.1 eyeball righteye\n", + p.m_ExpressionsFilename, + p.m_flRightUpperLidLowered - p.m_flRightEye[2], + p.m_flRightUpperLidNeutral - p.m_flRightEye[2], + p.m_flRightUpperLidRaised - p.m_flRightEye[2] ); + + AddText( "\teyelid lower_right \"%s\" lowerer 3 %.2f neutral 0 %.2f raiser 4 %.2f split 0.1 eyeball righteye\n", + p.m_ExpressionsFilename, + p.m_flRightLowerLidLowered - p.m_flRightEye[2], + p.m_flRightLowerLidNeutral - p.m_flRightEye[2], + p.m_flRightLowerLidRaised - p.m_flRightEye[2] ); + + AddText( "\teyelid upper_left \"%s\" lowerer 1 %.2f neutral 0 %.2f raiser 2 %.2f split -0.1 eyeball lefteye\n", + p.m_ExpressionsFilename, + p.m_flLeftUpperLidLowered - p.m_flLeftEye[2], + p.m_flLeftUpperLidNeutral - p.m_flLeftEye[2], + p.m_flLeftUpperLidRaised - p.m_flLeftEye[2] ); + + AddText( "\teyelid lower_left \"%s\" lowerer 3 %.2f neutral 0 %.2f raiser 4 %.2f split -0.1 eyeball lefteye\n\n", + p.m_ExpressionsFilename, + p.m_flLeftLowerLidLowered - p.m_flLeftEye[2], + p.m_flLeftLowerLidNeutral - p.m_flLeftEye[2], + p.m_flLeftLowerLidRaised - p.m_flLeftEye[2] ); + + AddText( "\tmouth 0 \"mouth\" \"ValveBiped.Bip01_Head1\" 0 1 0 // mouth illumination\n" ); + AddText( "\tflexfile \"%s\" {\n", p.m_ExpressionsFilename ); + AddText( "\t\t$include \"../standardflex_xsi.qci\"\n" ); + AddText( "\t}\n" ); + AddText( "\t$include \"../facerules_xsi.qci\"\n" ); + AddText( "\t$include \"../bodyrules_xsi.qci\"\n" ); + AddText( "}\n" ); + AddText( "//end eye/face data\n" ); +} + + +bool CQC_EyesDlg::CheckNumericInputs() +{ + struct + { + const char *pControlName; + UINT controlID; + } + controls[] = + { + {"Right Eye X", IDC_RIGHT_EYE_X}, + {"Right Eye Y", IDC_RIGHT_EYE_Y}, + {"Right Eye Z", IDC_RIGHT_EYE_Z}, + + {"Left Eye X", IDC_LEFT_EYE_X}, + {"Left Eye Y", IDC_LEFT_EYE_Y}, + {"Left Eye Z", IDC_LEFT_EYE_Z}, + + {"Upper Lid Raised", IDC_UPPER_LID_RAISED}, + {"Upper Lid Neutral", IDC_UPPER_LID_NEUTRAL}, + {"Upper Lid Lowered", IDC_UPPER_LID_LOWERED}, + + {"Lower Lid Raised", IDC_LOWER_LID_RAISED}, + {"Lower Lid Neutral", IDC_LOWER_LID_NEUTRAL}, + {"Lower Lid Lowered", IDC_LOWER_LID_LOWERED}, + + {"Upper Left Lid Raised", IDC_UPPER_LEFT_LID_RAISED}, + {"Upper Left Lid Neutral", IDC_UPPER_LEFT_LID_NEUTRAL}, + {"Upper Left Lid Lowered", IDC_UPPER_LEFT_LID_LOWERED}, + + {"Lower Left Lid Raised", IDC_LOWER_LEFT_LID_RAISED}, + {"Lower Left Lid Neutral", IDC_LOWER_LEFT_LID_NEUTRAL}, + {"Lower Left Lid Lowered", IDC_LOWER_LEFT_LID_LOWERED}, + + {"Iris Size", IDC_IRIS_SIZE}, + {"Eyeball Size", IDC_EYEBALL_SIZE} + }; + + for ( int i=0; i < sizeof( controls ) / sizeof( controls[0] ); i++ ) + { + char text[512]; + GetDlgItem( controls[i].controlID )->GetWindowText( text, sizeof( text ) ); + + for ( int z=0; z < (int)strlen( text ); z++ ) + { + if ( text[z] < '0' || text[z] > '9' ) + { + if ( text[z] != '.' && text[z] != '-' ) + { + char errMsg[512]; + _snprintf( errMsg, sizeof( errMsg ), "The '%s' control must have a numeric value.", controls[i].pControlName ); + AfxMessageBox( errMsg, MB_OK ); + return false; + } + } + } + } + + return true; +} + + +void CQC_EyesDlg::OnCreateQcText() +{ + if ( !CheckNumericInputs() ) + return; + + GenerateQCText(); + + // Clear the edit control. + LRESULT nLen = ::SendMessage( m_hOutputText, EM_GETLIMITTEXT, 0, 0 ); + ::SendMessage( m_hOutputText, EM_SETSEL, 0, nLen ); + ::SendMessage( m_hOutputText, EM_REPLACESEL, FALSE, (LPARAM)"" ); + + FormatAndSendToEditControl( m_hOutputText, m_Buf ); + + delete [] m_Buf; +} + +void CQC_EyesDlg::OnIrisColorBrown() +{ + ::SendMessage( ::GetDlgItem( m_hWnd, IDC_IRIS_COLOR_BROWN ), BM_SETCHECK, BST_CHECKED, 0 ); + ::SendMessage( ::GetDlgItem( m_hWnd, IDC_IRIS_COLOR_GREEN ), BM_SETCHECK, BST_UNCHECKED, 0 ); + ::SendMessage( ::GetDlgItem( m_hWnd, IDC_IRIS_COLOR_BLUE ), BM_SETCHECK, BST_UNCHECKED, 0 ); + SetupBitmapLabel( IDB_EYE_DEFAULT, "" ); +} + +void CQC_EyesDlg::OnIrisColorGreen() +{ + ::SendMessage( ::GetDlgItem( m_hWnd, IDC_IRIS_COLOR_BROWN ), BM_SETCHECK, BST_UNCHECKED, 0 ); + ::SendMessage( ::GetDlgItem( m_hWnd, IDC_IRIS_COLOR_GREEN ), BM_SETCHECK, BST_CHECKED, 0 ); + ::SendMessage( ::GetDlgItem( m_hWnd, IDC_IRIS_COLOR_BLUE ), BM_SETCHECK, BST_UNCHECKED, 0 ); + SetupBitmapLabel( IDB_EYE_DEFAULT, "" ); +} + +void CQC_EyesDlg::OnIrisColorBlue() +{ + ::SendMessage( ::GetDlgItem( m_hWnd, IDC_IRIS_COLOR_BROWN ), BM_SETCHECK, BST_UNCHECKED, 0 ); + ::SendMessage( ::GetDlgItem( m_hWnd, IDC_IRIS_COLOR_GREEN ), BM_SETCHECK, BST_UNCHECKED, 0 ); + ::SendMessage( ::GetDlgItem( m_hWnd, IDC_IRIS_COLOR_BLUE ), BM_SETCHECK, BST_CHECKED, 0 ); + SetupBitmapLabel( IDB_EYE_DEFAULT, "" ); +} + +void CQC_EyesDlg::OnEyeColorDark() +{ + ::SendMessage( ::GetDlgItem( m_hWnd, IDC_EYE_COLOR_LIGHT ), BM_SETCHECK, BST_UNCHECKED, 0 ); + ::SendMessage( ::GetDlgItem( m_hWnd, IDC_EYE_COLOR_DARK ), BM_SETCHECK, BST_CHECKED, 0 ); + SetupBitmapLabel( IDB_EYE_DEFAULT, "" ); +} + +void CQC_EyesDlg::OnEyeColorLight() +{ + ::SendMessage( ::GetDlgItem( m_hWnd, IDC_EYE_COLOR_LIGHT ), BM_SETCHECK, BST_CHECKED, 0 ); + ::SendMessage( ::GetDlgItem( m_hWnd, IDC_EYE_COLOR_DARK ), BM_SETCHECK, BST_UNCHECKED, 0 ); + SetupBitmapLabel( IDB_EYE_DEFAULT, "" ); +} + +void CQC_EyesDlg::SetupBitmapLabel( UINT iBitmapResourceID, const char *pString, ... ) +{ + char msg[4096]; + va_list marker; + va_start( marker, pString ); + _vsnprintf( msg, sizeof( msg ), pString, marker ); + msg[ ARRAYSIZE(msg) - 1 ] = 0; + va_end( marker ); + + m_PictureControl.SetBitmap( GetCachedBitmap( iBitmapResourceID ) ); + GetDlgItem( IDC_PICTURE_LABEL )->SetWindowText( msg ); +} + +void CQC_EyesDlg::OnSetfocusRightEyeX() +{ + SetupBitmapLabel( IDB_EYE_XY_R, "Enter the X position of the center vertex of the right eye" ); +} + +void CQC_EyesDlg::OnSetfocusRightEyeY() +{ + SetupBitmapLabel( IsOptionChecked( IDC_Y_AXIS_UP ) ? IDB_EYE_XY_R : IDB_EYE_Z_R, "Enter the Y position of the center vertex of the right eye" ); +} + +void CQC_EyesDlg::OnSetfocusRightEyeZ() +{ + SetupBitmapLabel( IsOptionChecked( IDC_Y_AXIS_UP ) ? IDB_EYE_Z_R : IDB_EYE_XY_R, "Enter the Z position of the center vertex of the right eye" ); +} + +void CQC_EyesDlg::OnSetfocusLeftEyeX() +{ + SetupBitmapLabel( IDB_EYE_XY_L, "Enter the X position of the center vertex of the right eye" ); +} + +void CQC_EyesDlg::OnSetfocusLeftEyeY() +{ + SetupBitmapLabel( IsOptionChecked( IDC_Y_AXIS_UP ) ? IDB_EYE_XY_L : IDB_EYE_Z_L, "Enter the Y position of the center vertex of the right eye" ); +} + +void CQC_EyesDlg::OnSetfocusLeftEyeZ() +{ + SetupBitmapLabel( IsOptionChecked( IDC_Y_AXIS_UP ) ? IDB_EYE_Z_L : IDB_EYE_XY_L, "Enter the Z position of the center vertex of the right eye" ); +} + +void CQC_EyesDlg::OnSetfocusUpperLidLowered() +{ + const char *pCoord = IsOptionChecked( IDC_Y_AXIS_UP ) ? "Y" : "Z"; + SetupBitmapLabel( IDB_EYE_UPPER_LO, "At Frame 1, enter the %s position of the center vertex of the right upper eye lid", pCoord ); +} + +void CQC_EyesDlg::OnSetfocusUpperLidNeutral() +{ + const char *pCoord = IsOptionChecked( IDC_Y_AXIS_UP ) ? "Y" : "Z"; + SetupBitmapLabel( IDB_EYE_UPPER_MID, "At Frame 0, enter the %s position of the center vertex of the right upper eye lid", pCoord ); +} + +void CQC_EyesDlg::OnSetfocusUpperLidRaised() +{ + const char *pCoord = IsOptionChecked( IDC_Y_AXIS_UP ) ? "Y" : "Z"; + SetupBitmapLabel( IDB_EYE_UPPER_HI, "At Frame 2, enter the %s position of the center vertex of the right upper eye lid", pCoord ); +} + + +void CQC_EyesDlg::OnSetfocusLowerLidLowered() +{ + const char *pCoord = IsOptionChecked( IDC_Y_AXIS_UP ) ? "Y" : "Z"; + SetupBitmapLabel( IDB_EYE_LOWER_LO, "At Frame 3, enter the %s position of the center vertex of the right lower eye lid", pCoord ); +} + +void CQC_EyesDlg::OnSetfocusLowerLidNeutral() +{ + const char *pCoord = IsOptionChecked( IDC_Y_AXIS_UP ) ? "Y" : "Z"; + SetupBitmapLabel( IDB_EYE_LOWER_MID, "At Frame 0, enter the %s position of the center vertex of the right lower eye lid", pCoord ); +} + +void CQC_EyesDlg::OnSetfocusLowerLidRaised() +{ + const char *pCoord = IsOptionChecked( IDC_Y_AXIS_UP ) ? "Y" : "Z"; + SetupBitmapLabel( IDB_EYE_LOWER_HI, "At Frame 4, enter the %s position of the center vertex of the right lower eye lid", pCoord ); +} + +void CQC_EyesDlg::OnCopyTextToClipboard() +{ + if ( !CheckNumericInputs() ) + return; + + GenerateQCText(); + + if ( !OpenClipboard() ) + return; + + size_t textLen = strlen( m_Buf ); + HANDLE hmem = GlobalAlloc( GMEM_MOVEABLE | GMEM_DDESHARE, textLen + 1 ); + if ( hmem ) + { + void *ptr = GlobalLock( hmem ); + if ( ptr ) + { + memcpy( ptr, m_Buf, textLen+1 ); + GlobalUnlock( hmem ); + + SetClipboardData( CF_TEXT, hmem ); + } + } + + CloseClipboard(); + + delete [] m_Buf; +} + + +int g_AdvancedControls[] = +{ + IDC_EYE_DETAIL_CONTROL_FRAME, + IDC_IRIS_SIZE, + IDC_IRIS_SIZE_LABEL, + IDC_EYEBALL_SIZE, + IDC_EYEBALL_SIZE_LABEL, + IDC_LEFT_LID_CONTROL +}; +#define NUM_ADVANCED_CONTROLS ( sizeof( g_AdvancedControls ) / sizeof( g_AdvancedControls[0] ) ) + +int g_LeftLidPositionControls[] = +{ + IDC_UPPER_LEFT_LID_PANEL, + IDC_UPPER_LEFT_LID_RAISED, + IDC_UPPER_LEFT_LID_RAISED_LABEL, + IDC_UPPER_LEFT_LID_NEUTRAL, + IDC_UPPER_LEFT_LID_NEUTRAL_LABEL, + IDC_UPPER_LEFT_LID_LOWERED, + IDC_UPPER_LEFT_LID_LOWERED_LABEL, + IDC_LOWER_LEFT_LID_PANEL, + IDC_LOWER_LEFT_LID_RAISED, + IDC_LOWER_LEFT_LID_RAISED_LABEL, + IDC_LOWER_LEFT_LID_NEUTRAL, + IDC_LOWER_LEFT_LID_NEUTRAL_LABEL, + IDC_LOWER_LEFT_LID_LOWERED, + IDC_LOWER_LEFT_LID_LOWERED_LABEL +}; +#define NUM_LEFT_LID_POSITION_CONTROLS ( sizeof( g_LeftLidPositionControls ) / sizeof( g_LeftLidPositionControls[0] ) ) + + +void CQC_EyesDlg::OnDefaultControls() +{ + GetDlgItem( IDC_PICTURES )->ShowWindow( SW_SHOW ); + + // Hide all the advanced controls. + for ( int i=0; i < NUM_ADVANCED_CONTROLS; i++ ) + { + GetDlgItem( g_AdvancedControls[i] )->ShowWindow( SW_HIDE ); + } + + for ( int i=0; i < NUM_LEFT_LID_POSITION_CONTROLS; i++ ) + { + GetDlgItem( g_LeftLidPositionControls[i] )->ShowWindow( SW_HIDE ); + } + +} + +void CQC_EyesDlg::OnAdvancedControls() +{ + GetDlgItem( IDC_PICTURES )->ShowWindow( SW_HIDE ); + + // Show the advanced controls. + for ( int i=0; i < NUM_ADVANCED_CONTROLS; i++ ) + { + GetDlgItem( g_AdvancedControls[i] )->ShowWindow( SW_SHOW ); + GetDlgItem( g_AdvancedControls[i] )->InvalidateRect( NULL ); + } + + if ( IsIndependentLeftLidControlEnabled() ) + { + OnLeftLidControl(); + } +} + + +bool CQC_EyesDlg::IsIndependentLeftLidControlEnabled() +{ + return m_IndependentLeftLidControl.GetCheck() == 1; +} + +void CQC_EyesDlg::OnLeftLidControl() +{ + if ( IsIndependentLeftLidControlEnabled() ) + { + for ( int i=0; i < NUM_LEFT_LID_POSITION_CONTROLS; i++ ) + { + GetDlgItem( g_LeftLidPositionControls[i] )->ShowWindow( SW_SHOW ); + GetDlgItem( g_LeftLidPositionControls[i] )->InvalidateRect( NULL ); + } + } + else + { + for ( int i=0; i < NUM_LEFT_LID_POSITION_CONTROLS; i++ ) + { + GetDlgItem( g_LeftLidPositionControls[i] )->ShowWindow( SW_HIDE ); + GetDlgItem( g_LeftLidPositionControls[i] )->InvalidateRect( NULL ); + } + } +} diff --git a/utils/qc_eyes/QC_EyesDlg.h b/utils/qc_eyes/QC_EyesDlg.h new file mode 100644 index 0000000..754e9ec --- /dev/null +++ b/utils/qc_eyes/QC_EyesDlg.h @@ -0,0 +1,134 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// QC_EyesDlg.h : header file +// + +#if !defined(AFX_QC_EYESDLG_H__9130E22D_05ED_4851_960C_38D90DA94967__INCLUDED_) +#define AFX_QC_EYESDLG_H__9130E22D_05ED_4851_960C_38D90DA94967__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +class CDialogParams +{ +public: + float m_flLeftEye[3]; + float m_flRightEye[3]; + + float m_flIrisSize; + float m_flEyeballSize; + + float m_flLeftUpperLidRaised; + float m_flLeftUpperLidNeutral; + float m_flLeftUpperLidLowered; + + float m_flLeftLowerLidRaised; + float m_flLeftLowerLidNeutral; + float m_flLeftLowerLidLowered; + + float m_flRightUpperLidRaised; + float m_flRightUpperLidNeutral; + float m_flRightUpperLidLowered; + + float m_flRightLowerLidRaised; + float m_flRightLowerLidNeutral; + float m_flRightLowerLidLowered; + + char m_ReferenceFilename[1024]; + char m_ExpressionsFilename[1024]; + char m_ModelFilename[1024]; + + char m_EyeballPrefix[1024]; // eyeball_ or dark_eyeball_ + char m_PupilPrefix[1024]; // pupil_ or grn_pupil_ or bl_pupil_ +}; + +///////////////////////////////////////////////////////////////////////////// +// CQC_EyesDlg dialog + +class CQC_EyesDlg : public CDialog +{ +// Construction +public: + CQC_EyesDlg(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CQC_EyesDlg) + enum { IDD = IDD_QC_EYES_DIALOG }; + CButton m_IndependentLeftLidControl; + CStatic m_PictureControl; + //}}AFX_DATA + + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CQC_EyesDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + HICON m_hIcon; + + void GenerateQCText(); + void AddText( const char *pFormat, ... ); + bool IsOptionChecked( UINT option ); + float GetDlgItemFloat( UINT id ); + void GetDialogParams( CDialogParams &p ); + void SetupBitmapLabel( UINT iBitmapResourceID, const char *pString, ... ); + + HWND m_hOutputText; + + + // Cached list of bitmaps. + class CBitmapRef + { + public: + UINT m_iResource; + HBITMAP m_hBitmap; + CBitmapRef *m_pNext; + }; + CBitmapRef *m_pBitmapHead; + HBITMAP GetCachedBitmap( UINT id ); + + + size_t m_BufSize; + char *m_Buf; + bool IsIndependentLeftLidControlEnabled(); + + bool CheckNumericInputs(); + + + // Generated message map functions + //{{AFX_MSG(CQC_EyesDlg) + virtual BOOL OnInitDialog(); + afx_msg void OnPaint(); + afx_msg HCURSOR OnQueryDragIcon(); + afx_msg void OnCreateQcText(); + afx_msg void OnIrisColorBrown(); + afx_msg void OnIrisColorGreen(); + afx_msg void OnIrisColorBlue(); + afx_msg void OnEyeColorDark(); + afx_msg void OnEyeColorLight(); + afx_msg void OnSetfocusRightEyeX(); + afx_msg void OnSetfocusRightEyeY(); + afx_msg void OnSetfocusRightEyeZ(); + afx_msg void OnSetfocusLeftEyeX(); + afx_msg void OnSetfocusLeftEyeY(); + afx_msg void OnSetfocusLeftEyeZ(); + afx_msg void OnSetfocusUpperLidLowered(); + afx_msg void OnSetfocusUpperLidNeutral(); + afx_msg void OnSetfocusUpperLidRaised(); + afx_msg void OnSetfocusLowerLidLowered(); + afx_msg void OnSetfocusLowerLidNeutral(); + afx_msg void OnSetfocusLowerLidRaised(); + afx_msg void OnCopyTextToClipboard(); + afx_msg void OnDefaultControls(); + afx_msg void OnAdvancedControls(); + afx_msg void OnLeftLidControl(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_QC_EYESDLG_H__9130E22D_05ED_4851_960C_38D90DA94967__INCLUDED_) diff --git a/utils/qc_eyes/StdAfx.cpp b/utils/qc_eyes/StdAfx.cpp new file mode 100644 index 0000000..8ffd641 --- /dev/null +++ b/utils/qc_eyes/StdAfx.cpp @@ -0,0 +1,9 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// stdafx.cpp : source file that includes just the standard includes +// QC_Eyes.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + + diff --git a/utils/qc_eyes/StdAfx.h b/utils/qc_eyes/StdAfx.h new file mode 100644 index 0000000..55723a6 --- /dev/null +++ b/utils/qc_eyes/StdAfx.h @@ -0,0 +1,28 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#if !defined(AFX_STDAFX_H__88FA48B3_A92C_49CA_8A82_50D120A84756__INCLUDED_) +#define AFX_STDAFX_H__88FA48B3_A92C_49CA_8A82_50D120A84756__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers + +#include <afxwin.h> // MFC core and standard components +#include <afxext.h> // MFC extensions +#include <afxdisp.h> // MFC Automation classes +#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include <afxcmn.h> // MFC support for Windows Common Controls +#endif // _AFX_NO_AFXCMN_SUPPORT + + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__88FA48B3_A92C_49CA_8A82_50D120A84756__INCLUDED_) diff --git a/utils/qc_eyes/qc_eyes.vpc b/utils/qc_eyes/qc_eyes.vpc new file mode 100644 index 0000000..a417fd7 --- /dev/null +++ b/utils/qc_eyes/qc_eyes.vpc @@ -0,0 +1,74 @@ +//----------------------------------------------------------------------------- +// QC_EYES.VPC +// +// Project Script +//----------------------------------------------------------------------------- + +$Macro SRCDIR "..\.." +$Macro OUTBINDIR "$SRCDIR\..\game\bin" + +$Include "$SRCDIR\vpc_scripts\source_exe_base.vpc" + +$Configuration +{ + $Compiler + { + // Deprecated MBCS MFC libraries for VS 2013 (nafxcw.lib and nafxcwd.lib) can be downloaded from http://go.microsoft.com/?linkid=9832071 + $PreprocessorDefinitions "$BASE;NO_WARN_MBCS_MFC_DEPRECATION" + $Create/UsePrecompiledHeader "Use Precompiled Header (/Yu)" + $PrecompiledHeaderFile "Debug/QC_Eyes.pch" + $EnableC++Exceptions "Yes (/EHsc)" + } + + $Linker + { + $AdditionalDependencies "$BASE;windowscodecs.lib" + } +} + +$Project "QC_Eyes" +{ + $Folder "Source Files" + { + -$File "$SRCDIR\public\tier0\memoverride.cpp" + + $File "QC_Eyes.cpp" + $File "QC_Eyes.rc" + $File "QC_EyesDlg.cpp" + $File "StdAfx.cpp" + { + $Configuration + { + $Compiler + { + $Create/UsePrecompiledHeader "Create Precompiled Header (/Yc)" + } + } + } + } + + $Folder "Header Files" + { + $File "QC_Eyes.h" + $File "QC_EyesDlg.h" + $File "Resource.h" + $File "StdAfx.h" + } + + $Folder "Resources" + { + $File "res\eye_default.bmp" + $File "res\eye_lower_hi.bmp" + $File "res\eye_lower_lo.bmp" + $File "res\eye_lower_mid.bmp" + $File "res\eye_upper_hi.bmp" + $File "res\eye_upper_lo.bmp" + $File "res\eye_upper_mid.bmp" + $File "res\eye_XY_L.bmp" + $File "res\eye_XY_R.bmp" + $File "res\eye_Z_L.bmp" + $File "res\eye_Z_R.bmp" + $File "res\QC_Eyes.ico" + $File "res\QC_Eyes.rc2" + } +} diff --git a/utils/qc_eyes/res/QC_Eyes.ico b/utils/qc_eyes/res/QC_Eyes.ico Binary files differnew file mode 100644 index 0000000..7eef0bc --- /dev/null +++ b/utils/qc_eyes/res/QC_Eyes.ico diff --git a/utils/qc_eyes/res/QC_Eyes.rc2 b/utils/qc_eyes/res/QC_Eyes.rc2 new file mode 100644 index 0000000..3ddd1c7 --- /dev/null +++ b/utils/qc_eyes/res/QC_Eyes.rc2 @@ -0,0 +1,13 @@ +// +// QC_EYES.RC2 - resources Microsoft Visual C++ does not edit directly +// + +#ifdef APSTUDIO_INVOKED + #error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// Add manually edited resources here... + +///////////////////////////////////////////////////////////////////////////// diff --git a/utils/qc_eyes/res/eye_XY_L.bmp b/utils/qc_eyes/res/eye_XY_L.bmp Binary files differnew file mode 100644 index 0000000..3350ed2 --- /dev/null +++ b/utils/qc_eyes/res/eye_XY_L.bmp diff --git a/utils/qc_eyes/res/eye_XY_R.bmp b/utils/qc_eyes/res/eye_XY_R.bmp Binary files differnew file mode 100644 index 0000000..9bfbc91 --- /dev/null +++ b/utils/qc_eyes/res/eye_XY_R.bmp diff --git a/utils/qc_eyes/res/eye_Z_L.bmp b/utils/qc_eyes/res/eye_Z_L.bmp Binary files differnew file mode 100644 index 0000000..949f9ac --- /dev/null +++ b/utils/qc_eyes/res/eye_Z_L.bmp diff --git a/utils/qc_eyes/res/eye_Z_R.bmp b/utils/qc_eyes/res/eye_Z_R.bmp Binary files differnew file mode 100644 index 0000000..72042e1 --- /dev/null +++ b/utils/qc_eyes/res/eye_Z_R.bmp diff --git a/utils/qc_eyes/res/eye_default.bmp b/utils/qc_eyes/res/eye_default.bmp Binary files differnew file mode 100644 index 0000000..705ac95 --- /dev/null +++ b/utils/qc_eyes/res/eye_default.bmp diff --git a/utils/qc_eyes/res/eye_lower_hi.bmp b/utils/qc_eyes/res/eye_lower_hi.bmp Binary files differnew file mode 100644 index 0000000..9a88d59 --- /dev/null +++ b/utils/qc_eyes/res/eye_lower_hi.bmp diff --git a/utils/qc_eyes/res/eye_lower_lo.bmp b/utils/qc_eyes/res/eye_lower_lo.bmp Binary files differnew file mode 100644 index 0000000..90b42b6 --- /dev/null +++ b/utils/qc_eyes/res/eye_lower_lo.bmp diff --git a/utils/qc_eyes/res/eye_lower_mid.bmp b/utils/qc_eyes/res/eye_lower_mid.bmp Binary files differnew file mode 100644 index 0000000..9affa70 --- /dev/null +++ b/utils/qc_eyes/res/eye_lower_mid.bmp diff --git a/utils/qc_eyes/res/eye_upper_hi.bmp b/utils/qc_eyes/res/eye_upper_hi.bmp Binary files differnew file mode 100644 index 0000000..fdc8b38 --- /dev/null +++ b/utils/qc_eyes/res/eye_upper_hi.bmp diff --git a/utils/qc_eyes/res/eye_upper_lo.bmp b/utils/qc_eyes/res/eye_upper_lo.bmp Binary files differnew file mode 100644 index 0000000..16313d5 --- /dev/null +++ b/utils/qc_eyes/res/eye_upper_lo.bmp diff --git a/utils/qc_eyes/res/eye_upper_mid.bmp b/utils/qc_eyes/res/eye_upper_mid.bmp Binary files differnew file mode 100644 index 0000000..724ede4 --- /dev/null +++ b/utils/qc_eyes/res/eye_upper_mid.bmp diff --git a/utils/qc_eyes/resource.h b/utils/qc_eyes/resource.h new file mode 100644 index 0000000..e963ea2 --- /dev/null +++ b/utils/qc_eyes/resource.h @@ -0,0 +1,78 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by QC_Eyes.rc +// +#define IDD_QC_EYES_DIALOG 102 +#define IDR_MAINFRAME 128 +#define IDB_EYE_DEFAULT 150 +#define IDB_EYE_LOWER_HI 151 +#define IDB_EYE_LOWER_LO 152 +#define IDB_EYE_LOWER_MID 153 +#define IDB_EYE_UPPER_HI 154 +#define IDB_EYE_UPPER_LO 155 +#define IDB_EYE_UPPER_MID 156 +#define IDB_EYE_XY_L 157 +#define IDB_EYE_XY_R 158 +#define IDB_EYE_Z_L 159 +#define IDB_EYE_Z_R 160 +#define IDC_REFERENCE_FILENAME 1000 +#define IDC_EXPRESSIONS_FILENAME 1001 +#define IDC_MODEL_FILENAME 1002 +#define IDC_RIGHT_EYE_X 1003 +#define IDC_RIGHT_EYE_Y 1004 +#define IDC_RIGHT_EYE_Z 1005 +#define IDC_LEFT_EYE_X 1006 +#define IDC_LEFT_EYE_Y 1007 +#define IDC_LEFT_EYE_Z 1008 +#define IDC_Y_AXIS_UP 1009 +#define IDC_Z_AXIS_UP 1010 +#define IDC_DEFAULT_CONTROLS 1011 +#define IDC_ADVANCED_CONTROLS 1012 +#define IDC_UPPER_LID_RAISED 1013 +#define IDC_OUTPUT_TEXT 1014 +#define IDC_UPPER_LEFT_LID_RAISED 1015 +#define IDC_UPPER_LID_LOWERED 1016 +#define IDC_UPPER_LID_NEUTRAL 1017 +#define IDC_LOWER_LID_RAISED 1018 +#define IDC_LOWER_LID_LOWERED 1019 +#define IDC_LOWER_LID_NEUTRAL 1020 +#define IDC_IRIS_COLOR_GREEN 1021 +#define IDC_IRIS_COLOR_BLUE 1022 +#define IDC_IRIS_COLOR_BROWN 1023 +#define IDC_EYE_COLOR_LIGHT 1024 +#define IDC_EYE_COLOR_DARK 1025 +#define IDC_IRIS_SIZE 1026 +#define IDC_CREATE_QC_TEXT 1027 +#define IDC_EYEBALL_SIZE 1028 +#define IDC_COPY_TEXT_TO_CLIPBOARD 1029 +#define IDC_PICTURES 1030 +#define IDC_PICTURE_LABEL 1031 +#define IDC_LEFT_LID_CONTROL 1032 +#define IDC_UPPER_LEFT_LID_NEUTRAL 1033 +#define IDC_UPPER_LEFT_LID_LOWERED 1034 +#define IDC_LOWER_LEFT_LID_RAISED 1035 +#define IDC_LOWER_LEFT_LID_NEUTRAL 1036 +#define IDC_LOWER_LEFT_LID_LOWERED 1037 +#define IDC_EYE_DETAIL_CONTROL_FRAME 1038 +#define IDC_IRIS_SIZE_LABEL 1039 +#define IDC_EYEBALL_SIZE_LABEL 1040 +#define IDC_UPPER_LEFT_LID_PANEL 1041 +#define IDC_UPPER_LEFT_LID_RAISED_LABEL 1042 +#define IDC_UPPER_LEFT_LID_NEUTRAL_LABEL 1043 +#define IDC_UPPER_LEFT_LID_LOWERED_LABEL 1044 +#define IDC_LOWER_LEFT_LID_PANEL 1045 +#define IDC_LOWER_LEFT_LID_RAISED_LABEL 1046 +#define IDC_LOWER_LEFT_LID_NEUTRAL_LABEL 1047 +#define IDC_LOWER_LEFT_LID_LOWERED_LABEL 1048 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 130 +#define _APS_NEXT_COMMAND_VALUE 32771 +#define _APS_NEXT_CONTROL_VALUE 1049 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif |