Re: [osg-users] Getting System time, milliseconds

2009-07-17 Thread Robert Osfield
Hi Kelly,

Is it just that you need to multiple the number of seconds my 1000 to
get milliseconds?  This does seem a bit of trivial answer so I do
wonder if your actually after something else.

Robert.

On Thu, Jul 16, 2009 at 7:05 PM, Kelly Fieldskelly.br...@jhuapl.edu wrote:
 Hi,

 I am new to Delta3d and have a question about getting system time (or local 
 time - really any form of time).  I am accessing time, but even though the 
 seconds is a float, it does not contain information for milliseconds.  How 
 would I get that?

 Here is my code...

 dtUtil::DateTime time;
 time.SetTimeType(dtUtil::DateTime::TimeType::SIMULATION_TIME);
 time.SetToLocalTime();
 double winTime = time.GetTimeInSeconds();

 Please help!!

 --
 Read this topic online here:
 http://forum.openscenegraph.org/viewtopic.php?p=15043#15043





 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Getting System time, milliseconds

2009-07-17 Thread Paul Melis

Robert Osfield wrote:

Is it just that you need to multiple the number of seconds my 1000 to
get milliseconds?  This does seem a bit of trivial answer so I do
wonder if your actually after something else.
  

I guess the OP wants millisecond precision?

Paul

Robert.

On Thu, Jul 16, 2009 at 7:05 PM, Kelly Fieldskelly.br...@jhuapl.edu wrote:
  

Hi,

I am new to Delta3d and have a question about getting system time (or local time - really 
any form of time).  I am accessing time, but even though the seconds is a 
float, it does not contain information for milliseconds.  How would I get that?

Here is my code...

dtUtil::DateTime time;
time.SetTimeType(dtUtil::DateTime::TimeType::SIMULATION_TIME);
time.SetToLocalTime();
double winTime = time.GetTimeInSeconds();

Please help!!

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=15043#15043





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

  


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Getting System time, milliseconds

2009-07-17 Thread Kelly Fields
Yes, sorry - I need millisecond precision.  So I need a number to be like 
3.234 seconds rather than 3 seconds

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=15066#15066





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Getting System time, milliseconds

2009-07-17 Thread Paul Melis

Kelly Fields wrote:

Yes, sorry - I need millisecond precision.  So I need a number to be like 3.234 seconds 
rather than 3 seconds
  
But aren't those methods you used from the Delta3D API? Are you sure 
these methods are in OSG?


Paul

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Getting System time, milliseconds

2009-07-17 Thread J.P. Delport

In OSG you could do something like:

osg::Timer *globalHighResTimer=osg::Timer::instance();
uint64_t currentTimeNanoSec()
{
osg::Timer_t timer_t=globalHighResTimer-tick();
		return (uint64_t)(timer_t * globalHighResTimer-getSecondsPerTick() * 
10);//timerTick * secondsPerTick * secondsToNanoSeconds

}

I'm not sure what the Delta3D class does under the hood.

jp

Paul Melis wrote:

Kelly Fields wrote:
Yes, sorry - I need millisecond precision.  So I need a number to be 
like 3.234 seconds rather than 3 seconds
  
But aren't those methods you used from the Delta3D API? Are you sure 
these methods are in OSG?


Paul

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


--
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.


This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.  MailScanner thanks Transtec Computers for their support.


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Getting System time, milliseconds

2009-07-17 Thread Paul Melis

J.P. Delport wrote:

In OSG you could do something like:

osg::Timer *globalHighResTimer=osg::Timer::instance();
uint64_t currentTimeNanoSec()
{
osg::Timer_t timer_t=globalHighResTimer-tick();
return (uint64_t)(timer_t * 
globalHighResTimer-getSecondsPerTick() * 10);//timerTick * 
secondsPerTick * secondsToNanoSeconds

}
This is win32-specific code right? There's no way you're going to get 
nanosecond precision on e.g. Linux where gettimeofday() is used by 
osg::Timer.


Paul
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Getting System time, milliseconds

2009-07-17 Thread Paul Melis

Paul Melis wrote:

J.P. Delport wrote:

In OSG you could do something like:

osg::Timer *globalHighResTimer=osg::Timer::instance();
uint64_t currentTimeNanoSec()
{
osg::Timer_t timer_t=globalHighResTimer-tick();
return (uint64_t)(timer_t * 
globalHighResTimer-getSecondsPerTick() * 10);//timerTick * 
secondsPerTick * secondsToNanoSeconds

}
This is win32-specific code right? There's no way you're going to get 
nanosecond precision on e.g. Linux where gettimeofday() is used by 
osg::Timer.
Ok ok, it would give valid results on non-windows, but give a false 
sense of nanosecond precision. And the OP needed only milliseconds...


Paul
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Getting System time, milliseconds

2009-07-17 Thread J.P. Delport

For Linux, play with this:

#ifndef WIN32

/// High resolution timers for Linux.


#define NSEC_PER_SEC 10LL

inline uint64_t timespec_to_ns(const struct timespec *ts)
{
return ((uint64_t) ts-tv_sec * NSEC_PER_SEC) + ts-tv_nsec;
}

/// Returns nanoseconds since epoch.
inline uint64_t currentTimeNanoSec()
{
struct timespec timestamp_ts;
//clock_gettime(CLOCK_MONOTONIC, timestamp_ts);
clock_gettime(CLOCK_REALTIME, timestamp_ts);
return timespec_to_ns(timestamp_ts);
}

inline uint64_t clockResNanoSec()
{
struct timespec timestamp_ts;
//clock_getres(CLOCK_MONOTONIC, timestamp_ts);
clock_getres(CLOCK_REALTIME, timestamp_ts);
return timespec_to_ns(timestamp_ts);
}

#if 0
int main(void)
{
printf(%lld, %lld\n, currentTimeNanoSec(), clockResNanoSec());
printf(%lld, %lld\n, currentTimeNanoSec(), clockResNanoSec());
}
#endif
#else

Paul Melis wrote:

Paul Melis wrote:

J.P. Delport wrote:

In OSG you could do something like:

osg::Timer *globalHighResTimer=osg::Timer::instance();
uint64_t currentTimeNanoSec()
{
osg::Timer_t timer_t=globalHighResTimer-tick();
return (uint64_t)(timer_t * 
globalHighResTimer-getSecondsPerTick() * 10);//timerTick * 
secondsPerTick * secondsToNanoSeconds

}
This is win32-specific code right? There's no way you're going to get 
nanosecond precision on e.g. Linux where gettimeofday() is used by 
osg::Timer.
Ok ok, it would give valid results on non-windows, but give a false 
sense of nanosecond precision. And the OP needed only milliseconds...


Paul
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


--
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.


This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.  MailScanner thanks Transtec Computers for their support.


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Getting System time, milliseconds

2009-07-17 Thread Paul Melis

J.P. Delport wrote:

For Linux, play with this:

#ifndef WIN32

/// High resolution timers for Linux.


#define NSEC_PER_SEC 10LL

inline uint64_t timespec_to_ns(const struct timespec *ts)
{
return ((uint64_t) ts-tv_sec * NSEC_PER_SEC) + ts-tv_nsec;
}

/// Returns nanoseconds since epoch.
inline uint64_t currentTimeNanoSec()
{
struct timespec timestamp_ts;
//clock_gettime(CLOCK_MONOTONIC, timestamp_ts);
clock_gettime(CLOCK_REALTIME, timestamp_ts);
return timespec_to_ns(timestamp_ts);
}

inline uint64_t clockResNanoSec()
{
struct timespec timestamp_ts;
//clock_getres(CLOCK_MONOTONIC, timestamp_ts);
clock_getres(CLOCK_REALTIME, timestamp_ts);
return timespec_to_ns(timestamp_ts);
}

#if 0
int main(void)
{
printf(%lld, %lld\n, currentTimeNanoSec(), clockResNanoSec());
printf(%lld, %lld\n, currentTimeNanoSec(), clockResNanoSec());
}
#endif
#else
Interesting, I had compared different ways of doing timing on Linux some 
time ago and was certain that clock_gettime() didn't work for me.
But now I tested it again it at least seems to provide enough precision. 
Ah well, I'll probably never figure out what happened :)


Thanks,
Paul

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Getting System time, milliseconds

2009-07-17 Thread Kelly Fields
I am working soley in Windows... any help there?

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=15078#15078





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Getting System time, milliseconds

2009-07-17 Thread Robert Osfield
Hi Kelly,

On Fri, Jul 17, 2009 at 12:35 PM, Kelly Fieldskelly.br...@jhuapl.edu wrote:
 Yes, sorry - I need millisecond precision.  So I need a number to be like 
 3.234 seconds rather than 3 seconds

I'm really surprised that Delta3D code gives an interger time back.
The OSG's FrameStamp stores the simulation in doubles so you'll get a
3.234 as you require, but for some reason Delta3D seems to be
truncating its own time.

Perhaps you could just ignore the Delta3D code and utilize the OSG's
osg::Timer to do timing or use osg::FrameStamp that the Viewer
maintains updating it for each new frame.  The OSG classes work on all
platforms.

Robert.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Getting System time, milliseconds

2009-07-16 Thread Kelly Fields
Hi,

I am new to Delta3d and have a question about getting system time (or local 
time - really any form of time).  I am accessing time, but even though the 
seconds is a float, it does not contain information for milliseconds.  How 
would I get that?

Here is my code...

dtUtil::DateTime time;   
time.SetTimeType(dtUtil::DateTime::TimeType::SIMULATION_TIME);
time.SetToLocalTime();
double winTime = time.GetTimeInSeconds();

Please help!!

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=15043#15043





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org