www.pudn.com > WaveSimulation.rar > GlobalVarDef.cpp
#include "stdafx.h" #include// OpenGL headers #include #include #include "myDefine.h" #include "Input.h" #include "Texture.h" #include "Wave.h" #include "Bezier.h" #include "terrian.h" //global varity defination CTexture g_cTexture; CInput g_cInput; CWave g_cWave[WAVETRAIN]; CBezier g_cBezier; CTerrian g_cTerrian; float g_timet; bool g_bPolygonMode = true; //多边形填充模式 bool g_bLighting = true; //光照模式 bool g_bTexture = true; bool g_bFog = false; GLfloat Xeye = -22.0f , Yeye = 0.0f , Zeye = 3.0f, //视点坐标 ViewLineLength = 1500.0f, Camera_HalfFov = 25.0f, ViewLineAngle = PI / 2.0f - 65.0 / 180 *PI; int quit=0; //判断程序是否正在运行 HINSTANCE g_hInst = NULL; //全局进程句柄 HDC GLOBhDC = NULL; //全局设备环境句柄 HWND mainwindow = NULL; //主窗口句柄 HGLRC hRC = NULL; // OpenGL Rendering context int width = 0 , height = 1; //显示窗口的宽度高度//handleresize()中使用 int base = 0; //字体列表 float fps = 0; //刷新楨率 void calcNormal(float v[][3], float out[]) { float v1[3],v2[3]; static const int x = 0; static const int y = 1; static const int z = 2; v1[x] = v[0][x] - v[1][x]; v1[y] = v[0][y] - v[1][y]; v1[z] = v[0][z] - v[1][z]; v2[x] = v[1][x] - v[2][x]; v2[y] = v[1][y] - v[2][y]; v2[z] = v[1][z] - v[2][z]; out[x] = v1[y]*v2[z] - v1[z]*v2[y]; out[y] = v1[z]*v2[x] - v1[x]*v2[z]; out[z] = v1[x]*v2[y] - v1[y]*v2[x]; //归一化 float *vector = out; float length; length = sqrtf((vector[0]*vector[0]) + (vector[1]*vector[1]) + (vector[2]*vector[2])); if(length <= 0.000001f) length = 1.0f; vector[0] /= length; vector[1] /= length; vector[2] /= length; }