#include <PfBasicSimulator.h>
Inheritance diagram for vrj::PfBasicSimulator:


Public Methods | |
| PfBasicSimulator () | |
| virtual | ~PfBasicSimulator () |
| virtual bool | config (jccl::ConfigElementPtr element) |
| Configure the basic simulator config. More... | |
| virtual void | initialize (SimViewport *simVp) |
| virtual void | setEventWindow (gadget::EventWindowInterface ewInterface) |
| Sets the event window the simulator can use to get input from the user. More... | |
| gmtl::Matrix44f | getCameraPos () |
| gmtl::Matrix44f | getHeadPos () |
| gmtl::Matrix44f | getWandPos () |
| virtual void | updateProjectionData (const float positionScale, Projection *leftProj, Projection *rightProj) |
| Called as part of the viewports updateProjection call. More... | |
| void | updateInternalData (float positionScale) |
| Update internal simulator data. More... | |
| virtual void | updateSimulatorSceneGraph () |
| Draws this sim device using the given information about the Window it will be drawing into. More... | |
| bool | configPerformerAPI (jccl::ConfigElementPtr element) |
| void | initSimulatorGraph () |
Static Public Methods | |
| std::string | getElementType () |
Protected Attributes | |
| SimViewport * | mSimViewport |
| bool | mDrawProjections |
| Should we draw projections. More... | |
| gmtl::Vec3f | mSurfaceColor |
| Color to draw surfaces. More... | |
| gadget::PositionInterface | mCamera |
| Proxy interfaces to devices needed. More... | |
| gadget::PositionInterface | mWand |
| gmtl::Matrix44f | mCameraPos |
| The data about the position of all this stuff. More... | |
| gmtl::Matrix44f | mHeadPos |
| gmtl::Matrix44f | mWandPos |
| pfScene * | mRootWithSim |
| The root with the simulator group & the sceneRoot. More... | |
Simulator stuff | |
| pfGroup * | mSimTree |
| The simulator scene graph. More... | |
| pfDCS * | mHeadDCS |
| The DCS above the head. More... | |
| pfDCS * | mWandDCS |
| The DCS above the wand. More... | |
| std::string | mHeadModel |
| The head model file path. More... | |
| std::string | mWandModel |
| The wand model file path. More... | |
Definition at line 54 of file PfBasicSimulator.h.
|
|
Definition at line 76 of file PfBasicSimulator.cpp.
00076 : mRootWithSim(NULL), 00077 mSimTree(NULL), mHeadDCS(NULL), mWandDCS(NULL) 00078 { 00079 //setDrawWandFunctor(new GlDrawConeWandFunctor()); 00080 //setDrawWandFunctor(new GlDrawRightAngleWandFunctor()); 00081 } |
|
|
Definition at line 59 of file PfBasicSimulator.h.
00059 {}
|
|
|
Configure the basic simulator config.
Implements vrj::DrawSimInterface. Definition at line 88 of file PfBasicSimulator.cpp. References configPerformerAPI, mCamera, mDrawProjections, mSurfaceColor, and mWand.
00089 {
00090 vprASSERT(element.get() != NULL);
00091 vprASSERT(element->getID() == std::string("default_simulator"));
00092
00093 std::string camera_proxy_str = element->getProperty<std::string>("camera_pos");
00094 std::string wand_proxy_str = element->getProperty<std::string>("wand_pos");
00095
00096 mCamera.init(camera_proxy_str);
00097 mWand.init(wand_proxy_str); // Configure the wand to use
00098
00099 if(!mCamera.isConnected())
00100 {
00101 vprDEBUG(vprDBG_ERROR, vprDBG_CRITICAL_LVL)
00102 << clrOutNORM(clrRED,"ERROR:")
00103 << "PfBasicSimulator:: Fatal Error: Camera not found named: "
00104 << camera_proxy_str.c_str() << vprDEBUG_FLUSH;
00105 vprASSERT(false);
00106 }
00107
00108 // Get drawing parameters
00109 mDrawProjections = element->getProperty<bool>("draw_projections");
00110 mSurfaceColor[0] = element->getProperty<float>("surface_color", 0);
00111 mSurfaceColor[1] = element->getProperty<float>("surface_color", 1);
00112 mSurfaceColor[2] = element->getProperty<float>("surface_color", 2);
00113
00114 configPerformerAPI(element);
00115
00116 return true;
00117 }
|
|
|
Definition at line 68 of file PfBasicSimulator.h.
00069 {
00070 return std::string("default_simulator");
00071 }
|
|
|
Implements vrj::DrawSimInterface. Definition at line 73 of file PfBasicSimulator.h. References mSimViewport.
00074 {
00075 mSimViewport = simVp;
00076 }
|
|
|
Sets the event window the simulator can use to get input from the user.
Implements vrj::PfSimInterface. Definition at line 122 of file PfBasicSimulator.cpp.
00123 {
00124 boost::ignore_unused_variable_warning(ewInterface);
00125 }
|
|
|
Definition at line 84 of file PfBasicSimulator.h. References mCameraPos. Referenced by updateProjectionData.
00085 { return mCameraPos; }
|
|
|
Definition at line 87 of file PfBasicSimulator.h. References mHeadPos. Referenced by updateSimulatorSceneGraph.
00088 { return mHeadPos; }
|
|
|
Definition at line 90 of file PfBasicSimulator.h. References mWandPos. Referenced by updateSimulatorSceneGraph.
00091 { return mWandPos; }
|
|
||||||||||||||||
|
Called as part of the viewports updateProjection call.
Reimplemented from vrj::DrawSimInterface. Definition at line 128 of file PfBasicSimulator.cpp. References getCameraPos, mSimViewport, and updateInternalData.
00130 {
00131 updateInternalData(positionScale);
00132
00133 gmtl::Matrix44f camera_pos = getCameraPos();
00134 gmtl::Vec3f camera_trans = gmtl::makeTrans<gmtl::Vec3f>(camera_pos);
00135
00136 gmtl::Matrix44f left_eye_pos, right_eye_pos; // NOTE: Eye coord system is -z forward, x-right, y-up
00137
00138 // -- Calculate camera (eye) Positions -- //
00139 vprDEBUG(vprDBG_ALL, vprDBG_HEX_LVL)
00140 << "vjDisplay::updateProjections: Getting cam position" << std::endl
00141 << vprDEBUG_FLUSH;
00142 vprDEBUG(vprDBG_ALL, vprDBG_HEX_LVL) << "CamPos:" << camera_trans << std::endl << vprDEBUG_FLUSH;
00143
00144 // Compute location of left and right eyes
00145 float interocular_dist = mSimViewport->getUser()->getInterocularDistance();
00146 interocular_dist *= positionScale; // Scale into correct units
00147 float eye_offset = interocular_dist / 2.0f; // Distance to move eye
00148
00149 left_eye_pos = camera_pos * gmtl::makeTrans<gmtl::Matrix44f>( gmtl::Vec3f(-eye_offset, 0.0f, 0.0f) );
00150 right_eye_pos = camera_pos * gmtl::makeTrans<gmtl::Matrix44f>( gmtl::Vec3f(eye_offset, 0.0f, 0.0f) );
00151
00152 leftProj->calcViewMatrix(left_eye_pos, positionScale);
00153 rightProj->calcViewMatrix(right_eye_pos, positionScale);
00154 }
|
|
|
Update internal simulator data.
Definition at line 157 of file PfBasicSimulator.cpp. References mCamera, mCameraPos, mHeadPos, mSimViewport, mWand, and mWandPos. Referenced by updateProjectionData.
00158 {
00159 mHeadPos = mSimViewport->getUser()->getHeadPosProxy()->getData(positionScale);
00160 mWandPos = mWand->getData(positionScale);
00161
00162 mCameraPos = mCamera->getData(positionScale);
00163 gmtl::invert(mCameraPos);
00164 }
|
|
|
Draws this sim device using the given information about the Window it will be drawing into.
Implements vrj::PfSimInterface. Definition at line 252 of file PfBasicSimulator.cpp. References getHeadPos, vrj::GetPfMatrix, getWandPos, mHeadDCS, and mWandDCS.
00253 {
00254 gmtl::Matrix44f vj_head_mat = getHeadPos(); // Get Juggler matrices
00255 gmtl::Matrix44f vj_wand_mat = getWandPos();
00256 pfMatrix head_mat = GetPfMatrix(vj_head_mat); // Convert to Performer
00257 pfMatrix wand_mat = GetPfMatrix(vj_wand_mat);
00258 mHeadDCS->setMat(head_mat); // Set the DCS nodes
00259 mWandDCS->setMat(wand_mat);
00260 }
|
|
|
Definition at line 169 of file PfBasicSimulator.cpp. References initSimulatorGraph, mHeadModel, mRootWithSim, mWandModel, and vrjDBG_DRAW_MGR. Referenced by config.
00170 {
00171 //vprASSERT(Element->getID() == std::string("apiPerformer"));
00172
00173 vprDEBUG(vrjDBG_DRAW_MGR,vprDBG_CONFIG_LVL) << "PfBasicSimulator::configPerformerAPI:"
00174 << " Configuring Performer\n" << vprDEBUG_FLUSH;
00175
00176 // --- Get simulator model info --- //
00177 std::string head_file = element->getProperty<std::string>("head_model");
00178 std::string wand_file = element->getProperty<std::string>("wand_model");
00179 if(head_file.empty())
00180 {
00181 vprDEBUG(vprDBG_ALL,vprDBG_CONFIG_LVL)
00182 << "WARNING: PfBasicSimulator::config: simHeadModel not set."
00183 << std::endl << vprDEBUG_FLUSH;
00184 }
00185 if(wand_file.empty())
00186 {
00187 vprDEBUG(vprDBG_ALL,vprDBG_CONFIG_LVL)
00188 << "WARNING: PfBasicSimulator::config: simWandModel not set."
00189 << std::endl << vprDEBUG_FLUSH;
00190 }
00191
00192 mHeadModel = vpr::replaceEnvVars(head_file);
00193 mWandModel = vpr::replaceEnvVars(wand_file);
00194
00195 vprDEBUG(vrjDBG_DRAW_MGR,vprDBG_CONFIG_LVL)
00196 << "Head Model: " << mHeadModel.c_str() << std::endl
00197 << "Wand Model: " << mWandModel.c_str() << std::endl << vprDEBUG_FLUSH;
00198
00199 mRootWithSim = PfDrawManager::instance()->getRootWithSim();
00200 if (NULL != mRootWithSim)
00201 {
00202 initSimulatorGraph();
00203 return true;
00204 }
00205 return false;
00206 }
|
|
|
Definition at line 208 of file PfBasicSimulator.cpp. References mHeadDCS, mHeadModel, mRootWithSim, mSimTree, mWandDCS, mWandModel, and vrjDBG_DRAW_MGR. Referenced by configPerformerAPI.
00209 {
00210 pfNode* head_node(NULL);
00211 pfNode* wand_node(NULL);
00212
00213 if(!mHeadModel.empty())
00214 {
00215 head_node = pfdLoadFile(mHeadModel.c_str()); // Load head model
00216 vprDEBUG(vrjDBG_DRAW_MGR,vprDBG_CONFIG_LVL) << "vjPfDrawManager: Loaded head model: " << mHeadModel.c_str() << std::endl << vprDEBUG_FLUSH;
00217 } else {
00218 vprDEBUG(vrjDBG_DRAW_MGR,vprDBG_CONFIG_LVL) << "vjPfDrawManager: No wand head specified.\n" << vprDEBUG_FLUSH;
00219 }
00220
00221 if(!mWandModel.empty())
00222 {
00223 wand_node = pfdLoadFile(mWandModel.c_str()); // Load wand model
00224 vprDEBUG(vrjDBG_DRAW_MGR,vprDBG_CONFIG_LVL) << "vjPfDrawManager: Loaded wand model: " << mWandModel.c_str() << std::endl << vprDEBUG_FLUSH;
00225 } else {
00226 vprDEBUG(vrjDBG_DRAW_MGR,vprDBG_CONFIG_LVL) << "vjPfDrawManager: No wand model specified.\n" << vprDEBUG_FLUSH;
00227 }
00228
00229 mSimTree = new pfGroup;
00230
00231 //mRootWithSim = new pfScene;
00232
00233 mHeadDCS = new pfDCS;
00234 mWandDCS = new pfDCS;
00235 mSimTree->addChild(mHeadDCS);
00236 mSimTree->addChild(mWandDCS);
00237 if(NULL != head_node)
00238 {
00239 mHeadDCS->addChild(head_node);
00240 }
00241 if(NULL != wand_node)
00242 {
00243 mWandDCS->addChild(wand_node);
00244 }
00245
00246 if((head_node != NULL) && (wand_node != NULL))
00247 {
00248 mRootWithSim->addChild(mSimTree); // Put sim stuff in the graph
00249 }
00250 }
|
|
|
Definition at line 112 of file PfBasicSimulator.h. Referenced by initialize, updateInternalData, and updateProjectionData. |
|
|
Should we draw projections.
Definition at line 115 of file PfBasicSimulator.h. Referenced by config. |
|
|
Color to draw surfaces.
Definition at line 116 of file PfBasicSimulator.h. Referenced by config. |
|
|
Proxy interfaces to devices needed.
Definition at line 118 of file PfBasicSimulator.h. Referenced by config, and updateInternalData. |
|
|
Definition at line 119 of file PfBasicSimulator.h. Referenced by config, and updateInternalData. |
|
|
The data about the position of all this stuff.
Definition at line 121 of file PfBasicSimulator.h. Referenced by getCameraPos, and updateInternalData. |
|
|
Definition at line 122 of file PfBasicSimulator.h. Referenced by getHeadPos, and updateInternalData. |
|
|
Definition at line 123 of file PfBasicSimulator.h. Referenced by getWandPos, and updateInternalData. |
|
|
The root with the simulator group & the sceneRoot.
Definition at line 125 of file PfBasicSimulator.h. Referenced by configPerformerAPI, and initSimulatorGraph. |
|
|
The simulator scene graph.
Definition at line 129 of file PfBasicSimulator.h. Referenced by initSimulatorGraph. |
|
|
The DCS above the head.
Definition at line 130 of file PfBasicSimulator.h. Referenced by initSimulatorGraph, and updateSimulatorSceneGraph. |
|
|
The DCS above the wand.
Definition at line 131 of file PfBasicSimulator.h. Referenced by initSimulatorGraph, and updateSimulatorSceneGraph. |
|
|
The head model file path.
Definition at line 132 of file PfBasicSimulator.h. Referenced by configPerformerAPI, and initSimulatorGraph. |
|
|
The wand model file path.
Definition at line 133 of file PfBasicSimulator.h. Referenced by configPerformerAPI, and initSimulatorGraph. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002