错误(活动) E0167 “void“ 类型的实参与 “void (__cdecl *)()“ 类型的形参不兼容

问题

严重性 代码 说明 项目 文件 行 禁止显示状态
错误(活动) E0167 “void” 类型的实参与 “void (__cdecl *)()” 类型的形参不兼容 BoneAnimationOpenGL E:\openGlExercise\BoneAnimationOpenGL\main.cpp 50

严重性 代码 说明 项目 文件 行 禁止显示状态
错误 C2664 “void glutDisplayFunc(void (__cdecl *)(void))”: 无法将参数 1 从“void”转换为“void (__cdecl *)(void)” BoneAnimationOpenGL E:\openGlExercise\BoneAnimationOpenGL\main.cpp 50

原因

回调函数是基于C编程的Windows SDK的技术,不是针对C++的,程序员可以将一个C函数直接作为回调函数,但是如果试图直接使用C++的成员函数作为回调函数将发生错误,甚至编译就不能通过。

分析原因:
普通的C++成员函数都隐含了一个传递函数作为参数,亦即“this”指针,C++通过传递一个指向自身的指针给其成员函数从而实现程序函数可以访问C++的数据成员。这也可以理解为什么C++类的多个实例可以共享成员函数但是确有不同的数据成员。由于this指针的作用,使得将一个CALLBACK型的成员函数作为回调函数安装时就会因为隐含的this指针使得函数参数个数不匹配,从而导致回调函数安装失败
解决方案:
一,不使用成员函数,直接使用普通C函数,为了实现在C函数中可以访问类的成员变量,可以使用友元操作符(friend),在C++中将该C函数说明为类的友元即可。这种处理机制与普通的C编程中使用回调函数一样。
二,使用静态成员函数,静态成员函数不使用this指针作为隐含参数,这样就可以作为回调函数了。静态成员函数具有两大特点:其一,可以在没有类实例的情况下使用;其二,只能访问静态成员变量和静态成员函数,不能访问非静态成员变量和非静态成员函数。由于在C++中使用类成员函数作为回调函数的目的就是为了访问所有的成员变量和成员函数,如果作不到这一点将不具有实际意义。我们通过使用静态成员函数对非静态成员函数包装的办法来解决问题。类实例可以通过附加参数或全局变量的方式的方式传递到静态成员函数中。分别举例如下:

1.参数传递的方式

#include <iostream.h>  
   class TClassA
   {
   public:
 
      void Display(const char* text) { cout << text << endl; };
      static void Wrapper_To_Call_Display(void* pt2Object, char* text);
      // more....
   };
 
   // 静态包装函数,能够调用成员函数Display(),本身做为回调函数来使用
   void TClassA::Wrapper_To_Call_Display(void* pt2Object, char* string)
   {
       // 显式类型转换
       TClassA* mySelf = (TClassA*) pt2Object;
 
       // 调用普通成员函数
       mySelf->Display(string);
   }
 
   // 回调函数的宿主,在这里回调用函数被使用
   void DoItA(void* pt2Object, void (*pt2Function)(void* pt2Object, char* text))
   {
      // 使用回调函数
      pt2Function(pt2Object, "hi, i'm calling back using a argument ;-)"); 
   }
 
   // 执行示例
   void Callback_Using_Argument()
   {
      TClassA objA;
      DoItA((void*) &objA, TClassA::Wrapper_To_Call_Display);
   }

2,全局变量的方式

#include <iostream.h>  
   void* pt2Object;        // 全局变量,可以指向任意对象
   class TClassB
   {
   public:
 
      void Display(const char* text) { cout << text << endl; };
      static void Wrapper_To_Call_Display(char* text);
 
   };
 
   // 静态的包装函数
   void TClassB::Wrapper_To_Call_Display(char* string)
   {
       //需要保证全局变量值的正确性
       TClassB* mySelf = (TClassB*) pt2Object;
       mySelf->Display(string);
   }
 
   // 回调用函数的宿主,在这里回调用函数被使用
   void DoItB(void (*pt2Function)(char* text))
   {
    
      pt2Function("hi, i'm calling back using a global ;-)");   // make callback
   }
 
   // 执行示例
   void Callback_Using_Global()
   {
      TClassB objB; 
      pt2Object = (void*) &objB;
      DoItB(TClassB::Wrapper_To_Call_Display);
   }

openGL例子

#pragma once

//#include "include/GL/GL.H"
//#include "include/GL/GLU.H"
#include <stdlib.h>
#include "include/GL/glut.h"
#include "include/GL/GLAUX.H"
#include "include/glfw/glfw3.h"
#include "tools.h"
#include <iostream>

//#pragma comment(lib, "lib/glut32.lib")

using namespace std;

class OpenGL
{
public:
	/*static OpenGL* currOpenGL;*/
	static void callback(void);
	void func();
	
	void setCurrentOpenGL()
	{
		/*currOpenGL = this;*/
	}
public:
	OpenGL();
	virtual ~OpenGL();
public:
	void Display();
	static void RenderScene(void);
	int  CreateOpenGLWindow(int width, int height);
	void InitOpneGL(void);
	//void OnOpenGlSize(GLFWwindow* window, int width, int height);
	/*void OnKeyboad(GLFWwindow* window, double xPos, double yPos);
	void OnMouseMove(GLFWwindow* window, double xPos, double yPos);*/

	void SetCamPos(int axis, int value, bool increment, bool apply);
	void SetSceneRot(int axis, int value, bool increment, bool apply);


	/*static void FrameBuffer_size_callback(GLFWwindow* window, int width, int height);
	static void Mouse_Move_callback(GLFWwindow* window, double xPos, double yPos);
	static void Scroll_callback(GLFWwindow* window, double xOffset, double yOffset);*/
public:
	GLFWwindow* m_window;
	int		    m_iWindowStatus;
	static float		camRot[3];
	static float camPos[3];
	static float sceneRot[3];
	static float		scenePos[3];
	BOOL		mouserightdown;
	BOOL		mouseleftdown;
	//CPoint		mouseprevpoint;

	static bool gIsStartTrackBall;
	static bool gIsMoveMap;
	static TrackBall trackball;
	static int xFar;
	static int yFar;
	static int zFar;
	static int oldX;
	static int oldY;
private:
	static bool m_GenModelList;
public:
	static void GenBoneList(void);
	static LPCWSTR stringToLPCWSTR(std::string orig);

	void ReceiveAnimationParam();
private:
	static unsigned int BodyModel;  //身体模型列表
	static unsigned int HeadModel;//头部模型列表
	static unsigned int SmallHandModel;//小手臂列表
	static unsigned int BigHandModel;//大手臂列表
	static unsigned int HandModel;//手模型列表
	static unsigned int BigLegModel;//大腿列表
	static unsigned int SmallLegModel;//小腿列表
	static unsigned int FootModel;//脚列表
public:
	static void DrawHead(float Angle1, float Angle2, float Angle3);//绘制头部
private:
	static float speed;//速度
	static float HeadAngle1;//头部转动角度
	static float HeadAngle2;//头部转动角度
public:
	//输入数据
	void ControlAngleInput(float HeadAngl1, float HeadAngl2, float HeadAngl3, float* LeftLeg, float* RightLeg, float* Lefthand, float* Righthand);
	//初始化角度
	void AngleToInit(void);
private:
	static float HeadRAngle1;//头部转动最大角度
	static float HeadRAngle2;//头部转动最大角度
public:
	void SpeedControl(float speed);
private:
	static float HeadAngle3;头部前后角度
	static float HeadRAngle3;//头部前后角度
//左腿
	static float LeftBigleg1;//左大腿角度设置
	static float LeftBigleg2;//左大腿角度设置
	static float LeftBigleg3;//左大腿角度设置
	static float LeftRBigleg1;//左大腿转动角度设置
	static float LeftRBigleg2;
	static float LeftRBigleg3;

	static float Leftsmallleg1;//左小腿角度
	static float Leftsmallleg2;
	static float Leftsmallleg3;
	static float LeftRsmallleg1;//左小腿转动角度
	static float LeftRsmallleg2;
	static float LeftRsmallleg3;

	static float Leftfoot1;//左脚角度
	static float Leftfoot2;
	static float Leftfoot3;
	static float LeftRfoot1;//左脚转动角度
	static float LeftRfoot2;
	static float LeftRfoot3;
	//右腿
	static float RightBigleg1;//右腿角度
	static float RightBigleg2;
	static float RightBigleg3;
	static float RightRBigleg1;//右腿转动角度
	static float RightRBigleg2;
	static float RightRBigleg3;

	static float Rightsmallleg1;//右小腿角度
	static float Rightsmallleg2;
	static float Rightsmallleg3;
	static float RightRsmallleg1;//右小腿转动角度
	static float RightRsmallleg2;
	static float RightRsmallleg3;

	static float Rightfoot1;//右脚角度
	static float Rightfoot2;
	static float Rightfoot3;
	static float RightRfoot1;//右脚转动角度
	static float RightRfoot2;
	static float RightRfoot3;
	//左臂
	static float LeftBighand1;//左大臂角度
	static float LeftBighand2;
	static float LeftBighand3;
	static float LeftRBighand1;//左大臂转动角度
	static float LeftRBighand2;
	static float LeftRBighand3;

	static float Leftsmallhand1;//左小手臂角度
	static float Leftsmallhand2;
	static float Leftsmallhand3;
	static float LeftRsmallhand1;//左小手臂转动角度
	static float LeftRsmallhand2;
	static float LeftRsmallhand3;

	static float Lefthand1;//左手角度
	static float Lefthand2;
	static float Lefthand3;
	static float LeftRhand1;//左手转动角度
	static float LeftRhand2;
	static float LeftRhand3;
	//右臂
	static float RightBighand1;//右大臂角度
	static float RightBighand2;
	static float RightBighand3;
	static float RightRBighand1;//右大臂转动角度
	static float RightRBighand2;
	static float RightRBighand3;

	static float Rightsmallhand1;//右小手臂角度
	static float Rightsmallhand2;
	static float Rightsmallhand3;
	static float RightRsmallhand1;//右小手臂转动角度
	static float RightRsmallhand2;
	static float RightRsmallhand3;

	static float Righthand1;//右手角度
	static float Righthand2;
	static float Righthand3;
	static float RightRhand1;//右手转动角度
	static float RightRhand2;
	static float RightRhand3;
public:
	//左腿旋转
	static void LeftLeg(float bigleg1, float bigleg2, float bigleg3, float smallleg1, float smallleg2, float smallleg3,
		float foot1, float foot2, float foot3);
	//右腿旋转
	static void RightLeg(float bigleg1, float bigleg2, float bigleg3, float smallleg1, float smallleg2, float smallleg3,
		float foot1, float foot2, float foot3);
	//左臂旋转
	static void LeftHand(float bighand1, float bighand2, float bighand3, float smallhand1, float smallhand2, float smallhand3,
		float hand1, float hand2, float hand3);
	//右臂旋转
	static void RightHand(float bighand1, float bighand2, float bighand3, float smallhand1, float smallhand2, float smallhand3,
		float hand1, float hand2, float hand3);
private:
	static unsigned int BodySkinModel;//蒙皮显示列表
public:
	static void GenTexture(void);//生成显示列表
private:
	static unsigned int texture[8];//材质
public:
	static void SkinOrBone(bool skinorbone);//设置显示模式
private:
	static bool m_skinorbone;//显示模式判断
	static unsigned int HeadSkin;//头部蒙皮列表数值
	static unsigned int FootSkin;//脚部蒙皮列表数值
};


#include "OpenGL.h"

void* currOpenGL = nullptr;
void OpenGL::callback(void)
{
	//currOpenGL->RenderScene();
	return ;
}

using namespace std;
//导入模型
GLint Gen3DObjectListBody();
GLint Gen3DObjectListHead();
GLint Gen3DObjectListSmallHand();
GLint Gen3DObjectListBigHand();
GLint Gen3DObjectListHand();
GLint Gen3DObjectListBigLeg();
GLint Gen3DObjectListSmallLeg();
GLint Gen3DObjectListFoot();

//导入蒙皮
GLint Gen3DObjectListBodySkin();
GLint Gen3DObjectListHeadSkin();
GLint Gen3DObjectListFootSkin();
//导入结束


float OpenGL::camRot[3] = { 0 };
float OpenGL::camPos[3] = { 0 };
float OpenGL::sceneRot[3] = { 0 };
float OpenGL::scenePos[3] = { 0 };
unsigned int OpenGL::texture[8] = {0};

bool OpenGL::gIsStartTrackBall = false;
bool OpenGL::gIsMoveMap = false;
int OpenGL::xFar = 0.0f;
int OpenGL::yFar = 0.0f;
int OpenGL::zFar = 0.0f;
int OpenGL::oldX = 0.0f;
int OpenGL::oldY = 0.0f;

bool OpenGL::m_GenModelList = false;
unsigned int OpenGL::BodyModel = 0;
unsigned int OpenGL::HeadModel = 0;
unsigned int OpenGL::SmallHandModel = 0;
unsigned int OpenGL::BigHandModel = 0;
unsigned int OpenGL::HandModel = 0;
unsigned int OpenGL::BigLegModel = 0;
unsigned int OpenGL::SmallLegModel = 0;
unsigned int OpenGL::FootModel = 0;
float OpenGL::speed = 0.1;
//头
float OpenGL::HeadAngle1 = 0;
float OpenGL::HeadAngle2 = 0;
float OpenGL::HeadRAngle1 = 0;
float OpenGL::HeadRAngle2 = 0;
float OpenGL::HeadAngle3 = 0;
float OpenGL::HeadRAngle3 = 0;
//左腿
float OpenGL::LeftBigleg1 = 0;
float OpenGL::LeftBigleg2 = 0;
float OpenGL::LeftBigleg3 = 0;
float OpenGL::LeftRBigleg1 = 0;
float OpenGL::LeftRBigleg2 = 0;
float OpenGL::LeftRBigleg3 = 0;

float OpenGL::Leftsmallleg1 = 0;
float OpenGL::Leftsmallleg2 = 0;
float OpenGL::Leftsmallleg3 = 0;
float OpenGL::LeftRsmallleg1 = 0;
float OpenGL::LeftRsmallleg2 = 0;
float OpenGL::LeftRsmallleg3 = 0;
//左脚
float OpenGL::Leftfoot1 = 0;
float OpenGL::Leftfoot2 = 0;
float OpenGL::Leftfoot3 = 0;
float OpenGL::LeftRfoot1 = 0;
float OpenGL::LeftRfoot2 = 0;
float OpenGL::LeftRfoot3 = 0;
//右腿
float OpenGL::RightBigleg1 = 0;
float OpenGL::RightBigleg2 = 0;
float OpenGL::RightBigleg3 = 0;
float OpenGL::RightRBigleg1 = 0;
float OpenGL::RightRBigleg2 = 0;
float OpenGL::RightRBigleg3 = 0;

float OpenGL::Rightsmallleg1 = 0;
float OpenGL::Rightsmallleg2 = 0;
float OpenGL::Rightsmallleg3 = 0;
float OpenGL::RightRsmallleg1 = 0;
float OpenGL::RightRsmallleg2 = 0;
float OpenGL::RightRsmallleg3 = 0;

//右脚
float OpenGL::Rightfoot1 = 0;
float OpenGL::Rightfoot2 = 0;
float OpenGL::Rightfoot3 = 0;
float OpenGL::RightRfoot1 = 0;
float OpenGL::RightRfoot2 = 0;
float OpenGL::RightRfoot3 = 0;

//手臂
float OpenGL::LeftBighand1 = 0;
float OpenGL::LeftBighand2 = 0;
float OpenGL::LeftBighand3 = 0;
float OpenGL::LeftRBighand1 = 0;
float OpenGL::LeftRBighand2 = 0;
float OpenGL::LeftRBighand3 = 0;

float OpenGL::Leftsmallhand1 = 0;
float OpenGL::Leftsmallhand2 = 0;
float OpenGL::Leftsmallhand3 = 0;
float OpenGL::LeftRsmallhand1 = 0;
float OpenGL::LeftRsmallhand2 = 0;
float OpenGL::LeftRsmallhand3 = 0;

float OpenGL::Lefthand1 = 0;
float OpenGL::Lefthand2 = 0;
float OpenGL::Lefthand3 = 0;
float OpenGL::LeftRhand1 = 0;
float OpenGL::LeftRhand2 = 0;
float OpenGL::LeftRhand3 = 0;

float OpenGL::RightBighand1 = 0;
float OpenGL::RightBighand2 = 0;
float OpenGL::RightBighand3 = 0;
float OpenGL::RightRBighand1 = 0;
float OpenGL::RightRBighand2 = 0;
float OpenGL::RightRBighand3 = 0;

float OpenGL::Rightsmallhand1 = 0;
float OpenGL::Rightsmallhand2 = 0;
float OpenGL::Rightsmallhand3 = 0;
float OpenGL::RightRsmallhand1 = 0;
float OpenGL::RightRsmallhand2 = 0;
float OpenGL::RightRsmallhand3 = 0;


float OpenGL::Righthand1 = 0;
float OpenGL::Righthand2 = 0;
float OpenGL::Righthand3 = 0;
float OpenGL::RightRhand1 = 0;
float OpenGL::RightRhand2 = 0;
float OpenGL::RightRhand3 = 0;


bool OpenGL::m_skinorbone = false;
unsigned int OpenGL::HeadSkin = 0;
unsigned int OpenGL::FootSkin = 0;

unsigned int OpenGL::BodySkinModel = 0;

void OpenGL::func()
{
	//开始绘图准备
	::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	::glMatrixMode(GL_MODELVIEW);
	::glLoadIdentity();

	//相机摆放位置
	::glTranslatef(camPos[0], camPos[1], camPos[2]);
	::glRotatef(camRot[0], 1.0F, 0.0F, 0.0F);//第一个参数是旋转角度,1,0,0是X轴旋转
	::glRotatef(camRot[1], 0.0F, 1.0F, 0.0F);//第一个参数是旋转角度,0,1,0是Y轴旋转
	::glRotatef(camRot[2], 0.0F, 0.0F, 1.0F);//第一个参数是旋转角度,0,0,1是Z轴旋转

	//观察点位置
	::glPushMatrix();
	::glTranslatef(scenePos[0], scenePos[1], scenePos[2]);
	::glRotatef(sceneRot[0], 1.0F, 0.0F, 0.0F);
	::glRotatef(sceneRot[1], 0.0F, 1.0F, 0.0F);
	::glRotatef(sceneRot[2], 0.0F, 0.0F, 1.0F);

	glPushMatrix();
	//添加绘图代码
	//导入模型列表
	GenBoneList();
	/******************************************************/
		//绘制模型
	glPushMatrix();//压入堆栈
	glTranslatef(0, 0, 5);//移动到(0,0,5)
	glPushMatrix();
	//绘制躯体
	glPushMatrix();
	glScalef(13, 13, 13);//放大模型13倍(x,y,z)三个方向放大缩小,如果数值不一样,就是不等比缩放
	glPushMatrix();
	if (m_skinorbone == FALSE)		glCallList(BodyModel);//根据选择的绘图模式(如骨骼、蒙皮)进行绘制
	else
	{
		glEnable(GL_TEXTURE_2D);//贴图启用
		glBindTexture(GL_TEXTURE_2D, texture[0]);//贴图选择
		glColor3f(1.0, 1.0, 1.0);//物体颜色
		glTranslatef(0.01, 0, -0.5);
		glScalef(1.9, 1.8, 1.9);
		glCallList(BodySkinModel);
		glDisable(GL_TEXTURE_2D);//贴图禁用
	}
	glPopMatrix();//释放堆栈
	glPopMatrix();
	//绘制头部
	DrawHead(HeadRAngle1, HeadRAngle2, HeadRAngle3);
	//绘制右臂
	glPushMatrix();
	glTranslatef(-2.8, 0, 3.5);
	glScalef(-.8, .8, .8);
	if (m_skinorbone == FALSE)
		RightHand(RightRBighand1, RightRBighand2, RightRBighand3, RightRsmallhand1, RightRsmallhand2, RightRsmallhand3, RightRhand1, RightRhand2, RightRhand3);
	glPopMatrix();
	//绘制左臂
	glPushMatrix();
	glTranslatef(2.8, 0, 3.5);
	glScalef(.8, .8, .8);
	if (m_skinorbone == FALSE)
		LeftHand(LeftRBighand1, LeftRBighand2, LeftRBighand3, LeftRsmallhand1, LeftRsmallhand2, LeftRsmallhand3, LeftRhand1, LeftRhand2, LeftRhand3);
	glPopMatrix();
	//绘制右腿
	glPushMatrix();
	glTranslatef(-1.8, -.5, -5.2);
	glScalef(-1, 1, 1);
	if (m_skinorbone == FALSE)
		RightLeg(RightRBigleg1, RightRBigleg2, RightRBigleg3, RightRsmallleg1, RightRsmallleg2, RightRsmallleg3, RightRfoot1, RightRfoot2, RightRfoot3);
	glPopMatrix();
	//绘制左腿
	glPushMatrix();
	glTranslatef(1.8, -.5, -5.2);
	if (m_skinorbone == FALSE)
		LeftLeg(LeftRBigleg1, LeftRBigleg2, LeftRBigleg3, LeftRsmallleg1, LeftRsmallleg2, LeftRsmallleg3, LeftRfoot1, LeftRfoot2, LeftRfoot3);
	glPopMatrix();
	//绘制模型结束
	glPopMatrix();
	/*******************************************/
	glPopMatrix();
	//绘制坐标轴
	glPushMatrix();
	glBegin(GL_LINES);
	// x
	glColor3f(1.0F, 0.0F, 0.0F);
	glVertex3f(-10.0f, 0.0f, 0.0f);
	glVertex3f(10.0f, 0.0f, 0.0f);
	// y
	glColor3f(0.0F, 1.0F, 0.0F);
	glVertex3f(0.0f, -10.0f, 0.0f);
	glVertex3f(0.0f, 10.0f, 0.0f);
	// z
	glColor3f(0.0F, 0.0F, 1.0F);
	glVertex3f(0.0f, 0.0f, -10.0f);
	glVertex3f(0.0f, 0.0f, 10.0f);
	glEnd();
	glPopMatrix();
	//绘制坐标轴结束
/********************************************/
	glPopMatrix();
}


OpenGL::OpenGL()
	//: m_GenModelList(false)
	//, BodyModel(0)
	//, HeadModel(0)
	//, SmallHandModel(0)
	//, BigHandModel(0)
	//, HandModel(0)
	//, BigLegModel(0)
	//, SmallLegModel(0)
	//, FootModel(0)
	//, speed(0.1)
	
	//, HeadAngle1(0)
	//, HeadAngle2(0)
	//, HeadRAngle1(0)
	//, HeadRAngle2(0)
	//, HeadAngle3(0)
	//, HeadRAngle3(0)
	
	//, LeftBigleg1(0)
	//, LeftBigleg2(0)
	//, LeftBigleg3(0)
	//, LeftRBigleg1(0)
	//, LeftRBigleg2(0)
	//, LeftRBigleg3(0)

	//, Leftsmallleg1(0)
	//, Leftsmallleg2(0)
	//, Leftsmallleg3(0)
	//, LeftRsmallleg1(0)
	//, LeftRsmallleg2(0)
	//, LeftRsmallleg3(0)

	//, Leftfoot1(0)
	//, Leftfoot2(0)
	//, Leftfoot3(0)
	//, LeftRfoot1(0)
	//, LeftRfoot2(0)
	//, LeftRfoot3(0)

	//, RightBigleg1(0)
	//, RightBigleg2(0)
	//, RightBigleg3(0)
	//, RightRBigleg1(0)
	//, RightRBigleg2(0)
	//, RightRBigleg3(0)

	//, Rightsmallleg1(0)
	//, Rightsmallleg2(0)
	//, Rightsmallleg3(0)
	//, RightRsmallleg1(0)
	//, RightRsmallleg2(0)
	//, RightRsmallleg3(0)

	//, Rightfoot1(0)
	//, Rightfoot2(0)
	//, Rightfoot3(0)
	//, RightRfoot1(0)
	//, RightRfoot2(0)
	//, RightRfoot3(0)
	手臂
	//, LeftBighand1(0)
	//, LeftBighand2(0)
	//, LeftBighand3(0)
	//, LeftRBighand1(0)
	//, LeftRBighand2(0)
	//, LeftRBighand3(0)

	//, Leftsmallhand1(0)
	//, Leftsmallhand2(0)
	//, Leftsmallhand3(0)
	//, LeftRsmallhand1(0)
	//, LeftRsmallhand2(0)
	//, LeftRsmallhand3(0)

	//, Lefthand1(0)
	//, Lefthand2(0)
	//, Lefthand3(0)
	//, LeftRhand1(0)
	//, LeftRhand2(0)
	//, LeftRhand3(0)

	//, RightBighand1(0)
	//, RightBighand2(0)
	//, RightBighand3(0)
	//, RightRBighand1(0)
	//, RightRBighand2(0)
	//, RightRBighand3(0)

	//, Rightsmallhand1(0)
	//, Rightsmallhand2(0)
	//, Rightsmallhand3(0)
	//, RightRsmallhand1(0)
	//, RightRsmallhand2(0)
	//, RightRsmallhand3(0)

	//, Righthand1(0)
	//, Righthand2(0)
	//, Righthand3(0)
	//, RightRhand1(0)
	//, RightRhand2(0)
	//, RightRhand3(0)
	//, BodySkinModel(0)
	//, skinorbone(false)
	//, HeadSkin(0)
	//, FootSkin(0)
{
		

}

OpenGL::~OpenGL()
{

}


int OpenGL::CreateOpenGLWindow(int width, int height)
{
	/*m_iWindowStatus = glfwInit();
	if (GLFW_FALSE == m_iWindowStatus)
	{
		cout << "Initilize GLFW failed!" << endl;
		glfwTerminate();
		return GLFW_FALSE;
	}

	glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
	glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
	glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
	
	m_window = glfwCreateWindow(800, 600, "BoneAnimation", nullptr, nullptr);
	if (nullptr == m_window)
	{
		cout << "GLFW create window failed!" << endl;
		glfwTerminate();
		return GLFW_FALSE;
	}

	glfwMakeContextCurrent(m_window);
	glfwSetFramebufferSizeCallback(m_window, FrameBuffer_size_callback);
	glfwSetCursorPosCallback(m_window, Mouse_Move_callback);
	glfwSetScrollCallback(m_window, Scroll_callback);
	glfwSetInputMode(m_window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);*/


	//glutInit(&argc, argv);                                             //初始化GLUT
	//glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_MULTISAMPLE);  //设置显示模式
	//glutInitWindowPosition(0, 0);  //设置显示窗口的左上角位置
	//glutInitWindowSize(wWidth, wHeight);         //设置窗口的长和高
	//glutCreateWindow("3DMap");     //创造显示窗口


	//设置初始相机观察位置
	//相机位置坐标
	camPos[0] = 0.0;
	camPos[1] = 0.0;
	camPos[2] = -100.0f;
	//旋转角度
	camRot[0] = 20.0f;
	camRot[1] = -20.0f;
	camRot[2] = 0.0f;

	//观察点位置坐标
	scenePos[0] = 0.0f;
	scenePos[1] = 0.0f;
	scenePos[2] = 0.0f;
	//观察点旋转角度
	sceneRot[0] = 0.0f;
	sceneRot[1] = 0.0f;
	sceneRot[2] = 0.0f;
	//鼠标点击信息以及预存位置
	/*mouseprevpoint.x = 0;
	mouseprevpoint.y = 0;*/

	mouserightdown = FALSE;
	mouseleftdown = FALSE;
	//初始化环境
	//init();
	InitOpneGL();

	return 0;
}

void OpenGL::Display()
{
	//InitOpneGL();
	//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //清除颜色缓存和深度缓存

	清除缓存
	//glClearColor(0.0, 0.1, 0.1, 1.0);
	//glEnable(GL_DEPTH_TEST);

	进行绘制
	//RenderScene();

	//glfwSwapBuffers(m_window);

		//开始绘图准备
	::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	::glMatrixMode(GL_MODELVIEW);
	::glLoadIdentity();

	//相机摆放位置
	::glTranslatef(camPos[0], camPos[1], camPos[2]);
	::glRotatef(camRot[0], 1.0F, 0.0F, 0.0F);//第一个参数是旋转角度,1,0,0是X轴旋转
	::glRotatef(camRot[1], 0.0F, 1.0F, 0.0F);//第一个参数是旋转角度,0,1,0是Y轴旋转
	::glRotatef(camRot[2], 0.0F, 0.0F, 1.0F);//第一个参数是旋转角度,0,0,1是Z轴旋转

	//观察点位置
	::glPushMatrix();
	::glTranslatef(scenePos[0], scenePos[1], scenePos[2]);
	::glRotatef(sceneRot[0], 1.0F, 0.0F, 0.0F);
	::glRotatef(sceneRot[1], 0.0F, 1.0F, 0.0F);
	::glRotatef(sceneRot[2], 0.0F, 0.0F, 1.0F);

	glPushMatrix();
	//添加绘图代码
	//导入模型列表
	GenBoneList();
	/******************************************************/
		//绘制模型
	glPushMatrix();//压入堆栈
	glTranslatef(0, 0, 5);//移动到(0,0,5)
	glPushMatrix();
	//绘制躯体
	glPushMatrix();
	glScalef(13, 13, 13);//放大模型13倍(x,y,z)三个方向放大缩小,如果数值不一样,就是不等比缩放
	glPushMatrix();
	if (m_skinorbone == FALSE)		glCallList(BodyModel);//根据选择的绘图模式(如骨骼、蒙皮)进行绘制
	else
	{
		glEnable(GL_TEXTURE_2D);//贴图启用
		glBindTexture(GL_TEXTURE_2D, texture[0]);//贴图选择
		glColor3f(1.0, 1.0, 1.0);//物体颜色
		glTranslatef(0.01, 0, -0.5);
		glScalef(1.9, 1.8, 1.9);
		glCallList(BodySkinModel);
		glDisable(GL_TEXTURE_2D);//贴图禁用
	}
	glPopMatrix();//释放堆栈
	glPopMatrix();
	//绘制头部
	DrawHead(HeadRAngle1, HeadRAngle2, HeadRAngle3);
	//绘制右臂
	glPushMatrix();
	glTranslatef(-2.8, 0, 3.5);
	glScalef(-.8, .8, .8);
	if (m_skinorbone == FALSE)
		RightHand(RightRBighand1, RightRBighand2, RightRBighand3, RightRsmallhand1, RightRsmallhand2, RightRsmallhand3, RightRhand1, RightRhand2, RightRhand3);
	glPopMatrix();
	//绘制左臂
	glPushMatrix();
	glTranslatef(2.8, 0, 3.5);
	glScalef(.8, .8, .8);
	if (m_skinorbone == FALSE)
		LeftHand(LeftRBighand1, LeftRBighand2, LeftRBighand3, LeftRsmallhand1, LeftRsmallhand2, LeftRsmallhand3, LeftRhand1, LeftRhand2, LeftRhand3);
	glPopMatrix();
	//绘制右腿
	glPushMatrix();
	glTranslatef(-1.8, -.5, -5.2);
	glScalef(-1, 1, 1);
	if (m_skinorbone == FALSE)
		RightLeg(RightRBigleg1, RightRBigleg2, RightRBigleg3, RightRsmallleg1, RightRsmallleg2, RightRsmallleg3, RightRfoot1, RightRfoot2, RightRfoot3);
	glPopMatrix();
	//绘制左腿
	glPushMatrix();
	glTranslatef(1.8, -.5, -5.2);
	if (m_skinorbone == FALSE)
		LeftLeg(LeftRBigleg1, LeftRBigleg2, LeftRBigleg3, LeftRsmallleg1, LeftRsmallleg2, LeftRsmallleg3, LeftRfoot1, LeftRfoot2, LeftRfoot3);
	glPopMatrix();
	//绘制模型结束
	glPopMatrix();
	/*******************************************/
	glPopMatrix();
	//绘制坐标轴
	glPushMatrix();
	glBegin(GL_LINES);
	// x
	glColor3f(1.0F, 0.0F, 0.0F);
	glVertex3f(-10.0f, 0.0f, 0.0f);
	glVertex3f(10.0f, 0.0f, 0.0f);
	// y
	glColor3f(0.0F, 1.0F, 0.0F);
	glVertex3f(0.0f, -10.0f, 0.0f);
	glVertex3f(0.0f, 10.0f, 0.0f);
	// z
	glColor3f(0.0F, 0.0F, 1.0F);
	glVertex3f(0.0f, 0.0f, -10.0f);
	glVertex3f(0.0f, 0.0f, 10.0f);
	glEnd();
	glPopMatrix();
	//绘制坐标轴结束
/********************************************/
	glPopMatrix();

	glFlush();
	glutSwapBuffers();  // 交换缓存 
}

//void OpenGL::FrameBuffer_size_callback(GLFWwindow* window, int width, int height)
//{
//	glViewport(0, 0, width, height);
//
//	//模型的观察视角
//	GLdouble aspect_ratio;//高度与宽度的比值
//	aspect_ratio = (GLdouble)width / (GLdouble)height;
//	::glMatrixMode(GL_PROJECTION);//投影模式
//	::glLoadIdentity();//载入矩阵
//	::gluPerspective(40.0F, aspect_ratio, 1.0F, 10000.0F);//绘制窗口大小
//	::glMatrixMode(GL_MODELVIEW);//模型显示模式
//	::glLoadIdentity();//载入矩阵
//}

void OpenGL::RenderScene(void)
{
	OpenGL* mySelf = (OpenGL*)currOpenGL;
	mySelf->Display();

	//currOpenGL->func();
	//setCurrentOpenGL();
//	//开始绘图准备
//	::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//	::glMatrixMode(GL_MODELVIEW);
//	::glLoadIdentity();
//
//	//相机摆放位置
//	::glTranslatef(camPos[0], camPos[1], camPos[2]);
//	::glRotatef(camRot[0], 1.0F, 0.0F, 0.0F);//第一个参数是旋转角度,1,0,0是X轴旋转
//	::glRotatef(camRot[1], 0.0F, 1.0F, 0.0F);//第一个参数是旋转角度,0,1,0是Y轴旋转
//	::glRotatef(camRot[2], 0.0F, 0.0F, 1.0F);//第一个参数是旋转角度,0,0,1是Z轴旋转
//
//	//观察点位置
//	::glPushMatrix();
//	::glTranslatef(scenePos[0], scenePos[1], scenePos[2]);
//	::glRotatef(sceneRot[0], 1.0F, 0.0F, 0.0F);
//	::glRotatef(sceneRot[1], 0.0F, 1.0F, 0.0F);
//	::glRotatef(sceneRot[2], 0.0F, 0.0F, 1.0F);
//
//	glPushMatrix();
//	//添加绘图代码
//	//导入模型列表
//	GenBoneList();
//	/******************************************************/
//		//绘制模型
//	glPushMatrix();//压入堆栈
//	glTranslatef(0, 0, 5);//移动到(0,0,5)
//	glPushMatrix();
//	//绘制躯体
//	glPushMatrix();
//	glScalef(13, 13, 13);//放大模型13倍(x,y,z)三个方向放大缩小,如果数值不一样,就是不等比缩放
//	glPushMatrix();
//	if (m_skinorbone == FALSE)		glCallList(BodyModel);//根据选择的绘图模式(如骨骼、蒙皮)进行绘制
//	else
//	{
//		glEnable(GL_TEXTURE_2D);//贴图启用
//		glBindTexture(GL_TEXTURE_2D, texture[0]);//贴图选择
//		glColor3f(1.0, 1.0, 1.0);//物体颜色
//		glTranslatef(0.01, 0, -0.5);
//		glScalef(1.9, 1.8, 1.9);
//		glCallList(BodySkinModel);
//		glDisable(GL_TEXTURE_2D);//贴图禁用
//	}
//	glPopMatrix();//释放堆栈
//	glPopMatrix();
//	//绘制头部
//	DrawHead(HeadRAngle1, HeadRAngle2, HeadRAngle3);
//	//绘制右臂
//	glPushMatrix();
//	glTranslatef(-2.8, 0, 3.5);
//	glScalef(-.8, .8, .8);
//	if (m_skinorbone == FALSE)
//		RightHand(RightRBighand1, RightRBighand2, RightRBighand3, RightRsmallhand1, RightRsmallhand2, RightRsmallhand3, RightRhand1, RightRhand2, RightRhand3);
//	glPopMatrix();
//	//绘制左臂
//	glPushMatrix();
//	glTranslatef(2.8, 0, 3.5);
//	glScalef(.8, .8, .8);
//	if (m_skinorbone == FALSE)
//		LeftHand(LeftRBighand1, LeftRBighand2, LeftRBighand3, LeftRsmallhand1, LeftRsmallhand2, LeftRsmallhand3, LeftRhand1, LeftRhand2, LeftRhand3);
//	glPopMatrix();
//	//绘制右腿
//	glPushMatrix();
//	glTranslatef(-1.8, -.5, -5.2);
//	glScalef(-1, 1, 1);
//	if (m_skinorbone == FALSE)
//		RightLeg(RightRBigleg1, RightRBigleg2, RightRBigleg3, RightRsmallleg1, RightRsmallleg2, RightRsmallleg3, RightRfoot1, RightRfoot2, RightRfoot3);
//	glPopMatrix();
//	//绘制左腿
//	glPushMatrix();
//	glTranslatef(1.8, -.5, -5.2);
//	if (m_skinorbone == FALSE)
//		LeftLeg(LeftRBigleg1, LeftRBigleg2, LeftRBigleg3, LeftRsmallleg1, LeftRsmallleg2, LeftRsmallleg3, LeftRfoot1, LeftRfoot2, LeftRfoot3);
//	glPopMatrix();
//	//绘制模型结束
//	glPopMatrix();
//	/*******************************************/
//	glPopMatrix();
//	//绘制坐标轴
//	glPushMatrix();
//	glBegin(GL_LINES);
//	// x
//	glColor3f(1.0F, 0.0F, 0.0F);
//	glVertex3f(-10.0f, 0.0f, 0.0f);
//	glVertex3f(10.0f, 0.0f, 0.0f);
//	// y
//	glColor3f(0.0F, 1.0F, 0.0F);
//	glVertex3f(0.0f, -10.0f, 0.0f);
//	glVertex3f(0.0f, 10.0f, 0.0f);
//	// z
//	glColor3f(0.0F, 0.0F, 1.0F);
//	glVertex3f(0.0f, 0.0f, -10.0f);
//	glVertex3f(0.0f, 0.0f, 10.0f);
//	glEnd();
//	glPopMatrix();
//	//绘制坐标轴结束
///********************************************/
//	glPopMatrix();
}

//void OpenGL::FrameBuffer_size_callback(GLFWwindow* window, int width, int height)
//{
//	glViewport(0, 0, width, height);
//
//	//模型的观察视角
//	GLdouble aspect_ratio;//高度与宽度的比值
//	aspect_ratio = (GLdouble)width / (GLdouble)height;
//	::glMatrixMode(GL_PROJECTION);//投影模式
//	::glLoadIdentity();//载入矩阵
//	::gluPerspective(40.0F, aspect_ratio, 1.0F, 10000.0F);//绘制窗口大小
//	::glMatrixMode(GL_MODELVIEW);//模型显示模式
//	::glLoadIdentity();//载入矩阵
//}

void OpenGL::InitOpneGL(void)
{
	::glShadeModel(GL_FLAT);
	::glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
	//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	::glClearDepth(1.0f);
	::glEnable(GL_DEPTH_TEST);
	::glEnable(GL_CULL_FACE);

	//设置环境参数
	GLfloat ambientLight[] = { 0.3f, 0.3f, 0.3f, 1.0f };//颜色(R,G,B),以及权重值//环境光
	GLfloat diffuseLight[] = { 0.7f, 0.7f, 0.7f, 1.0f };//漫反射光
	GLfloat lightPos[] = { 6.0f,6.0f,6.0f, 1.0f };   //灯光位置
	GLfloat ambient[] = { 0.2, 0.2, 0.2, 1.0 };//物体本身材质
	GLfloat diffuse[] = { 0.8, 0.8, 0.8, 1.0 };
	GLfloat specular[] = { 0.9, 0.9, 0.9, 1.0 };//高光
	GLfloat shininess = 65.0;  //高光
	//材质
	glMaterialfv(GL_FRONT, GL_AMBIENT, ambient);
	glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse);
	glMaterialfv(GL_FRONT, GL_SPECULAR, specular);
	glMaterialf(GL_FRONT, GL_SHININESS, shininess);

	//灯光
	glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight);
	glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight);
	glLightfv(GL_LIGHT0, GL_POSITION, lightPos);
	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientLight);

	//材质灯光模式设定
	glEnable(GL_COLOR_MATERIAL);
	glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);
}

void OpenGL::GenBoneList(void)
{
	if (m_GenModelList == FALSE)
	{
		//载入贴图
		GenTexture();

		//载入模型
		BodyModel = Gen3DObjectListBody();
		HeadModel = Gen3DObjectListHead();
		SmallHandModel = Gen3DObjectListSmallHand();
		BigHandModel = Gen3DObjectListBigHand();
		HandModel = Gen3DObjectListHand();
		BigLegModel = Gen3DObjectListBigLeg();
		SmallLegModel = Gen3DObjectListSmallLeg();
		FootModel = Gen3DObjectListFoot();

		//载入蒙皮模型列表
		BodySkinModel = Gen3DObjectListBodySkin();
		HeadSkin = Gen3DObjectListHeadSkin();
		FootSkin = Gen3DObjectListFootSkin();
		m_GenModelList = TRUE;
	}
}

void OpenGL::DrawHead(float Angle1, float Angle2, float Angle3)
{

	//必须防止速度增加值过大导致错误
	//头部转动角度判断
	if (Angle1 >= 0 && HeadAngle1 < Angle1)
	{
		HeadAngle1 += speed;		if (HeadAngle1 > Angle1) HeadAngle1 = Angle1;
	}
	if (Angle1<0 && HeadAngle1 > Angle1)
	{
		HeadAngle1 -= speed;	if (HeadAngle1 < Angle1) HeadAngle1 = Angle1;
	}

	//头部前后角度判断
	if (Angle2 >= 0 && HeadAngle2 < Angle2)
	{
		HeadAngle2 += speed;		if (HeadAngle2 > Angle2) HeadAngle2 = Angle2;
	}
	if (Angle2<0 && HeadAngle2 > Angle2)
	{
		HeadAngle2 -= speed;	if (HeadAngle2 < Angle2) HeadAngle2 = Angle2;
	}

	//头部高低角度判断
	if (Angle3 >= 0 && HeadAngle3 < Angle3)
	{
		HeadAngle3 += speed;		if (HeadAngle3 > Angle3) HeadAngle3 = Angle3;
	}
	if (Angle3<0 && HeadAngle3 > Angle3)
	{
		HeadAngle3 -= speed;	if (HeadAngle3 < Angle3) HeadAngle3 = Angle3;
	}


	glPushMatrix();
	glTranslatef(0, 0, 6.5);

	//glTranslatef(0,0,0.5);
	glRotatef(HeadAngle2, 0, 1, 0);
	glRotatef(HeadAngle1, 1, 0, 0);
	glRotatef(HeadAngle3, 0, 0, 1);
	glTranslatef(0, 0, 0.5);
	glPushMatrix();
	glScalef(4, 4, 4);
	glPushMatrix();
	glCallList(HeadModel);
	if (m_skinorbone == TRUE)
	{
		glEnable(GL_TEXTURE_2D);
		glBindTexture(GL_TEXTURE_2D, texture[1]);
		glColor3f(1.0, 1.0, 1.0);
		glTranslatef(-.02, -0.07, -3.6);
		glScalef(8.5, 8.5, 8.5);
		glCallList(HeadSkin);//绘制头部蒙皮模式
		glDisable(GL_TEXTURE_2D);
	}
	glPopMatrix();
	glPopMatrix();
	glPopMatrix();
}

void OpenGL::ControlAngleInput(float HeadAngl1, float HeadAngl2,
	float HeadAngl3, float LeftLeg[9], float RightLeg[9], float Lefthand[9], float Righthand[9])
{
	AngleToInit();
	//头部角度控制
	if (HeadAngl1 > 30)		HeadAngl1 = 30;
	if (HeadAngl1 < -30)		HeadAngl1 = -30;
	if (HeadAngl2 > 30)		HeadAngl2 = 30;
	if (HeadAngl2 < -30)		HeadAngl2 = -30;
	if (HeadAngl3 > 45)		HeadAngl3 = 45;
	if (HeadAngl3 < -45)		HeadAngl3 = -45;
	//左腿角度控制
	if (LeftLeg[0] > 165)		LeftLeg[0] = 165;
	if (LeftLeg[0] < -25)		LeftLeg[0] = -25;
	if (LeftLeg[1] > 90)		LeftLeg[1] = 90;
	if (LeftLeg[1] < -30)		LeftLeg[1] = -30;
	if (LeftLeg[2] > 10)		LeftLeg[2] = 10;
	if (LeftLeg[2] < -10)		LeftLeg[2] = -10;
	if (LeftLeg[3] > 0)		LeftLeg[3] = 0;
	if (LeftLeg[3] < -175)		LeftLeg[3] = -175;
	LeftLeg[4] = 0;	//膝盖处不能转动 所以置0
	if (LeftLeg[5] > 10)		LeftLeg[5] = 10;
	if (LeftLeg[5] < -10)		LeftLeg[5] = -10;
	if (LeftLeg[6] > 90)		LeftLeg[6] = 90;
	if (LeftLeg[6] < -25)		LeftLeg[6] = -25;
	if (LeftLeg[7] > 10)		LeftLeg[7] = 10;
	if (LeftLeg[7] < -10)		LeftLeg[7] = -10;
	LeftLeg[8] = 0; //无法转动 0
//右腿角度控制
	if (RightLeg[0] > 165)		RightLeg[0] = 165;
	if (RightLeg[0] < -25)		RightLeg[0] = -25;
	if (RightLeg[1] > 90)			RightLeg[1] = 90;
	if (RightLeg[1] < -30)		RightLeg[1] = -30;
	if (RightLeg[2] > 10)			RightLeg[2] = 10;
	if (RightLeg[2] < -10)		RightLeg[2] = -10;
	if (RightLeg[3] > 0)			RightLeg[3] = 0;
	if (RightLeg[3] < -175)		RightLeg[3] = -175;
	RightLeg[4] = 0;	//膝盖处不能转动 所以置0
	if (RightLeg[5] > 10)			RightLeg[5] = 10;
	if (RightLeg[5] < -10)		RightLeg[5] = -10;
	if (RightLeg[6] > 90)			RightLeg[6] = 90;
	if (RightLeg[6] < -25)		RightLeg[6] = -25;
	if (RightLeg[7] > 10)			RightLeg[7] = 10;
	if (RightLeg[7] < -10)		RightLeg[7] = -10;
	RightLeg[8] = 0; //无法转动 0
//左臂角度控制
	if (Lefthand[0] > 175)		Lefthand[0] = 175;
	if (Lefthand[0] < -45)		Lefthand[0] = -45;
	if (Lefthand[1] > 120)		Lefthand[1] = 120;
	if (Lefthand[1] < -30)		Lefthand[1] = -30;
	if (Lefthand[2] > 10)			Lefthand[2] = 10;
	if (Lefthand[2] < -10)		Lefthand[2] = -10;
	if (Lefthand[3] > 175)		Lefthand[3] = 175;
	if (Lefthand[3] < 0)			Lefthand[3] = 0;
	Lefthand[4] = 0;	//不能转动 所以置0
	if (Lefthand[5] > 10)		Lefthand[5] = 10;
	if (Lefthand[5] < 0)			Lefthand[5] = 0;
	if (Lefthand[6] > 35)			Lefthand[6] = 35;
	if (Lefthand[6] < -90)		Lefthand[6] = -90;
	if (Lefthand[7] > 10)			Lefthand[7] = 10;
	if (Lefthand[7] < -30)		Lefthand[7] = -30;
	Lefthand[8] = 0; //无法转动 0
//右臂角度控制
	if (Righthand[0] > 175)		Righthand[0] = 175;
	if (Righthand[0] < -45)		Righthand[0] = -45;
	if (Righthand[1] > 120)		Righthand[1] = 120;
	if (Righthand[1] < -30)		Righthand[1] = -30;
	if (Righthand[2] > 10)		Righthand[2] = 10;
	if (Righthand[2] < -10)		Righthand[2] = -10;
	if (Righthand[3] > 175)		Righthand[3] = 175;
	if (Righthand[3] < 0)			Righthand[3] = 0;
	Righthand[4] = 0;	//不能转动 所以置0
	if (Righthand[5] > 10)		Righthand[5] = 10;
	if (Righthand[5] < 0)			Righthand[5] = 0;
	if (Righthand[6] > 35)		Righthand[6] = 35;
	if (Righthand[6] < -90)		Righthand[6] = -90;
	if (Righthand[7] > 10)		Righthand[7] = 10;
	if (Righthand[7] < -30)		Righthand[7] = -30;
	Righthand[8] = 0; //无法转动 0


	//头部角度
	HeadRAngle1 = HeadAngl1;
	HeadRAngle2 = HeadAngl2;
	HeadRAngle3 = HeadAngl3;
	//左腿角度
	LeftRBigleg1 = LeftLeg[0];
	LeftRBigleg2 = LeftLeg[1];
	LeftRBigleg3 = LeftLeg[2];

	LeftRsmallleg1 = LeftLeg[3];
	LeftRsmallleg2 = LeftLeg[4];
	LeftRsmallleg3 = LeftLeg[5];

	LeftRfoot1 = LeftLeg[6];
	LeftRfoot2 = LeftLeg[7];
	LeftRfoot3 = LeftLeg[8];
	//右腿角度
	RightRBigleg1 = RightLeg[0];
	RightRBigleg2 = RightLeg[1];
	RightRBigleg3 = RightLeg[2];

	RightRsmallleg1 = RightLeg[3];
	RightRsmallleg2 = RightLeg[4];
	RightRsmallleg3 = RightLeg[5];

	RightRfoot1 = RightLeg[6];
	RightRfoot2 = RightLeg[7];
	RightRfoot3 = RightLeg[8];

	//左臂角度
	LeftRBighand1 = Lefthand[0];
	LeftRBighand2 = Lefthand[1];
	LeftRBighand3 = Lefthand[2];

	LeftRsmallhand1 = Lefthand[3];
	LeftRsmallhand2 = Lefthand[4];
	LeftRsmallhand3 = Lefthand[5];

	LeftRhand1 = Lefthand[6];
	LeftRhand2 = Lefthand[7];
	LeftRhand3 = Lefthand[8];
	//右臂角度
	RightRBighand1 = Righthand[0];
	RightRBighand2 = Righthand[1];
	RightRBighand3 = Righthand[2];

	RightRsmallhand1 = Righthand[3];
	RightRsmallhand2 = Righthand[4];
	RightRsmallhand3 = Righthand[5];

	RightRhand1 = Righthand[6];
	RightRhand2 = Righthand[7];
	RightRhand3 = Righthand[8];
}

void OpenGL::AngleToInit(void)
{
	//头部
	HeadAngle1 = 0;
	HeadAngle2 = 0;
	HeadAngle3 = 0;
	//左腿
	LeftBigleg1 = 0;
	LeftBigleg2 = 0;
	LeftBigleg3 = 0;

	Leftsmallleg1 = 0;
	Leftsmallleg2 = 0;
	Leftsmallleg3 = 0;

	Leftfoot1 = 0;
	Leftfoot2 = 0;
	Leftfoot3 = 0;
	//右腿
	RightBigleg1 = 0;
	RightBigleg2 = 0;
	RightBigleg3 = 0;

	Rightsmallleg1 = 0;
	Rightsmallleg2 = 0;
	Rightsmallleg3 = 0;

	Rightfoot1 = 0;
	Rightfoot2 = 0;
	Rightfoot3 = 0;
	//左臂
	LeftBighand1 = 0;
	LeftBighand2 = 0;
	LeftBighand3 = 0;

	Leftsmallhand1 = 0;
	Leftsmallhand2 = 0;
	Leftsmallhand3 = 0;

	Lefthand1 = 0;
	Lefthand2 = 0;
	Lefthand3 = 0;
	//右臂
	RightBighand1 = 0;
	RightBighand2 = 0;
	RightBighand3 = 0;

	Rightsmallhand1 = 0;
	Rightsmallhand2 = 0;
	Rightsmallhand3 = 0;

	Righthand1 = 0;
	Righthand2 = 0;
	Righthand3 = 0;
}

void OpenGL::SpeedControl(float speed)
{
	this->speed = speed;
}

void OpenGL::LeftLeg(float bigleg1, float bigleg2, float bigleg3,
	float smallleg1, float smallleg2, float smallleg3,
	float foot1, float foot2, float foot3)
{
	//必须防止速度增加值过大导致错误
	//大腿转动角度判断//例如45表示要向前旋转45度,-45表示向后旋转45度 旋转角度在此范围之内就要加上速度进行旋转
	if (bigleg1 >= 0 && LeftBigleg1 < bigleg1)//>0输入角度的判断,前进,<小于最大值的判断
	{
		LeftBigleg1 += speed;	if (LeftBigleg1 > bigleg1) LeftBigleg1 = bigleg1;
	}
	if (bigleg1<0 && LeftBigleg1 > bigleg1) //<0输入角度的判断,后退,<大于最小值的判断,以下判断同样道理
	{
		LeftBigleg1 -= speed;	if (LeftBigleg1 < bigleg1) LeftBigleg1 = bigleg1;
	}
	if (bigleg2 >= 0 && LeftBigleg2 < bigleg2)
	{
		LeftBigleg2 += speed;	if (LeftBigleg2 > bigleg2) LeftBigleg2 = bigleg2;
	}
	if (bigleg2<0 && LeftBigleg2 > bigleg2)
	{
		LeftBigleg2 -= speed;	if (LeftBigleg2 < bigleg2) LeftBigleg2 = bigleg2;
	}
	if (bigleg3 >= 0 && LeftBigleg3 < bigleg3)
	{
		LeftBigleg3 += speed;	if (LeftBigleg3 > bigleg3) LeftBigleg3 = bigleg3;
	}
	if (bigleg3<0 && LeftBigleg3 > bigleg3)
	{
		LeftBigleg3 -= speed;	if (LeftBigleg3 < bigleg3) LeftBigleg3 = bigleg3;
	}
	//小腿
	if (smallleg1 >= 0 && Leftsmallleg1 < smallleg1)
	{
		Leftsmallleg1 += speed;	if (Leftsmallleg1 > smallleg1) Leftsmallleg1 = smallleg1;
	}
	if (smallleg1<0 && Leftsmallleg1 > smallleg1)
	{
		Leftsmallleg1 -= speed;	if (Leftsmallleg1 < smallleg1) Leftsmallleg1 = smallleg1;
	}
	if (smallleg2 >= 0 && Leftsmallleg2 < smallleg2)
	{
		Leftsmallleg2 += speed;	if (Leftsmallleg2 > smallleg2) Leftsmallleg2 = smallleg2;
	}
	if (smallleg2<0 && Leftsmallleg2 > smallleg2)
	{
		Leftsmallleg2 -= speed;	if (Leftsmallleg2 < smallleg2) Leftsmallleg2 = smallleg2;
	}
	if (smallleg3 >= 0 && Leftsmallleg3 < smallleg3)
	{
		Leftsmallleg3 += speed;	if (Leftsmallleg3 > smallleg3) Leftsmallleg3 = smallleg3;
	}
	if (smallleg3<0 && Leftsmallleg3 > smallleg3)
	{
		Leftsmallleg3 -= speed;	if (Leftsmallleg3 < smallleg3) Leftsmallleg3 = smallleg3;
	}
	//脚
	if (foot1 >= 0 && Leftfoot1 < foot1)
	{
		Leftfoot1 += speed;	if (Leftfoot1 > foot1) Leftfoot1 = foot1;
	}
	if (foot1<0 && Leftfoot1 > foot1)
	{
		Leftfoot1 -= speed;	if (Leftfoot1 < foot1) Leftfoot1 = foot1;
	}

	if (foot2 >= 0 && Leftfoot2 < foot2)
	{
		Leftfoot2 += speed;	if (Leftfoot2 > foot2) Leftfoot2 = foot2;
	}
	if (foot2<0 && Leftfoot2 > foot2)
	{
		Leftfoot2 -= speed;	if (Leftfoot2 < foot2) Leftfoot2 = foot2;
	}

	if (foot3 >= 0 && Leftfoot3 < foot3)
	{
		Leftfoot3 += speed;	if (Leftfoot3 > foot3) Leftfoot3 = foot3;
	}
	if (foot3<0 && Leftfoot3 > foot3)
	{
		Leftfoot3 -= speed;	if (Leftfoot3 < foot3) Leftfoot3 = foot3;
	}



	glPushMatrix();
	//开始绘图
	//绘制左大腿
	glRotatef(-LeftBigleg1, 1, 0, 0);//旋转角度1,X轴旋转
	glRotatef(-LeftBigleg2, 0, 1, 0);//旋转角度2,Y轴旋转
	glRotatef(-LeftBigleg3, 0, 0, 1);//旋转角度3,Z轴旋转
	glTranslatef(-0.1, 0.9, -3.5);//从(0,0,0)点移动到(-0.1,0.9,-3.5)
	glScalef(-7, 7, 7);//放大7倍
	glPushMatrix();//压入堆栈,准备绘制
	glCallList(BigLegModel);//绘制模型
	//绘制左小腿
	glPushMatrix();
	glTranslatef(0, 0.1, -0.45);
	glRotatef(-Leftsmallleg1, 1, 0, 0);
	glRotatef(-Leftsmallleg2, 0, 1, 0);
	glRotatef(-Leftsmallleg3, 0, 0, 1);
	glTranslatef(0.08, -0, -0.35);
	glScalef(.88, .88, .88);
	glCallList(SmallLegModel);
	//绘制左脚
	glPushMatrix();
	glTranslatef(0, 0.1, -0.45);
	glRotatef(Leftfoot1, 1, 0, 0);
	glRotatef(-Leftfoot2, 0, 1, 0);
	glRotatef(-Leftfoot3, 0, 0, 1);
	glTranslatef(-0.05, -0.18, -0.05);
	glScalef(.6, .6, .6);
	glPushMatrix();
	glCallList(FootModel);
	glPopMatrix();

	glPopMatrix();//释放堆栈,绘图结束
	glPopMatrix();
	glPopMatrix();

	glPopMatrix();
	//绘制左脚
	glPopMatrix();
	//绘图结束

}

void OpenGL::RightLeg(float bigleg1, float bigleg2, float bigleg3,
	float smallleg1, float smallleg2, float smallleg3,
	float foot1, float foot2, float foot3)
{
	//必须防止速度增加值过大导致错误
	//大腿
	if (bigleg1 >= 0 && RightBigleg1 < bigleg1)
	{
		RightBigleg1 += speed;	if (RightBigleg1 > bigleg1) RightBigleg1 = bigleg1;
	}
	if (bigleg1<0 && RightBigleg1 > bigleg1)
	{
		RightBigleg1 -= speed;	if (RightBigleg1 < bigleg1) RightBigleg1 = bigleg1;
	}
	if (bigleg2 >= 0 && RightBigleg2 < bigleg2)
	{
		RightBigleg2 += speed;	if (RightBigleg2 > bigleg2) RightBigleg2 = bigleg2;
	}
	if (bigleg2<0 && RightBigleg2 > bigleg2)
	{
		RightBigleg2 -= speed;	if (RightBigleg2 < bigleg2) RightBigleg2 = bigleg2;
	}
	if (bigleg3 >= 0 && RightBigleg3 < bigleg3)
	{
		RightBigleg3 += speed;	if (RightBigleg3 > bigleg3) RightBigleg3 = bigleg3;
	}
	if (bigleg3<0 && RightBigleg3 > bigleg3)
	{
		RightBigleg3 -= speed;	if (RightBigleg3 < bigleg3) RightBigleg3 = bigleg3;
	}
	//小腿
	if (smallleg1 >= 0 && Rightsmallleg1 < smallleg1)
	{
		Rightsmallleg1 += speed;	if (Rightsmallleg1 > smallleg1) Rightsmallleg1 = smallleg1;
	}
	if (smallleg1<0 && Rightsmallleg1 > smallleg1)
	{
		Rightsmallleg1 -= speed;	if (Rightsmallleg1 < smallleg1) Rightsmallleg1 = smallleg1;
	}
	if (smallleg2 >= 0 && Rightsmallleg2 < smallleg2)
	{
		Rightsmallleg2 += speed;	if (Rightsmallleg2 > smallleg2) Rightsmallleg2 = smallleg2;
	}
	if (smallleg2<0 && Rightsmallleg2 > smallleg2)
	{
		Rightsmallleg2 -= speed;	if (Rightsmallleg2 < smallleg2) Rightsmallleg2 = smallleg2;
	}
	if (smallleg3 >= 0 && Rightsmallleg3 < smallleg3)
	{
		Rightsmallleg3 += speed;	if (Rightsmallleg3 > smallleg3) Rightsmallleg3 = smallleg3;
	}
	if (smallleg3<0 && Rightsmallleg3 > smallleg3)
	{
		Rightsmallleg3 -= speed;	if (Rightsmallleg3 < smallleg3) Rightsmallleg3 = smallleg3;
	}
	//脚
	if (foot1 >= 0 && Rightfoot1 < foot1)
	{
		Rightfoot1 += speed;	if (Rightfoot1 > foot1) Rightfoot1 = foot1;
	}
	if (foot1<0 && Rightfoot1 > foot1)
	{
		Rightfoot1 -= speed;	if (Rightfoot1 < foot1) Rightfoot1 = foot1;
	}

	if (foot2 >= 0 && Rightfoot2 < foot2)
	{
		Rightfoot2 += speed;	if (Rightfoot2 > foot2) Rightfoot2 = foot2;
	}
	if (foot2<0 && Rightfoot2 > foot2)
	{
		Rightfoot2 -= speed;	if (Rightfoot2 < foot2) Rightfoot2 = foot2;
	}

	if (foot3 >= 0 && Rightfoot3 < foot3)
	{
		Rightfoot3 += speed;	if (Rightfoot3 > foot3) Rightfoot3 = foot3;
	}
	if (foot3<0 && Rightfoot3 > foot3)
	{
		Rightfoot3 -= speed;	if (Rightfoot3 < foot3) Rightfoot3 = foot3;
	}



	glPushMatrix();
	//开始绘图
	//绘制左大腿
	glRotatef(-RightBigleg1, 1, 0, 0);
	glRotatef(-RightBigleg2, 0, 1, 0);
	glRotatef(-RightBigleg3, 0, 0, 1);
	glTranslatef(-0.1, 0.9, -3.5);
	glScalef(-7, 7, 7);
	glPushMatrix();
	glCallList(BigLegModel);
	//绘制左小腿
	glPushMatrix();
	glTranslatef(0, 0.1, -0.45);
	glRotatef(-Rightsmallleg1, 1, 0, 0);
	glRotatef(-Rightsmallleg2, 0, 1, 0);
	glRotatef(-Rightsmallleg3, 0, 0, 1);
	glTranslatef(0.08, -0, -0.35);
	glScalef(.88, .88, .88);
	glCallList(SmallLegModel);
	//绘制左脚
	glPushMatrix();
	glTranslatef(0, 0.1, -0.45);
	glRotatef(Rightfoot1, 1, 0, 0);
	glRotatef(-Rightfoot2, 0, 1, 0);
	glRotatef(-Rightfoot3, 0, 0, 1);
	glTranslatef(-0.05, -0.18, -0.05);
	glScalef(.6, .6, .6);
	glCallList(FootModel);
	glPopMatrix();
	glPopMatrix();

	glPopMatrix();
	//绘制左脚
	glPopMatrix();
	//绘图结束

}

void OpenGL::LeftHand(float bighand1, float bighand2, float bighand3,
	float smallhand1, float smallhand2, float smallhand3,
	float hand1, float hand2, float hand3)
{
	//必须防止速度增加值过大导致错误
	//大臂
	if (bighand1 >= 0 && LeftBighand1 < bighand1)
	{
		LeftBighand1 += speed;	if (LeftBighand1 > bighand1) LeftBighand1 = bighand1;
	}
	if (bighand1<0 && LeftBighand1 > bighand1)
	{
		LeftBighand1 -= speed;	if (LeftBighand1 < bighand1) LeftBighand1 = bighand1;
	}
	if (bighand2 >= 0 && LeftBighand2 < bighand2)
	{
		LeftBighand2 += speed;	if (LeftBighand2 > bighand2) LeftBighand2 = bighand2;
	}
	if (bighand2<0 && LeftBighand2 > bighand2)
	{
		LeftBighand2 -= speed;	if (LeftBighand2 < bighand2) LeftBighand2 = bighand2;
	}
	if (bighand3 >= 0 && LeftBighand3 < bighand3)
	{
		LeftBighand3 += speed;	if (LeftBighand3 > bighand3) LeftBighand3 = bighand3;
	}
	if (bighand3<0 && LeftBighand3 > bighand3)
	{
		LeftBighand3 -= speed;	if (LeftBighand3 < bighand3) LeftBighand3 = bighand3;
	}
	//小臂
	if (smallhand1 >= 0 && Leftsmallhand1 < smallhand1)
	{
		Leftsmallhand1 += speed;	if (Leftsmallhand1 > smallhand1) Leftsmallhand1 = smallhand1;
	}
	if (smallhand1<0 && Leftsmallhand1 > smallhand1)
	{
		Leftsmallhand1 -= speed;	if (Leftsmallhand1 < smallhand1) Leftsmallhand1 = smallhand1;
	}
	if (smallhand2 >= 0 && Leftsmallhand2 < smallhand2)
	{
		Leftsmallhand2 += speed;	if (Leftsmallhand2 > smallhand2) Leftsmallhand2 = smallhand2;
	}
	if (smallhand2<0 && Leftsmallhand2 > smallhand2)
	{
		Leftsmallhand2 -= speed;	if (Leftsmallhand2 < smallhand2) Leftsmallhand2 = smallhand2;
	}
	if (smallhand3 >= 0 && Leftsmallhand3 < smallhand3)
	{
		Leftsmallhand3 += speed;	if (Leftsmallhand3 > smallhand3) Leftsmallhand3 = smallhand3;
	}
	if (smallhand3<0 && Leftsmallhand3 > smallhand3)
	{
		Leftsmallhand3 -= speed;	if (Leftsmallhand3 < smallhand3) Leftsmallhand3 = smallhand3;
	}
	//手
	if (hand1 >= 0 && Lefthand1 < hand1)
	{
		Lefthand1 += speed;	if (Lefthand1 > hand1) Lefthand1 = hand1;
	}
	if (hand1<0 && Lefthand1 > hand1)
	{
		Lefthand1 -= speed;	if (Lefthand1 < hand1) Lefthand1 = hand1;
	}

	if (hand2 >= 0 && Lefthand2 < hand2)
	{
		Lefthand2 += speed;	if (Lefthand2 > hand2) Lefthand2 = hand2;
	}
	if (hand2<0 && Lefthand2 > hand2)
	{
		Lefthand2 -= speed;	if (Lefthand2 < hand2) Lefthand2 = hand2;
	}

	if (hand3 >= 0 && Lefthand3 < hand3)
	{
		Lefthand3 += speed;	if (Lefthand3 > hand3) Lefthand3 = hand3;
	}
	if (hand3<0 && Lefthand3 > hand3)
	{
		Lefthand3 -= speed;	if (Lefthand3 < hand3) Lefthand3 = hand3;
	}



	glPushMatrix();
	//开始绘图
	//绘制左hand
	glRotatef(-LeftBighand1, 1, 0, 0);
	glRotatef(-LeftBighand2, 0, 1, 0);
	glRotatef(-LeftBighand3, 0, 0, 1);
	glTranslatef(0.3, 0.0, -3.0);
	glScalef(-7, 7, 7);
	glPushMatrix();
	glCallList(BigHandModel);
	//绘制左hand
	glPushMatrix();
	glTranslatef(-.15, -0.02, -0.5);
	glRotatef(-Leftsmallhand1, 1, 0, 0);
	glRotatef(-Leftsmallhand2, 0, 1, 0);
	glTranslatef(0.08, -0, -0.35);
	glRotatef(Leftsmallhand3, 0, 0, 1);
	glScalef(.88, .88, .88);
	glCallList(SmallHandModel);
	//绘制hand
	glPushMatrix();
	glTranslatef(-0.1, -0.12, -0.45);
	glRotatef(Lefthand1, 1, 0, 0);
	glRotatef(-Lefthand2, 0, 1, 0);
	glRotatef(-Lefthand3, 0, 0, 1);
	glTranslatef(0, 0, -0.3);
	glScalef(.6, .6, .6);
	glCallList(HandModel);
	glPopMatrix();
	glPopMatrix();

	glPopMatrix();
	//绘制左脚
	glPopMatrix();
	//绘图结束

}

void OpenGL::RightHand(float bighand1, float bighand2, float bighand3,
	float smallhand1, float smallhand2, float smallhand3,
	float hand1, float hand2, float hand3)
{
	//必须防止速度增加值过大导致错误
	//大臂
	if (bighand1 >= 0 && RightBighand1 < bighand1)
	{
		RightBighand1 += speed;	if (RightBighand1 > bighand1) RightBighand1 = bighand1;
	}
	if (bighand1<0 && RightBighand1 > bighand1)
	{
		RightBighand1 -= speed;	if (RightBighand1 < bighand1) RightBighand1 = bighand1;
	}
	if (bighand2 >= 0 && RightBighand2 < bighand2)
	{
		RightBighand2 += speed;	if (RightBighand2 > bighand2) RightBighand2 = bighand2;
	}
	if (bighand2<0 && RightBighand2 > bighand2)
	{
		RightBighand2 -= speed;	if (RightBighand2 < bighand2) RightBighand2 = bighand2;
	}
	if (bighand3 >= 0 && RightBighand3 < bighand3)
	{
		RightBighand3 += speed;	if (RightBighand3 > bighand3) RightBighand3 = bighand3;
	}
	if (bighand3<0 && RightBighand3 > bighand3)
	{
		RightBighand3 -= speed;	if (RightBighand3 < bighand3) RightBighand3 = bighand3;
	}
	//小臂
	if (smallhand1 >= 0 && Rightsmallhand1 < smallhand1)
	{
		Rightsmallhand1 += speed;	if (Rightsmallhand1 > smallhand1) Rightsmallhand1 = smallhand1;
	}
	if (smallhand1<0 && Rightsmallhand1 > smallhand1)
	{
		Rightsmallhand1 -= speed;	if (Rightsmallhand1 < smallhand1) Rightsmallhand1 = smallhand1;
	}
	if (smallhand2 >= 0 && Rightsmallhand2 < smallhand2)
	{
		Rightsmallhand2 += speed;	if (Rightsmallhand2 > smallhand2) Rightsmallhand2 = smallhand2;
	}
	if (smallhand2<0 && Rightsmallhand2 > smallhand2)
	{
		Rightsmallhand2 -= speed;	if (Rightsmallhand2 < smallhand2) Rightsmallhand2 = smallhand2;
	}
	if (smallhand3 >= 0 && Rightsmallhand3 < smallhand3)
	{
		Rightsmallhand3 += speed;	if (Rightsmallhand3 > smallhand3) Rightsmallhand3 = smallhand3;
	}
	if (smallhand3<0 && Rightsmallhand3 > smallhand3)
	{
		Rightsmallhand3 -= speed;	if (Rightsmallhand3 < smallhand3) Rightsmallhand3 = smallhand3;
	}
	//手
	if (hand1 >= 0 && Righthand1 < hand1)
	{
		Righthand1 += speed;	if (Righthand1 > hand1) Righthand1 = hand1;
	}
	if (hand1<0 && Righthand1 > hand1)
	{
		Righthand1 -= speed;	if (Righthand1 < hand1) Righthand1 = hand1;
	}

	if (hand2 >= 0 && Righthand2 < hand2)
	{
		Righthand2 += speed;	if (Righthand2 > hand2) Righthand2 = hand2;
	}
	if (hand2<0 && Righthand2 > hand2)
	{
		Righthand2 -= speed;	if (Righthand2 < hand2) Righthand2 = hand2;
	}

	if (hand3 >= 0 && Righthand3 < hand3)
	{
		Righthand3 += speed;	if (Righthand3 > hand3) Righthand3 = hand3;
	}
	if (hand3<0 && Righthand3 > hand3)
	{
		Righthand3 -= speed;	if (Righthand3 < hand3) Righthand3 = hand3;
	}



	glPushMatrix();
	//开始绘图
	//绘制左hand
	glRotatef(-RightBighand1, 1, 0, 0);
	glRotatef(-RightBighand2, 0, 1, 0);
	glRotatef(-RightBighand3, 0, 0, 1);
	glTranslatef(0.3, 0.0, -3.0);
	glScalef(-7, 7, 7);
	glPushMatrix();
	glCallList(BigHandModel);
	//绘制左hand
	glPushMatrix();
	glTranslatef(-.15, -0.02, -0.5);
	glRotatef(-Rightsmallhand1, 1, 0, 0);
	glRotatef(-Rightsmallhand2, 0, 1, 0);
	glTranslatef(0.08, -0, -0.35);
	glRotatef(Rightsmallhand3, 0, 0, 1);
	glScalef(.88, .88, .88);
	glCallList(SmallHandModel);
	//绘制hand
	glPushMatrix();
	glTranslatef(-0.1, -0.12, -0.45);
	glRotatef(Righthand1, 1, 0, 0);
	glRotatef(-Righthand2, 0, 1, 0);
	glRotatef(-Righthand3, 0, 0, 1);
	glTranslatef(0, 0, -0.3);
	glScalef(.6, .6, .6);
	glCallList(HandModel);
	glPopMatrix();
	glPopMatrix();

	glPopMatrix();
	//绘制左脚
	glPopMatrix();
	//绘图结束

}


void OpenGL::GenTexture(void)
{
	AUX_RGBImageRec* Textureimage;

	std::string skinPath = "data/BodySkin.bmp";


	glGenTextures(1, &texture[0]);
	glBindTexture(GL_TEXTURE_2D, texture[0]);
	Textureimage = auxDIBImageLoad(stringToLPCWSTR(skinPath));
	glTexImage2D(GL_TEXTURE_2D, 0, 3, Textureimage->sizeX, Textureimage->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, Textureimage->data);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexEnvi(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_DECAL);

	glGenTextures(1, &texture[1]);
	glBindTexture(GL_TEXTURE_2D, texture[1]);
	std::string strHeadSkin = "data/HeadSkin.bmp";
	Textureimage = auxDIBImageLoad(stringToLPCWSTR(strHeadSkin));
	glTexImage2D(GL_TEXTURE_2D, 0, 3, Textureimage->sizeX, Textureimage->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, Textureimage->data);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexEnvi(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_DECAL);

	glGenTextures(1, &texture[2]);
	glBindTexture(GL_TEXTURE_2D, texture[2]);
	std::string strFootSkin = "data/footskin.bmp";
	Textureimage = auxDIBImageLoad(stringToLPCWSTR(strFootSkin));
	glTexImage2D(GL_TEXTURE_2D, 0, 3, Textureimage->sizeX, Textureimage->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, Textureimage->data);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexEnvi(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_DECAL);

}


void OpenGL::SkinOrBone(bool skinorbone)
{
	//this->skinorbone = skinorbone;
	m_skinorbone = skinorbone;
}

void OpenGL::ReceiveAnimationParam()
{
	//float LeftLeg[9];
	//LeftLeg[0] = LeftBigLeg1;		LeftLeg[1] = LeftBigLeg2;		LeftLeg[2] = LeftBigLeg3;
	//LeftLeg[3] = LeftsmallLeg1;		LeftLeg[4] = LeftsmallLeg2;		LeftLeg[5] = LeftsmallLeg3;
	//LeftLeg[6] = LeftFoot1;			LeftLeg[7] = LeftFoot2;			LeftLeg[8] = LeftFoot3;
	//float RightLeg[9];
	//RightLeg[0] = RightBigLeg1;		RightLeg[1] = RightBigLeg2;		RightLeg[2] = RightBigLeg3;
	//RightLeg[3] = RightsmallLeg1;	RightLeg[4] = RightsmallLeg2;	RightLeg[5] = RightsmallLeg3;
	//RightLeg[6] = RightFoot1;		RightLeg[7] = RightFoot2;		RightLeg[8] = RightFoot3;
	//float Lefthand[9];
	//Lefthand[0] = LeftBighand1;		Lefthand[1] = LeftBighand2;		Lefthand[2] = LeftBighand3;
	//Lefthand[3] = Leftsmallhand1;	Lefthand[4] = Leftsmallhand2;	Lefthand[5] = Leftsmallhand3;
	//Lefthand[6] = Lefthand1;		Lefthand[7] = Lefthand2;		Lefthand[8] = Lefthand3;
	//float Righthand[9];
	//Righthand[0] = RightBighand1;		Righthand[1] = RightBighand2;		Righthand[2] = RightBighand3;
	//Righthand[3] = Rightsmallhand1;		Righthand[4] = Rightsmallhand2;		Righthand[5] = Rightsmallhand3;
	//Righthand[6] = Righthand1;			Righthand[7] = Righthand2;			Righthand[8] = Righthand3;

	///*m_pDisplay.ControlAngleInput(HeadAngle1, HeadAngle2, m_HeadAngele3,
	//	LeftLeg, RightLeg, Lefthand, Righthand);*/
	//ControlAngleInput(HeadAngle1, HeadAngle2, m_HeadAngele3,
	//	LeftLeg, RightLeg, Lefthand, Righthand);
}


LPCWSTR OpenGL::stringToLPCWSTR(std::string orig)
{
	size_t origsize = orig.length() + 1;
	const size_t newsize = 100;
	size_t convertedChars = 0;
	wchar_t* wcstring = (wchar_t*)malloc(sizeof(wchar_t) * (orig.length() - 1));
	mbstowcs_s(&convertedChars, wcstring, origsize, orig.c_str(), _TRUNCATE);

	return wcstring;
}



//void OpenGL::Mouse_Move_callback(GLFWwindow* window, double xPos, double yPos)
//{
//	if (gIsStartTrackBall)
//	{
//		trackball.MouseMove(xPos, yPos);
//		glutPostRedisplay();
//	}
//	if (gIsMoveMap)
//	{
//		xFar -= oldX - xPos;
//		yFar += oldY - yPos;
//		oldX = xPos;
//		oldY = yPos;
//		glutPostRedisplay();
//	}
//}
//
//void OpenGL::Scroll_callback(GLFWwindow* window, double xOffset, double yOffset)
//{
//
//}
//
//


main.cpp

#include <iostream>
#include <Windows.h>  
//#include "tools.h"
#include "OpenGL.h"
//#include "Grids.h"
//#include "3dmap.h"
//#include "xFreeTypeLib.h"
#include "include/glm/glm.hpp"
#include "include/glm/gtc/matrix_transform.hpp"
#include "include/glm/gtc/type_ptr.hpp"

static const int wWidth = 800;
static const int wHeight = 600;

void* pCallback = nullptr;
OpenGL *m_pDisplay = nullptr;

static void* gCallback(void* arg)
{
	((OpenGL*)arg)->func();
}

void ReceiveBoneParam()
{

}

int main(int argc, char* argv[])
{
	glutInit(&argc, argv);                                             //初始化GLUT
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_MULTISAMPLE);  //设置显示模式
	glutInitWindowPosition(0, 0);  //设置显示窗口的左上角位置
	glutInitWindowSize(wWidth, wHeight);         //设置窗口的长和高
	glutCreateWindow("Bone Animation openGL");     //创造显示窗口

	/*int main_version, sub_version, release_version;
	const char* version = (const char*)glGetString(GL_VERSION);
	sscanf(version, "%d.%d.%d", &main_version, &sub_version, &release_version);
	printf("OpenGL 版本:%s\n", version);
	printf("主版本号:%d\n", main_version);
	printf("次版本号:%d\n", sub_version);
	printf("发行版本号:%d\n", release_version);*/

	
		
	//OpenGL m_pDisplay;
	m_pDisplay->InitOpneGL();
	m_pDisplay->setCurrentOpenGL();

	glutDisplayFunc(m_pDisplay->RenderScene());
	//glutDisplayFunc(OpenGL::RenderScene);
	
	float HeadAngle1 = 0.0f;
	float HeadAngle2 = 0.0f;
	float m_speed = 0.0f;
	float m_HeadAngele3 = 0.0f;
	float LeftBigLeg1 = 0.0f;
	float LeftBigLeg2 = 0.0f;
	float LeftBigLeg3 = 0.0f;
	float LeftsmallLeg1 = 0.0f;
	float LeftsmallLeg2 = 0.0f;
	float LeftsmallLeg3 = 0.0f;
	float LeftFoot1 = 0.0f;
	float LeftFoot2 = 0.0f;
	float LeftFoot3 = 0.0f;
	float RightBigLeg1 = 0.0f;
	float RightBigLeg2 = 0.0f;
	float RightBigLeg3 = 0.0f;
	float RightsmallLeg1 = 0.0f;
	float RightsmallLeg2 = 0.0f;
	float RightsmallLeg3 = 0.0f;
	float RightFoot1 = 0.0f;
	float RightFoot2 = 0.0f;
	float RightFoot3 = 0.0f;
	float LeftBighand1 = 0.0f;
	float LeftBighand2 = 0.0f;
	float LeftBighand3 = 0.0f;
	float Leftsmallhand1 = 0.0f;
	float Leftsmallhand2 = 0.0f;
	float Leftsmallhand3 = 0.0f;
	float Lefthand1 = 0.0f;
	float Lefthand2 = 0.0f;
	float Lefthand3 = 0.0f;
	float RightBighand1 = 0.0f;
	float RightBighand2 = 0.0f;
	float RightBighand3 = 0.0f;
	float Rightsmallhand1 = 0.0f;
	float Rightsmallhand2 = 0.0f;
	float Rightsmallhand3 = 0.0f;
	float Righthand1 = 0.0f;
	float Righthand2 = 0.0f;
	float Righthand3 = 0.0f;
	bool SkinOrBone = 0.0f;


	float LeftLeg[9];
	LeftLeg[0] = LeftBigLeg1;		LeftLeg[1] = LeftBigLeg2;		LeftLeg[2] = LeftBigLeg3;
	LeftLeg[3] = LeftsmallLeg1;		LeftLeg[4] = LeftsmallLeg2;		LeftLeg[5] = LeftsmallLeg3;
	LeftLeg[6] = LeftFoot1;			LeftLeg[7] = LeftFoot2;			LeftLeg[8] = LeftFoot3;
	float RightLeg[9];
	RightLeg[0] = RightBigLeg1;		RightLeg[1] = RightBigLeg2;		RightLeg[2] = RightBigLeg3;
	RightLeg[3] = RightsmallLeg1;	RightLeg[4] = RightsmallLeg2;	RightLeg[5] = RightsmallLeg3;
	RightLeg[6] = RightFoot1;		RightLeg[7] = RightFoot2;		RightLeg[8] = RightFoot3;
	float Lefthand[9];
	Lefthand[0] = LeftBighand1;		Lefthand[1] = LeftBighand2;		Lefthand[2] = LeftBighand3;
	Lefthand[3] = Leftsmallhand1;	Lefthand[4] = Leftsmallhand2;	Lefthand[5] = Leftsmallhand3;
	Lefthand[6] = Lefthand1;		Lefthand[7] = Lefthand2;		Lefthand[8] = Lefthand3;
	float Righthand[9];
	Righthand[0] = RightBighand1;		Righthand[1] = RightBighand2;		Righthand[2] = RightBighand3;
	Righthand[3] = Rightsmallhand1;		Righthand[4] = Rightsmallhand2;		Righthand[5] = Rightsmallhand3;
	Righthand[6] = Righthand1;			Righthand[7] = Righthand2;			Righthand[8] = Righthand3;

	m_pDisplay->ControlAngleInput(HeadAngle1, HeadAngle2, m_HeadAngele3,
		LeftLeg, RightLeg, Lefthand, Righthand);

	glutMainLoop();    //显示所有并等候

	getchar();

	return 0;
}

关键代码段

在这里插入图片描述
在这里插入图片描述

运行效果

在这里插入图片描述

在这里插入图片描述

工程源码

工程源码下载

  • 4
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
这个错误提示是因为 `GetVersionEx` 函数已经被微软标记为已经过时,不再推荐使用。为了解决这个问题,可以使用 `VerifyVersionInfo` 函数来获取操作系统版本信息。下面是一个使用 `VerifyVersionInfo` 函数获取操作系统版本信息的示例代码: ```cpp #include <iostream> #include <windows.h> #include <tchar.h> #pragma comment(lib, "version.lib") void getSystemInfo() { // 获取操作系统版本信息 OSVERSIONINFOEX osvi; ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); DWORDLONG dwlConditionMask = 0; VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, VER_EQUAL); VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION, VER_EQUAL); VER_SET_CONDITION(dwlConditionMask, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL); VER_SET_CONDITION(dwlConditionMask, VER_SERVICEPACKMINOR, VER_GREATER_EQUAL); osvi.dwMajorVersion = HIBYTE(_WIN32_WINNT_WIN7); osvi.dwMinorVersion = LOBYTE(_WIN32_WINNT_WIN7); osvi.wServicePackMajor = 1; osvi.wServicePackMinor = 0; if (VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, dwlConditionMask)) { std::cout << "操作系统版本:Windows 7 SP1 或更高版本" << std::endl; } else { std::cout << "无法获取操作系统版本信息" << std::endl; } // 获取计算机名称和用户名 TCHAR szComputerName[MAX_COMPUTERNAME_LENGTH + 1]; DWORD dwSize = sizeof(szComputerName) / sizeof(szComputerName[0]); GetComputerName(szComputerName, &dwSize); std::cout << "计算机名称:" << szComputerName << std::endl; TCHAR szUserName[UNLEN + 1]; dwSize = sizeof(szUserName) / sizeof(szUserName[0]); GetUserName(szUserName, &dwSize); std::cout << "当前用户:" << szUserName << std::endl; // 获取CPU信息 SYSTEM_INFO sysInfo; GetSystemInfo(&sysInfo); std::cout << "CPU核心数:" << sysInfo.dwNumberOfProcessors << std::endl; // 获取内存信息 MEMORYSTATUSEX memInfo; memInfo.dwLength = sizeof(MEMORYSTATUSEX); GlobalMemoryStatusEx(&memInfo); std::cout << "物理内存总量:" << memInfo.ullTotalPhys / (1024 * 1024) << "MB" << std::endl; std::cout << "可用物理内存:" << memInfo.ullAvailPhys / (1024 * 1024) << "MB" << std::endl; // 获取硬盘信息 TCHAR szVolumeName[MAX_PATH + 1], szFileSystem[MAX_PATH + 1]; DWORD dwSerialNumber, dwMaxComponentLen, dwFileSystemFlags; ULARGE_INTEGER FreeBytesAvailable, TotalNumberOfBytes, TotalNumberOfFreeBytes; GetVolumeInformation(_T("C:\\"), szVolumeName, MAX_PATH, &dwSerialNumber, &dwMaxComponentLen, &dwFileSystemFlags, szFileSystem, MAX_PATH); GetDiskFreeSpaceEx(_T("C:\\"), &FreeBytesAvailable, &TotalNumberOfBytes, &TotalNumberOfFreeBytes); std::cout << "硬盘总容量:" << TotalNumberOfBytes.QuadPart / (1024 * 1024 * 1024) << "GB" << std::endl; std::cout << "可用空间:" << FreeBytesAvailable.QuadPart / (1024 * 1024 * 1024) << "GB" << std::endl; } int main() { getSystemInfo(); return 0; } ``` 这个示例代码使用 `VerifyVersionInfo` 函数来检查操作系统版本是否符合条件,如果符合,则输出操作系统版本号。同时,这个示例代码还获取了计算机名称、当前用户名、CPU核心数、物理内存总量、可用物理内存、硬盘总容量和可用空间等基本信息。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值