5 /*! \defgroup GrpBase OpenSG Base Library
7 \brief The Base Library contains fundamental classes, functions and,
10 See \ref PageBase for details.
13 /*! \defgroup GrpBaseBase Base
19 /*! \defgroup GrpBaseBaseBaseTypes BaseTypes
25 /*! \defgroup GrpBaseBaseBaseTypeTraits BaseTypesTraits
31 /*! \defgroup GrpBaseBaseColors Colors
37 /*! \defgroup GrpBaseBaseCmpTimeFn Compile Time Functions
43 /*! \defgroup GrpBaseBaseConstants Constants
49 /*! \defgroup GrpBaseBaseFileSystem FileSystem
55 /*! \defgroup GrpBaseBaseGLConstants GLConstants
61 /*! \defgroup GrpBaseBaseHelper Helper
67 /*! \defgroup GrpBaseBaseInitExit Initialization / Termination
73 /*! \defgroup GrpBaseBaseMath Math
79 /*! \defgroup GrpBaseBaseMathObj Objects
80 \ingroup GrpBaseBaseMath
85 /*! \defgroup GrpBaseBaseMathFn Functions
86 \ingroup GrpBaseBaseMath
91 /*! \defgroup GrpBaseBaseMatrixFn Matrix Utility Functions
92 \ingroup GrpBaseBaseMath
97 /*! \defgroup GrpBaseBaseMiscFn Miscellaneous Functions
103 /*! \defgroup GrpBaseBaseMultiThreading Multithreading
109 /*! \defgroup GrpBaseBaseRefCountFn Reference Count Functions
115 /*! \defgroup GrpBaseBaseStringFn String Functions
121 /*! \defgroup GrpBaseBaseTypeSystem TypeSystem
127 /*! \defgroup GrpBaseBaseVolume Volume
134 /*! \defgroup GrpBaseNetwork Network
137 The network part of OpenSG contains all objects used for network
138 communication. This objects are mainly used by OpenSG-Cluster support
142 /*! \defgroup GrpBaseSTLHelpers STLHelpers
145 STLHelpers are little structures and classes that are need to run STL
146 algorithms or to use STL containers.
149 /*! \page PageBase Base
151 \latexonly Starter:NewChapter \endlatexonly
153 All OpenSG symbols are part of the OSG name space, and they have no prefix.
154 The actual files, including headers, all use the OSG prefix.
158 /*! \page PageBaseTypes Base Types
160 As one goal of OpenSG is the ability to run programs on a lot of different
161 platforms, especially Unix and Windows, we have our own types which are
162 guaranteed to have the same size on all platforms.
164 We have our own signed and unsigned integers in all useful
165 sizes: Int8, UInt8, Int16, UInt16, Int32, UInt32, Int64, UInt64 as well as the
166 two usual float sizes Real32 and Real64. Some useful constant are available:
167 Eps, Pi, Inf and NegInf. A useful construct for template programming is the
168 TypeConstants<type> structure, which defines some standard functions/values
169 for the given type, see OSGBaseTypes.h for details.
173 /*! \page PageBaseLog Log
175 All output that OpenSG generates is channeled through the Log class, which is
176 defined in OSGLog.h. OpenSG supplies a global Log object that is used by the
177 library, but the application can create its own logs, if needed.
179 Every log message has one specific level. Available levels are FATAL, WARNING,
180 NOTICE, INFO and DEBUG. They are also numbered from 0 to 5. The verbosity of
181 the system can be controlled by ignoring messages of specific levels. This can
182 be achieved by calling osgLog().setLogLevel( <enum> ); or by setting the
183 environment variable OSG_LOG_LEVEL.
185 The system log has two different interfaces. One is based on C++ streams, one
186 is based on C printf semantics.
188 The stream interface can be used by using SFATAL, SWARNING, SNOTICE or SINFO
189 instead of cout or cerr. Note that there is no SDEBUG for efficiency reasons,
190 as FDEBUG can be compiled out. These print the position in the code where the
191 log is executed. For multi-line outputs you'll only want that on the first
192 line, for the other lines use PFATAL, PWARNING, PNOTICE or PINFO.
194 To synchronize multiple outputs from various threads all S* commands lock the
195 stream. You have to use 'osg::endLog' (e.g. SFATAL << "Message" << endLog;) to
196 unlock the stream output.
198 Example: SINFO << "Line 1 of message 1" << endl; PINFO << "line2 of message 1"
199 << endLog; SINFO << "Message 2" << endLog;.
201 The C interface tries to mimic the printf semantics. The following functions
202 can be used for that: FFATAL, FWARNING, FNOTICE, FINFO and FDEBUG. The only
203 difference to printf is that they have to be called with double parentheses,
204 i.e. FWARNING(("What do you mean by %s?", s));. The nice thing about the C
205 style interface is that the whole output can be compiled out. Actually, the
206 FDEBUG (( )) are only compiled in when OSG_DEBUG is set. The OSG_DEBUG define
207 is automatically set while compiling the system in debug (default) mode.
209 The user can activate/deactivate various elements per log message at runtime
210 by changing the LogHeaderElem mask. The following elements are supported right
213 LOG_BEGIN_NEWLINE_HEADER (creates an extra newline in front of every output),
214 LOG_TYPE_HEADER (writes the Level (e.g. WARNING) as first element),
215 LOG_TIMESTAMP_HEADER (writes a timestamp), LOG_MODULE_HEADER (writes the name
216 of the current module), LOG_FILE_HEADER (writes the source file name),
217 LOG_LINE_HEADER (writes the source line number) and LOG_END_NEWLINE_HEADER
218 (creates an extra newline at the end)
220 When unchanged, the time stamp will be the time in seconds since the program
221 started. The user can set/reset the time stamp at any time (e.g.
222 osgLog().resetRefTime()).
226 /*! \page PageBaseTime Time & Date
228 To wrap time and date handling we have a little abstraction for them.
230 getSystemTime() returns the current time since system has been started in
231 seconds, using the highest resolution timer available.
233 The Date class provides a second resolution time stamp, factored into second,
234 minute, hour, day, month and year. Date::setSystemDate() can be used to set it
235 to the current date/time.
239 /*! \page PageBaseMath Math
241 Of course every scene-graph needs the basic math objects like Vectors, Points,
242 Matrices, Quaternions etc., and OpenSG is no exception.
244 \section BaseMatrices Matrices
246 OpenSG matrices are similar to the OpenGL matrices in their storage structure
247 and conventions, i.e. a matrix is per default a 4x4 Real32 matrix, and the
248 multiplication convention is just like OpenGL's: v'=M*v.
250 The matrix is stored column major and access methods respect the storage
251 format, i.e. matrix[0] yields the first column. This is also true for the
252 vector-based constructor. However, the constructor taking 16 single elements
253 expects its parameters row-major like the matrix is written on paper.
255 The positive side effect of this setup is the ability to access the base
256 vectors of the matrix' coordinate space by accessing the vectors, i.e.
257 matrix[3] is the translation to the origin of the local coordinate space. This
258 is useful if you want to create your matrices from vectors, if you don't want
259 to do that, don't worry about it.
261 Setting the contents of a matrix is done by the setValues() methods, accessing
262 the values via the [] operator for access to single columns or by using
263 getValues() to get a pointer to the first element. In general most classes in
264 OpenSG that keep an array of elements allow access to them via getValues().
266 If you need to create a matrix for a specific transformation, use the
267 setTransform() methods, which create a matrix that executes the given
270 Matrices also supply the standard set of matrix operations like det(), det3(),
271 invert(), transpose(), mult() and multLeft(). There are some variants that
272 change the matrix in place, return their results in a different matrix or get
273 their source data from a different matrix, see the class docs for details.
275 The default vector/point multiplication methods multMatrixVec() and
276 multMatrixPnt() assume that the matrix only uses the standard 3x4 elements. To
277 use the full 4x4 matrix use multFullMatrixPnt(). As Vectors have a w
278 coordinate of 0, compared to points which have w = 1, they don't need a full
281 \section BaseVectors Vectors/Points/Colors
283 OpenSG is different from most other systems in differentiating between
284 vectors, points and colors.
286 Vectors are the most common class, and they should behave like every other
287 vector library on the planet. They are templated to simplify having variants,
288 and the standard ones that are available are Vec4ub, Vec2us, Vec2s, Vec2f,
289 Vec3s, Vec3f and Vec4f. They have operators for the scalar operations, and
290 methods for everything else, see the doxygen docs for osg::VectorInterface for
291 details. Conceptually, the 3 element vector has a w coordinate of 0, thus
292 there is no full matrix multiplication for vectors.
294 Points represent positions in space, and as such they are more restricted than
295 vectors. The available variants are Pnt2f, Pnt3f and Pnt4f. Some vector
296 operations (dot, cross, etc.) don't make sense for points. Points can be
297 subtracted (creating a vector), scaled and a vector can be added to or
298 subtracted from them. If you want to represent a position, use a point. It
299 helps keeping the concepts in order and not mix up everything just because it
300 has the same data. When multiplied with a matrix, the w coordinate is set
301 as 1 for 3 element points.
303 If you really need to get from a point to a vector or vice versa, you can
306 - Vector &osg::Point.subZero()
307 - Point &osg::Vector.addToZero()
309 to cast a point to a vector and back.
311 Colors are RGB vectors, which also have access functions to the named
312 components. They also allow access via the HSV color model and scalar
313 multiplication, but no other operations.
315 \section BaseQuaternions Quaternions
317 Quaternions are the standard way to represent rotations. OpenSG quaternions
318 feature the standard set of methods to get and set the rotations, in variants
319 for radians and degrees. The standard order of the components is x,y,z,w. The
320 standard operations (length, normalize, mult) are available, as well as slerp
325 /* \page PageBaseLine Line
327 A Line defines a ray in space. It is defined by an origin and a direction,
328 which is stored normalized. Lines can be constructed from two points or
329 directly from a point and a direction.
331 A line can be intersected with all the bounding volumes and geometry. Only the
332 positive parameter range of the line is intersected.
334 The line can also find the closest point on itself to a given point or another
339 /* \page PageBasePlane Plane
341 A Plane defines a 3D infinite half-space. It is defined by a normal and the
342 distance from the origin, and can be constructed from all useful combinations
343 of points and vectors.
345 Planes can also be intersected with infinite lines, if needed. Points can be
346 tested for lying on the plane, or being in the positive half-space of the
351 /* \page PageBaseVolumes Volumes
353 Volumes are primarily used for bounding geometry to speed up culling or
354 intersection tests. All Volumes are derived from Volume. The supported volumes
355 are the usual BoxVolume, defined by min and max points, the SphereVolume,
356 defined by center and radius, and the FrustumVolume, which is defined by 6
357 planes and primarily used to define the viewing frustum.
359 Volumes are created empty (i.e. zero volume) and can be changed by extending
360 them by a point or another volume. All volumes have a variety of access
361 functions, some specific to the type of volume, some general. Every volume
362 supports getBounds() to access the min/max points, getCenter() and
363 getScalarVolume() to access the volume measure. Volumes can be intersected
364 with points, lines and other volumes, and they can be transformed by a matrix.
366 Volumes can be in one of several states. The default state is valid, special
367 states are invalid, empty, infinite and static. There are specific functions
368 to set them to any one of those states and to check if they are in any of
371 Invalid volumes have to be set to valid explicitly, before extending them has
372 any effect. setEmpty() makes it valid implicitly. The states except empty
373 define how extensions and intersections are handled. Invalid volumes stay
374 invalid and ignore changes, static and infinite volumes keep their values and
375 are not changed by extensions. Intersecting an infinite volume is always true,
376 just as intersecting an empty volume is never true.
380 /* \page PageBaseThreads Threads
382 OpenSG supports a thread abstraction to support efficient threading on all
383 supported platforms. On Windows that means Windows threads, on Irix sproc() is
384 used, for every other system pthreads are used.
386 Every thread uses a Thread object for thread-specific data, most of which is
387 needed for thread-safe data, see [threadsafety]. To create a new thread, the
388 Thread object has a run() method, which executes a given function in a new
391 For thread synchronization Lock and Barrier objects are available. They act
392 like standard locks and barriers, see the doc for details.
396 /* \page PageBaseImage Image
398 Defines and holds a 1D/2D/3D image and optionally a mipmap pyramid and/or a
399 list of equally sized frames with a single frameDelay. Various pixelTypes are
400 supported to handle gray and RGB color images with or without alpha channel.
401 The image data starts in the lower left (front) corner and all bytes for a
402 single pixel (e.g. RGB) are stored sequentially in memory. They are not
403 organized in separate layers or channels.
405 An Image is only a container for the pixel data and image description. It does
406 not create or handle any OpenGL state elements. However, image objects are
407 utilized to handle the data for texture (e.g. SimpleTextureMaterial) or bitmap
408 objects (e.g. ImageForeground).
410 The system provides loaders and writers for various formats (see section
411 [imageLoaderSection]). The graph loaders (e.g. OSGLoader, VRMLLoader) use
412 image loaders to fetch the raster data.
416 /* \page PageBaseIDString IDString
418 A primitive string class. Mainly used for string IDs (e.g. node type names).
419 It is not a generic class like the std::string implementation. It's only for
420 internal use to built efficient maps for names, not for application use. If
421 you need a string class use std::string instead.
423 We decided to create our own specific string class since the std::string did
424 not provide all features we needed (e.g. shared memory pointer, automatic
425 preferred pointer comparison when comparing objects)
429 /* \page PageBaseFunctors Functors
431 Functors are the main method for OpenSG to call configurable actions. Functors
432 wrap calls to a standard function, to a member of a specific instance or to a
433 member of the first parameter.
435 Functors will have to be redesigned for 1.1, as they don't compile using the
436 Microsoft Visual Studio compiler. :( Thus we don't talk much about them here,
437 if you need to add a new action or GL object, send us mail.