SCM Library
Spherical Cube Map rendering library
 All Classes Files Functions Variables Friends Pages
Public Member Functions | List of all members
scm_system Class Reference

An scm_system encapsulates all of the state of an SCM renderer. Its interface is the primary API of the SCM rendering library. More...

#include <scm-system.hpp>

Public Member Functions

 scm_system (int w, int h, int d, int l)
 Create a new empty SCM system. Instantiate a render handler and a sphere handler. More...
 
 ~scm_system ()
 Finalize all SCM system state.
 
void render_sphere (const double *, const double *, int) const
 Render the sphere. This is among the most significant entry points of the SCM API as it is the simplest function that accomplishes the goal. It should be called once per frame. More...
 
System queries
scm_sphereget_sphere () const
 Return a pointer to the sphere geometry handler.
 
scm_renderget_render () const
 Return a pointer to the render manager.
 
scm_sceneget_fore () const
 Return a pointer to the current foreground scene.
 
scm_sceneget_back () const
 Return a pointer to the current background scene.
 
Scene collection handlers
int add_scene (int i)
 Allocate and insert a new scene before index i. Return its index.
 
void del_scene (int i)
 Delete the scene at index i.
 
scm_sceneget_scene (int i)
 Return a pointer to the scene at index i, or 0 if i is out-of-range.
 
int get_scene_count () const
 Return the number of scenes in the collection.
 
double set_scene_blend (double)
 Set the scene caches and fade coefficient to produce a rendering of the current step queue at time t.
 
Step collection handlers
int add_step (int i)
 Allocate and insert a new step before index i. Return its index.
 
void del_step (int i)
 Delete the step at index i.
 
scm_stepget_step (int i)
 Return a pointer to the step at index i.
 
int get_step_count () const
 Return the number of steps in the collection.
 
scm_step get_step_blend (double) const
 Compute the interpolated values of the current step queue at the given time. Extrapolate the first and last steps to produce a clean start and stop.
 
Step queue handlers
void import_queue (const std::string &)
 Parse the given string as a series of camera states. Enqueue each. This function ingests Maya MOV exports.
 
void export_queue (std::string &)
 Print all steps on the current queue to the given string using the same format expected by import_queue.
 
void append_queue (scm_step *)
 Take ownership of the given step and append it to the current queue.
 
void flush_queue ()
 Flush the current step queue, deleting all steps in it.
 
Cache handlers
void update_cache ()
 Update all image caches. This is among the most significant entry points of the SCM API as it handles image input. It ensures that any page requests being serviced in the background are properly transmitted to the OpenGL context. It should be called once per frame. More...
 
void render_cache ()
 Render a 2D overlay of the contents of all caches. This can be a helpful visual debugging tool as well as an effective demonstration of the inner workings of the library. More...
 
void flush_cache ()
 Flush all image caches. All pages are ejected from all caches. More...
 
void set_synchronous (bool)
 In synchronous mode, scm_cache::update will block until all background input handling is complete. This ensures perfect data each frame, but may delay frames. More...
 
bool get_synchronous () const
 Return the synchronous flag.
 
Data queries
float get_current_ground (const double *) const
 Return the ground level of current scene at the given location. O(log n). This may incur data access in the render thread. More...
 
float get_minimum_ground () const
 Return the minimum ground level of the current scene, e.g. the radius of the planet at the bottom of the deepest valley. O(1).
 
Internal Interface
int acquire_scm (const std::string &)
 Internal: Load the named SCM file, if not already loaded. More...
 
int release_scm (const std::string &)
 Release the named SCM file. More...
 
scm_scenefind_scene (const std::string &) const
 Return the scene with the given name.
 
scm_cacheget_cache (int)
 Return the cache associated with the given file index.
 
scm_fileget_file (int)
 Return the file associated with the given file index.
 
float get_page_sample (int f, const double *v)
 Sample an SCM file at the given location. O(log n). This may incur data access in the render thread. More...
 
bool get_page_status (int f, long long i)
 Return true if a page is present in the SCM file. O(log n). More...
 
void get_page_bounds (int f, long long i, float &r0, float &r1)
 Determine the minimum and maximum values of an SCM file page. O(log n). More...
 

Detailed Description

An scm_system encapsulates all of the state of an SCM renderer. Its interface is the primary API of the SCM rendering library.

The SCM system maintains the list of scenes and steps currently held open by an application, all of the image that these scenes and steps refer to, all of the caches that store the data of these images, the sphere manager used to render it, and the render handler that manages this rendering. A queue of steps enables the recording and playback of camera motion.

Constructor & Destructor Documentation

scm_system::scm_system ( int  w,
int  h,
int  d,
int  l 
)

Create a new empty SCM system. Instantiate a render handler and a sphere handler.

See Also
scm_render::scm_render
scm_sphere::scm_sphere
Parameters
wWidth of the off-screen render target (in pixels)
hHeight of the off-screen render target (in pixels)
dDetail with which sphere pages are drawn (in vertices)
lLimit at which sphere pages are subdivided (in pixels)

Member Function Documentation

void scm_system::render_sphere ( const double *  P,
const double *  M,
int  channel 
) const

Render the sphere. This is among the most significant entry points of the SCM API as it is the simplest function that accomplishes the goal. It should be called once per frame.

The request is forwarded directly to the render handler, augmented with the current foreground and background scenes and cross-fade parameters.

See Also
scm_render::render
Parameters
PProjection matrix in column-major OpenGL form
MModel-view matrix in column-major OpenGL form
channelChannel index (e.g. 0 for left eye, 1 for right eye)
void scm_system::update_cache ( )

Update all image caches. This is among the most significant entry points of the SCM API as it handles image input. It ensures that any page requests being serviced in the background are properly transmitted to the OpenGL context. It should be called once per frame.

See Also
scm_cache::update
void scm_system::render_cache ( )

Render a 2D overlay of the contents of all caches. This can be a helpful visual debugging tool as well as an effective demonstration of the inner workings of the library.

See Also
scm_cache::render
void scm_system::flush_cache ( )

Flush all image caches. All pages are ejected from all caches.

See Also
scm_cache::flush
void scm_system::set_synchronous ( bool  b)

In synchronous mode, scm_cache::update will block until all background input handling is complete. This ensures perfect data each frame, but may delay frames.

See Also
scm_cache::update
float scm_system::get_current_ground ( const double *  v) const

Return the ground level of current scene at the given location. O(log n). This may incur data access in the render thread.

Parameters
vVector from the center of the planet to the query position.
int scm_system::acquire_scm ( const std::string &  name)

Internal: Load the named SCM file, if not already loaded.

Add a new scm_file object to the collection and return its index. If needed, create a new scm_cache object to manage this file's data. This will always succeed as an scm_file object produces fallback data under error conditions, such as an unfound SCM TIFF.

int scm_system::release_scm ( const std::string &  name)

Release the named SCM file.

The file collection is reference-counted, and the scm_file object is only deleted when all acquisitions are released. If a deleted file is the only file handled by an scm_cache then delete that cache.

float scm_system::get_page_sample ( int  f,
const double *  v 
)

Sample an SCM file at the given location. O(log n). This may incur data access in the render thread.

See Also
scm_file::get_page_sample
Parameters
fFile index
vVector from the center of the planet to the query position.
bool scm_system::get_page_status ( int  f,
long long  i 
)

Return true if a page is present in the SCM file. O(log n).

See Also
scm_file::get_page_status
Parameters
fFile index
iPage index
void scm_system::get_page_bounds ( int  f,
long long  i,
float &  r0,
float &  r1 
)

Determine the minimum and maximum values of an SCM file page. O(log n).

See Also
scm_file::get_page_bounds
Parameters
fFile index
iPage index
r0Minimum radius output
r1Maximum radius output

The documentation for this class was generated from the following files: