The path constrained manipulator. More...
#include <trackmode.h>
Public Member Functions | |
void | Apply (Trackball *trackball, float WheelNotch) |
Apply a translation, function of the user mouse wheel action. | |
void | Apply (Trackball *trackball, Point3f new_point) |
Apply a translation, function of the user mouse drag action. | |
void | Draw (Trackball *trackball) |
Render this manipulator. | |
bool | isSticky () |
The (non) avaibility to manipulator changes inside an action. | |
const char * | Name () |
Return this manipulator's name. | |
PathMode (const Point3f &start, const Point3f &end) | |
The segment constructor. | |
PathMode (const std::vector< Point3f > &pts, bool w=false) | |
The vector-boolean constructor. | |
void | Reset () |
The reset function. | |
void | SetAction () |
The begin action function. | |
Point3f | SetStartNear (Point3f p) |
Try to set the inital point. | |
void | Undo () |
The undo function. | |
Private Member Functions | |
void | GetPoints (float state, Point3f &point, Point3f &prev_point, Point3f &next_point) |
The state interpreter. | |
float | HitPoint (float state, Ray3fN ray, Point3f &hit_point) |
Compute the new point and the -state. | |
void | Init (const std::vector< Point3f > &points) |
The data initializer. | |
float | Normalize (float state) |
The state normalizer. | |
int | Verse (Point3f reference_point, Point3f current_point, Point3f prev_point, Point3f next_point) |
Compute the verse to follow for slide nearer to a given point. | |
Private Attributes | |
float | current_state |
The current state. | |
float | initial_state |
The initial state. | |
float | min_seg_length |
The length of the shostest path segment. | |
Point3f | old_hitpoint |
The point relative to the old state. | |
float | path_length |
The path length. | |
std::vector< Point3f > | points |
The node vector. | |
float | undo_current_state |
current_state after an Undo() call. | |
Point3f | undo_old_hitpoint |
old_hitpoint after an Undo() call. | |
bool | wrap |
True if the path is closed, false otherwise. |
The path constrained manipulator.
This manipulator moves the object along an eventually closed path.
The user can either drag the mouse or scroll the wheel, when the user drags the mouse, the object tries to slide toward it.
The object is assumed to initially be on the same position of the first point on the path.
This is a stateful manipulator, result of the Apply functions is determined by the objects's position along the path and by either the mouse coordinates or the mouse wheel notch.
Definition at line 649 of file trackmode.h.
vcg::PathMode::PathMode | ( | const std::vector< Point3f > & | pts, | |
bool | w = false | |||
) | [inline] |
The vector-boolean constructor.
The vector passed to build the path is copied locally. The boolean value specifies if the path is to be closed. If the boolean value is not specified, the path is not closed.
pts | the path nodes. | |
w | a boolean value that closes the path. |
Definition at line 663 of file trackmode.h.
The segment constructor.
If the path is a simple segment, it can be specified just with the endpoints.
start | the starting point. | |
end | the ending point. |
Definition at line 677 of file trackmode.h.
void PathMode::Apply | ( | Trackball * | trackball, | |
float | WheelNotch | |||
) | [virtual] |
Apply a translation, function of the user mouse wheel action.
The manipulated object is moved along the path. A step of the mouse wheel makes the object slide by a distance equal to the half of the shortest segment on the path.
trackball | the manipulator manager. | |
WheelNotch | the mouse wheel notch. |
Reimplemented from vcg::TrackMode.
Definition at line 449 of file trackmode.cpp.
Apply a translation, function of the user mouse drag action.
The manipulated object is moved along the path. This function implements an algorithm that makes the object try to slide on the path towards the mouse pointer.
trackball | the manipulator manager. | |
new_point | the new mouse pointer coordinate. |
Reimplemented from vcg::TrackMode.
Definition at line 541 of file trackmode.cpp.
void PathMode::Draw | ( | Trackball * | trackball | ) | [virtual] |
Render this manipulator.
trackball | the manipulator manager. |
Reimplemented from vcg::TrackMode.
Definition at line 562 of file trackmode.cpp.
void PathMode::GetPoints | ( | float | state, | |
Point3f & | point, | |||
Point3f & | prev_point, | |||
Point3f & | next_point | |||
) | [private] |
The state interpreter.
Given the state, return the current point, the previous node and the next node on the path. The algoritm is linear in the node paths.
state | the given state. | |
point | is set to the current point. | |
prev_point | is set to the point of current point's previous node. | |
next_point | is set to the point of current point's next node. |
Definition at line 389 of file trackmode.cpp.
Compute the new point and the -state.
Given a state and the mouse coords ray, computes the new state point and return the -state. The algoritm is linear in the node paths.
state | the given state. | |
ray | the ray relative to mouse coords. | |
hit_point | is set to the new state point. |
Definition at line 511 of file trackmode.cpp.
void PathMode::Init | ( | const std::vector< Point3f > & | points | ) | [private] |
The data initializer.
Initialize the internal state and checks params validity.
points | the path nodes. |
Definition at line 322 of file trackmode.cpp.
bool PathMode::isSticky | ( | ) | [virtual] |
The (non) avaibility to manipulator changes inside an action.
This manipulator has an internal state and does not allow a switch in the middle of a function.
Reimplemented from vcg::TrackMode.
Definition at line 553 of file trackmode.cpp.
const char* vcg::PathMode::Name | ( | ) | [inline, virtual] |
Return this manipulator's name.
Reimplemented from vcg::TrackMode.
Definition at line 691 of file trackmode.h.
float PathMode::Normalize | ( | float | state | ) | [private] |
The state normalizer.
Normalize a given state in the right interval:
state | the given state. |
Definition at line 463 of file trackmode.cpp.
void PathMode::Reset | ( | ) | [virtual] |
The reset function.
This function reset the object position to the initial point.
Reimplemented from vcg::TrackMode.
Definition at line 345 of file trackmode.cpp.
void PathMode::SetAction | ( | ) | [virtual] |
The begin action function.
This function is to be called at the begin of an user action.
Reimplemented from vcg::TrackMode.
Definition at line 536 of file trackmode.cpp.
Try to set the inital point.
This function try to set the starting point in the point passed as parameter, if the point passed does not reside on the path, the start is put on the closest point on it.
p | the point wished for the start. |
Definition at line 350 of file trackmode.cpp.
void PathMode::Undo | ( | ) | [virtual] |
The undo function.
This function recreates the state present before the last Apply() call.
Reimplemented from vcg::TrackMode.
Definition at line 557 of file trackmode.cpp.
int PathMode::Verse | ( | Point3f | reference_point, | |
Point3f | current_point, | |||
Point3f | prev_point, | |||
Point3f | next_point | |||
) | [private] |
Compute the verse to follow for slide nearer to a given point.
Given the current state point, the point of previus and next node and a reference point, compute the verse to follow for the object to come closer to the reference point.
reference_point | ||
current_point | ||
prev_point | ||
next_point |
Definition at line 480 of file trackmode.cpp.
float vcg::PathMode::current_state [private] |
The current state.
Definition at line 827 of file trackmode.h.
float vcg::PathMode::initial_state [private] |
The initial state.
Definition at line 829 of file trackmode.h.
float vcg::PathMode::min_seg_length [private] |
The length of the shostest path segment.
Definition at line 833 of file trackmode.h.
Point3f vcg::PathMode::old_hitpoint [private] |
The point relative to the old state.
Definition at line 835 of file trackmode.h.
float vcg::PathMode::path_length [private] |
The path length.
Definition at line 831 of file trackmode.h.
std::vector< Point3f > vcg::PathMode::points [private] |
The node vector.
Definition at line 823 of file trackmode.h.
float vcg::PathMode::undo_current_state [private] |
current_state after an Undo() call.
Definition at line 837 of file trackmode.h.
Point3f vcg::PathMode::undo_old_hitpoint [private] |
old_hitpoint after an Undo() call.
Definition at line 839 of file trackmode.h.
bool vcg::PathMode::wrap [private] |
True if the path is closed, false otherwise.
Definition at line 825 of file trackmode.h.