Main Page | Modules | Namespace List | Class Hierarchy | Class List | Namespace Members | Class Members | Related Pages

openvrml::viewer Class Reference

Inheritance diagram for openvrml::viewer:

Inheritance graph
[legend]
List of all members.

Detailed Description

Map the scene graph to the underlying graphics library.


Public Types

typedef long object_t
 An object handle.
typedef long texture_object_t
 An texture object handle.
enum  {
  mask_none = 0,
  mask_ccw = 1,
  mask_convex = 2,
  mask_solid = 4,
  mask_bottom = 8,
  mask_top = 16,
  mask_side = 32,
  mask_color_per_vertex = 64,
  mask_normal_per_vertex = 128
}
enum  rendering_mode {
  draw_mode,
  pick_mode
}
 The rendering mode. More...

Public Member Functions

virtual ~viewer ()=0 throw ()
 Destroy.
openvrml::browserbrowser () const throw ()
virtual rendering_mode mode ()=0
 Get the rendering mode.
virtual double frame_rate ()=0
 Get the frame rate.
virtual void reset_user_navigation ()=0
 Return view to the last bound Viewpoint.
virtual object_t begin_object (const char *id, bool retain=false)=0
 Begin a display list.
virtual void end_object ()=0
 End a display list.
virtual object_t insert_background (const std::vector< float > &ground_angle, const std::vector< color > &ground_color, const std::vector< float > &sky_angle, const std::vector< color > &sky_color, const image &front, const image &back, const image &left, const image &right, const image &top, const image &bottom)=0
 Insert a background into a display list.
virtual object_t insert_box (const vec3f &size)=0
 Insert a box into a display list.
virtual object_t insert_cone (float height, float radius, bool bottom, bool side)=0
 Insert a cone into a display list.
virtual object_t insert_cylinder (float height, float radius, bool bottom, bool side, bool top)=0
 Insert a cylinder into a display list.
virtual object_t insert_elevation_grid (unsigned int mask, const std::vector< float > &height, int32 x_dimension, int32 z_dimension, float x_spacing, float z_spacing, const std::vector< color > &color, const std::vector< vec3f > &normal, const std::vector< vec2f > &tex_coord)=0
 Insert an elevation grid into a display list.
virtual object_t insert_extrusion (unsigned int, const std::vector< vec3f > &spine, const std::vector< vec2f > &cross_section, const std::vector< rotation > &orientation, const std::vector< vec2f > &scale)=0
virtual object_t insert_line_set (const std::vector< vec3f > &coord, const std::vector< int32 > &coord_index, bool color_per_vertex, const std::vector< color > &color, const std::vector< int32 > &color_index)=0
 Insert a line set into a display list.
virtual object_t insert_point_set (const std::vector< vec3f > &coord, const std::vector< color > &color)=0
 Insert a point set into a display list.
virtual object_t insert_shell (unsigned int mask, const std::vector< vec3f > &coord, const std::vector< int32 > &coord_index, const std::vector< color > &color, const std::vector< int32 > &color_index, const std::vector< vec3f > &normal, const std::vector< int32 > &normal_index, const std::vector< vec2f > &tex_coord, const std::vector< int32 > &tex_coord_index)=0
 Insert a shell into a display list.
virtual object_t insert_sphere (float radius)=0
 Insert a sphere into a display list.
virtual object_t insert_dir_light (float ambient_intensity, float intensity, const color &color, const vec3f &direction)=0
 Insert a directional light into a display list.
virtual object_t insert_point_light (float ambient_intensity, const vec3f &attenuation, const color &color, float intensity, const vec3f &location, float radius)=0
 Insert a point light into a display list.
virtual object_t insert_spot_light (float ambient_intensity, const vec3f &attenuation, float beam_width, const color &color, float cut_off_angle, const vec3f &direction, float intensity, const vec3f &location, float radius)=0
 Insert a point light into a display list.
virtual object_t insert_reference (object_t existing_object)=0
 Insert a reference to an existing object into a display list.
virtual void remove_object (object_t ref)=0
 Remove an object from the display list.
virtual void enable_lighting (bool val)=0
 Enable/disable lighting.
virtual void set_fog (const color &color, float visibility_range, const char *type)=0
 Set the fog.
virtual void set_color (const color &rgb, float a=1.0)=0
 Set the color.
virtual void set_material (float ambient_intensity, const color &diffuse_color, const color &emissive_color, float shininess, const color &specular_color, float transparency)=0
 Set the material.
virtual void set_material_mode (size_t tex_components, bool geometry_color)=0
 Set the material mode.
virtual void set_sensitive (node *object)=0
 Indicate that a node should be sensitive to the pointing device.
virtual texture_object_t insert_texture (const image &img, bool repeat_s, bool repeat_t, bool retainHint=false)=0
 Create a texture object.
virtual void insert_texture_reference (texture_object_t ref, size_t components)=0
 Insert a texture into the display list from an existing handle.
virtual void remove_texture_object (texture_object_t ref)=0
 Remove a texture from the display list.
virtual void set_texture_transform (const vec2f &center, float rotation, const vec2f &scale, const vec2f &translation)=0
 Set the texture transform.
virtual void set_viewpoint (const vec3f &position, const rotation &orientation, float field_of_view, float avatar_size, float visibility_limit)=0
 Set the viewpoint.
virtual void transform (const mat4f &mat)=0
 Transform the modelview.
virtual void transform_points (size_t nPoints, vec3f *point) const =0
 Transform points by the current modelview matrix.
virtual const openvrml::frustumfrustum () const
virtual void frustum (const openvrml::frustum &f)
 Set the frustum.
virtual bounding_volume::intersection intersect_view_volume (const bounding_volume &bvolume) const
virtual void draw_bounding_sphere (const bounding_sphere &bs, bounding_volume::intersection intersection)=0
 Draw a bounding sphere.

Protected Member Functions

 viewer () throw ()
 Construct.

Protected Attributes

openvrml::frustum frustum_
 The frustum.

Private Attributes

openvrml::browserbrowser_
 A pointer to the browser with which the viewer is currently associated.

Friends

class browser
 A pointer to the browser with which the viewer is currently associated.

Member Typedef Documentation

openvrml::viewer::object_t
 

An object handle.

openvrml::viewer::texture_object_t
 

An texture object handle.


Member Enumeration Documentation

enum openvrml::viewer::rendering_mode
 

The rendering mode.

Enumerator:
draw_mode  Draw mode.
pick_mode  Pick mode.

Constructor & Destructor Documentation

openvrml::viewer::~viewer  )  throw () [pure virtual]
 

Destroy.

Implemented in openvrml::gl::viewer.

openvrml::viewer::viewer  )  throw () [protected]
 

Construct.

Reimplemented in openvrml::gl::viewer.


Member Function Documentation

viewer::rendering_mode openvrml::viewer::mode  )  [pure virtual]
 

Get the rendering mode.

Returns:
the rendering mode.

Implemented in openvrml::gl::viewer.

double openvrml::viewer::frame_rate  )  [pure virtual]
 

Get the frame rate.

Returns:
the frame rate.

Implemented in openvrml::gl::viewer.

void openvrml::viewer::reset_user_navigation  )  [pure virtual]
 

Return view to the last bound Viewpoint.

Implemented in openvrml::gl::viewer.

viewer::object_t openvrml::viewer::begin_object const char *  id,
bool  retain = false
[pure virtual]
 

Begin a display list.

Parameters:
id object identifier.
retain whether the object should be retained for reuse.
Returns:
the display object identifier.

Implemented in openvrml::gl::viewer.

void openvrml::viewer::end_object  )  [pure virtual]
 

End a display list.

Implemented in openvrml::gl::viewer.

viewer::object_t openvrml::viewer::insert_background const std::vector< float > &  ground_angle,
const std::vector< color > &  ground_color,
const std::vector< float > &  sky_angle,
const std::vector< color > &  sky_color,
const image front,
const image back,
const image left,
const image right,
const image top,
const image bottom
[pure virtual]
 

Insert a background into a display list.

Parameters:
ground_angle ground angles.
ground_color ground colors.
sky_angle sky angles.
sky_color sky colors.
front front texture.
back back texture.
left left texture.
right right texture.
top top texture.
bottom bottom texture.
Returns:
display object identifier.

Implemented in openvrml::gl::viewer.

viewer::object_t openvrml::viewer::insert_box const vec3f size  )  [pure virtual]
 

Insert a box into a display list.

Parameters:
size box dimensions.
Returns:
display object identifier.

Implemented in openvrml::gl::viewer.

viewer::object_t openvrml::viewer::insert_cone float  height,
float  radius,
bool  bottom,
bool  side
[pure virtual]
 

Insert a cone into a display list.

Parameters:
height height.
radius radius at base.
bottom show the bottom.
side show the side.
Returns:
display object identifier.

Implemented in openvrml::gl::viewer.

viewer::object_t openvrml::viewer::insert_cylinder float  height,
float  radius,
bool  bottom,
bool  side,
bool  top
[pure virtual]
 

Insert a cylinder into a display list.

Parameters:
height height.
radius radius.
bottom show the bottom.
side show the side.
top show the top.
Returns:
display object identifier.

Implemented in openvrml::gl::viewer.

viewer::object_t openvrml::viewer::insert_elevation_grid unsigned int  mask,
const std::vector< float > &  height,
int32  x_dimension,
int32  z_dimension,
float  x_spacing,
float  z_spacing,
const std::vector< color > &  color,
const std::vector< vec3f > &  normal,
const std::vector< vec2f > &  tex_coord
[pure virtual]
 

Insert an elevation grid into a display list.

Parameters:
mask 
height height field.
x_dimension vertices in the x direction.
z_dimension vertices in the z direction.
x_spacing distance between vertices in the x direction.
z_spacing distance between vertices in the z direction.
color colors.
normal normals.
tex_coord texture coordinates.
Returns:
display object identifier.

Implemented in openvrml::gl::viewer.

viewer::object_t openvrml::viewer::insert_line_set const std::vector< vec3f > &  coord,
const std::vector< int32 > &  coord_index,
bool  color_per_vertex,
const std::vector< color > &  color,
const std::vector< int32 > &  color_index
[pure virtual]
 

Insert a line set into a display list.

Parameters:
coord coordinates.
coord_index coordinate indices.
color_per_vertex whether colors are applied per-vertex or per-face.
color colors.
color_index color indices.
Returns:
display object identifier.

Implemented in openvrml::gl::viewer.

viewer::object_t openvrml::viewer::insert_point_set const std::vector< vec3f > &  coord,
const std::vector< color > &  color
[pure virtual]
 

Insert a point set into a display list.

Parameters:
coord points.
color colors.
Returns:
display object identifier.

Implemented in openvrml::gl::viewer.

viewer::object_t openvrml::viewer::insert_shell unsigned int  mask,
const std::vector< vec3f > &  coord,
const std::vector< int32 > &  coord_index,
const std::vector< color > &  color,
const std::vector< int32 > &  color_index,
const std::vector< vec3f > &  normal,
const std::vector< int32 > &  normal_index,
const std::vector< vec2f > &  tex_coord,
const std::vector< int32 > &  tex_coord_index
[pure virtual]
 

Insert a shell into a display list.

Parameters:
mask 
coord coordinates.
coord_index coordinate indices.
color colors.
color_index color indices.
normal normals.
normal_index normal indices.
tex_coord texture coordinates.
tex_coord_index texture coordinate indices.
Returns:
display object identifier.

Implemented in openvrml::gl::viewer.

viewer::object_t openvrml::viewer::insert_sphere float  radius  )  [pure virtual]
 

Insert a sphere into a display list.

Parameters:
radius sphere radius.
Returns:
display object identifier.

Implemented in openvrml::gl::viewer.

viewer::object_t openvrml::viewer::insert_dir_light float  ambient_intensity,
float  intensity,
const color color,
const vec3f direction
[pure virtual]
 

Insert a directional light into a display list.

Parameters:
ambient_intensity ambient intensity.
intensity intensity.
color color.
direction direction.
Returns:
display object identifier.

Implemented in openvrml::gl::viewer.

viewer::object_t openvrml::viewer::insert_point_light float  ambient_intensity,
const vec3f attenuation,
const color color,
float  intensity,
const vec3f location,
float  radius
[pure virtual]
 

Insert a point light into a display list.

Parameters:
ambient_intensity ambient intensity.
attenuation attenuation.
color color.
intensity intensity.
location location.
radius radius.
Returns:
display object identifier.

Implemented in openvrml::gl::viewer.

viewer::object_t openvrml::viewer::insert_spot_light float  ambient_intensity,
const vec3f attenuation,
float  beam_width,
const color color,
float  cut_off_angle,
const vec3f direction,
float  intensity,
const vec3f location,
float  radius
[pure virtual]
 

Insert a point light into a display list.

Parameters:
ambient_intensity ambient intensity.
attenuation attenuation.
beam_width beam width.
color color.
cut_off_angle cut-off angle.
direction direction.
intensity intensity.
location location.
radius radius.
Returns:
display object identifier.

Implemented in openvrml::gl::viewer.

viewer::object_t openvrml::viewer::insert_reference object_t  existing_object  )  [pure virtual]
 

Insert a reference to an existing object into a display list.

Returns:
display object identifier.

void openvrml::viewer::remove_object object_t  ref  )  [pure virtual]
 

Remove an object from the display list.

Parameters:
ref object handle.

void openvrml::viewer::enable_lighting bool  val  )  [pure virtual]
 

Enable/disable lighting.

Parameters:
val whether lighting should be enabled.

Implemented in openvrml::gl::viewer.

void openvrml::viewer::set_fog const color color,
float  visibility_range,
const char *  type
[pure virtual]
 

Set the fog.

Parameters:
color fog color.
visibility_range the distance at which objects are fully obscured by fog.
type fog type.

Implemented in openvrml::gl::viewer.

void openvrml::viewer::set_color const color rgb,
float  a = 1.0
[pure virtual]
 

Set the color.

Parameters:
rgb red, green, and blue components.
a alpha (transparency) component.

Implemented in openvrml::gl::viewer.

void openvrml::viewer::set_material float  ambient_intensity,
const color diffuse_color,
const color emissive_color,
float  shininess,
const color specular_color,
float  transparency
[pure virtual]
 

Set the material.

Parameters:
ambient_intensity ambient intensity.
diffuse_color diffuse color.
emissive_color emissive color.
shininess shininess.
specular_color specular color.
transparency transparency.

Implemented in openvrml::gl::viewer.

void openvrml::viewer::set_material_mode size_t  tex_components,
bool  geometry_color
[pure virtual]
 

Set the material mode.

Parameters:
tex_components texture components.
geometry_color geometry color.

Implemented in openvrml::gl::viewer.

void openvrml::viewer::set_sensitive node object  )  [pure virtual]
 

Indicate that a node should be sensitive to the pointing device.

Parameters:
object a node.

Implemented in openvrml::gl::viewer.

viewer::texture_object_t openvrml::viewer::insert_texture const image img,
bool  repeat_s,
bool  repeat_t,
bool  retainHint = false
[pure virtual]
 

Create a texture object.

Parameters:
img image.
repeat_s repeat in the S direction.
repeat_t repeat in the T direction.
retainHint whether the texture is likely to be reused.
Returns:
a handle to the inserted texture.

Implemented in openvrml::gl::viewer.

void openvrml::viewer::insert_texture_reference texture_object_t  ref,
size_t  components
[pure virtual]
 

Insert a texture into the display list from an existing handle.

Parameters:
ref texture handle.
components number of components.

void openvrml::viewer::remove_texture_object texture_object_t  ref  )  [pure virtual]
 

Remove a texture from the display list.

Parameters:
ref texture handle.

void openvrml::viewer::set_texture_transform const vec2f center,
float  rotation,
const vec2f scale,
const vec2f translation
[pure virtual]
 

Set the texture transform.

Parameters:
center center.
rotation rotation.
scale scale.
translation translation.

Implemented in openvrml::gl::viewer.

void openvrml::viewer::set_viewpoint const vec3f position,
const rotation orientation,
float  field_of_view,
float  avatar_size,
float  visibility_limit
[pure virtual]
 

Set the viewpoint.

Parameters:
position position.
orientation orientation.
field_of_view field of view.
avatar_size avatar size.
visibility_limit visiblity limit.

Implemented in openvrml::gl::viewer.

void openvrml::viewer::transform const mat4f mat  )  [pure virtual]
 

Transform the modelview.

Make the modelview matrix the result of multiplying mat by the current modelview matrix.

Parameters:
mat transformation matrix.

Implemented in openvrml::gl::viewer.

void openvrml::viewer::transform_points size_t  nPoints,
vec3f point
const [pure virtual]
 

Transform points by the current modelview matrix.

Parameters:
nPoints number of points.
point pointer to the first point in an array.

Implemented in openvrml::gl::viewer.

const frustum & openvrml::viewer::frustum  )  const [virtual]
 

Todo:
We're forcing everybody to carry around a frustum whether they want it or not. It shouldn't be used except for debugging and stuff since it might not be valid in some implementations

Returns:
the frustum.

void openvrml::viewer::frustum const openvrml::frustum f  )  [virtual]
 

Set the frustum.

Parameters:
f new frustum value.

bounding_volume::intersection openvrml::viewer::intersect_view_volume const bounding_volume bvolume  )  const [virtual]
 

Intersect the given bounding volume with the view volume. This goes into the viewer to provide a hook for systems that use non-standard view volumes. Most subclasses should be able to use the default implementation provided here. If your view volume is so strange that there's no way to cull to is, then reimplement to always return bounding_volume::inside.

Parameters:
bvolume the bounding volume to intersect with the view volume.
Returns:
bounding_volume::inside, bounding_volume::outside, or bounding_volume::partial.

void openvrml::viewer::draw_bounding_sphere const bounding_sphere bs,
bounding_volume::intersection  intersection
[pure virtual]
 

Draw a bounding sphere.

Used for debugging view culling. Probably should be draw_bounding_volume and handle axis_aligned_bounding_boxes as well.

Parameters:
bs a bounding sphere; if max, will not be drawn
intersection one of the bvolume intersection test constants, or 4 to draw in unique way. (useful for debugging)

Implemented in openvrml::gl::viewer.


Friends And Related Function Documentation

openvrml::browser * openvrml::viewer::browser [friend]
 

A pointer to the browser with which the viewer is currently associated.

Returns:
a pointer to the browser with which the viewer is currently associated, or 0 if the viewer is not associated with a browser.

Member Data Documentation

browser * openvrml::viewer::browser_ [private]
 

A pointer to the browser with which the viewer is currently associated.

frustum openvrml::viewer::frustum_ [protected]
 

The frustum.