Update of /cvsroot/openvrml/openvrml/src/libopenvrml-gl/openvrml/gl
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv13318/src/libopenvrml-gl/openvrml/gl
Modified Files:
viewer.cpp viewer.h
Log Message:
Separated specification of the view frustum from specification of the viewpoint. The former needs to happen before the background is rendered; the latter needs to happen after it.
Index: viewer.h
===================================================================
RCS file: /cvsroot/openvrml/openvrml/src/libopenvrml-gl/openvrml/gl/viewer.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** viewer.h 22 Jan 2007 04:32:23 -0000 1.16
--- viewer.h 22 Jan 2007 23:38:01 -0000 1.17
***************
*** 297,303 ****
const vec2f & translation);
virtual void do_set_viewpoint(const vec3f & position,
const openvrml::rotation & orientation,
- float fieldOfView,
float avatarSize,
float visibilityLimit);
--- 297,305 ----
const vec2f & translation);
+ virtual void do_set_frustum(float field_of_view,
+ float avatar_size,
+ float visibility_limit);
virtual void do_set_viewpoint(const vec3f & position,
const openvrml::rotation & orientation,
float avatarSize,
float visibilityLimit);
Index: viewer.cpp
===================================================================
RCS file: /cvsroot/openvrml/openvrml/src/libopenvrml-gl/openvrml/gl/viewer.cpp,v
retrieving revision 1.59
retrieving revision 1.60
diff -C2 -d -r1.59 -r1.60
*** viewer.cpp 22 Jan 2007 22:58:47 -0000 1.59
--- viewer.cpp 22 Jan 2007 23:38:01 -0000 1.60
***************
*** 3806,3809 ****
--- 3806,3830 ----
}
+ void openvrml::gl::viewer::do_set_frustum(float field_of_view,
+ const float avatar_size,
+ const float visibility_limit)
+ {
+ glMatrixMode(GL_PROJECTION);
+ if (!this->select_mode) { glLoadIdentity(); }
+
+ (field_of_view *= 180.0) /= pi;
+ const float aspect = float(this->win_width) / this->win_height;
+ const float znear = (avatar_size > 0.0)
+ ? float(0.5 * avatar_size)
+ : 0.01f;
+ const float zfar = (visibility_limit > 0.0)
+ ? visibility_limit
+ : 30000.0f;
+ gluPerspective(field_of_view, aspect, znear, zfar);
+
+ this->frustum(openvrml::frustum(field_of_view, aspect, znear, zfar));
+ glMatrixMode(GL_MODELVIEW);
+ }
+
namespace {
***************
*** 3847,3851 ****
* @param[in] position position.
* @param[in] orientation orientation.
- * @param[in] fieldOfView field of view.
* @param[in] avatarSize avatar size.
* @param[in] visibilityLimit visiblity limit.
--- 3868,3871 ----
***************
*** 3854,3875 ****
openvrml::gl::viewer::do_set_viewpoint(const vec3f & position,
const openvrml::rotation & orientation,
- const float fieldOfView,
const float avatarSize,
const float visibilityLimit)
{
! glMatrixMode( GL_PROJECTION );
! if (!this->select_mode) { glLoadIdentity(); }
!
! float field_of_view = float(fieldOfView * 180.0 / pi);
! float aspect = float(this->win_width) / this->win_height;
! float znear = (avatarSize > 0.0)
! ? float(0.5 * avatarSize)
! : 0.01f;
! float zfar = (visibilityLimit > 0.0)
! ? visibilityLimit
! : 30000.0f;
! gluPerspective(field_of_view, aspect, znear, zfar);
!
! this->frustum(openvrml::frustum(field_of_view, aspect, znear, zfar));
glMatrixMode(GL_MODELVIEW);
--- 3874,3886 ----
openvrml::gl::viewer::do_set_viewpoint(const vec3f & position,
const openvrml::rotation & orientation,
const float avatarSize,
const float visibilityLimit)
{
! const float znear = (avatarSize > 0.0)
! ? float(0.5 * avatarSize)
! : 0.01f;
! const float zfar = (visibilityLimit > 0.0)
! ? visibilityLimit
! : 30000.0f;
glMatrixMode(GL_MODELVIEW);
|