SCM Library
Spherical Cube Map rendering library
|
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_sphere * | get_sphere () const |
Return a pointer to the sphere geometry handler. | |
scm_render * | get_render () const |
Return a pointer to the render manager. | |
scm_scene * | get_fore () const |
Return a pointer to the current foreground scene. | |
scm_scene * | get_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_scene * | get_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_step * | get_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_scene * | find_scene (const std::string &) const |
Return the scene with the given name. | |
scm_cache * | get_cache (int) |
Return the cache associated with the given file index. | |
scm_file * | get_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... | |
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.
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.
w | Width of the off-screen render target (in pixels) |
h | Height of the off-screen render target (in pixels) |
d | Detail with which sphere pages are drawn (in vertices) |
l | Limit at which sphere pages are subdivided (in pixels) |
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.
P | Projection matrix in column-major OpenGL form |
M | Model-view matrix in column-major OpenGL form |
channel | Channel 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.
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.
void scm_system::flush_cache | ( | ) |
Flush all image caches. All pages are ejected from all caches.
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.
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.
v | Vector 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 | ) |
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.
f | File index |
v | Vector 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).
f | File index |
i | Page 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).
f | File index |
i | Page index |
r0 | Minimum radius output |
r1 | Maximum radius output |