📄 毕业设计view.h
字号:
// 毕业设计View.h : interface of the CMyView class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_VIEW_H__5B4EA882_E744_46AD_B54E_2EDCA98EE8A6__INCLUDED_)
#define AFX_VIEW_H__5B4EA882_E744_46AD_B54E_2EDCA98EE8A6__INCLUDED_
#include "Operation.h" // Added by ClassView
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "windows.h"
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glaux.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "Operation.h"
#define GL_MODEL
#ifndef M_PI
#define M_PI 3.14159265
#endif
#define GLM_NONE (0) /* 只绘制顶点 */
#define GLM_FLAT (1 << 0) /* 按面法向量进行绘制 */
#define GLM_SMOOTH (1 << 1) /* 按顶点法向量进行绘制 */
#define GLM_TEXTURE (1 << 2) /* 指定纹理坐标 */
#define GLM_COLOR (1 << 3) /* 按颜色进行绘制 */
#define GLM_MATERIAL (1 << 4) /* 按材质进行绘制 */
typedef struct _GLMmaterial
{
char* name; /* 材质名 */
GLfloat diffuse[4]; /* 漫反射分量 */
GLfloat ambient[4]; /* 环境光分量 */
GLfloat specular[4]; /* 镜面反射分量 */
GLfloat emmissive[4]; /* 发射光分量 */
GLfloat shininess; /* 照射强度 */
} GLMmaterial;
typedef struct _GLMtriangle {
GLuint vindices[3]; /* 顶点下标数组 */
GLuint nindices[3]; /* 顶点法向量下标数组 */
GLuint tindices[3]; /* 顶点纹理下标数组*/
GLuint findex; /* 三角形小面片的法向量数据 */
} GLMtriangle;
typedef struct _GLMgroup {
char* name; /* 组名称 */
GLuint numtriangles; /* 组中三角形的数目 */
GLuint* triangles; /* 三角形列表(下标) */
GLuint material; /* 组的材质下标 */
struct _GLMgroup* next; /* 指向下一个组的指针*/
} GLMgroup;
typedef struct _GLMmodel {
char* pathname; /* 模型所在的路径和文件名 */
char* mtllibname; /* 材质库文件名 */
GLuint numvertices; /* 模型中的顶点数 */
GLfloat* vertices; /* 顶点数组 */
GLboolean* selected; /* 顶点是否被选中 */
GLuint numnormals; /* 模型中法向量的数目 */
GLfloat* normals; /* 法向量数组 */
GLuint numtexcoords; /* 模型中纹理坐标数目 */
GLfloat* texcoords; /* 纹理坐标数组 */
GLuint numfacetnorms; /* 模型中面片法向量数目 */
GLfloat* facetnorms; /* 面片法向量数组 */
GLuint numtriangles; /* 模型中三角形数目 */
GLMtriangle* triangles; /* 三角形数组 */
GLuint nummaterials; /* 模型中材质数目 */
GLMmaterial* materials; /* 材质数组 */
GLuint numgroups; /* 模型中组的数目 */
GLMgroup* groups; /* 所有组构成的链表 */
GLfloat position[3]; /* 模型的位置 */
} GLMmodel;
#define T(x) (model->triangles[(x)])
#define fsin(x) (float)sin(x)
#define fcos(x) (float)cos(x)
#define fasin(x) (float)asin(x)
#define facos(x) (float)acos(x)
#define fsqrt(x) (float)sqrt(x)
typedef struct _GLMnode {
GLuint index;
GLboolean averaged;
struct _GLMnode* next;
} GLMnode;
class CMyView : public CView
{
protected: // create from serialization only
CMyView();
DECLARE_DYNCREATE(CMyView)
// Attributes
public:
CMyDoc* GetDocument();
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMyView)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
//}}AFX_VIRTUAL
// Implementation
public:
bool m_leftButtonDown;
int k;/*走步控制切换参数*/
int spin;/*舞台旋转参数*/
void go();/*走步控制参数*/
void walkbone();/*骨骼绘制*/
void road();/*道路绘制函数*/
void displayBoneWalk();/*显示骨骼走步函数*/
BOOL m_play;/*是否播放*/
bool render_select;/*进入选择与拾取控制*/
bool nod_true;
int throwHead_x;/*摇头幅度控制参数*/
int nod_x;/*点头幅度控制参数*/
GLuint select_buf[512];/*选择与拾取返回缓存*/
void LocalScale( );/*局部放大函数*/
GLint hits;/*选择与拾取的选中记录数*/
void displayTop( GLenum mode);/*显示顶视图*/
void displayBeside( GLenum mode);/*显示侧视图*/
void displayFront(GLenum mode);/*显示前景图*/
GLfloat light_position[4] ;
GLMmodel *head;/*头模型指针对象*/
GLMmodel *body;/*身体模型指针对象*/
GLMmodel *leftdatui;/*身体模型指针对象*/
GLMmodel *rightdatui;/*身体模型指针对象*/
GLMmodel *leftxiaotui;/*左小腿模型指针对象*/
GLMmodel *rightxiaotui;/*右小腿模型指针对象*/
GLMmodel *leftfoot;/*左脚模型指针对象*/
GLMmodel *rightfoot;/*右脚模型指针对象*/
GLMmodel *leftbi;/*左臂模型指针对象*/
GLMmodel *rightbi;/*右臂模型指针对象*/
GLMmodel *leftzhou;/*左肘模型指针对象*/
GLMmodel *rightzhou;/*右肘模型指针对象*/
GLMmodel *righthand;/*右手模型指针对象*/
GLMmodel *lefthand;/*左手模型指针对象*/
int h;/*客户区的宽度*/
int w;/*客户区的长度*/
GLfloat glmUnitize(GLMmodel* model);
GLfloat glmMax(GLfloat a, GLfloat b);
GLfloat glmAbs(GLfloat f);
GLfloat glmDot(GLfloat* u, GLfloat* v);
GLvoid glmCross(GLfloat* u, GLfloat* v, GLfloat* n);
GLvoid glmNormalize(GLfloat* v);
GLboolean glmEqual(GLfloat* u, GLfloat* v, GLfloat epsilon);
GLfloat* glmWeldVectors(GLfloat* vectors, GLuint* numvectors, GLfloat epsilon);
GLMgroup* glmFindGroup(GLMmodel* model, char* name);
GLMgroup* glmAddGroup(GLMmodel* model, char* name);
GLuint glmFindMaterial(GLMmodel* model, char* name);
char* glmDirName(char* path);
GLvoid glmReadMTL(GLMmodel* model, char* name);
GLvoid glmFirstPass(GLMmodel* model, FILE* file);
GLvoid glmSecondPass(GLMmodel* model, FILE* file);
GLvoid glmDimensions(GLMmodel* model, GLfloat* dimensions);
GLvoid glmScale(GLMmodel* model, GLfloat scale);
GLvoid glmReverseWinding(GLMmodel* model);
GLvoid glmFacetNormals(GLMmodel* model);
GLvoid glmVertexNormals(GLMmodel* model, GLfloat angle);
GLvoid glmLinearTexture(GLMmodel* model);
GLvoid glmSpheremapTexture(GLMmodel* model);
GLvoid glmDelete(GLMmodel* model);
GLMmodel* glmReadOBJ(char* filename);
GLvoid glmDraw(GLMmodel* model, GLuint mode);
GLuint glmList(GLMmodel* model, GLuint mode);
void display();/*显示函数*/
void myinit();/*初始化函数*/
bool CreateOpenGLContext();/*创建绘图描述表*/
bool SetupPixelFormat();/*设置像素格式*/
HGLRC m_hRC;/*绘图描述表句柄*/
HDC m_hDC;/*设备描述表句柄*/
virtual ~CMyView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
GLfloat distance;/*骨骼走步距离*/
bool bWalk;/*进入走步方式控制*/
long m_leftDownPos[2];//存放原始鼠标坐标
float m_xRotation;//X方向旋转角度
float m_yRotation;//Z方向旋转角度
GLfloat scaleMolNow;/*放大系数*/
GLint scaleMol;/*放大次数*/
GLfloat left_right;/*左右平移控制*/
GLfloat up_down;/*上下平移控制*/
GLint rightDatui_x;/*右大腿角度控制参数*/
GLint rightDatui;/*右大腿旋转控制*/
GLint leftDatui_x;/*左大腿角度控制参数*/
GLint leftDatui;/*左大腿旋转控制*/
int rightHand_x;/*右臂角度控制参数*/
int leftHand_x;/*左臂角度控制参数*/
bool scaleMode;/*进入放大模式控制参数*/
bool ok;/*进入侧顶视图控制参数*/
GLfloat rotate_left_right;/*左右旋转控制*/
GLfloat rotate_up_down;/*上下旋转控制*/
GLfloat throwHead;/*摇头控制参数*/
GLfloat nod;/*点头控制参数*/
GLfloat leftFoot;/*右脚控制参数*/
GLfloat rightFoot;/*右脚控制参数*/
GLfloat leftHand;/*左手控制参数*/
GLfloat rightHand;/*右手控制参数*/
//{{AFX_MSG(CMyView)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnDestroy();
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnHelpOperation();
afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
afx_msg void OnControlLrotate();
afx_msg void OnControlDrotate();
afx_msg void OnControlRrotate();
afx_msg void OnControlUrotate();
afx_msg void OnControlTls();
afx_msg void OnControlTrs();
afx_msg void OnWindowOpen();
afx_msg void OnUpdateWindowOpen(CCmdUI* pCmdUI);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnControlNod();
afx_msg void OnControlYt();
afx_msg void OnControlClosetb();
afx_msg void OnControlOpentb();
afx_msg void OnControlRecover();
afx_msg void OnControlTlt();
afx_msg void OnControlTrt();
afx_msg void OnControlPlay();
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnUpdateControlPlay(CCmdUI* pCmdUI);
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnControlMoveUp();
afx_msg void OnControlMoveRight();
afx_msg void OnControlMoveLeft();
afx_msg void OnControlMoveDown();
afx_msg void OnHelpNumber();
afx_msg void OnControlScale();
afx_msg void OnUpdateControlScale(CCmdUI* pCmdUI);
afx_msg void OnControlWalk();
afx_msg void OnUpdateControlWalk(CCmdUI* pCmdUI);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // debug version in 毕业设计View.cpp
inline CMyDoc* CMyView::GetDocument()
{ return (CMyDoc*)m_pDocument; }
#endif
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_VIEW_H__5B4EA882_E744_46AD_B54E_2EDCA98EE8A6__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -