2012-03-22 01:36:20 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
2003-01-22 00:45:36 +08:00
|
|
|
*
|
2012-03-22 01:36:20 +08:00
|
|
|
* This library is open source and may be redistributed and/or modified under
|
|
|
|
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
2003-01-22 00:45:36 +08:00
|
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
|
|
* included with this distribution, and on the openscenegraph.org website.
|
2012-03-22 01:36:20 +08:00
|
|
|
*
|
2003-01-22 00:45:36 +08:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2012-03-22 01:36:20 +08:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2003-01-22 00:45:36 +08:00
|
|
|
* OpenSceneGraph Public License for more details.
|
|
|
|
*/
|
2001-10-04 23:12:57 +08:00
|
|
|
|
2001-09-20 07:52:12 +08:00
|
|
|
#ifndef OSG_FRAMESTAMP
|
|
|
|
#define OSG_FRAMESTAMP 1
|
|
|
|
|
|
|
|
#include <osg/Referenced>
|
|
|
|
|
2002-02-23 07:39:42 +08:00
|
|
|
#if defined(__sgi) || (defined(WIN32) && !defined(__MWERKS__))
|
2001-10-15 23:50:55 +08:00
|
|
|
#include <time.h>
|
|
|
|
#else
|
2001-09-20 07:52:12 +08:00
|
|
|
#include <ctime>
|
2001-10-15 23:50:55 +08:00
|
|
|
using std::tm;
|
|
|
|
#endif
|
2001-09-20 07:52:12 +08:00
|
|
|
|
|
|
|
namespace osg
|
|
|
|
{
|
|
|
|
|
2004-08-31 22:08:12 +08:00
|
|
|
/** Class which encapsulates the frame number, reference time and calendar
|
2007-12-11 01:30:18 +08:00
|
|
|
* time of specific frame, used to synchronize operations on the scene graph
|
2004-08-31 22:08:12 +08:00
|
|
|
* and other machines when using a graphics cluster. Note the calendar
|
2001-09-20 07:52:12 +08:00
|
|
|
* time can be an artificial simulation time or capture the real time
|
2012-03-22 01:36:20 +08:00
|
|
|
* of day etc.*/
|
2005-04-12 01:14:17 +08:00
|
|
|
class OSG_EXPORT FrameStamp : public Referenced
|
2001-09-20 07:52:12 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
FrameStamp();
|
|
|
|
FrameStamp(const FrameStamp& fs);
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2001-09-20 07:52:12 +08:00
|
|
|
FrameStamp& operator = (const FrameStamp& fs);
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2010-12-23 04:11:05 +08:00
|
|
|
void setFrameNumber(unsigned int fnum) { _frameNumber = fnum; }
|
|
|
|
unsigned int getFrameNumber() const { return _frameNumber; }
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2001-09-20 07:52:12 +08:00
|
|
|
void setReferenceTime(double refTime) { _referenceTime = refTime; }
|
|
|
|
double getReferenceTime() const { return _referenceTime; }
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2007-01-25 20:02:51 +08:00
|
|
|
void setSimulationTime(double refTime) { _simulationTime = refTime; }
|
|
|
|
double getSimulationTime() const { return _simulationTime; }
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2002-05-23 03:58:43 +08:00
|
|
|
void setCalendarTime(const tm& calendarTime);
|
|
|
|
void getCalendarTime(tm& calendarTime) const;
|
2003-01-10 17:25:42 +08:00
|
|
|
|
2012-03-22 01:36:20 +08:00
|
|
|
// keep public to allow it to be permit allocation which is
|
2003-01-10 17:25:42 +08:00
|
|
|
// not on the heap used osgcluster
|
|
|
|
virtual ~FrameStamp();
|
|
|
|
|
2001-09-20 07:52:12 +08:00
|
|
|
protected:
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2003-01-10 17:25:42 +08:00
|
|
|
|
2001-09-20 07:52:12 +08:00
|
|
|
// note no dynamic memory is used so that data can be passed
|
|
|
|
// via a simple memory copy or within a data packet across
|
|
|
|
// the network.
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2010-12-23 04:11:05 +08:00
|
|
|
unsigned int _frameNumber;
|
|
|
|
double _referenceTime;
|
2012-03-22 01:36:20 +08:00
|
|
|
double _simulationTime;
|
|
|
|
|
2004-08-31 22:08:12 +08:00
|
|
|
// member variables of time.h's tm structure, copied here to
|
|
|
|
// ensure that all data is not dynamic. The tm structure itself
|
2007-12-11 01:30:18 +08:00
|
|
|
// is not completely consistent between implementations, which
|
2001-09-20 07:52:12 +08:00
|
|
|
// could be a problem when sending the FrameStamp across a network
|
2004-08-31 22:08:12 +08:00
|
|
|
// with different versions of tm (i.e mixing Unix and Windows.)
|
2001-09-20 07:52:12 +08:00
|
|
|
int tm_sec; /* Seconds. [0-60] (1 leap second) */
|
|
|
|
int tm_min; /* Minutes. [0-59] */
|
|
|
|
int tm_hour; /* Hours. [0-23] */
|
|
|
|
int tm_mday; /* Day. [1-31] */
|
|
|
|
int tm_mon; /* Month. [0-11] */
|
|
|
|
int tm_year; /* Year - 1900. */
|
|
|
|
int tm_wday; /* Day of week. [0-6] */
|
|
|
|
int tm_yday; /* Days in year. [0-365] */
|
|
|
|
int tm_isdst; /* DST. [-1/0/1]*/
|
2012-03-22 01:36:20 +08:00
|
|
|
|
|
|
|
|
2001-09-20 07:52:12 +08:00
|
|
|
};
|
|
|
|
|
2002-02-03 20:33:41 +08:00
|
|
|
}
|
2001-09-20 07:52:12 +08:00
|
|
|
|
|
|
|
|
|
|
|
#endif
|