📄 main.h
字号:
//-----------------------------------------------------------------------------
// Name: D3D_AnimationEditor
//
// Description: Example code showing how edit animations.
//
// File Function: Header file for the program (main.h)
//
// Code:
// Copyright (c) 2003 LostLogic Corporation. All rights reserved.
//
// Libraries Required:
// d3d9.lib dxguid.lib d3dx9dt.lib d3dxof.lib comctl32.lib winmm.lib dinput8.lib
//
// Local Files Required:
// main.cpp
// main.h
// Object3DClass.cpp
// Object3DClass.h
// ExceptionClass.cpp
// ExceptionClass.h
// C3DAnimation.cpp
// C3DAnimation.h
//
// DX Files:
// Copyright (c) 1997-2001 Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#ifndef MAIN_H
#define MAIN_H
// Set the direct input version
#define DIRECTINPUT_VERSION 0x0800
#define STRICT
#include <windows.h>
#include <stdio.h>
#include <D3DX9.h>
#include "C3DAnimation.h"
//-----------------------------------------------------------------------------
// Global variables
//-----------------------------------------------------------------------------
LPDIRECT3D9 g_pD3D = NULL; // Used to create the D3DDevice
LPDIRECT3DDEVICE9 g_pd3dDevice = NULL; // Our rendering device
LPDIRECT3DVERTEXBUFFER9 g_pVBInterface = NULL; // Buffer to hold vertices
D3DMATERIAL9 g_mtrlDefault;
// Global array to hold tiles
LPDIRECT3DTEXTURE9 g_pTexture[ 32 ];
// Viewable window offsets
int g_iXOffset = 0;
int g_iYOffset = 0;
// Window dimensions
int g_iWindowWidth = 640;
int g_iWindowHeight = 480;
// Mouse buttons
int g_iLeftButtonDown = 0;
// A structure for our custom vertex type
struct CUSTOMVERTEX
{
D3DXVECTOR3 position; // The position
D3DXVECTOR3 vecNorm; // The normal
DWORD color; // color
FLOAT tu, tv; // The texture coordinates
};
// Custom FVF, which describes the custom vertex structure
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_DIFFUSE|D3DFVF_TEX1)
//-----------------------------------------------------------------------------
// Function headers
//-----------------------------------------------------------------------------
void vDraw3DObject( D3DXVECTOR3 fPos, D3DXVECTOR3 fSize, D3DXVECTOR3 fRot, int iTexture );
void vInitInterfaceObjects( void );
LRESULT WINAPI fnMessageProcessor( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
HRESULT InitD3D( HWND hWnd );
void vRender( void );
void vCleanup( void );
void vCreateToolbar( HWND hwnd, HINSTANCE hinst );
void vCheckMouse( void );
void vSaveMap( void );
void vLoadMap( void );
void vCreateLights(void);
void vSetupView( D3DXVECTOR3 origin, D3DXVECTOR3 target );
//
// 3D globals
//
D3DXVECTOR3 g_vecCameraOrigin;
D3DXVECTOR3 g_vecCameraTarget;
// Macro for figuring out degrees
#define PI 3.1415926535897932384626433832795
#define DegToRad(deg) ((deg/180.0f)*PI)
// Global handle to the game window
HWND g_hWnd;
// Font to display text fields
LPD3DXFONT pD3DXFont = NULL;
HFONT hFont = NULL;
// Toolbar data
HWND hWndToolBar;
const int ID_BUTTON_SAVE = 40001;
const int ID_BUTTON_LOAD = 40002;
const int ID_BUTTON_LOADOBJ = 40004;
const int ID_BUTTON_PREVOBJ = 40006;
const int ID_BUTTON_NEXTOBJ = 40007;
const int ID_BUTTON_PREVFRAME = 40008;
const int ID_BUTTON_NEXTFRAME = 40009;
const int ID_BUTTON_NEWFRAME = 40010;
const int ID_BUTTON_STARTSTOP = 40012;
const int ID_EDITBOX_X = 40013;
const int ID_EDITBOX_Y = 40014;
const int ID_EDITBOX_Z = 40015;
const int ID_EDITBOX_XROT = 40016;
const int ID_EDITBOX_YROT = 40017;
const int ID_EDITBOX_ZROT = 40018;
HWND hBUTTON_SAVE = NULL;
HWND hBUTTON_LOAD = NULL;
HWND hBUTTON_LOADOBJ = NULL;
HWND hBUTTON_PREVOBJ = NULL;
HWND hBUTTON_NEXTOBJ = NULL;
HWND hBUTTON_PREVFRAME = NULL;
HWND hBUTTON_NEXTFRAME = NULL;
HWND hBUTTON_NEWFRAME = NULL;
HWND hBUTTON_STARTSTOP = NULL;
HWND hEDITBOX_X = NULL;
HWND hEDITBOX_Y = NULL;
HWND hEDITBOX_Z = NULL;
HWND hEDITBOX_XROT = NULL;
HWND hEDITBOX_YROT = NULL;
HWND hEDITBOX_ZROT = NULL;
//------------------------------------------------------------------------
//
// DIRECT INPUT DATA
//
//------------------------------------------------------------------------
#include <dinput.h>
// Keyboard buffer size
const int KEYBOARD_BUFFERSIZE = 10;
// Error codes
const int INPUTERROR_SUCCESS = 0;
const int INPUTERROR_NODI = 1;
const int INPUTERROR_NOKEYBOARD = 2;
const int INPUTERROR_KEYBOARDEXISTS = 3;
const int INPUTERROR_DI_EXISTS = 4;
// Device pointers
LPDIRECTINPUT8 pDI = NULL;
LPDIRECTINPUTDEVICE8 pKeyboard = NULL;
// Keyboard buffers
BYTE diks[ 256 ][ KEYBOARD_BUFFERSIZE ];
BYTE ascKeys[ 256 ][ KEYBOARD_BUFFERSIZE ];
// Keyboard layout
HKL g_Layout;
// Program instance pointer
HINSTANCE g_hInstance;
// Global if SHIFT key is down
bool g_bShift = 0;
//
// Animation vars
//
int g_iCurObj = 0;
int g_iAnimActive = 0;
// Global animation object
C3DAnimation animTest;
//-----------------------------------------------------------------------------
// Function headers
//-----------------------------------------------------------------------------
int iInitDirectInput(void);
int iInitKeyboard(HWND hWnd);
BYTE Scan2Ascii(DWORD scancode);
int iReadKeyboard( void );
void vCheckInput( void );
void vUpdateToolbarStats( void );
void vInitAnimation( void );
void vLoadObject( void );
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -