opengl中对于天空盒,如何把观察者放在内部
opengl中对于天空盒,怎么把观察者放在内部
void view(GLsizei w,GLsizei h)
{
if(h==0)
h=1;
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if(w<h)
glOrtho(-50.0f,50.0f,-50.0f*h/w,50.0f*h/w,-200,200);
else
glOrtho(-150.0f*w/h,150.0f*w/h,-100.0f,100.0f,-200,200);
// gluPerspective(75.0f,(float)w/(float)h,0.1f,2000.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//gluLookAt(0,0,0,0,0,100,0,1,0);
winWidth = w;
winHeight = h;
}
我是以世界坐标系中心用glVertex画的一个立方体,我想在内部观察,可是怎么设定都是在外面??急急急
------解决方案--------------------
用glut库的gluLookAt()函数来设置相机位置
Name
gluLookAt — define a viewing transformation
C Specification
void gluLookAt
(GLdouble eyeX
, GLdouble eyeY
, GLdouble eyeZ
, GLdouble centerX
, GLdouble centerY
, GLdouble centerZ
, GLdouble upX
, GLdouble upY
, GLdouble upZ
);
Parameters
eyeX, eyeY, eyeZ: Specifies the position of the eye point.
centerX, centerY, centerZ: Specifies the position of the reference point.
upX, upY, upZ: Specifies the direction of the up vector.
------解决方案--------------------
是不是只贴了一面的图。试一下贴双面图。
void view(GLsizei w,GLsizei h)
{
if(h==0)
h=1;
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if(w<h)
glOrtho(-50.0f,50.0f,-50.0f*h/w,50.0f*h/w,-200,200);
else
glOrtho(-150.0f*w/h,150.0f*w/h,-100.0f,100.0f,-200,200);
// gluPerspective(75.0f,(float)w/(float)h,0.1f,2000.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//gluLookAt(0,0,0,0,0,100,0,1,0);
winWidth = w;
winHeight = h;
}
我是以世界坐标系中心用glVertex画的一个立方体,我想在内部观察,可是怎么设定都是在外面??急急急
------解决方案--------------------
用glut库的gluLookAt()函数来设置相机位置
Name
gluLookAt — define a viewing transformation
C Specification
void gluLookAt
(GLdouble eyeX
, GLdouble eyeY
, GLdouble eyeZ
, GLdouble centerX
, GLdouble centerY
, GLdouble centerZ
, GLdouble upX
, GLdouble upY
, GLdouble upZ
);
Parameters
eyeX, eyeY, eyeZ: Specifies the position of the eye point.
centerX, centerY, centerZ: Specifies the position of the reference point.
upX, upY, upZ: Specifies the direction of the up vector.
------解决方案--------------------
是不是只贴了一面的图。试一下贴双面图。