Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | Namespace Members | Class Members

Utility Namespace Reference


Detailed Description

Utility routines for use with OSG.

Author:
Nicolas Brodu


Classes

struct  EventFusionnedText
 GRRRRRRRRRRRRRRRRRR!!!!! OSG didn't make setText virtual!!! More...
class  KeyboardEventHandler
struct  FileLogger
struct  BatchThread

Enumerations

enum  TextHUDPosition { TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT }
 For use in createTextHUD method.

Functions

EventQueueViewercreateViewer (const char *windowTitle)
 Creates the viewer. Fills the Environment viewer field too.
osg::Group * drawLine (osg::Vec3d p1, osg::Vec3d p2, osg::Vec4 c1, osg::Group *lineGroup)
 Create a line between the 2 points with the given end colors, and add it to the given group.
osg::Group * drawLine (osg::Vec3d p1, osg::Vec3d p2, osg::Vec4 c1, osg::Vec4 c2, osg::Group *lineGroup)
static void addSceneHelper (osg::Projection *p)
static EventFusionnedTextgetTextHUD (TextHUDPosition where)
void setStatus (const std::string &status, TextHUDPosition where, bool alsoOut)
 Display some status text.
void checkTime ()
void displayTime ()
void toggleSimulationTime ()
 Show or hides the time.
void resetView ()
 reset position of the viewer to it's initial position
void createKeyboardHandler (osg::Group *tileableNode, osg::Group *tileableParent)
 Creates a keyboard handler for use in the main program.
static TRandomMersenne * getRNG ()
long RandomInit ()
void RandomInit (long seed)
 Initialize the random number generator with the given seed.
int IRandom (int min, int max)
 Returns a random integer in the range [min, max], bounds included: min <= x <= max, from a uniform distribution.
double Random ()
 Returns a random number between 0 (included) and 1 (excluded) 0 <= x < 1 drawn from a uniform distribution.
long BRandom ()
 Return 32 random bits as a long.
double NRandom ()
 Utility to get a number from a Normal distribution with mean 0, variance 1.
LoggercreateLogger (const std::string &id, const std::vector< std::string > &names)
 Creates a Logger.
void mainLoop ()
 main program loop. Handles both simulator and OSG, both batch and graphics modes

Variables

osgGA::TrackballManipulator * trackBallManipulator = 0
static osg::Geode * topHUD = 0
static osg::Geode * bottomHUD = 0
static EventFusionnedTexttopLeftText = 0
static EventFusionnedTexttopRightText = 0
static EventFusionnedTextbottomLeftText = 0
static EventFusionnedTextbottomRightText = 0
bool statusToConsole = false
 Set this to true if you also want status messages sent to cout on graphics mode.
bool statusTimeStamped = false
 Set this to true if you also want timestamp each message by prefixing it by "t=XXX: " where XXX is the simulator time at which the message was emitted.
static bool firstTime = true
static double sysTimeOri = 0.0
static double simTimeOri = 0.0
static const Simulator::GenericDispatchercheckTimeEvent = 0
static const Simulator::GenericDispatcherdisplayTimeEvent = 0
static TRandomMersenne * rng = 0
static long randomSeed = 42


Function Documentation

void Utility::createKeyboardHandler osg::Group *  tileableNode = 0,
osg::Group *  tileableParent = 0
 

Creates a keyboard handler for use in the main program.

Right now, this is only supported in graphics mode. This function has no effect in batch mode, or if the viewer isn't initialized yet.

It adds the following keys to the current viewer:

  • g: Increase the gravity
  • G: Decrease the gravity
  • p: Simulation pause
  • P: Simulation restart
  • n,N: Show/Hide floor normal (only if TerrainAgent terrain is non null)
  • c: cyclic world repeats, up to 3 levels. Available only if tileableNode != 0
  • t,T: start/stop performance timer
  • r,R: reset position of the viewer to it's initial position
  • space: clear status message

osg::Group * Utility::drawLine osg::Vec3d  p1,
osg::Vec3d  p2,
osg::Vec4  c1,
osg::Group *  lineGroup = 0
 

Create a line between the 2 points with the given end colors, and add it to the given group.

Returns the group, a new one is created if the argument is null.

Parameters:
p1 the line starting point
p2 the line ending point
c1 the line color at the starting point, or the whole line color if c2 isn't specified.
c2 the line color at the ending point. Equals c1 by default.
lineGroup an osg group to add this line to. Null by default, meaning a new group is created.
Returns:
the group in which this line was added

int Utility::IRandom int  min,
int  max
 

Returns a random integer in the range [min, max], bounds included: min <= x <= max, from a uniform distribution.

See comments in RandomInit.

double Utility::NRandom  ) 
 

Utility to get a number from a Normal distribution with mean 0, variance 1.

Added to the other functions for this project

double Utility::Random  ) 
 

Returns a random number between 0 (included) and 1 (excluded) 0 <= x < 1 drawn from a uniform distribution.

See comments in RandomInit. For the Mersene twister there is 32 random bits in the returned number.

void Utility::RandomInit long  seed  ) 
 

Initialize the random number generator with the given seed.

By default, the seed is taken from system time and printed out so the experiment is reproducible.

You can set here a previous seed to reproduce it.

This interface allows independance from the actual RNG used, and/or system functions.

The RNG used is very precisely the Mersenne twister implementation by Agner Fog, released under GNU GPL at http://www.agner.org/random/randomc.htm.

See also Utility.cpp and mersenne.cpp for information.

void Utility::setStatus const std::string &  status,
TextHUDPosition  where = BOTTOM_LEFT,
bool  alsoOut = statusToConsole
 

Display some status text.

Creates a text HUD if necessary


Variable Documentation

bool Utility::statusTimeStamped = false
 

Set this to true if you also want timestamp each message by prefixing it by "t=XXX: " where XXX is the simulator time at which the message was emitted.

Default is false.

bool Utility::statusToConsole = false
 

Set this to true if you also want status messages sent to cout on graphics mode.

Default is false.


Generated on Mon Mar 28 11:28:17 2005 for Crogai by  doxygen 1.4.1