Removed files.... synching witn 0.8.42

This commit is contained in:
Don BURNS
2001-09-19 21:51:06 +00:00
parent bc739f47a9
commit 77494207fb
37 changed files with 0 additions and 6019 deletions

View File

@@ -1,45 +0,0 @@
#ifndef OSG_DCS
#define OSG_DCS 1
#include <osg/Group>
#include <osg/Matrix>
namespace osg {
/** DCS - Dynamic Coordinate System a is group which all children
are transformed by the the DCS's osg::Matrix. Typical uses
of the DCS is for positioning objects within a scene or
producing trakerball functionality.
*/
class SG_EXPORT DCS : public Group
{
public :
DCS();
DCS(const Matrix& matix);
virtual Object* clone() const { return new DCS(); }
virtual bool isSameKindAs(Object* obj) { return dynamic_cast<DCS*>(obj)!=NULL; }
virtual const char* className() const { return "DCS"; }
virtual void accept(NodeVisitor& nv) { nv.apply(*this); }
void setMatrix(const Matrix& mat );
Matrix* getMatrix() { return _mat; }
void preTranslate( float tx, float ty, float tz );
void preRotate( float deg, float x, float y, float z );
bool computeBound();
protected :
virtual ~DCS();
virtual bool readLocalData(Input& fr);
virtual bool writeLocalData(Output& fw);
Matrix *_mat;
};
};
#endif

View File

@@ -1,51 +0,0 @@
#ifndef OSG_DYNAMICLIBRARY
#define OSG_DYNAMICLIBRARY 1
#include <string>
#include <osg/Referenced>
#ifdef WIN32
//#include <Windows.h>
#endif
namespace osg {
/** DynamicLibrary - encapsulates the loading and unloading of dynamic libraries,
typically used for loading ReaderWriter plug-ins.
*/
class SG_EXPORT DynamicLibrary : public Referenced
{
public:
#ifdef WIN32
// from Snados.h
typedef void* HANDLE;
// from Delayimp.h
typedef void* PROC_ADDRESS;
#else
typedef void* HANDLE;
typedef void* PROC_ADDRESS;
#endif
static DynamicLibrary* loadLibrary(const std::string& libraryName);
const std::string& getName() const { return _name; }
const std::string& getFullName() const { return _fullName; }
HANDLE getHandle() const { return _handle; }
PROC_ADDRESS getProcAddress(const std::string& procName);
protected:
DynamicLibrary(const std::string& name,HANDLE handle);
~DynamicLibrary();
HANDLE _handle;
std::string _name;
std::string _fullName;
};
};
#endif // __DYNAMIC_LIBRARY_H

View File

@@ -1,15 +0,0 @@
#ifndef OSG_EXTENSIONSUPPORTED
#define OSG_EXTENSIONSUPPORTED 1
#include <osg/Export>
namespace osg {
/** return true if OpenGL "extension" is supported.
note: Must only called within a valid OpenGL context,
undefined behaviour may occur otherwise.*/
SG_EXPORT extern bool ExtensionSupported(const char *extension);
};
#endif

View File

@@ -1,100 +0,0 @@
#ifndef OSG_FIELD
#define OSG_FIELD 1
#include <osg/Export>
#include <string>
#include <stdlib.h>
namespace osg {
class SG_EXPORT Field
{
public:
enum {
MIN_CACHE_SIZE = 256
};
Field();
Field(const Field& field);
virtual ~Field();
virtual Field& operator = (const Field& ic);
void reset();
void addChar(char c);
int getNoCharacters() const { return _fieldCacheSize; }
void setWithinQuotes(bool withinQuotes=true);
bool getWithinQuotes();
void setNoNestedBrackets(int no);
int getNoNestedBrackets();
enum FieldType
{
OPEN_BRACKET,
CLOSE_BRACKET,
STRING,
WORD,
REAL,
INTEGER,
BLANK,
UNINTIALISED
};
FieldType getFieldType() const;
bool isValid() const;
bool isOpenBracket() const;
bool isCloseBracket() const;
bool isWord() const;
bool matchWord(const char* str) const;
bool matchWord(const char* str,int noCharacters) const;
bool isString() const;
bool matchString(const char* str) const;
bool matchString(const char* str,int noCharacters) const;
bool isQuotedString() const;
const char* getStr() const;
char* takeStr();
bool isInt() const;
bool matchInt(int i) const;
bool getInt(int& i) const;
bool isFloat() const;
bool matchFloat(float f) const;
bool getFloat(float& f) const;
bool isDouble() const;
bool matchDouble(double f) const;
bool getDouble(double& d) const;
static FieldType calculateFieldType(const char* str,bool withinQuotes=false);
protected:
void _init();
void _free();
void _copy(const Field& ic);
int _fieldCacheCapacity;
int _fieldCacheSize;
char* _fieldCache;
mutable FieldType _fieldType;
bool _withinQuotes;
int _noNestedBrackets;
};
};
#endif // __SG_FIELD_H

View File

@@ -1,62 +0,0 @@
#ifndef OSG_FIELDREADER
#define OSG_FIELDREADER 1
#include <osg/Export>
#include <string.h>
#include <stdlib.h>
#ifdef OSG_USE_IO_DOT_H
#include <iostream.h>
#else
#include <iostream>
using namespace std;
#endif
namespace osg {
class Field;
class SG_EXPORT FieldReader
{
public:
FieldReader();
FieldReader(const FieldReader& ic);
virtual ~FieldReader();
virtual FieldReader& operator = (const FieldReader& ic);
void attach(istream* input);
void detach();
virtual bool eof() const;
bool readField(Field& fieldPtr);
void ignoreField();
/** no of unmatched `{' encounterd so far in file*/
int getNoNestedBrackets() const;
private:
bool _readField(Field* fieldPtr);
void _init();
void _free();
void _copy(const FieldReader& ic);
istream* _fin;
bool _eof;
bool findStartOfNextField();
int _noNestedBrackets;
bool _delimatorEatLookUp[256];
bool _delimatorKeepLookUp[256];
};
};
#endif // __SG_FIELD_READER_H

View File

@@ -1,68 +0,0 @@
#ifndef OSG_FIELDREADERITERATOR
#define OSG_FIELDREADERITERATOR 1
#include <osg/Field>
#include <osg/FieldReader>
namespace osg {
class SG_EXPORT FieldReaderIterator
{
public:
enum {
MINIMUM_FIELD_READER_QUEUE_SIZE = 10
};
FieldReaderIterator();
FieldReaderIterator(const FieldReaderIterator& ic);
virtual ~FieldReaderIterator();
virtual FieldReaderIterator& operator = (const FieldReaderIterator& ic);
void attach(istream* input);
void detach();
virtual bool eof() const;
FieldReader& getFieldReader() { return _reader; }
void insert(int pos,Field* field);
void insert(int pos,const char* str);
Field& operator [] (int pos);
Field& field (int pos);
FieldReaderIterator& operator ++ ();
FieldReaderIterator& operator += (int no);
/** increments the itetor of the next simple field or
whole block if the current field[0] is an open bracket */
void advanceOverCurrentFieldOrBlock();
void advanceToEndOfCurrentBlock();
void advanceToEndOfBlock(int noNestBrackets);
bool matchSequence(const char* str);
private:
void _init();
void _free();
void _copy(const FieldReaderIterator& ic);
FieldReader _reader;
Field _blank;
Field* _previousField;
Field** _fieldQueue;
int _fieldQueueSize;
int _fieldQueueCapacity;
};
};
#endif // __OSG_FIELD_READER_QUEUE_H

View File

@@ -1,18 +0,0 @@
#ifndef OSG_FILENAMEUTILS
#define OSG_FILENAMEUTILS 1
#include <osg/Export>
#include <string>
namespace osg {
SG_EXPORT extern std::string getFilePath(const std::string& filename);
SG_EXPORT extern std::string getFileExtension(const std::string& filename);
SG_EXPORT extern std::string getLowerCaseFileExtension(const std::string& filename);
SG_EXPORT extern std::string getSimpleFileName(const std::string& fileName);
SG_EXPORT extern std::string getStrippedName(const std::string& fileName);
};
#endif

View File

@@ -1,150 +0,0 @@
#ifndef OSG_GEOSTATE
#define OSG_GEOSTATE 1
#include <osg/OSG>
#include <osg/Texture>
#include <osg/TexGen>
#include <osg/Light>
#include <osg/Material>
#include <osg/TexEnv>
#include <osg/Transparency>
#include <osg/Lighting>
#include <osg/Fog>
#include <osg/TexMat>
#include <osg/CullFace>
#include <osg/Point>
#include <osg/PolygonOffset>
#include <osg/AlphaFunc>
namespace osg {
class Input;
class Output;
/**
Encapsulates OpenGL state modes and attributes.
Used to specificy textures etc of osg::GeoSet's which hold references
to a single osg::GeoState. GeoState can be shared between GeoSet's
and is recommend if possible as it minimize expensive state changes
in the graphics pipeline.
*/
class SG_EXPORT GeoState : public Object
{
public :
enum AttributeType
{
ANTIALIAS,
FACE_CULL,
FOG,
LIGHTING,
MATERIAL,
POINT,
POLYGON_OFFSET,
TEXENV,
TEXGEN,
TEXMAT,
TEXTURE,
TRANSPARENCY,
WIREFRAME,
ALPHAFUNC
};
enum AttributeMode
{
INHERIT,
OFF,
ON,
OVERRIDE_OFF,
OVERRIDE_ON,
};
GeoState();
static GeoState* instance();
virtual Object* clone() const { return new GeoState(); }
virtual bool isSameKindAs(Object* obj) { return dynamic_cast<GeoState*>(obj)!=NULL; }
const char* className() const { return "GeoState"; }
/** set all the modes to on or off so that it defines a
complete state, typically used for a default global state.*/
void setGlobalDefaults();
/** set all the modes to inherit, typically used to signifiy
nodes which inherit all of their modes for the global state.*/
void setAllToInherit();
void setMode(AttributeType type, AttributeMode mode);
AttributeMode getMode(AttributeType type) const;
void setAttribute(AttributeType type, Object *attribute);
Object* getAttribute(AttributeType type) const;
bool isTransparent() { return _transparencing==ON; }
void apply();
void apply(GeoState* global,GeoState* prev);
bool check();
static AttributeMode combineMode(const AttributeMode g,const AttributeMode p,const AttributeMode c)
{
AttributeMode gp = mergeMode(g,p);
AttributeMode gc = mergeMode(g,c);
if (gc==gp) return INHERIT;
else return gc;
}
static AttributeMode mergeMode(const AttributeMode lhs,const AttributeMode rhs)
{
AttributeMode mode;
if (rhs==INHERIT || lhs==OVERRIDE_OFF || lhs==OVERRIDE_ON) mode = lhs;
else mode = rhs;
if (mode==OVERRIDE_OFF) return OFF;
else if (mode==OVERRIDE_OFF) return ON;
return mode;
}
protected :
virtual ~GeoState();
GeoState(const GeoState&):Object() {}
GeoState& operator = (const GeoState&) { return *this; }
virtual bool readLocalData(Input& fr);
virtual bool writeLocalData(Output& fw);
bool matchModeStr(const char* str, AttributeMode& mode);
const char* getModeStr(AttributeMode flag);
// Modes
AttributeMode _transparencing;
AttributeMode _face_culling;
AttributeMode _lighting;
AttributeMode _texturing;
AttributeMode _fogging;
AttributeMode _texgening;
AttributeMode _antialiasing;
AttributeMode _colortable;
AttributeMode _pointSmoothing;
AttributeMode _polygonOffsetting;
AttributeMode _alphaTesting;
// Attributes
ref_ptr<Texture> _texture;
ref_ptr<TexGen> _texgen;
ref_ptr<Material> _material;
ref_ptr<TexEnv> _texenv;
ref_ptr<Transparency> _transparency;
ref_ptr<TexMat> _texmat;
ref_ptr<Fog> _fog;
ref_ptr<Point> _point;
ref_ptr<PolygonOffset> _polygonOffset;
ref_ptr<CullFace> _cullFace;
ref_ptr<AlphaFunc> _alphaFunc;
};
};
#endif

View File

@@ -1,49 +0,0 @@
#ifndef OSG_INPUT
#define OSG_INPUT 1
#include <osg/FieldReaderIterator>
#include <map>
#include <string>
namespace osg {
class Object;
class Image;
class Node;
/** Class for managing the reading of ASCII .osg files.*/
class SG_EXPORT Input : public FieldReaderIterator
{
public:
// Will extend to handle #DEF and use
// functionality similar to Inventor,
// and add the ability to handle #include
// from within the OSG file format.
Input();
virtual ~Input();
virtual Object* readObject();
virtual Object* readObject(const std::string& fileName);
virtual Image* readImage();
virtual Image* readImage(const std::string& fileName);
virtual Node* readNode();
virtual Node* readNode(const std::string& fileName);
virtual Object* getObjectForUniqueID(const std::string& uniqueID);
virtual void regisiterUniqueIDForObject(const std::string& uniqueID,Object* obj);
private:
typedef std::map<std::string,Object*> UniqueIDToObjectMapping;
UniqueIDToObjectMapping _uniqueIDToObjectMap;
};
};
#endif // __SG_INPUT_H

View File

@@ -1,21 +0,0 @@
#ifndef OSG_LIGHTING
#define OSG_LIGHTING 1
#include <osg/Export>
namespace osg {
/** Class to globally control OpenGL's lighting.*/
class SG_EXPORT Lighting
{
public :
/** Enable lighting.*/
static void enable();
/** Disable lighting.*/
static void disable();
};
};
#endif

View File

@@ -1,15 +0,0 @@
#ifndef OSG_OSG
#define OSG_OSG 1
#include <osg/Node>
namespace osg {
SG_EXPORT extern void Init( void );
SG_EXPORT extern void SetFilePath( const char *_path );
SG_EXPORT extern char *FindFile( const char *file );
SG_EXPORT extern char *findDSO( const char *name );
};
#endif

View File

@@ -1,98 +0,0 @@
#ifndef OSG_OUTPUT
#define OSG_OUTPUT 1
#include <osg/Export>
#include <string>
#include <map>
#ifdef OSG_USE_IO_DOT_H
#include <fstream.h>
#else
#include <fstream>
using namespace std;
#endif
namespace osg {
class Object;
/** ofstream wrapper class for adding support for indenting.
Used in output of .osg ASCII files to improve their readability.*/
class SG_EXPORT Output : public ofstream
{
public:
Output();
virtual ~Output();
Output& indent();
int getIndentStep() const { return _indentStep; }
void setIndentStep(int step) { _indentStep = step; }
int getIndent() const { return _indent; }
void setIndent(int indent) { _indent = indent; }
int getNumIndicesPerLine() const { return _numIndicesPerLine; }
void setNumIndicesPerLine(int num) { _numIndicesPerLine = num; }
void moveIn();
void moveOut();
bool getUniqueIDForObject(Object* obj,std::string& uniqueID);
bool createUniqueIDForObject(Object* obj,std::string& uniqueID);
bool registerUniqueIDForObject(Object* obj,std::string& uniqueID);
protected:
// prevent copy construction and assignment.
Output(const Output&) : ofstream() {}
Output& operator = (const Output&) { return *this; }
virtual void _init();
virtual void _free();
int _indent;
int _indentStep;
int _numIndicesPerLine;
typedef std::map<Object*,std::string> UniqueIDToLabelMapping;
UniqueIDToLabelMapping _objectToUniqueIDMap;
};
template<class T>
bool writeArrayBlock(Output& fw,T* start,T* finish)
{
fw.indent() << "{" << endl;
fw.moveIn();
int numIndicesThisLine = 0;
for(T* itr=start;itr!=finish;++itr)
{
if (numIndicesThisLine>=fw.getNumIndicesPerLine())
{
fw << endl;
numIndicesThisLine = 0;
}
if (numIndicesThisLine==0) fw.indent();
else fw << " ";
fw << *itr;
++numIndicesThisLine;
}
fw << endl;
fw.moveOut();
fw.indent() << "}" << endl;
return true;
}
};
#endif // __SG_OUTPUT_H

View File

@@ -1,168 +0,0 @@
#ifndef OSG_REGISTRY
#define OSG_REGISTRY 1
#include <vector>
#include <string>
#include <osg/Referenced>
#include <osg/DynamicLibrary>
namespace osg {
// forward declare referenced classes to help avoid mutiple includes
class Object;
class Image;
class Node;
class Input;
SG_EXPORT extern Object* loadObjectFile(const char *name);
SG_EXPORT extern Image* loadImageFile(const char *name);
SG_EXPORT extern Node* loadNodeFile(const char *name);
SG_EXPORT extern bool saveObjectFile(Object& object, const char *name);
SG_EXPORT extern bool saveImageFile(Image& image, const char *name);
SG_EXPORT extern bool saveNodeFile(Node& node, const char *name);
/** pure virtual base class for reading and writing of non native formats. */
class SG_EXPORT ReaderWriter : public Referenced
{
public:
virtual ~ReaderWriter() {}
virtual const char* className() = 0;
virtual bool acceptsExtension(const std::string& /*extension*/) { return false; }
virtual Object* readObject(const std::string& /*fileName*/) { return NULL; }
virtual Image* readImage(const std::string& /*fileName*/) { return NULL; }
virtual Node* readNode(const std::string& /*fileName*/) { return NULL; }
virtual bool writeObject(Object& /*obj*/,const std::string& /*fileName*/) {return false; }
virtual bool writeImage(Image& /*image*/,const std::string& /*fileName*/) {return false; }
virtual bool writeNode(Node& /*node*/,const std::string& /*fileName*/) { return false; }
};
/**
Registry is a singleton factory which stores
the Objects types available at runtime for loading,
and any Object reader or writers which are linked in
at runtime for reading non-native file formats.
The RegisterObjectProxy defined in Object.h can be
used to automatically register at runtime a Object
with the Registry.
The RegisterReaderWriterProxy defined in ReaderWriter.h can
be used to automatically register at runtime a reader/writer
with the Registry.
*/
class SG_EXPORT Registry
{
public:
~Registry();
static Registry* instance();
void addPrototype(Object* obj);
void removePrototype(Object* obj);
void addReaderWriter(ReaderWriter* rw);
void removeReaderWriter(ReaderWriter* rw);
/** create the platform specific library name associated with file.*/
std::string createLibraryNameForFile(const std::string& fileName);
/** create the platform specific library name associated with file extension.*/
std::string createLibraryNameForExt(const std::string& ext);
/** find the library in the SG_LIBRARY_PATH and load it.*/
bool loadLibrary(const std::string& fileName);
/** close the attached library with specified name.*/
bool closeLibrary(const std::string& fileName);
Object* readObject(Input& fr);
Object* readObject(const std::string& fileName);
bool writeObject(Object& obj, const std::string& fileName);
Image* readImage(Input& fr);
Image* readImage(const std::string& fileName);
bool writeImage(Image& obj, const std::string& fileName);
Node* readNode(Input& fr);
Node* readNode(const std::string& fileName);
bool writeNode(Node& node, const std::string& fileName);
private:
typedef std::vector<ref_ptr<Object> > PrototypeList;
typedef std::vector<ref_ptr<ReaderWriter> > ReaderWriterList;
typedef std::vector<ref_ptr<DynamicLibrary> > DynamicLibraryList;
/** constructor is private, as its a singleton, preventing
construction other than via the instance() method and
therefore ensuring only one copy is ever constructed*/
Registry();
/** get the attached library with specified name.*/
DynamicLibraryList::iterator getLibraryItr(const std::string& fileName);
DynamicLibrary* getLibrary(const std::string& fileName);
PrototypeList _protoList;
ReaderWriterList _rwList;
DynamicLibraryList _dlList;
std::vector<int> _nodeProtoList;
std::vector<int> _imageProtoList;
bool _openingLibrary;
};
/** Proxy class for automatic registration of reader/writers with the
Registry.*/
template<class T>
class RegisterObjectProxy
{
public:
RegisterObjectProxy()
{
_obj = new T;
_obj->ref();
Registry::instance()->addPrototype(_obj);
}
~RegisterObjectProxy()
{
Registry::instance()->removePrototype(_obj);
_obj->unref();
}
protected:
T* _obj;
};
/** Proxy class for automatic registration of reader/writers with the
Registry.*/
template<class T>
class RegisterReaderWriterProxy
{
public:
RegisterReaderWriterProxy()
{
_rw = new T;
_rw->ref();
Registry::instance()->addReaderWriter(_rw);
}
~RegisterReaderWriterProxy()
{
Registry::instance()->removeReaderWriter(_rw);
_rw->unref();
}
protected:
T* _rw;
};
};
#endif // __SG_OBJECT_FACTORY_H

View File

@@ -1,39 +0,0 @@
#ifndef OSG_SCENE
#define OSG_SCENE 1
#include <osg/Group>
#include <osg/GeoState>
namespace osg {
/** The top level group node in a scene graph. */
class SG_EXPORT Scene : public Group
{
public :
Scene();
virtual Object* clone() const { return new Scene(); }
virtual bool isSameKindAs(Object* obj) { return dynamic_cast<Scene*>(obj)!=NULL; }
virtual const char* className() const { return "Scene"; }
virtual void accept(NodeVisitor& nv) { nv.apply(*this); }
/** set the scene's GeoState.*/
void setGState(osg::GeoState* gstate);
/** return the scene's GeoState.*/
osg::GeoState* getGState() { return _gstate; }
protected :
virtual ~Scene();
virtual bool readLocalData(Input& fr);
virtual bool writeLocalData(Output& fw);
osg::GeoState* _gstate;
};
};
#endif

View File

@@ -1,63 +0,0 @@
#ifndef OSG_SEG
#define OSG_SEG 1
#include <osg/Vec3>
#include <osg/Types>
#include <osg/Matrix>
#include <osg/Referenced>
#include <osg/BoundingBox>
#include <osg/BoundingSphere>
namespace osg {
/** Segment class for representing a line segment.*/
class SG_EXPORT Seg : public Referenced
{
public:
Seg() {};
Seg(const Seg& seg) : Referenced(),_s(seg._s),_e(seg._e) {}
Seg(const Vec3& s,const Vec3& e) : _s(s),_e(e) {}
virtual ~Seg() {}
Seg& operator = (const Seg& seg) { _s = seg._s; _e = seg._e; return *this; }
void set(const Vec3& s,const Vec3& e) { _s=s; _e=e; }
const Vec3& start() const { return _s; }
Vec3& start() { return _s; }
const Vec3& end() const { return _e; }
Vec3& end() { return _e; }
/** return true if segment intersects BoundingBox.*/
bool intersect(const BoundingBox& bb) const;
/** return true if segment intersects BoundingSphere and return the intersection ratio's.*/
bool intersect(const BoundingBox& bb,float& r1,float& r2) const;
/** return true if segment intersects BoundingSphere.*/
bool intersect(const BoundingSphere& bs) const;
/** return true if segment intersects BoundingSphere and return the intersection ratio's.*/
bool intersect(const BoundingSphere& bs,float& r1,float& r2) const;
/** return true if segment intersects triangle and set ratio long segment. */
bool intersect(const Vec3& v1,const Vec3& v2,const Vec3& v3,float& r);
/** post multiply a segment by matrix.*/
void mult(const Seg& seg,const Matrix& m) { _s = seg._s*m; _e = seg._e*m; }
/** pre multiply a segment by matrix.*/
void mult(const Matrix& m,const Seg& seg) { _s = m*seg._s; _e = m*seg._e; }
protected:
static bool intersectAndClip(Vec3& s,Vec3& e,const BoundingBox& bb);
Vec3 _s;
Vec3 _e;
};
};
#endif

View File

@@ -1,28 +0,0 @@
#ifndef OSG_SEQUENCE
#define OSG_SEQUENCE 1
#include <osg/Switch>
namespace osg {
/** Sequence - Switch node which allows iterators between children.
Note: has not been implemented yet!
*/
class SG_EXPORT Sequence : public Group
{
public :
Sequence() {}
virtual Object* clone() const { return new Sequence(); }
virtual bool isSameKindAs(Object* obj) { return dynamic_cast<Sequence*>(obj)!=NULL; }
virtual const char* className() const { return "Sequence"; }
virtual void accept(NodeVisitor& nv) { nv.apply(*this); }
protected :
virtual ~Sequence() {}
};
};
#endif

View File

@@ -1,196 +0,0 @@
#ifndef OSGUTIL_RENDERVISITOR
#define OSGUTIL_RENDERVISITOR 1
#include <osg/NodeVisitor>
#include <osg/BoundingSphere>
#include <osg/BoundingBox>
#include <osg/Matrix>
#include <osg/GeoSet>
#include <osg/GeoState>
#include <osg/Camera>
#include <osgUtil/Export>
#include <map>
#include <vector>
namespace osgUtil {
/** Container class for encapsulating the viewing state in local
coordinates, during the cull traversal.
*/
class OSGUTIL_EXPORT ViewState : public osg::Referenced
{
public:
ViewState();
osg::Matrix* _matrix;
osg::Matrix* _inverse;
osg::Vec3 _eyePoint;
osg::Vec3 _centerPoint;
osg::Vec3 _lookVector;
osg::Vec3 _upVector;
osg::Vec3 _frustumTopNormal;
osg::Vec3 _frustumBottomNormal;
osg::Vec3 _frustumLeftNormal;
osg::Vec3 _frustumRightNormal;
float _ratio;
bool _viewFrustumCullingActive;
bool _smallFeatureCullingActive;
bool isCulled(const osg::BoundingSphere& sp);
bool isCulled(const osg::BoundingBox& bb);
protected:
~ViewState();
};
/**
* Basic NodeVisitor implementation for rendering a scene.
* This visitor traverses the scene graph, collecting transparent and
* opaque osg::GeoSets into a depth sorted transparent bin and a state
* sorted opaque bin. The opaque bin is rendered first, and then the
* transparent bin in rendered in order from the furthest osg::GeoSet
* from the eye to the one nearest the eye.
*/
class OSGUTIL_EXPORT RenderVisitor : public osg::NodeVisitor
{
public:
RenderVisitor();
virtual ~RenderVisitor();
void reset();
virtual void apply(osg::Node&);
virtual void apply(osg::Geode& node);
virtual void apply(osg::Billboard& node);
virtual void apply(osg::LightSource& node);
virtual void apply(osg::Group& node);
virtual void apply(osg::DCS& node);
virtual void apply(osg::Switch& node);
virtual void apply(osg::LOD& node);
virtual void apply(osg::Scene& node);
void setGlobalState(osg::GeoState* global);
void setPerspective(const osg::Camera& camera);
void setPerspective(float fovy,float aspect,float znear,float zfar);
void setLookAt(const osg::Camera& camera);
void setLookAt(const osg::Vec3& eye,const osg::Vec3& center,const osg::Vec3& upVector);
void setLookAt(double eyeX,double eyeY,double eyeZ,
double centerX,double centerY,double centerZ,
double upX,double upY,double upZ);
void setLODBias(float bias) { _LODBias = bias; }
float getLODBias() { return _LODBias; }
enum TransparencySortMode {
LOOK_VECTOR_DISTANCE,
OBJECT_EYE_POINT_DISTANCE
};
void setTransparencySortMode(TransparencySortMode tsm) { _tsm = tsm; }
enum CullingType {
VIEW_FRUSTUM_CULLING,
SMALL_FEATURE_CULLING
};
/**
* Enables/disables the specified culling type.
* @param ct The culling type to enable/disable.
* @param active true enables the culling type, false disables.
*/
void setCullingActive(CullingType ct, bool active);
/**
* Returns the state of the specified culling type.
* @result true, if culling type is enabled, false otherwise.
*/
bool getCullingActive(CullingType ct);
/**
* Calculates the near_plane and the far_plane for the current
* camera view depending on the objects currently stored in the
* opaque and transparent bins.
* @param near_plane reference to a variable that can store the
* near plane result.
* @param far_plane reference to a variable that can store the
* far plane result.
* @result true, if near_plane and far_plane contain valid values,
* false otherwise.
*/
bool calcNearFar(double& near_plane, double& far_plane);
/**
* Renders the osg::GeoSets that were collected in the opaque and
* transparent bins before.
*/
void render();
protected:
void pushMatrix(const osg::Matrix& matrix);
void popMatrix();
osg::Matrix* getCurrentMatrix();
osg::Matrix* getInverseCurrentMatrix();
const osg::Vec3& getEyeLocal();
const osg::Vec3& getCenterLocal();
const osg::Vec3& getLookVectorLocal();
bool _viewFrustumCullingActive;
bool _smallFeatureCullingActive;
bool isCulled(const osg::BoundingSphere& sp);
bool isCulled(const osg::BoundingBox& bb);
typedef std::pair<osg::Matrix*,osg::GeoSet*> MatrixGeoSet;
typedef std::vector<ViewState*> ViewStateStack;
ViewStateStack _viewStateStack;
ViewState* _tvs;
ViewState* _cvs;
typedef std::multimap<osg::GeoState*,MatrixGeoSet> OpaqueList;
typedef std::multimap<float,MatrixGeoSet> TransparentList;
typedef std::map<osg::Matrix*,osg::Light*> LightList;
OpaqueList _opaqueGeoSets;
TransparentList _transparentGeoSets;
LightList _lights;
osg::GeoState* _globalState;
float _LODBias;
float _fovy;
float _aspect;
float _znear;
float _zfar;
void calculateClippingPlanes();
// frustum clipping normals.
osg::Vec3 _frustumTop;
osg::Vec3 _frustumBottom;
osg::Vec3 _frustumLeft;
osg::Vec3 _frustumRight;
TransparencySortMode _tsm;
};
};
#endif