Difference between revisions of "COVISE and OpenCOVER support"
Line 3: | Line 3: | ||
We are using Suse Linux 10.0 on most of our lab machines. The names of the lab machines you have an account on are: | We are using Suse Linux 10.0 on most of our lab machines. The names of the lab machines you have an account on are: | ||
− | * coutsound.ucsd.edu: AMD Opteron based file server and computer connected to dual-head setup next to projectors. Use this machine to compile and to change your password. Let me know when you change your password so that I can update it on the rest of the lab machines. | + | * coutsound.ucsd.edu: AMD Opteron based file server and computer connected to dual-head setup next to projectors. Use this machine to compile and to change your password. Let me know when you change your password so that I can update it on the rest of the lab machines. |
− | * visualtest01.ucsd.edu: AMD Opteron based, drives lower half of c-wall | + | * visualtest01.ucsd.edu: AMD Opteron based, drives lower half of c-wall |
− | * visualtest02.ucsd.edu: AMD Opteron based, drives upper half of c-wall | + | * visualtest02.ucsd.edu: AMD Opteron based, drives upper half of c-wall |
− | * flint.ucsd.edu: Intel Pentium D based Dell in terminal room | + | * flint.ucsd.edu: Intel Pentium D based Dell in terminal room |
− | * chert.ucsd.edu: Intel Pentium D based Dell in terminal room | + | * chert.ucsd.edu: Intel Pentium D based Dell in terminal room |
− | * basalt.ucsd.edu: Intel Pentium D based Dell in terminal room | + | * basalt.ucsd.edu: Intel Pentium D based Dell in terminal room |
− | * rubble.ucsd.edu: Intel Pentium D based Dell in terminal room | + | * rubble.ucsd.edu: Intel Pentium D based Dell in terminal room |
Due to the different computer hardware we use in the terminal room and the cave room, you should always compile your plugins on coutsound. | Due to the different computer hardware we use in the terminal room and the cave room, you should always compile your plugins on coutsound. |
Revision as of 10:48, 2 May 2007
Contents |
Lab hardware
We are using Suse Linux 10.0 on most of our lab machines. The names of the lab machines you have an account on are:
- coutsound.ucsd.edu: AMD Opteron based file server and computer connected to dual-head setup next to projectors. Use this machine to compile and to change your password. Let me know when you change your password so that I can update it on the rest of the lab machines.
- visualtest01.ucsd.edu: AMD Opteron based, drives lower half of c-wall
- visualtest02.ucsd.edu: AMD Opteron based, drives upper half of c-wall
- flint.ucsd.edu: Intel Pentium D based Dell in terminal room
- chert.ucsd.edu: Intel Pentium D based Dell in terminal room
- basalt.ucsd.edu: Intel Pentium D based Dell in terminal room
- rubble.ucsd.edu: Intel Pentium D based Dell in terminal room
Due to the different computer hardware we use in the terminal room and the cave room, you should always compile your plugins on coutsound.
Account information
In order to cross login between lab machines without a password you will need to create a DSA key pair. To generate this you run the command 'ssh-keygen -t dsa' on any lab machine and use the default file names, and do not enter a pass phrase. This should generate two files in your ~/.ssh/ directory: id_dsa and id_dsa.pub. The last step is to copy the file id_dsa.pub to new file authorized_keys, or append the contents of id_dsa.pub to authorized_keys if it already exists.
General information about Covise modules
The entire Covise installation, including all plugins, is located at ~jschulze/covise/. Each user should have a link in their home directory named 'covise' which points to this directory. There should also be a link 'plugins' which points to the plugins directory. You should put all the plugins you write in this course into the directory: plugins/cse291/.
Other directories you might need throughout the project are:
- covise/src/renderer/OpenCOVER/kernel/: core OpenCOVER functionality, especially coVRModuleSupport.cpp
- covise/src/kernel/OpenVRUI/: OpenCOVER's user interface elements. useful documentation in doc/html subdirectory; browse by running Firefox on index.html
- covise/src/renderer/OpenCOVER/osgcaveui/: special CaveUI functions, not required in class but useful
You compile your plugin with the 'make' command. This creates a library file in covise/amd64/lib/OpenCOVER/plugins/. Covise uses qmake, so the make file is being generated by the .pro file. The name of the plugin is determined by the project name in the .pro file in your plugin directory (first line, keyword TARGET). I defaulted TARGET to be p1<username> for project #1. It is important that the TARGET name be unique, or else you will overwrite somebody else's plugin. You can change the name of your source files or add additional source files (.cpp,.h) by listing them after the SOURCES tag in the .pro file.
You run OpenCOVER by typing 'opencover' anywhere at the command line. You quit opencover by hitting the 'q' key on the keyboard or ctrl-c in the shell window you started it from.
Good examples for plugins are plugins/Volume and plugins/PDBPlugin. Look at the code in these plugins to find out how to add menu items and how to do interaction. Note that there are two ways to do interaction: with pure OpenCOVER routines, or with OSGCaveUI. In this course we will try to use only OpenCOVER's own routines. Plugins do not get loaded by opencover before they are configured in the configuration file.
Covise configuration files
The configuration files are in the directory covise/config/. In class, the only files you need to look at are:
- config.ucsd.xml: contains configuration information for all lab machines, except the c-wall machines
- config.calitcave.xml: contains configuration information for the c-wall machines only (visualtest01, visualtest02)
The configuration files are XML files which can be edited with any ASCII text editor (vi, emacs, nedit, gedit, ...). There are sections specific for certain machines. To load your plugin (e.g., p1jschulze) on one or more machines (e.g., chert and basalt), you need to add or modify a section to contain:
<LOCAL host="chert,basalt"> <COVERConfig> <Module value="p1jschulze" name="p1jschulze"/> </COVERConfig> </LOCAL>
Intersection testing
If you have wondered how you can find out if the wand pointer intersects your objects, here is a template routine for it. You need to pass it the beginning and end of a line you're intersecting with, in world coordinates. The line will be starting from the hand position and extend along the Y axis.
class IsectInfo // this is an optional class to illustrate the return values of the accept() function { public: bool found; ///< false: no intersection found osg::Vec3 point; ///< intersection point osg::Vec3 normal; ///< intersection normal osg::Geode geode; ///< intersected Geode }; void getObjectIntersection(Vec3& wPointerStart, Vec3& wPointerEnd, IsectInfo& isect) { // Compute intersections of viewing ray with objects: osgUtil::IntersectVisitor iv; osg::ref_ptr<osg::LineSegment> testSegment = new LineSegment; testSegment->set(wStart, wEnd); iv.addLineSegment(testSegment.get()); iv.setTraversalMask(2); // Traverse the whole scenegraph. // Non-Interactive objects must have been marked with setNodeMask(~2): _worldRoot->accept(iv); isect.found = false; if (iv.hits()) { osgUtil::IntersectVisitor::HitList& hitList = iv.getHitList(testSegment.get()); if(!hitList.empty()) { isect.point = hitList.front().getWorldIntersectPoint(); isect.normal = hitList.front().getWorldIntersectNormal(); isect.geode = hitList.front()._geode; } } }
Here is some code to get the pointer (=wand) position (pos1) and a point 1000 millimeters from it (pos2) along the pointer line:
Vec3 pointerPos1Wld = cover->getPointerMat().getTrans(); pointerPos1Wld.set(0.0, 1000.0, 0.0); Vec3 pointerPos2Wld = pointerPos1Wld * cover->getPointerMat();
Interaction handling
To register an interaction so that only your plugin uses the mouse pointer while a button on the wand is pressed, you want to use the TrackerButtonInteraction class. For sample usage see plugins/Volume. Here are the main calls you will need. Most of these functions go in the preFrame routine, unless otherwise noted:
- Make sure you include at the top of your code:
#include <OpenVRUI/coTrackerButtonInteraction.h>
- In the constructor you want to create your interaction for button A, which is the left wand button:
interaction = new coTrackerButtonInteraction(coInteraction::ButtonA,"MoveObject",coInteraction::Menu);
- In the destructor you want to call:
delete interaction;
- To register your interaction and thus disable button A interaction in all other plugins call the following function. Make sure that to call this function before other modules can register the interaction. In particular, this might mean that you need to register the interaction before a mouse button is pressed, for instance by registering it when intersecting with the object to interact with.
if(!interaction->registered) { coInteractionManager::the()->registerInteraction(interaction); }
- To do something just once, after the interaction has just started:
if(interaction->wasStarted()) { }
- To do something every frame while the interaction is running:
if(interaction->isRunning()) { }
- To do something once at the end of the interaction:
if(interaction->wasStopped()) { }
- To unregister the interaction and free button A for other plugins:
if(interaction->registered && (interaction->getState()!=coInteraction::Active)) { coInteractionManager::the()->unregisterInteraction(interaction); }
OSG Text
Make sure you #include <osgText/Text>. There is a good example for how osgText can be used in ~/covise/src/renderer/OpenCOVER/osgcaveui/Card.cpp. _highlight is the osg::Geode the text gets created for, createLabel() returns the Drawable with the text, _labelText is the text string, and osgText::readFontFile() reads the font.
OSG Images (Textures)
Again, the file ~/covise/src/renderer/OpenCOVER/osgcaveui/Card.cpp has a good example for this. _highlight is again the osg::Geode the image gets added to as a osg::Geometry. The osg::Geometry gets created in Card::createIcon(). The image itself is stored in _icon, which gets created at the top of Card::createGeometry(), but using osg::Image and osg::Texture2D.