实现漫游者模式控制正十二面体的转动和视角平移
/*****************************
Author :Tanrunj
Time :2014-03-27 23:30
School :SYSU school of software
Program:Tracking Dodecahedron
Reference:http://blog.csdn.net/pleasecallmewhy/article/details/8179302
*******************************/
#include "stdafx.h"
#include <stdlib.h>
#include <GL/glut.h>
#include <math.h>
#define PI 3.14159
//当前窗口大小
int winWidth, winHeight;
//旋转角度,法向量 ,位移向量
float angle = 0.0, nor_vec[3], trans[3];
bool click_and_move = false; //鼠标点击下移动
bool rotate = false; //旋转标志
bool tracking = false; //跟踪球的视觉变换
float last_position[3] = {0.0F, 0.0F, 0.0F}; //记录之前位置
int current_x, current_y; //鼠标当前位置
int start_x, start_y; //鼠标开始移动位置
int click; //鼠标点击状态 0:左键 1:右键
bool fill; //是否填充五边形 false:不填充 true:填充
//20个顶点数组
GLfloat vertices[][3] = {
{1.214124,0.000000,1.589309},
{0.375185,1.154701,1.589309},
{-0.982247,0.713644,1.589309},
{-0.982247,-0.713644,1.589309},
{0.375185,-1.154701,1.589309},
{1.964494,0.000000,0.375185},
{0.607062,1.868345,0.375185},
{-1.589309,1.154701,0.375185},
{-1.589309,-1.154701,0.375185},
{0.607062,-1.868345,0.375185},
{1.589309,1.154701,-0.375185},
{-0.607062,1.868345,-0.375185},