- 1、本文档共11页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
OpenGL魔方设计与代码
#ifndef _MagicCube_H_
#define _MagicCube_H_
#include gl/glut.h
#include stdio.h
#include stdlib.h
#include gl/glaux.h
#include math.h
#define PI 3.141596
typedef struct
{
GLfloat Xpos[8]; //x coord of 8 pointers
GLfloat Ypos[8];
GLfloat Zpos[8];
GLfloat Center[3]; //Center pos (x,y,z)
}SmallCube;
SmallCube SmCube[27];
GLuint Texture[27];
void CubeInit(); //initial of 8 SmCube
void MathInit();
void EntireRot();
void EntireRotAng();
void PartRot(); //rand the spin axis
void ProPartRotX(int iCube);
void ProPartRotY(int iCube);
void ProPartRotZ(int iCube);
void PointRot(GLfloat *X1,GLfloat *X2,GLfloat *X3);
void StartEffect();
void DrawSmCube();
void DrawMgCube();
GLfloat Point[8][3]= //point coord of a SmCube
{
{ -1.0f, -1.0f, 1.0f}, //0 -- front
{ 1.0f, -1.0f, 1.0f }, //1
{1.0f, 1.0f, 1.0f }, //2 --
{-1.0f, 1.0f, 1.0f}, //3
{-1.0f, -1.0f, -1.0f}, //4 --back
{-1.0f, 1.0f, -1.0f}, //5
{1.0f, 1.0f, -1.0f}, //6 --
{1.0f, -1.0f, -1.0f}, //7
};
GLfloat CenterInit[3]={0,0,0}; //init center point
//point sequence of SmCube face
GLint Face[6][4]={{0,1,2,3},{4,5,6,7},{3,2,6,5}, //front ,back ,up
{0,4,7,1},{1,7,6,2},{0,3,5,4}}; // bottom, right ,left
GLint TexCd[4][2]={{0,0},{1,0},{1,1},{0,1}}; //texture coord array for one square
int xAng=0; //entire rotate angle
int yAng=0;
int zAng=0;
int PartRotAng=0; //remember the part rotate ang
int Axis=0; //mark the spin axis
GLfloat sina=0;
GLfloat cosa=0;
int Start=1;
#endif
#include MagicCube.h
void WindowsInit()
{
glClearColor(0,0,0,1);
glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
glCullFace(GL_FRONT);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glEnable(GL_TEXTURE_2D);
//smooth the cube
glEnable(GL_POLYGON_SMOOTH);
glHint(GL_POLYGON_SMOOTH,GL_NICEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
MathInit();
CubeInit();
}
void MathInit()
{
GLfloat a=PI/180 ; /
您可能关注的文档
- WorkingwithHibernateinEclipse英文原文.doc
- C语言第七课.ppt
- 潜能开发培训师课程简介.doc
- 第十一章报告、请.ppt
- 概预算名词解释打印.doc
- 华师附中2012届高三考前热身(理数).doc
- 三招教你装修不超支.doc
- 拓展训练中的安全理念和器械知识.doc
- (吴正亮)浅谈建筑工程施工管理.ppt
- 4信息交流与协商控制程序4.doc
- 2023咸阳职业技术学院招聘笔试真题参考答案详解.docx
- 2023四川化工职业技术学院招聘笔试真题及参考答案详解.docx
- 2023哈尔滨职业技术学院招聘笔试真题及参考答案详解.docx
- 2023商洛职业技术学院招聘笔试真题及答案详解1套.docx
- 2023呼伦贝尔职业技术学院招聘笔试真题参考答案详解.docx
- 2023南阳农业职业学院招聘笔试真题参考答案详解.docx
- 2023天津公安警官职业学院招聘笔试真题带答案详解.docx
- 2023年上海电机学院招聘笔试真题参考答案详解.docx
- 2023年四川艺术职业学院招聘笔试真题参考答案详解.docx
- 2023安徽体育运动职业技术学院招聘笔试真题及答案详解一套.docx
文档评论(0)