📄 lesson32.cpp
字号:
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = LB_Parent_Hwnd;
ofn.lpstrTitle = "Load Animation File\0";
ofn.lpstrFilter = "B-Clopd3D Animation Files (*.ANI)\0*.ANI\0All files (*.*)\0*.*\0\0";
ofn.lpstrCustomFilter = NULL;
ofn.nFilterIndex = 1;
ofn.lpstrFile = szFile;
ofn.nMaxFile = 2048;
ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = 2048;
ofn.lpstrInitialDir = ".\0";
ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
/*
Display the Open dialog box.
*/
if (GetOpenFileName(&ofn))
{
char *path = ofn.lpstrFile;
char *fname = ofn.lpstrFile;
char *outp;
LoadDaAnimation(fname);
};
}
void LoadBaseAnimationWindows(HWND LB_Parent_Hwnd) // L鋎t ne .dat
{
OPENFILENAME ofn; /* common dialog box structure */
char szDirName[MAX_PATH]; /* directory string */
char szFile[4096]; /* filename string */
char szFileTitle[4096]; /* filename string */
/*
hinst = (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE);
*/
/*
Obtain the system directory name and store it in szDirName.
*/
GetSystemDirectory(szDirName, sizeof(szDirName));
/*
Place the terminating null character in the szFile.
*/
szFile[0] = '\0';
/*
Set the members of the OPENFILENAME structure.
*/
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = LB_Parent_Hwnd;
ofn.lpstrTitle = "Load Animation File\0";
ofn.lpstrFilter = "B-Clopd3D Animation Files (*.ANI)\0*.ANI\0All files (*.*)\0*.*\0\0";
ofn.lpstrCustomFilter = NULL;
ofn.nFilterIndex = 1;
ofn.lpstrFile = szFile;
ofn.nMaxFile = 2048;
ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = 2048;
ofn.lpstrInitialDir = ".\0";
ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
/*
Display the Open dialog box.
*/
if (GetOpenFileName(&ofn))
{
char *path = ofn.lpstrFile;
char *fname = ofn.lpstrFile;
char *outp;
LoadDaBaseAnimation(fname);
LoadDaAnimation(fname);
};
}
void SaveModelWindows(HWND LB_Parent_Hwnd) // Saved n Model
{
OPENFILENAME ofn; /* common dialog box structure */
char szDirName[MAX_PATH]; /* directory string */
char szFile[4096]; /* filename string */
char szFileTitle[4096]; /* filename string */
/*
hinst = (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE);
*/
/*
Obtain the system directory name and store it in szDirName.
*/
GetSystemDirectory(szDirName, sizeof(szDirName));
/*
Place the terminating null character in the szFile.
*/
szFile[0] = '\0';
/*
Set the members of the OPENFILENAME structure.
*/
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = LB_Parent_Hwnd;
ofn.lpstrTitle = "Save Model File\0";
ofn.lpstrFilter = "B-Clopd3D Model Files (*.B3D)\0*.B3D\0All files (*.*)\0*.*\0\0";
ofn.lpstrCustomFilter = NULL;
ofn.nFilterIndex = 1;
ofn.lpstrFile = szFile;
ofn.nMaxFile = 2048;
ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = 2048;
ofn.lpstrInitialDir = ".\0";
ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST /*| OFN_ALLOWMULTISELECT*/;
/*
Display the Open dialog box.
*/
if (GetSaveFileName(&ofn))
{
char *path = ofn.lpstrFile;
char *fname = ofn.lpstrFile;
char *outp;
SaveModel(fname);
};
}
void SendTappedOnce(char Ch)
{
if ((g_keys->keyDown [Ch]))
{
KeyAction(Ch);
g_keys->keyDown [Ch]=false;
}
}
void SendKeyDown(char Ch)
{
if ((g_keys->keyDown [Ch]))
{ KeyAction(Ch);}
}
void MainLoop(HWND WindowHandle)
{
long FpS=50;
long I,K,M,FramesToDo;
MainWindow=WindowHandle;
if(mouse_klick<0) mouse_klick=0;
KeyAction('1');
/*
if ((g_keys->keyDown [VK_F2]))
{
ShowCursor(true);
SaveModelWindows(WindowHandle);
g_keys->keyDown [VK_F2]=false;
ShowCursor(false);
}
if ((g_keys->keyDown [VK_F3]))
{
ShowCursor(true);
LoadPureModelWindows(WindowHandle);
MyTimer=0;
g_keys->keyDown [VK_F3]=false;
ShowCursor(false);
}
*/
/*
if ((g_keys->keyDown [VK_F4]))
{
LoadPureModel("wespe.dat");
g_keys->keyDown [VK_F4]=false;
}
*/
if ((g_keys->keyDown [VK_F2]))
{
ShowCursor(true);
SaveAnimationWindows(WindowHandle);
g_keys->keyDown [VK_F2]=false;
ShowCursor(false);
}
if ((g_keys->keyDown [VK_F3]))
{
ShowCursor(true);
LoadAnimationWindows(WindowHandle);
MyTimer=0;
g_keys->keyDown [VK_F3]=false;
ShowCursor(false);
}
if ((g_keys->keyDown [VK_F4]))
{
ShowCursor(true);
LoadBaseAnimationWindows(WindowHandle);
MyTimer=0;
g_keys->keyDown [VK_F4]=false;
ShowCursor(false);
}
SendKeyDown('K');
SendKeyDown('Q');
SendKeyDown('E');
SendKeyDown('Z');
SendKeyDown('H');
SendKeyDown('R');
SendKeyDown('F');
SendKeyDown('T');
SendKeyDown('G');
SendKeyDown('W');
SendKeyDown('S');
SendKeyDown('A');
SendKeyDown('D');
SendKeyDown('J');
SendKeyDown('U');
SendKeyDown(VK_SUBTRACT);
SendKeyDown(VK_ADD);
SendTappedOnce(VK_SPACE);
SendTappedOnce(VK_TAB);
SendTappedOnce(VK_F5);
/*
SendTappedOnce(VK_F6);
SendTappedOnce(VK_F7);
*/
SendTappedOnce(VK_F8);
SendTappedOnce(VK_F9);
SendTappedOnce(VK_F11);
SendTappedOnce(VK_F12);
SendTappedOnce('M');
SendTappedOnce('I');
SendTappedOnce('O');
SendTappedOnce('P');
SendTappedOnce('L');
SendTappedOnce(VK_UP);
SendTappedOnce(VK_DOWN);
SendKeyDown(VK_RIGHT);
SendKeyDown(VK_LEFT);
FramesToDo=MyTimer/(1000/FpS);
MyTimer-=FramesToDo*(1000/FpS);
if(FramesToDo>0) CalcAllStuff(FramesToDo);
}
void Update (DWORD milliseconds) // Perform Motion Updates Here
{
long I,K,M,D;
if (g_keys->keyDown [VK_ESCAPE] == TRUE) // Is ESC Being Pressed?
{
TerminateApplication (g_window); // Terminate The Program
}
if (g_keys->keyDown [VK_F1] == TRUE) // Is F1 Being Pressed?
{
ToggleFullscreen (g_window); // Toggle Fullscreen Mode
}
xRotation += (float)(milliseconds) / 10.0f;
yRotation += (float)(milliseconds) / 7.0f;
zRotation += (float)(milliseconds) / 5.0f;
MyTimer+=milliseconds;
/*
D=10;
M=((MyTimer+milliseconds)/D)-(MyTimer/D);
MyTimer+=M*D;
for(K=0;K<M;K++)
{*/
// MoveParticles(mouse_x,mouse_y,mouse_klick);
// CalcParticles(g_window->hWnd);
//}
MainLoop(g_window->hWnd);
}
void Draw (void)
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
DrawScene();
glFlush (); // Flush The GL Rendering Pipeline
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -