Initial revision
This commit is contained in:
22
include/osgGLUT/Export
Normal file
22
include/osgGLUT/Export
Normal file
@@ -0,0 +1,22 @@
|
||||
// The following symbole has a underscore suffix for compatibility.
|
||||
#ifndef OSGGLUT_EXPORT_
|
||||
#define OSGGLUT_EXPORT_ 1
|
||||
|
||||
#ifdef WIN32
|
||||
#pragma warning( disable : 4251 )
|
||||
#pragma warning( disable : 4275 )
|
||||
#pragma warning( disable : 4786 )
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# ifdef OSGGLUT_LIBRARY
|
||||
# define OSGGLUT_EXPORT __declspec(dllexport)
|
||||
# else
|
||||
# define OSGGLUT_EXPORT __declspec(dllimport)
|
||||
#endif /* OSGGLUT_LIBRARY */
|
||||
#else
|
||||
#define OSGGLUT_EXPORT
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
108
include/osgGLUT/GLUTEventAdapter
Normal file
108
include/osgGLUT/GLUTEventAdapter
Normal file
@@ -0,0 +1,108 @@
|
||||
#ifndef OSGGLUT_GLUTEVENTADAPTER
|
||||
#define OSGGLUT_GLUTEVENTADAPTER 1
|
||||
|
||||
#include <osgUtil/GUIEventAdapter>
|
||||
|
||||
#include <osgGLUT/Export>
|
||||
|
||||
namespace osgGLUT{
|
||||
|
||||
/** Class for adapting GLUT events so that they can be used as input to osgUtil::CameraManipulators.*/
|
||||
class OSGGLUT_EXPORT GLUTEventAdapter : public osgUtil::GUIEventAdapter
|
||||
{
|
||||
|
||||
public:
|
||||
GLUTEventAdapter();
|
||||
virtual ~GLUTEventAdapter() {}
|
||||
|
||||
/** Get the EventType of the GUI event.*/
|
||||
virtual EventType getEventType() const { return _eventType; }
|
||||
|
||||
/** key pressed, return -1 if inapropriate for this event. */
|
||||
virtual int getKey() const { return _key; }
|
||||
|
||||
/** button pressed/released, return -1 if inappropriate for this event.*/
|
||||
virtual int getButton() const { return _button; }
|
||||
|
||||
/** window minimum x. */
|
||||
virtual int getXmin() const { return _Xmin; }
|
||||
|
||||
/** window maximum x. */
|
||||
virtual int getXmax() const { return _Xmax; }
|
||||
|
||||
/** window minimum y. */
|
||||
virtual int getYmin() const { return _Ymin; }
|
||||
|
||||
/** window maximum y. */
|
||||
virtual int getYmax() const { return _Ymax; }
|
||||
|
||||
/** current mouse x position.*/
|
||||
virtual int getX() const { return _mx; }
|
||||
|
||||
/** current mouse y position.*/
|
||||
virtual int getY() const { return _my; }
|
||||
|
||||
/** current mouse button state */
|
||||
virtual unsigned int getButtonMask() const { return _buttonMask; }
|
||||
|
||||
/** time in seconds of event. */
|
||||
virtual float time() const { return _time; }
|
||||
|
||||
|
||||
/** static method for setting window dimensions.*/
|
||||
static void setWindowSize(int Xmin, int Ymin, int Xmax, int Ymax);
|
||||
|
||||
/** static method for setting button state.*/
|
||||
static void setButtonMask(unsigned int buttonMask);
|
||||
|
||||
/** method for adapting resize events. */
|
||||
void adaptResize(float t, int Xmin, int Ymin, int Xmax, int Ymax);
|
||||
|
||||
/** method for adapting mouse motion events whilst mouse buttons are pressed.*/
|
||||
void adaptMouseMotion(float t, int x, int y);
|
||||
|
||||
/** method for adapting mouse motion events whilst no mouse button are pressed.*/
|
||||
void adaptMousePassiveMotion(float t,int x, int y);
|
||||
|
||||
/** method for adapting mouse button pressed/released events.*/
|
||||
void adaptMouse(float t,int button, int state, int x, int y);
|
||||
|
||||
/** method for adapting keyboard events.*/
|
||||
void adaptKeyboard(float t,unsigned char key, int x, int y );
|
||||
|
||||
/** method for adapting frame events, i.e. iddle/display callback.*/
|
||||
void adaptFrame(float t);
|
||||
|
||||
void copyStaticVariables();
|
||||
|
||||
protected:
|
||||
|
||||
EventType _eventType;
|
||||
int _key;
|
||||
int _button;
|
||||
int _Xmin,_Xmax;
|
||||
int _Ymin,_Ymax;
|
||||
int _mx;
|
||||
int _my;
|
||||
unsigned int _buttonMask;
|
||||
float _time;
|
||||
|
||||
// used to accumulate the button mask state, it represents
|
||||
// the current button mask state, which is modified by the
|
||||
// adaptMouse() method which then copies it to value _buttonMask
|
||||
// which required the mouse buttons state at the time of the event.
|
||||
static unsigned int _s_accumulatedButtonMask;
|
||||
|
||||
// used to store window min and max values.
|
||||
static int _s_Xmin;
|
||||
static int _s_Xmax;
|
||||
static int _s_Ymin;
|
||||
static int _s_Ymax;
|
||||
static int _s_mx;
|
||||
static int _s_my;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
35
include/osgGLUT/Version
Executable file
35
include/osgGLUT/Version
Executable file
@@ -0,0 +1,35 @@
|
||||
#ifndef OSGGLUT_VERSION
|
||||
#define OSGGLUT_VERSION 1
|
||||
|
||||
#include <osgGLUT/Export>
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
/**
|
||||
* getVersion_osgGLUT() returns the library version number.
|
||||
* Numbering conventon : osg_src-0.8-31 will return 0.8.31 from getVersion_osgGLUT.
|
||||
*
|
||||
* This C function can be also used to check for the existance of the OpenSceneGraph
|
||||
* library using autoconf and its m4 macro AC_CHECK_LIB.
|
||||
*
|
||||
* Here is the code to add to your configure.in:
|
||||
\verbatim
|
||||
#
|
||||
# Check for the OpenSceneGraph (OSG) GLUT library
|
||||
#
|
||||
AC_CHECK_LIB(osg, osgGLUTGetVersion, ,
|
||||
[AC_MSG_ERROR(OpenSceneGraph GLUT library not found. See http://www.openscenegraph.org)],)
|
||||
\endverbatim
|
||||
*/
|
||||
extern OSGGLUT_EXPORT const char* osgGLUTGetVersion();
|
||||
|
||||
/**
|
||||
* getLibraryName_osgGLUT() returns the library name in human friendly form.
|
||||
*/
|
||||
extern OSGGLUT_EXPORT const char* osgGLUTGetLibraryName();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
147
include/osgGLUT/Viewer
Normal file
147
include/osgGLUT/Viewer
Normal file
@@ -0,0 +1,147 @@
|
||||
#ifndef OSGGLUT_VIEWER
|
||||
#define OSGGLUT_VIEWER 1
|
||||
|
||||
#include <osg/OSG>
|
||||
#include <osg/GeoState>
|
||||
#include <osg/Scene>
|
||||
#include <osg/Light>
|
||||
#include <osg/DCS>
|
||||
#include <osg/GL>
|
||||
#include <osg/NodeVisitor>
|
||||
#include <osg/Geode>
|
||||
#include <osg/Timer>
|
||||
|
||||
#include <osgUtil/GUIEventAdapter>
|
||||
#include <osgUtil/CameraManipulator>
|
||||
#include <osgUtil/SceneView>
|
||||
|
||||
#include <osgGLUT/Export>
|
||||
|
||||
#ifdef SGV_USE_RTFS
|
||||
#include <rtfs/rtfs.h>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifdef OSG_USE_IO_DOT_H
|
||||
#include <iostream.h>
|
||||
#else
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
#endif
|
||||
|
||||
namespace osgGLUT{
|
||||
|
||||
/** A basic viewer base class which provides a window, simple keyboard and mouse interaction.
|
||||
* Please note, this viewer class has been developed via a rather haphazzard
|
||||
* path and *needs* a total rewrite. It currently surfices for osg demo's
|
||||
* but shouldn't be viewed as the be all or end of osg viewer classes.
|
||||
* Someone please rewrite it :-)
|
||||
*/
|
||||
class OSGGLUT_EXPORT Viewer : public osgUtil::GUIActionAdapter
|
||||
{
|
||||
public:
|
||||
|
||||
Viewer();
|
||||
virtual ~Viewer();
|
||||
|
||||
virtual bool init( osg::Node* );
|
||||
|
||||
virtual bool run();
|
||||
|
||||
// called on each frame redraw..
|
||||
virtual bool update();
|
||||
virtual bool traverse();
|
||||
virtual bool draw();
|
||||
|
||||
// initialize the clock.
|
||||
long initClock();
|
||||
// time since initClock() in seconds.
|
||||
float clockSeconds() { return _timer.delta_s(_initialTick,clockTick()); }
|
||||
|
||||
// update the number of ticks since the last frame update.
|
||||
osg::Timer_t updateFrameTick();
|
||||
|
||||
// time from the current frame update and the previous one in seconds.
|
||||
float frameSeconds() { return _timer.delta_s(_lastFrameTick,_frameTick); }
|
||||
float frameRate() { return 1.0f/frameSeconds(); }
|
||||
|
||||
void help(ostream& fout);
|
||||
|
||||
// hande multiple camera.
|
||||
void registerCameraManipulator(osgUtil::CameraManipulator* cm);
|
||||
void selectCameraManipulator(unsigned int pos);
|
||||
|
||||
// derived from osgUtil::GUIActionAdapter
|
||||
virtual void needRedraw(bool /*needed*/) {} // redraw always done.
|
||||
virtual void needContinuousUpdate(bool /*needed*/) {} // continous update always
|
||||
virtual void needWarpPointer(int x,int y);
|
||||
|
||||
protected:
|
||||
|
||||
static void displayCB();
|
||||
static void reshapeCB(GLint w, GLint h);
|
||||
static void visibilityCB(int state);
|
||||
static void mouseMotionCB(int x, int y);
|
||||
static void mousePassiveMotionCB(int x, int y);
|
||||
static void mouseCB(int button, int state, int x, int y);
|
||||
static void keyboardCB(unsigned char key, int x, int y );
|
||||
|
||||
virtual void display();
|
||||
virtual void reshape(GLint w, GLint h);
|
||||
virtual void visibility(int state);
|
||||
virtual void mouseMotion(int x, int y);
|
||||
virtual void mousePassiveMotion(int x, int y);
|
||||
virtual void mouse(int button, int state, int x, int y);
|
||||
virtual void keyboard(unsigned char key, int x, int y);
|
||||
|
||||
|
||||
static Viewer* s_theViewer;
|
||||
|
||||
osg::ref_ptr<osgUtil::SceneView> _sceneView;
|
||||
|
||||
typedef std::vector<osg::ref_ptr<osgUtil::CameraManipulator> > CameraManipList;
|
||||
|
||||
osg::ref_ptr<osgUtil::CameraManipulator> _cameraManipulator;
|
||||
CameraManipList _cameraManipList;
|
||||
|
||||
std::string _saveFileName;
|
||||
|
||||
int ww, wh;
|
||||
|
||||
#ifdef SGV_USE_RTFS
|
||||
unsigned int frame_rate;
|
||||
RTfs *fs;
|
||||
#endif
|
||||
|
||||
bool _viewFrustumCullingActive;
|
||||
bool _smallFeatureCullingActive;
|
||||
|
||||
int mx, my, mbutton;
|
||||
int polymode;
|
||||
int texture;
|
||||
int backface;
|
||||
int lighting;
|
||||
int flat_shade;
|
||||
int _two_sided_lighting;
|
||||
bool fullscreen;
|
||||
int _saved_ww,_saved_wh;
|
||||
bool _printStats;
|
||||
bool _useDisplayLists;
|
||||
|
||||
osg::Timer _timer;
|
||||
osg::Timer_t _tickRatePerSecond;
|
||||
osg::Timer_t _initialTick;
|
||||
osg::Timer_t _lastFrameTick;
|
||||
osg::Timer_t _frameTick;
|
||||
|
||||
// system tick.
|
||||
osg::Timer_t clockTick();
|
||||
osg::Timer_t frameTick();
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // SG_VIEWIER_H
|
||||
Reference in New Issue
Block a user