資源簡介
計算機圖形學 OpenGL 實驗七 頂點數組 拾取

代碼片段和文件信息
#include?
#include?
#include?
#include?
bool?selected[20]={false};
float?center[]?=?{0?-0.8?-6};
float?eye[]?=?{0?1.2?2};
float?fTranslate;
float?fRotate?=?156.5f;
float?fScale?????=?1.0f; //?set?inital?scale?value?to?1.0f
bool?bPersp?=?false;//注意要轉換成?正投影下才能?進行拾取!!!
bool?bAnim?=?false;
bool?bWire?=?false;
int?wHeight?=?0;
int?wWidth?=?0;
GLint?dl?=?0;
void?Draw_Leg();
int??drawMode?=?0;
#define?SIZE?512
#define?N?5
GLuint?selectBuf[SIZE];
GLint?hits=0;
extern?void?drawNaive();
extern?void?drawVA();
extern?GLint?Gen3DobjectList();
void?drawDL()?{
glCallList(dl);
}
void?drawBunny()
{
glRotatef(90?1?0?0);
glScalef(3?3?3);
if?(drawMode?==?0)
drawNaive();
else?if?(drawMode?==?1)
drawVA();
else
drawDL();
}
void?Draw_Desk()
{
glPushMatrix();
glTranslatef(0?0?3.5);
glScalef(5?4?1);
glutSolidCube(1.0);
glPopMatrix();
glPushMatrix();
glTranslatef(1.5?1?1.5);
Draw_Leg();
glPopMatrix();
glPushMatrix();
glTranslatef(-1.5?1?1.5);
Draw_Leg();
glPopMatrix();
glPushMatrix();
glTranslatef(1.5?-1?1.5);
Draw_Leg();
glPopMatrix();
glPushMatrix();
glTranslatef(-1.5?-1?1.5);
Draw_Leg();
glPopMatrix();
}
void?render(bool?s)
{
GLfloat?mat[4];
if(s){
mat[0]?=?0;?mat[1]?=?0;?mat[2]?=?1;?mat[3]?=?1.0;
glMaterialfv(GL_FRONT?GL_AMBIENT?mat);
}
else{
mat[0]?=?0;?mat[1]?=?0;?mat[2]?=?0;?mat[3]?=?1.0;
glMaterialfv(GL_FRONT?GL_AMBIENT?mat);
}
}
void?Draw_Scene(GLenum?mode)
{
if?(mode?==?GL_SELECT)?
glLoadName(1);
glPushMatrix();
glTranslatef(-1?-1?5.5);
render(selected[1]);
drawBunny();
glPopMatrix();
if?(mode?==?GL_SELECT)?
glLoadName(2);
glPushMatrix();
glTranslatef(0?-1?5.5);
render(selected[2]);
drawBunny();
glPopMatrix();
if?(mode?==?GL_SELECT)?
glLoadName(3);
glPushMatrix();
glTranslatef(1?-1?5.5);
render(selected[3]);
drawBunny();
glPopMatrix();
if?(mode?==?GL_SELECT)?
glLoadName(4);
glPushMatrix();
glTranslatef(-1?1?5.5);
render(selected[4]);
drawBunny();
glPopMatrix();
if?(mode?==?GL_SELECT)?
glLoadName(5);
glPushMatrix();
glTranslatef(0?1?5.5);
render(selected[5]);
drawBunny();
glPopMatrix();
if?(mode?==?GL_SELECT)?
glLoadName(6);
glPushMatrix();
glTranslatef(1?1?5.5);
render(selected[6]);
drawBunny();
glPopMatrix();
if?(mode?==?GL_SELECT)?
glLoadName(7);
glPushMatrix();
glTranslatef(-1?0?5.5);
render(selected[7]);
drawBunny();
glPopMatrix();
if?(mode?==?GL_SELECT)?
glLoadName(8);
glPushMatrix();
glTranslatef(0?0?5.5);
render(selected[8]);
drawBunny();
glPopMatrix();
if?(mode?==?GL_SELECT)?
glLoadName(9);
glPushMatrix();
glTranslatef(1?0?5.5);
render(selected[9]);
drawBunny();
glPopMatrix();
if?(mode?==?GL_SELECT)?
glLoadName(10);
glPushMatrix();
glTranslatef(-1?-1?7.5);
r
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2011-11-30?19:09??Exp7\
?????目錄???????????0??2011-11-30?19:09??Exp7\Exp7\
?????文件?????????879??2011-05-05?13:08??Exp7\Exp7.sln
?????文件???????13312??2011-05-19?15:16??Exp7\Exp7.suo
?????文件????????8912??2011-05-19?15:16??Exp7\Exp7\all-bunny.cpp
?????文件??????931863??2011-05-05?22:26??Exp7\Exp7\bunny.cpp
?????文件????????3262??2011-05-05?13:14??Exp7\Exp7\Exp7.vcxproj
?????文件????????1036??2011-05-05?13:14??Exp7\Exp7\Exp7.vcxproj.filters
評論
共有 條評論