#include <scripted_camera.H>
Public Member Functions | |
scripted_camera_t (conf_t &conf, world_state_t *ws_, char const *camera_script_file, bool static_mode) | |
Create a new scripted camera object. | |
void | init_data () |
Initialize scripted camera by reading configuration and events. | |
void | update_data (double bot_pos[3]) |
Will check cbmesg queue for new events triggered using the event watcher. | |
void | display (double bot_pos[3]) |
Function called during display loop. | |
void | toggle_display () |
Toggle displaying of the data. | |
void | print_data () |
Will print all scripted camera data. | |
void | print_head () |
Print head element of scripted camera data. | |
void | print_tail () |
Print tail element of scripted camera data. | |
unsigned | size () |
Print the size of the scripted camera data queue. | |
bool | empty () |
Test if the scripted camera data queue is empty. | |
scripted_camera_data_t | head () |
Get the head element from the scripted camera data queue. | |
void | pop () |
Remove the head element from the scripted camera data queue. | |
bool | set_elem_free (scripted_camera_data_t &data, bool abs_tstamp, double tstamp, double eye_x, double eye_y, double eye_z, double ctr_x, double ctr_y, double ctr_z) |
Set a free-mode scripted camera data element. | |
bool | set_elem_follow (scripted_camera_data_t &data, bool abs_tstamp, double tstamp, double eye_x, double eye_y, double eye_z) |
Set a follow-mode scripted camera data element. | |
bool | set_elem_focus (scripted_camera_data_t &data, bool abs_tstamp, double tstamp, double eye_x, double eye_y, double eye_z) |
Set a focus-mode scripted camera data element. | |
bool | set_elem_inside (scripted_camera_data_t &data, bool abs_tstamp, double tstamp, double rotation_angle, double elevation_angle) |
Set an inside-mode scripted camera data element. | |
bool | set_elems_free_spline (queue< scripted_camera_data_t > &data, bool abs_tstamp_beg, double tstamp_beg, bool abs_tstamp_end, double tstamp_end, double eye_spline_pts[12], double ctr_spline_pts[12]) |
Setup the spline and also timestamps for a free-mode spline. | |
bool | set_elems_follow_spline (queue< scripted_camera_data_t > &data, bool abs_tstamp_beg, double tstamp_beg, bool abs_tstamp_end, double tstamp_end, double spline_pts[12]) |
Setup the spline and also timestamps for a follow-mode spline. | |
bool | set_elems_focus_spline (queue< scripted_camera_data_t > &data, bool abs_tstamp_beg, double tstamp_beg, bool abs_tstamp_end, double tstamp_end, double spline_pts[12]) |
Setup the spline and also timestamps for a focus-mode spline. | |
bool | set_elems_inside_spline (queue< scripted_camera_data_t > &data, bool abs_tstamp_beg, double tstamp_beg, bool abs_tstamp_end, double tstamp_end, double spline_pts[8]) |
Setup the spline and also timestamps for a inside-mode spline. | |
Private Member Functions | |
bool | skip_line (string read) |
Test if the given line needs to be skipped or not (commented). | |
void | clear_queue () |
Remove alll scripted camera data from the queue. | |
bool | add_elem (scripted_camera_data_t &data) |
Add a data element to the scripted camera data queue. | |
bool | parse_and_add_style (string read, bool is_from_event) |
Take a line of text and parse it as a camera style. | |
bool | time_ok (double timestamp) |
Test if the given timestamp is ok to add to the queue. | |
double | get_abs_tstamp (double rel_tstamp) |
Convert a relative timestamp into an absolute timestamp. | |
void | print_elem (scripted_camera_data_t &data) |
Print a scripted camera data element. | |
bool | set_elem (scripted_camera_data_t &data, double tstamp, camera_style_t style, double eye_x, double eye_y, double eye_z, double ctr_x, double ctr_y, double ctr_z) |
Used to set the scripted camera data element correctly. | |
bool | set_spline (spline_curve_t &spline, bool abs_tstamp_beg, double &tstamp_beg, bool abs_tstamp_end, double &tstamp_end, double spline_pts_[12]) |
Setup the spline and also timestamps. | |
Private Attributes | |
bool | m_static_mode |
Currently unused. | |
bool | m_draw_free_splines |
Should splines be drawn. | |
float | m_draw_free_splines_vec_length |
Vector length for drawn splines. | |
char const * | m_camera_script_file |
Script file containing scripted camera commands. | |
ifstream | fd |
Handle for scripted camera file. | |
queue< scripted_camera_data_t > * | m_data |
Scripted camera data queue. | |
event_watch_t | m_event_watcher |
Used for checking for events from cbmesg. | |
const event_t * | m_event |
An event that has occurred. | |
vector< event_t * > | m_events |
List of events to watch for. | |
double | m_spline_detail |
How detailed should the splines be. | |
cbmesg_data_t | m_cbmesg_data |
Used for watching events. | |
bool | m_cbmesg_ok |
Cbmesg data queue is ok. | |
bool | m_events_take_priority |
If new events should wipe out the existing queue. |
scripted_camera_t::scripted_camera_t | ( | conf_t & | conf, | |
world_state_t * | ws_, | |||
char const * | camera_script_file, | |||
bool | static_mode | |||
) |
Create a new scripted camera object.
conf | Conf handle to read in parameters. | |
ws_ | World state handle to get cbmesg data. | |
camera_script_file | To read scripted camera parameters. | |
static_mode | Unused at the moment. |
References fd, m_camera_script_file, m_data, m_draw_free_splines, m_draw_free_splines_vec_length, m_events_take_priority, m_spline_detail, m_static_mode, and cajun::component_interface_t::m_world_state.
bool scripted_camera_t::add_elem | ( | scripted_camera_data_t & | data | ) | [private] |
Add a data element to the scripted camera data queue.
data | The data element to add. |
References m_data.
Referenced by parse_and_add_style().
void scripted_camera_t::clear_queue | ( | ) | [private] |
void cajun::scripted_camera_t::display | ( | double | bot_bos_[3] | ) | [inline, virtual] |
Function called during display loop.
Implements cajun::component_interface_t.
bool scripted_camera_t::empty | ( | ) |
Test if the scripted camera data queue is empty.
References m_data.
Referenced by cajun::simview_t::set_view().
double scripted_camera_t::get_abs_tstamp | ( | double | rel_tstamp | ) | [private] |
Convert a relative timestamp into an absolute timestamp.
rel_tstamp | Time stamp in relative form. |
References m_data.
Referenced by set_elem_focus(), set_elem_follow(), set_elem_free(), set_elem_inside(), and set_spline().
scripted_camera_data_t scripted_camera_t::head | ( | ) |
Get the head element from the scripted camera data queue.
References m_data.
Referenced by cajun::simview_t::set_view().
void scripted_camera_t::init_data | ( | ) | [virtual] |
Initialize scripted camera by reading configuration and events.
Any events that need to be watched for are loaded here, as well as the camera styles from the script.
Reimplemented from cajun::component_interface_t.
References fd, m_camera_script_file, m_event_watcher, m_events, parse_and_add_style(), cajun::progname, and skip_line().
Referenced by cajun::simview_t::init_data().
bool scripted_camera_t::parse_and_add_style | ( | string | read, | |
bool | is_from_event | |||
) | [private] |
Take a line of text and parse it as a camera style.
read | The line of text containing a camera style. | |
is_from_event | If the text is event triggered, then absolute time is not used. |
References add_elem(), cajun::draw_camera_splines_t::add_eye(), cajun::draw_camera_splines_t::add_lookat(), m_draw_free_splines, m_draw_free_splines_vec_length, cajun::progname, set_elem_focus(), set_elem_follow(), set_elem_free(), set_elem_inside(), set_elems_focus_spline(), set_elems_follow_spline(), set_elems_free_spline(), and set_elems_inside_spline().
Referenced by init_data(), and update_data().
void scripted_camera_t::pop | ( | ) |
Remove the head element from the scripted camera data queue.
References m_data.
Referenced by cajun::simview_t::set_view().
void scripted_camera_t::print_data | ( | ) |
Will print all scripted camera data.
References m_data, and print_elem().
void scripted_camera_t::print_elem | ( | scripted_camera_data_t & | data | ) | [private] |
Print a scripted camera data element.
data | The element to print. |
References cajun::CAMERA_AT_ORIGIN, cajun::CAMERA_FOCUS_CAR, cajun::CAMERA_IN_CAR, cajun::CAMERA_WITH_CAR, cajun::scripted_camera_data_t::ctr_x, cajun::scripted_camera_data_t::ctr_y, cajun::scripted_camera_data_t::ctr_z, cajun::scripted_camera_data_t::eye_x, cajun::scripted_camera_data_t::eye_y, cajun::scripted_camera_data_t::eye_z, cajun::scripted_camera_data_t::style, and cajun::scripted_camera_data_t::tstamp.
Referenced by print_data(), print_head(), and print_tail().
void scripted_camera_t::print_head | ( | ) |
Print head element of scripted camera data.
References m_data, and print_elem().
void scripted_camera_t::print_tail | ( | ) |
Print tail element of scripted camera data.
References m_data, and print_elem().
bool scripted_camera_t::set_elem | ( | scripted_camera_data_t & | data, | |
double | tstamp, | |||
camera_style_t | style, | |||
double | eye_x, | |||
double | eye_y, | |||
double | eye_z, | |||
double | ctr_x, | |||
double | ctr_y, | |||
double | ctr_z | |||
) | [private] |
Used to set the scripted camera data element correctly.
data | The scripted camera data element to set. | |
tstamp | Timestamp to apply for the element. | |
style | Camera style of the element. | |
eye_x | Eye x location. | |
eye_y | Eye y location. | |
eye_z | Eye z location. | |
ctr_x | Lookat x location. | |
ctr_y | Lookat y location. | |
ctr_z | Lookat z location. |
References cajun::CAMERA_FOCUS_CAR, cajun::CAMERA_IN_CAR, cajun::CAMERA_WITH_CAR, cajun::scripted_camera_data_t::ctr_x, cajun::scripted_camera_data_t::ctr_y, cajun::scripted_camera_data_t::ctr_z, cajun::scripted_camera_data_t::eye_x, cajun::scripted_camera_data_t::eye_y, cajun::scripted_camera_data_t::eye_z, cajun::progname, cajun::scripted_camera_data_t::style, time_ok(), and cajun::scripted_camera_data_t::tstamp.
Referenced by set_elem_focus(), set_elem_follow(), set_elem_free(), and set_elem_inside().
bool scripted_camera_t::set_elem_focus | ( | scripted_camera_data_t & | data, | |
bool | abs_tstamp, | |||
double | tstamp, | |||
double | eye_x, | |||
double | eye_y, | |||
double | eye_z | |||
) |
Set a focus-mode scripted camera data element.
data | The scripted camera data element to set. | |
abs_tstamp | If the tstamp is in absolute form. | |
tstamp | Timestamp to apply for the element. | |
eye_x | Eye x location. | |
eye_y | Eye y location. | |
eye_z | Eye z location. |
References cajun::CAMERA_FOCUS_CAR, get_abs_tstamp(), cajun::progname, and set_elem().
Referenced by parse_and_add_style(), and set_elems_focus_spline().
bool scripted_camera_t::set_elem_follow | ( | scripted_camera_data_t & | data, | |
bool | abs_tstamp, | |||
double | tstamp, | |||
double | eye_x, | |||
double | eye_y, | |||
double | eye_z | |||
) |
Set a follow-mode scripted camera data element.
data | The scripted camera data element to set. | |
abs_tstamp | If the tstamp is in absolute form. | |
tstamp | Timestamp to apply for the element. | |
eye_x | Eye x location. | |
eye_y | Eye y location. | |
eye_z | Eye z location. |
References cajun::CAMERA_WITH_CAR, get_abs_tstamp(), cajun::progname, and set_elem().
Referenced by parse_and_add_style(), and set_elems_follow_spline().
bool scripted_camera_t::set_elem_free | ( | scripted_camera_data_t & | data, | |
bool | abs_tstamp, | |||
double | tstamp, | |||
double | eye_x, | |||
double | eye_y, | |||
double | eye_z, | |||
double | ctr_x, | |||
double | ctr_y, | |||
double | ctr_z | |||
) |
Set a free-mode scripted camera data element.
data | The scripted camera data element to set. | |
abs_tstamp | If the tstamp is in absolute form. | |
tstamp | Timestamp to apply for the element. | |
eye_x | Eye x location. | |
eye_y | Eye y location. | |
eye_z | Eye z location. | |
ctr_x | Lookat x location. | |
ctr_y | Lookat y location. | |
ctr_z | Lookat z location. |
References cajun::CAMERA_AT_ORIGIN, get_abs_tstamp(), cajun::progname, and set_elem().
Referenced by parse_and_add_style(), and set_elems_free_spline().
bool scripted_camera_t::set_elem_inside | ( | scripted_camera_data_t & | data, | |
bool | abs_tstamp, | |||
double | tstamp, | |||
double | rotation_angle, | |||
double | elevation_angle | |||
) |
Set an inside-mode scripted camera data element.
data | The scripted camera data element to set. | |
abs_tstamp | If the tstamp is in absolute form. | |
tstamp | Timestamp to apply for the element. | |
rotation_angle | The left-right angle of the viewer. | |
elevation_angle | The up-down angle of the viewer. |
References cajun::CAMERA_IN_CAR, get_abs_tstamp(), cajun::progname, and set_elem().
Referenced by parse_and_add_style(), and set_elems_inside_spline().
bool scripted_camera_t::set_elems_focus_spline | ( | queue< scripted_camera_data_t > & | data, | |
bool | abs_tstamp_beg, | |||
double | tstamp_beg, | |||
bool | abs_tstamp_end, | |||
double | tstamp_end, | |||
double | spline_pts_[12] | |||
) |
Setup the spline and also timestamps for a focus-mode spline.
The timestamps get converted appropriately and the spline is initialized from the given points.
data | A queue of the generated elements. | |
abs_tstamp_beg | If the beginning timestamp is in absolute form. | |
tstamp_beg | The beginning timestamp. | |
abs_tstamp_end | If the ending timestamp is in absolute form. | |
tstamp_end | The ending timestamp. | |
spline_pts_ | The control points to use for the spline curve. |
References m_spline_detail, cajun::progname, set_elem_focus(), and set_spline().
Referenced by parse_and_add_style().
bool scripted_camera_t::set_elems_follow_spline | ( | queue< scripted_camera_data_t > & | data, | |
bool | abs_tstamp_beg, | |||
double | tstamp_beg, | |||
bool | abs_tstamp_end, | |||
double | tstamp_end, | |||
double | spline_pts_[12] | |||
) |
Setup the spline and also timestamps for a follow-mode spline.
The timestamps get converted appropriately and the spline is initialized from the given points.
data | A queue of the generated elements. | |
abs_tstamp_beg | If the beginning timestamp is in absolute form. | |
tstamp_beg | The beginning timestamp. | |
abs_tstamp_end | If the ending timestamp is in absolute form. | |
tstamp_end | The ending timestamp. | |
spline_pts_ | The control points to use for the spline curve. |
References m_spline_detail, cajun::progname, set_elem_follow(), and set_spline().
Referenced by parse_and_add_style().
bool scripted_camera_t::set_elems_free_spline | ( | queue< scripted_camera_data_t > & | data, | |
bool | abs_tstamp_beg, | |||
double | tstamp_beg, | |||
bool | abs_tstamp_end, | |||
double | tstamp_end, | |||
double | eye_spline_pts_[12], | |||
double | ctr_spline_pts_[12] | |||
) |
Setup the spline and also timestamps for a free-mode spline.
The timestamps get converted appropriately and the spline is initialized from the given points.
data | A queue of the generated elements. | |
abs_tstamp_beg | If the beginning timestamp is in absolute form. | |
tstamp_beg | The beginning timestamp. | |
abs_tstamp_end | If the ending timestamp is in absolute form. | |
tstamp_end | The ending timestamp. | |
eye_spline_pts_ | The control points to use for the eye spline curve. | |
ctr_spline_pts_ | The control points to use for the lookat spline curve. |
References m_spline_detail, cajun::progname, set_elem_free(), and set_spline().
Referenced by parse_and_add_style().
bool scripted_camera_t::set_elems_inside_spline | ( | queue< scripted_camera_data_t > & | data, | |
bool | abs_tstamp_beg, | |||
double | tstamp_beg, | |||
bool | abs_tstamp_end, | |||
double | tstamp_end, | |||
double | spline_pts_[8] | |||
) |
Setup the spline and also timestamps for a inside-mode spline.
The timestamps get converted appropriately and the spline is initialized from the given points.
data | A queue of the generated elements. | |
abs_tstamp_beg | If the beginning timestamp is in absolute form. | |
tstamp_beg | The beginning timestamp. | |
abs_tstamp_end | If the ending timestamp is in absolute form. | |
tstamp_end | The ending timestamp. | |
spline_pts_ | The control points to use for the spline curve, as a set of 4 pairs for (rotation_angle, elevation_angle) |
References m_spline_detail, cajun::progname, set_elem_inside(), and set_spline().
Referenced by parse_and_add_style().
bool scripted_camera_t::set_spline | ( | spline_curve_t & | spline, | |
bool | abs_tstamp_beg, | |||
double & | tstamp_beg, | |||
bool | abs_tstamp_end, | |||
double & | tstamp_end, | |||
double | spline_pts_[12] | |||
) | [private] |
Setup the spline and also timestamps.
The timestamps get converted appropriately and the spline is initialized from the given points.
spline | An unitialized spline curve. | |
abs_tstamp_beg | If the beginning timestamp is in absolute form. | |
tstamp_beg | The beginning timestamp. | |
abs_tstamp_end | If the ending timestamp is in absolute form. | |
tstamp_end | The ending timestamp. | |
spline_pts_ | The control points to use for the spline curve. |
References get_abs_tstamp(), cajun::progname, and time_ok().
Referenced by set_elems_focus_spline(), set_elems_follow_spline(), set_elems_free_spline(), and set_elems_inside_spline().
unsigned scripted_camera_t::size | ( | ) |
Print the size of the scripted camera data queue.
References m_data.
bool scripted_camera_t::skip_line | ( | string | read | ) | [private] |
Test if the given line needs to be skipped or not (commented).
read | The line to test. |
Referenced by init_data().
bool scripted_camera_t::time_ok | ( | double | timestamp | ) | [private] |
Test if the given timestamp is ok to add to the queue.
timestamp | The timestamp to test. |
References m_data.
Referenced by set_elem(), and set_spline().
void cajun::scripted_camera_t::toggle_display | ( | ) | [inline, virtual] |
Toggle displaying of the data.
Implements cajun::component_interface_t.
void scripted_camera_t::update_data | ( | double | bot_pos[3] | ) | [virtual] |
Will check cbmesg queue for new events triggered using the event watcher.
bot_pos | Current bot position. |
Implements cajun::component_interface_t.
References clear_queue(), m_event, m_event_watcher, m_events, m_events_take_priority, and parse_and_add_style().
Referenced by cajun::simview_t::update_data().
ifstream cajun::scripted_camera_t::fd [private] |
Handle for scripted camera file.
Referenced by init_data(), and scripted_camera_t().
char const* cajun::scripted_camera_t::m_camera_script_file [private] |
Script file containing scripted camera commands.
Referenced by init_data(), and scripted_camera_t().
cbmesg_data_t cajun::scripted_camera_t::m_cbmesg_data [private] |
Used for watching events.
bool cajun::scripted_camera_t::m_cbmesg_ok [private] |
Cbmesg data queue is ok.
queue<scripted_camera_data_t>* cajun::scripted_camera_t::m_data [private] |
Scripted camera data queue.
Referenced by add_elem(), clear_queue(), empty(), get_abs_tstamp(), head(), pop(), print_data(), print_head(), print_tail(), scripted_camera_t(), size(), and time_ok().
bool cajun::scripted_camera_t::m_draw_free_splines [private] |
Should splines be drawn.
Referenced by parse_and_add_style(), and scripted_camera_t().
float cajun::scripted_camera_t::m_draw_free_splines_vec_length [private] |
Vector length for drawn splines.
Referenced by parse_and_add_style(), and scripted_camera_t().
const event_t* cajun::scripted_camera_t::m_event [private] |
An event that has occurred.
Referenced by update_data().
event_watch_t cajun::scripted_camera_t::m_event_watcher [private] |
Used for checking for events from cbmesg.
Referenced by init_data(), and update_data().
vector<event_t *> cajun::scripted_camera_t::m_events [private] |
List of events to watch for.
Referenced by init_data(), and update_data().
bool cajun::scripted_camera_t::m_events_take_priority [private] |
If new events should wipe out the existing queue.
Referenced by scripted_camera_t(), and update_data().
double cajun::scripted_camera_t::m_spline_detail [private] |
How detailed should the splines be.
Referenced by scripted_camera_t(), set_elems_focus_spline(), set_elems_follow_spline(), set_elems_free_spline(), and set_elems_inside_spline().
bool cajun::scripted_camera_t::m_static_mode [private] |
Currently unused.
Referenced by scripted_camera_t().