#include <navigation.h>
Public Member Functions | |
Navigation (const MODULE_ID &_id, const wxString &_name, EventHandler *msgSink) | |
Class constructor. | |
virtual | ~Navigation () |
Class destructor. | |
virtual wxString | GetDesc () const |
Get module description - Module overload. | |
Protected Types | |
enum | NavigationStyle { CAMERA_MANIPULATOR = 0, CATIA = 1, ICEMSURF = 2, DELTAGEN = 3, VD2 = 4, CORTONA = 5, CINEMA4D = 6, MAYA = 7 } |
Enums of the supported navigation styles. More... | |
enum | ViewName { FRONT, SIDE, TOP, REAR } |
typedef std::vector < NavigationStyleInterface * > | NavigationStyleVector |
Vector of supported navigation styles typedef. | |
typedef std::vector< const SceneNode * > | SceneNodeVector |
Vector of scene node pointers. | |
typedef std::list < NavigationOperationPair > | ParameterIdentificatorList |
List of ParameterIdentificator. | |
Protected Member Functions | |
wxString | buildCurrentCameraString (const SceneNode *node) |
Creates a string for the camera selection combobox. | |
void | lowMouseEventTimeout () |
Sets the mouse event timeout low. | |
void | highMouseEventTimeout () |
Sets the mouse event timeout high. | |
void | registerGUI () |
Convenience method for registering all gui elements. | |
void | refreshGUI () |
Called whenever the gui elements are changed. | |
void | registerCommonGUIControls () |
Register the gui controls which arent specific for any emulation. | |
void | registerTextControl (Parameter::ParameterIdentificator ¶mID, const wxString &value) |
Convenience method for registering a text field. Macro can not be used because it does not work when used inside the embedded class (eg. NavigationStyleCATIASpecific). | |
void | registerButton (Parameter::ParameterIdentificator ¶mID) |
Convenience method for registering single button. Macro can not be used because it does not work when used inside the embedded class (eg. NavigationStyleCATIASpecific). | |
void | registerButtonList (ParameterIdentificatorList &buttonList) |
Convenience method for registering a whole List of buttons. | |
bool | isAnyButtonSelected (const ParameterIdentificatorList &buttonList) const |
Returns true if any button was selected, false oterwise. | |
bool | getAndFixButtonValues (const wxCommandEvent &evt, ParameterIdentificatorList &buttonList) |
Determines which button was pressed last. Returns true if any button changed its value. | |
void | clearButtonValues (ParameterIdentificatorList &buttonList) |
Sets that no button is pressed. | |
void | clearButtonValuesConditional (const wxCommandEvent &evt, ParameterIdentificatorList &buttonList) |
Sets that no button is pressed if the passed event is generated by one of the buttons. | |
NavigationStyleInterface * | resolveStyleFromString (const wxString &string) const |
Returns corresponding enum associated with the style string. | |
void | select (Scene *scene, Camera *camera, wxMouseEvent &evt) |
Convenience method for selecting an object in a scene. | |
void | pickScenePivot (Scene *scene, Camera *camera, const NODE_ID &cameraID, wxMouseEvent &evt) |
Method for setting the scenePivot to a selected surface. | |
void | translateCameraCenterToSelection (Scene *scene, Camera *camera, const NODE_ID &cameraID, wxMouseEvent &evt) |
Convenience method for translating a camera center to a selected surface. | |
void | pan (Scene *scene, Camera *camera, const NODE_ID &cameraID, const wxPoint &mouseDelta, float speed) |
Convenience method for panning a camera in a scene. | |
void | rotate (Scene *scene, Camera *camera, const NODE_ID &cameraID, const wxPoint &mouseAbsolute, const wxPoint &mouseDelta, bool rollControl, bool yAlignedUpVector, bool rotateAroundScenePivot) |
Convenience method for rotating a camera around a point in a scene. | |
void | turnHead (Scene *scene, Camera *camera, const NODE_ID &cameraID, const wxPoint &mouseDelta, bool yAlignedUpVector) |
Convenience method for rotating a camera around the camera origin. | |
void | fly (Scene *scene, Camera *camera, const NODE_ID &cameraID, const wxPoint &mouseDelta) |
Convenience method for a camera fly-through. | |
void | zoom (Scene *scene, Camera *camera, const NODE_ID &cameraID, int mouseDelta, float speed) |
Convenience method for zooming a camera in a scene. | |
void | roll (Scene *scene, Camera *camera, const NODE_ID &cameraID, int mouseDelta, float speed, bool rotateAroundScenePivot) |
Convenience method for rolling a camera in a scene. | |
void | turnHeadLeftRightWithYAlignedUpVector (Scene *scene, Camera *camera, const NODE_ID &cameraID, int mouseXDelta, float speed) |
Convenience method for turning camera left or right around the 0,1,0 vector. | |
void | moveWithCollisionTesting (Scene *scene, Camera *camera, const NODE_ID &cameraID, const VECTOR3 &walkDirection, float speedModifier, float maxStepHeight, float avatarHeight) |
Moving around with the collision detection enabled. | |
void | planWalk (Scene *scene, Camera *camera, const NODE_ID &cameraID, const wxPoint &mouseDelta, float speedModifier, float maxStepHeight, float avatarHeight) |
Convenience method for the Cortona plan walk. | |
void | panWalk (Scene *scene, Camera *camera, const NODE_ID &cameraID, const wxPoint &mouseDelta, float speedModifier, float maxStepHeight, float avatarHeight) |
Convenience method for the Cortona pan walk. | |
void | turnWalk (Scene *scene, Camera *camera, const NODE_ID &cameraID, const wxPoint &mouseDelta, float speedModifier) |
Convenience method for the Cortona turn walk. | |
void | planFly (Scene *scene, Camera *camera, const NODE_ID &cameraID, const wxPoint &mouseDelta, float speedModifier) |
Convenience method for the Cortona plan fly. | |
void | panFly (Scene *scene, Camera *camera, const NODE_ID &cameraID, const wxPoint &mouseDelta, float speedModifier) |
Convenience method for the Cortona pan fly. | |
void | turnFly (Scene *scene, Camera *camera, const NODE_ID &cameraID, const wxPoint &mouseDelta, float speedModifier) |
Convenience method for the Cortona turn fly. | |
void | rollFly (Scene *scene, Camera *camera, const NODE_ID &cameraID, const wxPoint &mouseDelta, float speedModifier) |
Convenience method for the Cortona roll fly. | |
void | planStudy (Scene *scene, Camera *camera, const NODE_ID &cameraID, const wxPoint &mouseDelta, float speedModifier) |
Convenience method for the Cortona plan study. | |
void | panStudy (Scene *scene, Camera *camera, const NODE_ID &cameraID, const wxPoint &mouseDelta, float speedModifier) |
Convenience method for the Cortona pan study. | |
void | turnStudy (Scene *scene, Camera *camera, const NODE_ID &cameraID, const wxPoint &mouseDelta, float speedModifier) |
Convenience method for the Cortona turn study. | |
void | rollStudy (Scene *scene, Camera *camera, const NODE_ID &cameraID, const wxPoint &mouseDelta, float speedModifier) |
Convenience method for the Cortona roll study. | |
void | processNavigationOperationButtonEvent () |
Executes actions of some navigation buttons which require immediate reaction (like zoom in, zoom out). | |
void | findCameras (SceneNodeVector &cameras) |
Finds all cameras in the scene. | |
void | setInitialScenePivot () |
Sets the scene pivot as the center of the root BVH. | |
void | removePitch () |
Rotates the camera so that its pitch is zero. | |
void | alignView (ViewName name) |
Aligns the camera to the world axis. | |
virtual void | processEvent (wxCommandEvent &evt) |
Process event - CameraModule overload. | |
virtual void | processKeyEvent (wxKeyEvent &evt) |
Process key event - CameraModule overload. | |
virtual void | processMouseEvent (wxMouseEvent &evt) |
Process mouse event - CameraModule overload. | |
virtual void | run () |
The run method for this module. Used for the fly-throughs. | |
Protected Attributes | |
NavigationStyleVector | navigationStyleDefinition |
Vector of supported navigation styles. | |
SceneNodeVector | cameras |
Vector of scene cameras. | |
wxArrayString | navigationStyleString |
Navigation style strings. | |
wxArrayString | cameraString |
Scene camera names. | |
Parameter::ParameterIdentificator | navigationStyleParamID |
navigationStyle param identificator | |
Parameter::ParameterIdentificator | selectedCameraParamID |
selectedCamera param identificator | |
wxPoint | lastPos |
Last mouse position. | |
wxPoint | mouseDelta |
Mouse coordinate difference between the current frame and the last frame. | |
VECTOR3 | scenePivot |
Scene pivot. | |
bool | scenePivotWasSet |
Scene pivot was set. | |
NODE_ID | selectedObject |
NavigationStyleInterface * | activeNavigationStyle |
Pointer to the active navigation style. | |
NavigationStyleCameraManipulatorSpecific | navigationStyleCameraManipulatorSpecific |
CameraManipulator specific variables needed for a proper emulation. | |
NavigationStyleCATIASpecific | navigationStyleCATIASpecific |
CATIA specific variables needed for a proper emulation. | |
NavigationStyleCortonaSpecific | navigationStyleCortonaSpecific |
Cortona specific variables needed for a proper emulation. | |
NavigationStyleCinema4DSpecific | navigationStyleCinema4DSpecific |
Cinema4D specific variables needed for a proper emulation. | |
NavigationStyleMayaSpecific | navigationStyleMayaSpecific |
Maya specific variables needed for a proper emulation. | |
NavigationStyleDeltaViewSpecific | navigationStyleDeltaViewSpecific |
DeltaView specific variables needed for a proper emulation. | |
NavigationStyleICEMSurfSpecific | navigationStyleICEMSurfSpecific |
Icem Surf specific variables needed for a proper emulation. | |
NavigationStyleVD2Specific | navigationStyleVD2Specific |
Virtual Design 2 specific variables needed for a proper emulation. | |
Parameter::ParameterIdentificator | cameraCenterDistanceParamID |
Camera center distance param identificator | |
bool | fovChangeOperationStarted |
We set the fov param id only when the user releases the mouse button. This variable helps us know when this happens. | |
float | nearPlane |
Camera near plane. | |
float | farPlane |
Camera far plane. | |
float | fov |
Field of view. | |
Parameter::ParameterIdentificator | fovParamID |
fov param identificator | |
Parameter::ParameterIdentificator | farPlaneParamID |
farPlane param identificator | |
Parameter::ParameterIdentificator | nearPlaneParamID |
nearPlane param identificator | |
float | rotspeed |
Rotate sensitivity coef. | |
float | zoomStep |
Zoom step. | |
float | flySpeedStep |
Fly speed step. | |
Parameter::ParameterIdentificator | rotspeedParamID |
rotspeed param identificator | |
float | zoomspeed |
Zoom sensitivity coef. | |
Parameter::ParameterIdentificator | zoomspeedParamID |
zoomspeed param identificator | |
float | cruisespeed |
Cruise sensitivity coef. | |
Parameter::ParameterIdentificator | cruisespeedParamID |
cruisespeed param identificator | |
float | panspeed |
Navigation speed coef for pan. | |
Parameter::ParameterIdentificator | panspeedParamID |
panspeed param identificator | |
Private Attributes | |
wxString | defaultMouseEventTimeout |
Classes | |
struct | NavigationOperationPair |
Navigation operation pair. More... | |
class | NavigationStyleCameraManipulatorSpecific |
Type for CameraManipulator specific variables needed for a proper emulation. More... | |
class | NavigationStyleCATIASpecific |
Type for CATIA specific variables needed for a proper emulation. More... | |
class | NavigationStyleCinema4DSpecific |
Type for Cinema4D specific variables needed for a proper emulation. More... | |
class | NavigationStyleCortonaSpecific |
Type for Cortona specific variables needed for a proper emulation. More... | |
class | NavigationStyleDeltaViewSpecific |
Type for DeltaView specific variables needed for a proper emulation. More... | |
class | NavigationStyleICEMSurfSpecific |
Type for ICEMSurf specific variables needed for a proper emulation. More... | |
class | NavigationStyleMayaSpecific |
Type for Maya specific variables needed for a proper emulation. More... | |
class | NavigationStyleVD2Specific |
Type for VD2 specific variables needed for a proper emulation. More... |
Definition at line 27 of file navigation.h.
typedef std::vector<NavigationStyleInterface*> VRUT::Navigation::NavigationStyleVector [protected] |
typedef std::vector<const SceneNode*> VRUT::Navigation::SceneNodeVector [protected] |
typedef std::list<NavigationOperationPair> VRUT::Navigation::ParameterIdentificatorList [protected] |
enum VRUT::Navigation::NavigationStyle [protected] |
Enums of the supported navigation styles.
Definition at line 32 of file navigation.h.
00033 { 00034 CAMERA_MANIPULATOR = 0, 00035 CATIA = 1, 00036 ICEMSURF = 2, 00037 DELTAGEN = 3, 00038 VD2 = 4, 00039 CORTONA = 5, 00040 CINEMA4D = 6, 00041 MAYA = 7 00042 };
enum VRUT::Navigation::ViewName [protected] |
Navigation::Navigation | ( | const MODULE_ID & | _id, | |
const wxString & | _name, | |||
EventHandler * | msgSink | |||
) |
Class constructor.
Definition at line 20 of file navigation.cpp.
00021 : CameraModule(_id, _name, 0, msgSink), 00022 navigationStyleCameraManipulatorSpecific(_id, _name, this), 00023 navigationStyleCATIASpecific(_id, _name, this), 00024 navigationStyleCortonaSpecific(_id, _name, this), 00025 navigationStyleCinema4DSpecific(_id, _name, this), 00026 navigationStyleMayaSpecific(_id, _name, this), 00027 navigationStyleDeltaViewSpecific(_id, _name, this), 00028 navigationStyleICEMSurfSpecific(_id, _name, this), 00029 navigationStyleVD2Specific(_id, _name, this) 00030 { 00031 //navigationStyleDefinition.push_back(&navigationStyleCameraManipulatorSpecific); 00032 navigationStyleDefinition.push_back(&navigationStyleCATIASpecific); 00033 navigationStyleDefinition.push_back(&navigationStyleCortonaSpecific); 00034 navigationStyleDefinition.push_back(&navigationStyleCinema4DSpecific); 00035 navigationStyleDefinition.push_back(&navigationStyleMayaSpecific); 00036 navigationStyleDefinition.push_back(&navigationStyleDeltaViewSpecific); 00037 navigationStyleDefinition.push_back(&navigationStyleICEMSurfSpecific); 00038 navigationStyleDefinition.push_back(&navigationStyleVD2Specific); 00039 00040 for (NavigationStyleVector::iterator i = navigationStyleDefinition.begin(); i != navigationStyleDefinition.end(); i++) 00041 { 00042 navigationStyleString.Add((*i)->getStyleName()); 00043 } 00044 00045 //activeNavigationStyle = &navigationStyleCameraManipulatorSpecific; 00046 activeNavigationStyle = &navigationStyleVD2Specific; 00047 00048 SET_DEFAULT_PARAM(eventTimeoutParamID, wxT("0")); 00049 SET_DEFAULT_PARAM(keyEventTimeoutParamID, wxT("0")); 00050 defaultMouseEventTimeout = wxT("50"); 00051 SET_DEFAULT_PARAM(msEventTimeoutParamID, defaultMouseEventTimeout); 00052 00053 fov = 0.0f; 00054 nearPlane = 0.0f; 00055 farPlane = 0.0f; 00056 rotspeed = 5e-3f; 00057 zoomspeed = 2e-1f; 00058 cruisespeed = 6e-2f; 00059 panspeed = 0.06f; 00060 zoomStep = 10.0f; 00061 flySpeedStep = 0.05f; 00062 00063 selectedObject = NODE_ID_NONE; 00064 00065 scenePivotWasSet = false; 00066 fovChangeOperationStarted = false; 00067 00068 registerGUI(); 00069 00070 REGISTER_LISTENER(Event::EVT_SCENE_CAM_PROJECTION_CHANGED); 00071 //REGISTER_LISTENER(Event::EVT_SCENE_NODE_TRANSFORMED); 00072 }
Navigation::~Navigation | ( | ) | [virtual] |
wxString Navigation::buildCurrentCameraString | ( | const SceneNode * | node | ) | [protected] |
Creates a string for the camera selection combobox.
Definition at line 89 of file navigation.cpp.
00090 { 00091 wxString id; 00092 if (node && node->IsOfType(SceneNode::CAMERA)) 00093 { 00094 id << node->GetName() << wxT(" [id = ") << node->GetID() << wxT("]"); 00095 } 00096 return id; 00097 }
void Navigation::lowMouseEventTimeout | ( | ) | [protected] |
Sets the mouse event timeout low.
Definition at line 1111 of file navigation.cpp.
01112 { 01113 wxCommandEvent paramEvt = Event::GET_EVT_PARAM_SET_DO(msEventTimeoutParamID, wxT("0"), false); 01114 PostToKernel(paramEvt); 01115 }
void Navigation::highMouseEventTimeout | ( | ) | [protected] |
Sets the mouse event timeout high.
Definition at line 1117 of file navigation.cpp.
01118 { 01119 wxCommandEvent paramEvt = Event::GET_EVT_PARAM_SET_DO(msEventTimeoutParamID, defaultMouseEventTimeout, false); 01120 PostToKernel(paramEvt); 01121 }
void Navigation::registerGUI | ( | ) | [protected] |
Convenience method for registering all gui elements.
Definition at line 74 of file navigation.cpp.
00075 { 00076 registerCommonGUIControls(); 00077 activeNavigationStyle->registerButtons(); 00078 }
void Navigation::refreshGUI | ( | ) | [protected] |
Called whenever the gui elements are changed.
Definition at line 80 of file navigation.cpp.
00081 { 00082 Parameter::ParameterIdentificator param = eventTimeoutParamID; //Any parameter ID can be here as long it is from this module. All I need it for is the module name and instance number. 00083 param.paramName = wxT("*"); 00084 wxCommandEvent paramGuiEvt = Event::GET_EVT_PARAM_GUIUNREGISTER(param); 00085 PostToKernel(paramGuiEvt); 00086 registerGUI(); 00087 }
void Navigation::registerCommonGUIControls | ( | ) | [protected] |
Register the gui controls which arent specific for any emulation.
Definition at line 99 of file navigation.cpp.
00100 { 00101 wxString paramValue; 00102 REGISTER_PARAM_GUI_TEXTCONTROL(sceneIDParamID, wxT("sceneID"), wxString::Format(wxT("%i"), sceneID), wxT("ID of scene to handle.")); 00103 REGISTER_PARAM_GUI_TEXTCONTROL(windowIDParamID, wxT("windowID"), wxString::Format(wxT("%i"), windowID), wxT("ID of renderer window.")); 00104 REGISTER_PARAM_GUI_COMBOBOX(navigationStyleParamID, wxT("navigationStyle"), activeNavigationStyle->getStyleName(), navigationStyleString, wxT("Style of navigation.")); 00105 00106 wxString cameraCenterDistanceValue, fovValue, nearPlaneValue, farPlaneValue, zero(wxT("0.0")); 00107 00108 wxString currentCameraName; 00109 00110 if (sceneMgr) 00111 { 00112 const Scene * scene = GetSceneMgr()->GetScene(getSceneID()); 00113 if (scene) 00114 { 00115 const SceneNode * camNode = scene->GetNode(getCameraID()); 00116 if (camNode && camNode->IsOfType(SceneNode::CAMERA)) 00117 { 00118 ReadLocker rLock(*camNode); 00119 cameraCenterDistanceValue = wxString::Format(wxT("%g"), ((Camera *)camNode)->GetCenterDist()); 00120 fovValue = wxString::Format(wxT("%g"), ((Camera *)camNode)->GetFOV()); 00121 nearPlaneValue = wxString::Format(wxT("%g"), ((Camera *)camNode)->GetNearPlane()); 00122 farPlaneValue = wxString::Format(wxT("%g"), ((Camera *)camNode)->GetFarPlane()); 00123 currentCameraName = buildCurrentCameraString(scene->GetNode(getCameraID())); 00124 } 00125 } 00126 } 00127 else 00128 { 00129 cameraCenterDistanceValue = zero; 00130 fovValue = zero; 00131 nearPlaneValue = zero; 00132 farPlaneValue = zero; 00133 } 00134 00135 findCameras(cameras); 00136 cameraString.clear(); 00137 for (SceneNodeVector::iterator i = cameras.begin(); i != cameras.end(); i++) 00138 { 00139 LOGDEBUG(wxT("Navigation found a camera named: ")+buildCurrentCameraString((*i))); 00140 cameraString.Add(buildCurrentCameraString((*i))); 00141 } 00142 REGISTER_PARAM_GUI_COMBOBOX(selectedCameraParamID, wxT("selectedCamera"), currentCameraName, cameraString, wxT("Camera node used to view.")); 00143 00144 REGISTER_PARAM_GUI_TEXTCONTROL(cameraCenterDistanceParamID, wxT("cameraCenterDistance"), cameraCenterDistanceValue, wxT("cameraCenterDistance")); 00145 REGISTER_PARAM_GUI_TEXTCONTROL(fovParamID, wxT("FOV"), fovValue, wxT("Field of view.")); 00146 REGISTER_PARAM_GUI_TEXTCONTROL(nearPlaneParamID, wxT("nearPlane"), nearPlaneValue, wxT("Near clipping plane.")); 00147 REGISTER_PARAM_GUI_TEXTCONTROL(farPlaneParamID, wxT("farPlane"), farPlaneValue, wxT("Far clipping plane.")); 00148 00149 paramValue << rotspeed; 00150 REGISTER_PARAM_GUI_TEXTCONTROL(rotspeedParamID, wxT("rotspeed"), paramValue, wxT("Speed of rotation.")); 00151 paramValue.clear(); 00152 paramValue << zoomspeed; 00153 REGISTER_PARAM_GUI_TEXTCONTROL(zoomspeedParamID, wxT("zoomspeed"), paramValue, wxT("Speed of zoom.")); 00154 paramValue.clear(); 00155 paramValue << cruisespeed; 00156 REGISTER_PARAM_GUI_TEXTCONTROL(cruisespeedParamID, wxT("cruisespeed"), paramValue, wxT("cruisespeed")); 00157 paramValue.clear(); 00158 paramValue << panspeed; 00159 REGISTER_PARAM_GUI_TEXTCONTROL(panspeedParamID, wxT("panspeed"), paramValue, wxT("Speed of pannign.")); 00160 }
void Navigation::registerTextControl | ( | Parameter::ParameterIdentificator & | paramID, | |
const wxString & | value | |||
) | [protected] |
Convenience method for registering a text field. Macro can not be used because it does not work when used inside the embedded class (eg. NavigationStyleCATIASpecific).
Definition at line 222 of file navigation.cpp.
00223 { 00224 REGISTER_PARAM_GUI_TEXTCONTROL(paramID, paramID.paramName, value, paramID.description); 00225 }
void Navigation::registerButton | ( | Parameter::ParameterIdentificator & | paramID | ) | [protected] |
Convenience method for registering single button. Macro can not be used because it does not work when used inside the embedded class (eg. NavigationStyleCATIASpecific).
Definition at line 227 of file navigation.cpp.
00228 { 00229 wxCommandEvent paramEvt = Event::GET_EVT_PARAM_REGISTER(paramID, wxT("0")); 00230 PostToKernel(paramEvt); 00231 GUIEnvironment::GUIParamInfo guiPI(paramID, GUIEnvironment::GUIParamInfo::GUI_TYPE_BUTTON); 00232 wxCommandEvent paramGuiEvt = Event::GET_EVT_PARAM_GUIREGISTER(guiPI, wxT("0")); 00233 PostToKernel(paramGuiEvt); 00234 }
void Navigation::registerButtonList | ( | ParameterIdentificatorList & | buttonList | ) | [protected] |
Convenience method for registering a whole List of buttons.
Definition at line 200 of file navigation.cpp.
00201 { 00202 for (ParameterIdentificatorList::iterator i = buttonList.begin(); i != buttonList.end(); i++) 00203 { 00204 REGISTER_PARAM_GUI_BUTTON(i->paramId, i->paramId.paramName, i->paramId.description); 00205 } 00206 }
bool Navigation::isAnyButtonSelected | ( | const ParameterIdentificatorList & | buttonList | ) | const [protected] |
Returns true if any button was selected, false oterwise.
Definition at line 360 of file navigation.cpp.
00361 { 00362 for (ParameterIdentificatorList::const_iterator i = buttonList.begin(); i != buttonList.end(); i++) 00363 { 00364 if (i->paramValue) 00365 { 00366 return true; 00367 } 00368 } 00369 return false; 00370 }
bool Navigation::getAndFixButtonValues | ( | const wxCommandEvent & | evt, | |
ParameterIdentificatorList & | buttonList | |||
) | [protected] |
Determines which button was pressed last. Returns true if any button changed its value.
Definition at line 208 of file navigation.cpp.
00209 { 00210 bool changed = false; 00211 for (ParameterIdentificatorList::iterator i = buttonList.begin(); i != buttonList.end(); i++) 00212 { 00213 if (Parameter::ParameterIdentificator::FromEvent(evt) == i->paramId) 00214 { 00215 i->paramValue = !i->paramValue; 00216 changed = true; 00217 } 00218 } 00219 return changed; 00220 }
void Navigation::clearButtonValues | ( | ParameterIdentificatorList & | buttonList | ) | [protected] |
Sets that no button is pressed.
Definition at line 384 of file navigation.cpp.
00385 { 00386 for (ParameterIdentificatorList::iterator i = buttonList.begin(); i != buttonList.end(); i++) 00387 { 00388 i->paramValue = 0; 00389 } 00390 }
void Navigation::clearButtonValuesConditional | ( | const wxCommandEvent & | evt, | |
ParameterIdentificatorList & | buttonList | |||
) | [protected] |
Sets that no button is pressed if the passed event is generated by one of the buttons.
Definition at line 392 of file navigation.cpp.
00393 { 00394 bool clear = false; 00395 for (ParameterIdentificatorList::iterator i = buttonList.begin(); i != buttonList.end(); i++) 00396 { 00397 if (Parameter::ParameterIdentificator::FromEvent(evt) == i->paramId) 00398 { 00399 clear = true; 00400 break; 00401 } 00402 } 00403 if (clear) 00404 { 00405 for (ParameterIdentificatorList::iterator i = buttonList.begin(); i != buttonList.end(); i++) 00406 { 00407 i->paramValue = 0; 00408 } 00409 } 00410 }
NavigationStyleInterface * Navigation::resolveStyleFromString | ( | const wxString & | string | ) | const [protected] |
Returns corresponding enum associated with the style string.
Definition at line 188 of file navigation.cpp.
00189 { 00190 for (NavigationStyleVector::const_iterator i = navigationStyleDefinition.begin(); i != navigationStyleDefinition.end(); i++) 00191 { 00192 if ( (*i)->getStyleName() == string ) 00193 { 00194 return *i; 00195 } 00196 } 00197 return 0; 00198 }
Convenience method for selecting an object in a scene.
Definition at line 732 of file navigation.cpp.
00733 { 00734 unsigned width, height; 00735 camera->GetWidthHeight(&width, &height); 00736 00737 float px = ((( 2.0f * evt.GetPosition().x) / width) - 1.0f) / camera->GetProjectionMatrix()->_m11; 00738 float py = (((-2.0f * evt.GetPosition().y) / height) + 1.0f) / camera->GetProjectionMatrix()->_m22; 00739 00740 VECTOR3 origin(0, 0, 0); 00741 VECTOR3 direction(px, py, -1.0f); 00742 00743 origin = camera->GetWorldTransMatrix()->TransformCoord(origin); 00744 direction = camera->GetWorldTransMatrix()->TransformNormal(direction).Normalize(); 00745 Ray ray(origin, direction); 00746 00747 BVH::IntersectionInfo info; 00748 00749 if (scene->GetBVH()) 00750 { 00751 if (scene->GetBVH()->BoundProbe(ray, &info)) 00752 { 00753 const SceneNode * node = scene->GetNode(info.nodeID); 00754 if (node) 00755 { 00756 selectedObject = node->GetID(); 00757 LOGDEBUG(wxString::Format(wxT("Selected object ID=%i, Name=%s"), info.nodeID, node->GetName().c_str())); 00758 } 00759 } 00760 else 00761 { 00762 selectedObject = NODE_ID_NONE; 00763 LOGDEBUG(wxT("No object selected")); 00764 } 00765 } 00766 }
void Navigation::pickScenePivot | ( | Scene * | scene, | |
Camera * | camera, | |||
const NODE_ID & | cameraID, | |||
wxMouseEvent & | evt | |||
) | [protected] |
Method for setting the scenePivot to a selected surface.
Definition at line 768 of file navigation.cpp.
00769 { 00770 unsigned width, height; 00771 camera->GetWidthHeight(&width, &height); 00772 00773 float px = ((( 2.0f * evt.GetPosition().x) / width) - 1.0f) / camera->GetProjectionMatrix()->_m11; 00774 float py = (((-2.0f * evt.GetPosition().y) / height) + 1.0f) / camera->GetProjectionMatrix()->_m22; 00775 00776 VECTOR3 origin(0, 0, 0); 00777 VECTOR3 direction(px, py, -1.0f); 00778 00779 origin = camera->GetWorldTransMatrix()->TransformCoord(origin); 00780 direction = camera->GetWorldTransMatrix()->TransformNormal(direction).Normalize(); 00781 Ray ray(origin, direction); 00782 00783 RayIntersectionInfo info; 00784 if (scene->GetBVH() && scene->GetBVH()->CastRay(ray, info)) 00785 { 00786 const SceneNode * node = scene->GetNode(info.nodeID); 00787 if (node) 00788 { 00789 scenePivot = origin + direction * info.dist; 00790 LOGDEBUG(wxT("scenePivot was set")); 00791 } 00792 } 00793 }
void Navigation::translateCameraCenterToSelection | ( | Scene * | scene, | |
Camera * | camera, | |||
const NODE_ID & | cameraID, | |||
wxMouseEvent & | evt | |||
) | [protected] |
Convenience method for translating a camera center to a selected surface.
Definition at line 795 of file navigation.cpp.
00796 { 00797 unsigned width, height; 00798 camera->GetWidthHeight(&width, &height); 00799 00800 float px = ((( 2.0f * evt.GetPosition().x) / width) - 1.0f) / camera->GetProjectionMatrix()->_m11; 00801 float py = (((-2.0f * evt.GetPosition().y) / height) + 1.0f) / camera->GetProjectionMatrix()->_m22; 00802 00803 VECTOR3 origin(0, 0, 0); 00804 VECTOR3 direction(px, py, -1.0f); 00805 00806 origin = camera->GetWorldTransMatrix()->TransformCoord(origin); 00807 direction = camera->GetWorldTransMatrix()->TransformNormal(direction).Normalize(); 00808 Ray ray(origin, direction); 00809 00810 RayIntersectionInfo info; 00811 if (scene->GetBVH() && scene->GetBVH()->CastRay(ray, info)) 00812 { 00813 const SceneNode * node = scene->GetNode(info.nodeID); 00814 if (node) 00815 { 00816 scene->Transform(cameraID, MATRIX::Translation((origin + direction * info.dist) - camera->GetCenterPoint())); 00817 scene->UpdateTransformation(cameraID); 00818 } 00819 } 00820 }
void Navigation::pan | ( | Scene * | scene, | |
Camera * | camera, | |||
const NODE_ID & | cameraID, | |||
const wxPoint & | mouseDelta, | |||
float | speed | |||
) | [protected] |
Convenience method for panning a camera in a scene.
Definition at line 412 of file navigation.cpp.
00413 { 00414 VECTOR3 camUp = camera->GetUp().Normalize(); 00415 VECTOR3 move = mouseDelta.x * camUp.Cross(camera->GetView()).Normalize(); 00416 move += mouseDelta.y * camUp; 00417 move *= speed; 00418 scene->Transform(cameraID, MATRIX::Translation(move)); 00419 scene->UpdateTransformation(cameraID); 00420 if (!KERNEL) 00421 { 00422 wxCommandEvent ev = Event::GET_EVT_RENDER_UPDATE(scene->GetID()); 00423 PostToKernel(ev, true); 00424 } 00425 }
void Navigation::rotate | ( | Scene * | scene, | |
Camera * | camera, | |||
const NODE_ID & | cameraID, | |||
const wxPoint & | mouseAbsolute, | |||
const wxPoint & | mouseDelta, | |||
bool | rollControl, | |||
bool | yAlignedUpVector, | |||
bool | rotateAroundScenePivot | |||
) | [protected] |
Convenience method for rotating a camera around a point in a scene.
Definition at line 427 of file navigation.cpp.
00428 { 00429 //unsigned int windowWidth, windowHeight; 00430 //camera->GetWidthHeight(&windowWidth, &windowHeight); 00431 //VECTOR3 mouse(mouseAbsolute.x-(int)windowWidth/2, mouseAbsolute.y-(int)windowHeight/2, 0); //I am using a 3d vector because the 2d equivalent has no length() method. 00432 //unsigned int trackballRadius = windowHeight / 3; 00433 00434 //if (mouse.Length()<trackballRadius || !rollControl) //yaw and pitch 00435 //{ 00436 float angleX = mouseDelta.x * rotspeed; 00437 float angleY = -mouseDelta.y * rotspeed; 00438 VECTOR3 camUp = camera->GetUp().Normalize(); 00439 VECTOR3 center = camera->GetCenterPoint(); 00440 MATRIX m; 00441 00442 if (rotateAroundScenePivot) 00443 m *= MATRIX::Translation(-scenePivot); 00444 00445 if (angleX) 00446 { 00447 m *= MATRIX::RotationAxis(yAlignedUpVector ? VECTOR3(0.0f, 1.0f, 0.0f) : camUp, angleX); 00448 } 00449 if (angleY) 00450 { 00451 m *= MATRIX::RotationAxis(camUp.Cross(camera->GetView()).Normalize(), angleY); 00452 } 00453 00454 if (rotateAroundScenePivot) 00455 m *= MATRIX::Translation(scenePivot); 00456 00457 if (angleX || angleY) 00458 { 00459 scene->Transform(cameraID, m); 00460 scene->UpdateTransformation(cameraID); 00461 } 00462 00463 if (!rotateAroundScenePivot) 00464 { 00465 scene->TranslateAbs(cameraID, center - camera->GetView().Normalize()*camera->GetCenterDist()); 00466 scene->UpdateTransformation(cameraID); 00467 } 00468 //} 00469 00470 //Deprecated. But the code still might come in handy while coding the navigation emulation of 3DS Max in the future 00471 00472 //else //roll 00473 // //TODO: draw a circle to show where the roll area starts 00474 //{ 00475 // VECTOR3 prevMouseCoord(mouse); 00476 // prevMouseCoord -= VECTOR3(mouseDelta.x, mouseDelta.y, 0); 00477 // //Assume a 2D space divided by a prevMouseCoord vector into two half spaces. 00478 // //We have to check in which half space the current mouse coordinate lies in, to determine the rotation direction. 00479 00480 // //First, we compute the prevMouseCoord vector normal so that we can insert the current mouse coord into the line equation ax+by=0 00481 // //The c parameter is 0 because the line goes through the origin. 00482 // VECTOR3 prevMouseCoordNormal(-prevMouseCoord.y, prevMouseCoord.x); 00483 // prevMouseCoordNormal = prevMouseCoordNormal.Normalize(); 00484 // //This dot product is the insertion of values into the equation. Result is the signed distance from the prevMouseCoord vector. 00485 // float distance = prevMouseCoordNormal.x*mouse.x+prevMouseCoordNormal.y*mouse.y; 00486 00487 // roll(scene, camera, cameraID, wxPoint(1, 0), rotspeed * distance); 00488 //} 00489 00490 if (!KERNEL) 00491 { 00492 wxCommandEvent ev = Event::GET_EVT_RENDER_UPDATE(scene->GetID()); 00493 PostToKernel(ev, true); 00494 } 00495 }
void Navigation::turnHead | ( | Scene * | scene, | |
Camera * | camera, | |||
const NODE_ID & | cameraID, | |||
const wxPoint & | mouseDelta, | |||
bool | yAlignedUpVector | |||
) | [protected] |
Convenience method for rotating a camera around the camera origin.
Definition at line 497 of file navigation.cpp.
00498 { 00499 float angleX = mouseDelta.x * rotspeed; 00500 float angleY = -mouseDelta.y * rotspeed; 00501 VECTOR3 camUp = camera->GetUp().Normalize(); 00502 00503 VECTOR3 position = camera->GetWorldTransMatrix()->ExtractTranslation(); 00504 00505 if (angleX) 00506 { 00507 scene->Transform(cameraID, MATRIX::RotationAxis(yAlignedUpVector ? VECTOR3(0.0f, 1.0f, 0.0f) : camUp, angleX)); 00508 scene->UpdateTransformation(cameraID); 00509 } 00510 if (angleY) 00511 { 00512 scene->Transform(cameraID, MATRIX::RotationAxis(camUp.Cross(camera->GetView()).Normalize(), angleY)); 00513 scene->UpdateTransformation(cameraID); 00514 } 00515 00516 scene->TranslateAbs(cameraID, position); 00517 scene->UpdateTransformation(cameraID); 00518 00519 if (!KERNEL) 00520 { 00521 wxCommandEvent ev = Event::GET_EVT_RENDER_UPDATE(scene->GetID()); 00522 PostToKernel(ev, true); 00523 } 00524 }
void Navigation::fly | ( | Scene * | scene, | |
Camera * | camera, | |||
const NODE_ID & | cameraID, | |||
const wxPoint & | mouseDelta | |||
) | [protected] |
Convenience method for a camera fly-through.
Definition at line 526 of file navigation.cpp.
00527 { 00528 turnHead(scene, camera, cameraID, mouseDelta, false); 00529 zoom(scene, camera, cameraID, 1, -cruisespeed); 00530 }
void Navigation::zoom | ( | Scene * | scene, | |
Camera * | camera, | |||
const NODE_ID & | cameraID, | |||
int | mouseDelta, | |||
float | speed | |||
) | [protected] |
Convenience method for zooming a camera in a scene.
Definition at line 822 of file navigation.cpp.
00823 { 00824 float moveY = -mouseDelta * speed; 00825 if (moveY) 00826 { 00827 VECTOR3 camView = camera->GetView().Normalize(); 00828 float dist = camera->GetCenterDist(); 00829 camera->SetCenterDist(dist - moveY); 00830 scene->Transform(cameraID, MATRIX::Translation(camera->GetView().Normalize() * moveY)); 00831 scene->UpdateTransformation(cameraID); 00832 if (!KERNEL) 00833 { 00834 wxCommandEvent ev = Event::GET_EVT_RENDER_UPDATE(scene->GetID()); 00835 PostToKernel(ev, true); 00836 } 00837 } 00838 }
void Navigation::roll | ( | Scene * | scene, | |
Camera * | camera, | |||
const NODE_ID & | cameraID, | |||
int | mouseDelta, | |||
float | speed, | |||
bool | rotateAroundScenePivot | |||
) | [protected] |
Convenience method for rolling a camera in a scene.
Definition at line 840 of file navigation.cpp.
00841 { 00842 VECTOR3 position = camera->GetWorldTransMatrix()->ExtractTranslation(); 00843 00844 MATRIX m; 00845 00846 if (rotateAroundScenePivot) 00847 m *= MATRIX::Translation(-scenePivot); 00848 00849 m *= MATRIX::RotationAxis(camera->GetView().Normalize(), mouseDelta * speed); 00850 00851 if (rotateAroundScenePivot) 00852 m *= MATRIX::Translation(scenePivot); 00853 00854 scene->Transform(cameraID, m); 00855 scene->UpdateTransformation(cameraID); 00856 00857 if (!rotateAroundScenePivot) 00858 { 00859 scene->TranslateAbs(cameraID, position); 00860 scene->UpdateTransformation(cameraID); 00861 } 00862 }
void Navigation::turnHeadLeftRightWithYAlignedUpVector | ( | Scene * | scene, | |
Camera * | camera, | |||
const NODE_ID & | cameraID, | |||
int | mouseXDelta, | |||
float | speed | |||
) | [protected] |
Convenience method for turning camera left or right around the 0,1,0 vector.
Definition at line 532 of file navigation.cpp.
00533 { 00534 float angleX = mouseXDelta * rotspeed * speed; 00535 VECTOR3 camUp = camera->GetUp().Normalize(); 00536 00537 VECTOR3 position = camera->GetWorldTransMatrix()->ExtractTranslation(); 00538 scene->TranslateAbs(cameraID, VECTOR3()); 00539 scene->UpdateTransformation(cameraID); 00540 00541 if (angleX) 00542 { 00543 scene->Transform(cameraID, MATRIX::RotationAxis(VECTOR3(0.0f, 1.0f, 0.0f), angleX)); 00544 scene->UpdateTransformation(cameraID); 00545 } 00546 00547 scene->TranslateAbs(cameraID, position); 00548 scene->UpdateTransformation(cameraID); 00549 }
void Navigation::moveWithCollisionTesting | ( | Scene * | scene, | |
Camera * | camera, | |||
const NODE_ID & | cameraID, | |||
const VECTOR3 & | walkDirection, | |||
float | speedModifier, | |||
float | maxStepHeight, | |||
float | avatarHeight | |||
) | [protected] |
Moving around with the collision detection enabled.
Definition at line 551 of file navigation.cpp.
00552 { 00553 VECTOR3 direction = walkDirection * cruisespeed * speedModifier; 00554 VECTOR3 directionNormalized = direction.Normalize(); 00555 VECTOR3 cameraOrigin = camera->GetWorldTransMatrix()->ExtractTranslation(); 00556 00557 RayIntersectionInfo info; 00558 if (scene->GetBVH()) 00559 { 00560 Ray forwardRay(cameraOrigin, directionNormalized); 00561 wxString ss; 00562 forwardRay.origin.y += maxStepHeight; 00563 if (scene->GetBVH() && scene->GetBVH()->CastRay(forwardRay, info)) 00564 { 00565 //wall in front of us 00566 if (info.dist < direction.Length()) 00567 { 00568 //we ll hit it 00569 direction = directionNormalized * (info.dist - 0.001f); 00570 } 00571 } 00572 vector3 tmp1(cameraOrigin + direction); 00573 vector3 tmp2(0.0f, -1.0f, 0.0f); 00574 Ray gravityRay(tmp1, tmp2); 00575 gravityRay.origin.y += maxStepHeight; 00576 if (scene->GetBVH()->CastRay(gravityRay, info)) 00577 { 00578 //there will be ground under our feet 00579 const SceneNode * node = scene->GetNode(info.nodeID); 00580 if (node) 00581 { 00582 VECTOR3 collisionPosition = gravityRay.origin + gravityRay.direction * info.dist; 00583 collisionPosition.y += avatarHeight; 00584 scene->TranslateAbs(cameraID, collisionPosition); 00585 scene->UpdateTransformation(cameraID); 00586 } 00587 } 00588 else 00589 { 00590 //we are above an infinite void space - so we ll just float above it 00591 scene->Transform(cameraID, MATRIX::Translation(direction)); 00592 scene->UpdateTransformation(cameraID); 00593 } 00594 } 00595 00596 if (!KERNEL) 00597 { 00598 wxCommandEvent ev = Event::GET_EVT_RENDER_UPDATE(scene->GetID()); 00599 PostToKernel(ev, true); 00600 } 00601 }
void Navigation::planWalk | ( | Scene * | scene, | |
Camera * | camera, | |||
const NODE_ID & | cameraID, | |||
const wxPoint & | mouseDelta, | |||
float | speedModifier, | |||
float | maxStepHeight, | |||
float | avatarHeight | |||
) | [protected] |
Convenience method for the Cortona plan walk.
Definition at line 603 of file navigation.cpp.
00604 { 00605 //LOGDEBUG(wxT("planWalk")); 00606 00607 turnHeadLeftRightWithYAlignedUpVector(scene, camera, cameraID, mouseDelta.x, speedModifier); 00608 00609 VECTOR3 camUp = camera->GetUp().Normalize(); 00610 VECTOR3 normalizedView = camera->GetView().Normalize(); 00611 VECTOR3 pitchAxis = camUp.Cross(normalizedView); 00612 VECTOR3 walkDirection = VECTOR3(0.0f, 1.0f, 0.0f).Cross(pitchAxis) * mouseDelta.y; 00613 00614 moveWithCollisionTesting(scene, camera, cameraID, walkDirection, speedModifier, maxStepHeight, avatarHeight); 00615 00616 }
void Navigation::panWalk | ( | Scene * | scene, | |
Camera * | camera, | |||
const NODE_ID & | cameraID, | |||
const wxPoint & | mouseDelta, | |||
float | speedModifier, | |||
float | maxStepHeight, | |||
float | avatarHeight | |||
) | [protected] |
Convenience method for the Cortona pan walk.
Definition at line 618 of file navigation.cpp.
00619 { 00620 VECTOR3 up(0.0f, 1.0f, 0.0f); 00621 VECTOR3 camUp = camera->GetUp().Normalize(); 00622 VECTOR3 normalizedView = camera->GetView().Normalize(); 00623 VECTOR3 pitchAxis = camUp.Cross(normalizedView); 00624 VECTOR3 walkDirection = up.Cross(pitchAxis) * mouseDelta.y; 00625 00626 VECTOR3 viewAxis = normalizedView.Cross(up) * mouseDelta.x; 00627 walkDirection += viewAxis; 00628 00629 moveWithCollisionTesting(scene, camera, cameraID, walkDirection, speedModifier, maxStepHeight, avatarHeight); 00630 00631 }
void Navigation::turnWalk | ( | Scene * | scene, | |
Camera * | camera, | |||
const NODE_ID & | cameraID, | |||
const wxPoint & | mouseDelta, | |||
float | speedModifier | |||
) | [protected] |
Convenience method for the Cortona turn walk.
Definition at line 633 of file navigation.cpp.
00634 { 00635 float angleX = mouseDelta.x * rotspeed * speedModifier; 00636 float angleY = -mouseDelta.y * rotspeed * speedModifier; 00637 VECTOR3 camUp = camera->GetUp().Normalize(); 00638 VECTOR3 center = camera->GetCenterPoint(); 00639 00640 VECTOR3 position = camera->GetWorldTransMatrix()->ExtractTranslation(); 00641 scene->TranslateAbs(cameraID, VECTOR3()); 00642 scene->UpdateTransformation(cameraID); 00643 00644 if (angleX) 00645 { 00646 scene->Transform(cameraID, MATRIX::RotationAxis(VECTOR3(0.0f, 1.0f, 0.0f), angleX)); 00647 scene->UpdateTransformation(cameraID); 00648 } 00649 if (angleY) 00650 { 00651 scene->Transform(cameraID, MATRIX::RotationAxis(camUp.Cross(camera->GetView()).Normalize(), angleY)); 00652 scene->UpdateTransformation(cameraID); 00653 } 00654 00655 scene->TranslateAbs(cameraID, position); 00656 scene->UpdateTransformation(cameraID); 00657 00658 if (!KERNEL) 00659 { 00660 wxCommandEvent ev = Event::GET_EVT_RENDER_UPDATE(scene->GetID()); 00661 PostToKernel(ev, true); 00662 } 00663 }
void Navigation::planFly | ( | Scene * | scene, | |
Camera * | camera, | |||
const NODE_ID & | cameraID, | |||
const wxPoint & | mouseDelta, | |||
float | speedModifier | |||
) | [protected] |
Convenience method for the Cortona plan fly.
Definition at line 665 of file navigation.cpp.
00666 { 00667 turnHeadLeftRightWithYAlignedUpVector(scene, camera, cameraID, mouseDelta.x, speedModifier); 00668 zoom(scene, camera, cameraID, mouseDelta.y, cruisespeed * speedModifier); 00669 }
void Navigation::panFly | ( | Scene * | scene, | |
Camera * | camera, | |||
const NODE_ID & | cameraID, | |||
const wxPoint & | mouseDelta, | |||
float | speedModifier | |||
) | [protected] |
Convenience method for the Cortona pan fly.
Definition at line 671 of file navigation.cpp.
00672 { 00673 float panspeedTemp = panspeed; 00674 panspeed *= speedModifier; 00675 pan(scene, camera, cameraID, wxPoint(-mouseDelta.x, -mouseDelta.y), panspeed); 00676 panspeed = panspeedTemp; 00677 }
void Navigation::turnFly | ( | Scene * | scene, | |
Camera * | camera, | |||
const NODE_ID & | cameraID, | |||
const wxPoint & | mouseDelta, | |||
float | speedModifier | |||
) | [protected] |
Convenience method for the Cortona turn fly.
Definition at line 679 of file navigation.cpp.
00680 { 00681 float rotspeedTemp = rotspeed; 00682 rotspeed *= speedModifier; 00683 turnHead(scene, camera, cameraID, mouseDelta, false); 00684 rotspeed = rotspeedTemp; 00685 }
void Navigation::rollFly | ( | Scene * | scene, | |
Camera * | camera, | |||
const NODE_ID & | cameraID, | |||
const wxPoint & | mouseDelta, | |||
float | speedModifier | |||
) | [protected] |
Convenience method for the Cortona roll fly.
Definition at line 687 of file navigation.cpp.
00688 { 00689 float rotspeedTemp = rotspeed; 00690 rotspeed *= speedModifier; 00691 turnHead(scene, camera, cameraID, wxPoint(0, mouseDelta.y), false); 00692 rotspeed = rotspeedTemp; 00693 00694 roll(scene, camera, cameraID, -mouseDelta.x, rotspeed * speedModifier, false); 00695 }
void Navigation::planStudy | ( | Scene * | scene, | |
Camera * | camera, | |||
const NODE_ID & | cameraID, | |||
const wxPoint & | mouseDelta, | |||
float | speedModifier | |||
) | [protected] |
Convenience method for the Cortona plan study.
Definition at line 697 of file navigation.cpp.
00698 { 00699 float rotspeedTemp = rotspeed; 00700 rotspeed *= speedModifier; 00701 rotate(scene, camera, cameraID, wxPoint(), wxPoint(mouseDelta.x, 0), false, false, false); 00702 rotspeed = rotspeedTemp; 00703 zoom(scene, camera, cameraID, mouseDelta.y, cruisespeed * speedModifier); 00704 }
void Navigation::panStudy | ( | Scene * | scene, | |
Camera * | camera, | |||
const NODE_ID & | cameraID, | |||
const wxPoint & | mouseDelta, | |||
float | speedModifier | |||
) | [protected] |
Convenience method for the Cortona pan study.
Definition at line 706 of file navigation.cpp.
00707 { 00708 float panspeedTemp = panspeed; 00709 panspeed *= speedModifier; 00710 pan(scene, camera, cameraID, wxPoint(-mouseDelta.x, -mouseDelta.y), panspeed); 00711 panspeed = panspeedTemp; 00712 }
void Navigation::turnStudy | ( | Scene * | scene, | |
Camera * | camera, | |||
const NODE_ID & | cameraID, | |||
const wxPoint & | mouseDelta, | |||
float | speedModifier | |||
) | [protected] |
Convenience method for the Cortona turn study.
Definition at line 714 of file navigation.cpp.
00715 { 00716 float rotspeedTemp = rotspeed; 00717 rotspeed *= speedModifier; 00718 rotate(scene, camera, cameraID, wxPoint(), mouseDelta, false, false, false); 00719 rotspeed = rotspeedTemp; 00720 }
void Navigation::rollStudy | ( | Scene * | scene, | |
Camera * | camera, | |||
const NODE_ID & | cameraID, | |||
const wxPoint & | mouseDelta, | |||
float | speedModifier | |||
) | [protected] |
Convenience method for the Cortona roll study.
Definition at line 722 of file navigation.cpp.
00723 { 00724 float rotspeedTemp = rotspeed; 00725 rotspeed *= speedModifier; 00726 rotate(scene, camera, cameraID, wxPoint(), wxPoint(0, mouseDelta.y), false, false, false); 00727 rotspeed = rotspeedTemp; 00728 00729 roll(scene, camera, cameraID, -mouseDelta.x, rotspeed * speedModifier, false); 00730 }
void Navigation::processNavigationOperationButtonEvent | ( | ) | [protected] |
Executes actions of some navigation buttons which require immediate reaction (like zoom in, zoom out).
Definition at line 355 of file navigation.cpp.
00356 { 00357 activeNavigationStyle->buttonEvent(); 00358 }
void Navigation::findCameras | ( | SceneNodeVector & | cameras | ) | [protected] |
Finds all cameras in the scene.
Definition at line 166 of file navigation.cpp.
00167 { 00168 if (sceneMgr) 00169 { 00170 const Scene * scene = GetSceneMgr()->GetScene(getSceneID()); 00171 if (scene) 00172 { 00173 std::vector<NODE_ID> nodes; 00174 scene->GetNodeIDs(&nodes); 00175 cameras.clear(); 00176 for (std::vector<NODE_ID>::iterator i = nodes.begin(); i != nodes.end(); i++) 00177 { 00178 const SceneNode * camNode = scene->GetNode(*i); 00179 if (camNode && camNode->IsOfType(SceneNode::CAMERA)) 00180 { 00181 cameras.push_back(camNode); 00182 } 00183 } 00184 } 00185 } 00186 }
void Navigation::setInitialScenePivot | ( | ) | [protected] |
Sets the scene pivot as the center of the root BVH.
Definition at line 1033 of file navigation.cpp.
01034 { 01035 if (sceneMgr && (getSceneID() != SCENE_ID_NONE)) 01036 { 01037 const Scene * scene = GetSceneMgr()->GetScene(getSceneID()); 01038 if (scene && scene->GetBVH()) 01039 { 01040 scenePivot = scene->GetBVH()->GetRoot()->GetBSphere()->Center; 01041 } 01042 } 01043 }
void Navigation::removePitch | ( | ) | [protected] |
Rotates the camera so that its pitch is zero.
This dot product can not tell us the orientation. To get it, we ll check on which side of plane (with the camView normal and d=0 ) the 0,1,0 point lies
Definition at line 1045 of file navigation.cpp.
01046 { 01047 NODE_ID cameraID = getCameraID(); 01048 Scene * scene = GetSceneMgr()->GetScene(getSceneID()); 01049 const SceneNode * camNode = scene->GetNode(cameraID); 01050 Camera * camera = (Camera *)(const_cast<SceneNode *>(camNode)); 01051 VECTOR3 camView = camera->GetView().Normalize(); 01052 VECTOR3 camUp = camera->GetUp().Normalize(); 01053 VECTOR3 camPosition = camera->GetWorldTransMatrix()->ExtractTranslation(); 01054 float angle = camUp.Dot(VECTOR3(0.0f, 1.0f, 0.0f)); 01055 if (angle<-1.0f) 01056 angle = -1.0f; 01057 if (angle>1.0f) 01058 angle = 1.0f; 01059 angle = acos(angle); 01061 angle = camView.Dot(VECTOR3(0.0f, 1.0f, 0.0f))>0 ? -angle : angle; 01062 scene->Transform(cameraID, MATRIX::RotationAxis(camUp.Cross(camView), angle)); 01063 scene->UpdateTransformation(cameraID); 01064 scene->TranslateAbs(cameraID, camPosition); 01065 scene->UpdateTransformation(cameraID); 01066 }
void Navigation::alignView | ( | ViewName | name | ) | [protected] |
Aligns the camera to the world axis.
Definition at line 1070 of file navigation.cpp.
01071 { 01072 NODE_ID cameraID = getCameraID(); 01073 Scene * scene = GetSceneMgr()->GetScene(getSceneID()); 01074 if (!scene) 01075 return; 01076 01077 const SceneNode * camNode = scene->GetNode(cameraID); 01078 if (!camNode || !camNode->IsOfType(SceneNode::CAMERA)) 01079 return; 01080 01081 Camera * camera = (Camera *)(const_cast<SceneNode *>(camNode)); 01082 WriteLocker camLock(*camera); 01083 01084 MATRIX m; 01085 01086 switch(name) 01087 { 01088 case SIDE: 01089 m *= MATRIX::RotationY(M_PI_2); 01090 break; 01091 case TOP: 01092 m *= MATRIX::RotationX(M_PI_2); 01093 break; 01094 case REAR: 01095 m *= MATRIX::RotationY(M_PI); 01096 break; 01097 }; 01098 01099 scene->SetTransformation(cameraID, m); 01100 scene->UpdateTransformation(cameraID); 01101 scene->Fit(cameraID); 01102 }
void Navigation::processEvent | ( | wxCommandEvent & | evt | ) | [protected, virtual] |
Process event - CameraModule
overload.
Try to sync with kernel so no redundant param updates occur
Reimplemented from VRUT::CameraModule.
Definition at line 236 of file navigation.cpp.
00237 { 00238 CameraModule::processEvent(evt); 00239 bool updateCamParams = false; 00240 switch (evt.GetEventType()) 00241 { 00242 case Event::EVT_SCENE_CAM_PROJECTION_CHANGED: 00243 updateCamParams = ((evt.GetId() == int(getSceneID())) && (evt.GetInt() == int(getCameraID())) && !fovChangeOperationStarted); 00244 break; 00245 case Event::EVT_PARAM_SET: 00246 { 00247 Parameter::ParameterIdentificator fromEventIdentificator = Parameter::ParameterIdentificator::FromEvent(evt); 00248 if (fromEventIdentificator == nodeIDParamID) 00249 { 00250 updateCamParams = true; 00251 } 00252 else 00253 { 00254 wxString selectedNavigationStyleString; 00255 UPDATE_PARAM_FROM_EVENT_STRING(navigationStyleParamID, selectedNavigationStyleString, evt); 00256 00257 if (fromEventIdentificator == navigationStyleParamID) 00258 { 00259 NavigationStyleInterface *newStyle = resolveStyleFromString(selectedNavigationStyleString); 00260 if (newStyle != activeNavigationStyle) 00261 { 00262 activeNavigationStyle = newStyle; 00263 refreshGUI(); 00264 } 00265 } 00266 00267 activeNavigationStyle->getAndFixButtonValues(evt); 00268 00269 UPDATE_PARAM_FROM_EVENT_FLOAT(rotspeedParamID, rotspeed, evt); 00270 UPDATE_PARAM_FROM_EVENT_FLOAT(zoomspeedParamID, zoomspeed, evt); 00271 UPDATE_PARAM_FROM_EVENT_FLOAT(cruisespeedParamID, cruisespeed, evt); 00272 UPDATE_PARAM_FROM_EVENT_FLOAT(panspeedParamID, panspeed, evt); 00273 float cameraCenterDistance = 0.0f; 00274 UPDATE_PARAM_FROM_EVENT_FLOAT(cameraCenterDistanceParamID, cameraCenterDistance, evt); 00275 UPDATE_PARAM_FROM_EVENT_FLOAT(fovParamID, fov, evt); 00276 UPDATE_PARAM_FROM_EVENT_FLOAT(nearPlaneParamID, nearPlane, evt); 00277 UPDATE_PARAM_FROM_EVENT_FLOAT(farPlaneParamID, farPlane, evt); 00278 00279 activeNavigationStyle->updateParams(evt); 00280 00281 if (fromEventIdentificator == sceneIDParamID) //Scene is assigned 00282 { 00283 refreshGUI(); 00284 scenePivotWasSet = false; 00285 } 00286 00287 if (fromEventIdentificator == selectedCameraParamID) 00288 { 00289 wxString selectedCamera; 00290 UPDATE_PARAM_FROM_EVENT_STRING(selectedCameraParamID, selectedCamera, evt); 00291 for (SceneNodeVector::iterator i = cameras.begin(); i != cameras.end(); i++) 00292 { 00293 if ((*i)->GetName() == selectedCamera) 00294 { 00295 wxCommandEvent ev = Event::GET_EVT_PARAM_SET_DO(nodeIDParamID, wxString::Format(wxT("%i"), (*i)->GetID())); 00296 PostToKernel(ev); 00297 } 00298 } 00299 } 00300 00301 processNavigationOperationButtonEvent(); 00302 00303 if ( (fov || nearPlane || farPlane) 00304 && (getSceneID() != SCENE_ID_NONE) 00305 && (getCameraID() != NODE_ID_NONE) ) 00306 { 00307 wxCommandEvent camEvt = Event::GET_EVT_SCENE_CAM_PROJECTION_SET(getSceneID(), getCameraID(), 0, 0, nearPlane, farPlane, fov); 00308 PostToKernel(camEvt, true); 00310 WaitForEvent(Event::EVT_SCENE_CAM_PROJECTION_CHANGED, 100, int(getSceneID()), int(getCameraID())); 00311 } 00312 if (fromEventIdentificator == cameraCenterDistanceParamID) 00313 { 00314 Scene * scene = GetSceneMgr()->GetScene(getSceneID()); 00315 if (scene) 00316 { 00317 NODE_ID cameraID = getCameraID(); 00318 const SceneNode * camNode = scene->GetNode(cameraID); 00319 if (camNode && camNode->IsOfType(SceneNode::CAMERA)) 00320 { 00321 Camera * camera = (Camera *)(const_cast<SceneNode *>(camNode)); 00322 WriteLocker camLock(*camera); 00323 camera->SetCenterDist(cameraCenterDistance); 00324 } 00325 } 00326 } 00327 } 00328 } 00329 break; 00330 default: 00331 break; 00332 } 00333 if (updateCamParams) 00334 { 00335 const Scene * scene = GetSceneMgr()->GetScene(getSceneID()); 00336 if (scene) 00337 { 00338 const SceneNode * camNode = scene->GetNode(getCameraID()); 00339 if (camNode && camNode->IsOfType(SceneNode::CAMERA)) 00340 { 00341 ReadLocker rLock(*camNode); 00342 wxCommandEvent ev1 = Event::GET_EVT_PARAM_SET_DO(fovParamID, wxString::Format(wxT("%g"), ((Camera *)camNode)->GetFOV())); 00343 PostToKernel(ev1); 00344 wxCommandEvent ev2 = Event::GET_EVT_PARAM_SET_DO(nearPlaneParamID, wxString::Format(wxT("%g"), ((Camera *)camNode)->GetNearPlane())); 00345 PostToKernel(ev2); 00346 wxCommandEvent ev3 = Event::GET_EVT_PARAM_SET_DO(farPlaneParamID, wxString::Format(wxT("%g"), ((Camera *)camNode)->GetFarPlane())); 00347 PostToKernel(ev3); 00348 wxCommandEvent ev4 = Event::GET_EVT_PARAM_SET_DO(cameraCenterDistanceParamID, wxString::Format(wxT("%g"), ((Camera *)camNode)->GetCenterDist())); 00349 PostToKernel(ev4); 00350 } 00351 } 00352 } 00353 }
void Navigation::processKeyEvent | ( | wxKeyEvent & | evt | ) | [protected, virtual] |
Process key event - CameraModule
overload.
Implements VRUT::ManipulatorModule.
Definition at line 864 of file navigation.cpp.
00865 { 00866 #ifdef EVENT_DEBUG 00867 LOGERROR(wxT("<Navigation>Received key event")); 00868 #endif 00869 activeNavigationStyle->keyStyle(evt); 00870 }
void Navigation::processMouseEvent | ( | wxMouseEvent & | evt | ) | [protected, virtual] |
Process mouse event - CameraModule
overload.
Implements VRUT::ManipulatorModule.
Definition at line 873 of file navigation.cpp.
00874 { 00875 if (int(windowID) != evt.GetId()) 00876 return; 00877 00878 NODE_ID cameraID = getCameraID(); 00879 Scene * scene = GetSceneMgr()->GetScene(getSceneID()); 00880 if (!scene) 00881 return; 00882 00883 const SceneNode * camNode = scene->GetNode(cameraID); 00884 if (!camNode || !camNode->IsOfType(SceneNode::CAMERA)) 00885 return; 00886 00887 Camera * camera = (Camera *)(const_cast<SceneNode *>(camNode)); 00888 WriteLocker camLock(*camera); 00889 00890 scene->UpdateTransformation(cameraID); 00891 00892 activeNavigationStyle->mouseStyle(evt); 00893 }
void Navigation::run | ( | ) | [protected, virtual] |
The run method for this module. Used for the fly-throughs.
Reimplemented from VRUT::Module.
Definition at line 895 of file navigation.cpp.
00896 { 00897 if (navigationStyleCATIASpecific.fly) 00898 { 00899 wxMilliSleep(10); //10ms is a compromise between an interactive frame rate and a low cpu load 00900 00901 NODE_ID cameraID = getCameraID(); 00902 Scene * scene = GetSceneMgr()->GetScene(getSceneID()); 00903 if (!scene) 00904 return; 00905 00906 const SceneNode * camNode = scene->GetNode(cameraID); 00907 if (!camNode || !camNode->IsOfType(SceneNode::CAMERA)) 00908 return; 00909 00910 Camera * camera = (Camera *)(const_cast<SceneNode *>(camNode)); 00911 WriteLocker camLock(*camera); 00912 scene->UpdateTransformation(cameraID); 00913 00914 fly(scene, camera, cameraID, mouseDelta); 00915 mouseDelta = wxPoint(0, 0); 00916 } 00917 00918 if (navigationStyleCortonaSpecific.operationStarted) 00919 { 00920 wxMilliSleep(10); 00921 00922 NODE_ID cameraID = getCameraID(); 00923 Scene * scene = GetSceneMgr()->GetScene(getSceneID()); 00924 if (!scene) 00925 return; 00926 00927 const SceneNode * camNode = scene->GetNode(cameraID); 00928 if (!camNode || !camNode->IsOfType(SceneNode::CAMERA)) 00929 return; 00930 00931 Camera * camera = (Camera *)(const_cast<SceneNode *>(camNode)); 00932 WriteLocker camLock(*camera); 00933 scene->UpdateTransformation(cameraID); 00934 00935 int cortonaWalk = navigationStyleCortonaSpecific.walkButtonIter->paramValue; 00936 int cortonaFly = navigationStyleCortonaSpecific.flyButtonIter->paramValue; 00937 int cortonaStudy = navigationStyleCortonaSpecific.studyButtonIter->paramValue; 00938 00939 if (navigationStyleCortonaSpecific.planWalkButtonIter->paramValue && cortonaWalk) 00940 { 00941 planWalk(scene, camera, cameraID, mouseDelta, navigationStyleCortonaSpecific.speedCompensation, navigationStyleCortonaSpecific.maxStepHeight, navigationStyleCortonaSpecific.avatarHeight); 00942 } 00943 else if (navigationStyleCortonaSpecific.panWalkButtonIter->paramValue && cortonaWalk) 00944 { 00945 panWalk(scene, camera, cameraID, mouseDelta, navigationStyleCortonaSpecific.speedCompensation, navigationStyleCortonaSpecific.maxStepHeight, navigationStyleCortonaSpecific.avatarHeight); 00946 } 00947 else if (navigationStyleCortonaSpecific.turnWalkButtonIter->paramValue && cortonaWalk) 00948 { 00949 turnWalk(scene, camera, cameraID, mouseDelta, navigationStyleCortonaSpecific.speedCompensation); 00950 } 00951 00952 if (navigationStyleCortonaSpecific.planFlyButtonIter->paramValue && cortonaFly) 00953 { 00954 planFly(scene, camera, cameraID, mouseDelta, navigationStyleCortonaSpecific.speedCompensation); 00955 } 00956 else if (navigationStyleCortonaSpecific.panFlyButtonIter->paramValue && cortonaFly) 00957 { 00958 panFly(scene, camera, cameraID, mouseDelta, navigationStyleCortonaSpecific.speedCompensation); 00959 } 00960 else if (navigationStyleCortonaSpecific.turnFlyButtonIter->paramValue && cortonaFly) 00961 { 00962 turnFly(scene, camera, cameraID, mouseDelta, navigationStyleCortonaSpecific.speedCompensation); 00963 } 00964 else if (navigationStyleCortonaSpecific.rollFlyButtonIter->paramValue && cortonaFly) 00965 { 00966 rollFly(scene, camera, cameraID, mouseDelta, navigationStyleCortonaSpecific.speedCompensation); 00967 } 00968 00969 if (navigationStyleCortonaSpecific.planStudyButtonIter->paramValue && cortonaStudy) 00970 { 00971 planStudy(scene, camera, cameraID, mouseDelta, navigationStyleCortonaSpecific.speedCompensation); 00972 } 00973 else if (navigationStyleCortonaSpecific.panStudyButtonIter->paramValue && cortonaStudy) 00974 { 00975 panStudy(scene, camera, cameraID, mouseDelta, navigationStyleCortonaSpecific.speedCompensation); 00976 } 00977 else if (navigationStyleCortonaSpecific.turnStudyButtonIter->paramValue && cortonaStudy) 00978 { 00979 turnStudy(scene, camera, cameraID, mouseDelta, navigationStyleCortonaSpecific.speedCompensation); 00980 } 00981 else if (navigationStyleCortonaSpecific.rollStudyButtonIter->paramValue && cortonaStudy) 00982 { 00983 rollStudy(scene, camera, cameraID, mouseDelta, navigationStyleCortonaSpecific.speedCompensation); 00984 } 00985 } 00986 00987 if (navigationStyleCortonaSpecific.altDown || navigationStyleCortonaSpecific.spaceDown) 00988 { 00989 int cortonaWalk = navigationStyleCortonaSpecific.walkButtonIter->paramValue; 00990 int cortonaFly = navigationStyleCortonaSpecific.flyButtonIter->paramValue; 00991 int cortonaStudy = navigationStyleCortonaSpecific.studyButtonIter->paramValue; 00992 00993 if (cortonaWalk) 00994 { 00995 //LOGDEBUG(wxT("walk")); 00996 clearButtonValues(navigationStyleCortonaSpecific.walkButtonsInfo); 00997 if (navigationStyleCortonaSpecific.altDown && navigationStyleCortonaSpecific.spaceDown) 00998 navigationStyleCortonaSpecific.turnWalkButtonIter->paramValue = 1; 00999 else if (navigationStyleCortonaSpecific.altDown) 01000 navigationStyleCortonaSpecific.panWalkButtonIter->paramValue = 1; 01001 else if (navigationStyleCortonaSpecific.spaceDown) 01002 //LOGDEBUG(wxT("space")); 01003 navigationStyleCortonaSpecific.turnWalkButtonIter->paramValue = 1; 01004 } 01005 if (cortonaFly) 01006 { 01007 clearButtonValues(navigationStyleCortonaSpecific.flyButtonsInfo); 01008 if (navigationStyleCortonaSpecific.altDown && navigationStyleCortonaSpecific.spaceDown) 01009 navigationStyleCortonaSpecific.rollFlyButtonIter->paramValue = 1; 01010 else if (navigationStyleCortonaSpecific.altDown) 01011 navigationStyleCortonaSpecific.panFlyButtonIter->paramValue = 1; 01012 else if (navigationStyleCortonaSpecific.spaceDown) 01013 navigationStyleCortonaSpecific.turnFlyButtonIter->paramValue = 1; 01014 } 01015 if (cortonaStudy) 01016 { 01017 clearButtonValues(navigationStyleCortonaSpecific.studyButtonsInfo); 01018 if (navigationStyleCortonaSpecific.altDown && navigationStyleCortonaSpecific.spaceDown) 01019 navigationStyleCortonaSpecific.rollStudyButtonIter->paramValue = 1; 01020 else if (navigationStyleCortonaSpecific.altDown) 01021 navigationStyleCortonaSpecific.panStudyButtonIter->paramValue = 1; 01022 else if (navigationStyleCortonaSpecific.spaceDown) 01023 navigationStyleCortonaSpecific.planStudyButtonIter->paramValue = 1; 01024 } 01025 } 01026 if (!scenePivotWasSet) //When the sceneID changes in the processEvent, the BVH does not exist yet, so i keep checking here 01027 { 01028 setInitialScenePivot(); 01029 scenePivotWasSet = true; 01030 } 01031 }
wxString Navigation::GetDesc | ( | ) | const [virtual] |
Get module description - Module
overload.
Implements VRUT::Module.
Definition at line 1106 of file navigation.cpp.
wxString VRUT::Navigation::defaultMouseEventTimeout [private] |
Definition at line 29 of file navigation.h.
SceneNodeVector VRUT::Navigation::cameras [protected] |
wxArrayString VRUT::Navigation::navigationStyleString [protected] |
wxArrayString VRUT::Navigation::cameraString [protected] |
wxPoint VRUT::Navigation::lastPos [protected] |
wxPoint VRUT::Navigation::mouseDelta [protected] |
Mouse coordinate difference between the current frame and the last frame.
Definition at line 79 of file navigation.h.
VECTOR3 VRUT::Navigation::scenePivot [protected] |
bool VRUT::Navigation::scenePivotWasSet [protected] |
NODE_ID VRUT::Navigation::selectedObject [protected] |
Definition at line 466 of file navigation.h.
NavigationStyleCameraManipulatorSpecific VRUT::Navigation::navigationStyleCameraManipulatorSpecific [protected] |
CameraManipulator specific variables needed for a proper emulation.
Definition at line 470 of file navigation.h.
CATIA specific variables needed for a proper emulation.
Definition at line 472 of file navigation.h.
Cortona specific variables needed for a proper emulation.
Definition at line 474 of file navigation.h.
Cinema4D specific variables needed for a proper emulation.
Definition at line 476 of file navigation.h.
DeltaView specific variables needed for a proper emulation.
Definition at line 480 of file navigation.h.
Icem Surf specific variables needed for a proper emulation.
Definition at line 482 of file navigation.h.
Virtual Design 2 specific variables needed for a proper emulation.
Definition at line 484 of file navigation.h.
bool VRUT::Navigation::fovChangeOperationStarted [protected] |
We set the fov param id only when the user releases the mouse button. This variable helps us know when this happens.
Definition at line 488 of file navigation.h.
float VRUT::Navigation::nearPlane [protected] |
float VRUT::Navigation::farPlane [protected] |
float VRUT::Navigation::fov [protected] |
float VRUT::Navigation::rotspeed [protected] |
float VRUT::Navigation::zoomStep [protected] |
float VRUT::Navigation::flySpeedStep [protected] |
float VRUT::Navigation::zoomspeed [protected] |
float VRUT::Navigation::cruisespeed [protected] |
float VRUT::Navigation::panspeed [protected] |