Panda3D
 All Classes Functions Variables Enumerations
timedCycle.cxx
1 // Filename: timedCycle.cxx
2 // Created by: jason (01Aug00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 #include "pandabase.h"
15 #include "timedCycle.h"
16 
17 #include "datagram.h"
18 #include "datagramIterator.h"
19 
20 ////////////////////////////////////////////////////////////////////
21 // Function: TimedCycle::write_object
22 // Description: Writes the contents of this object to the datagram
23 // for shipping out to a Bam file.
24 ////////////////////////////////////////////////////////////////////
25 void TimedCycle::
27  me.add_stdfloat(_cycle_time);
28  me.add_uint16(_element_count);
29 }
30 
31 ////////////////////////////////////////////////////////////////////
32 // Function: TimedCycle::fillin
33 // Access: Protected
34 // Description: This internal function is called by make_TimedCycle to
35 // read in all of the relevant data from the BamFile for
36 // the new TimedCycle.
37 ////////////////////////////////////////////////////////////////////
38 void TimedCycle::
40  _cycle_time = scan.get_stdfloat();
41  _element_count = scan.get_uint16();
42  _inv_cycle_time = 1. / _cycle_time;
43 
44  _global_clock = ClockObject::get_global_clock();
45  _next_switch = _global_clock->get_real_time() + _cycle_time;
46  _current_child = 0;
47 }
static ClockObject * get_global_clock()
Returns a pointer to the global ClockObject.
Definition: clockObject.I:271
PN_stdfloat get_stdfloat()
Extracts either a 32-bit or a 64-bit floating-point number, according to Datagram::set_stdfloat_doubl...
PN_uint16 get_uint16()
Extracts an unsigned 16-bit integer.
void add_stdfloat(PN_stdfloat value)
Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double().
Definition: datagram.I:240
void write_datagram(Datagram &me)
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition: timedCycle.cxx:26
void fillin(DatagramIterator &scan)
This internal function is called by make_TimedCycle to read in all of the relevant data from the BamF...
Definition: timedCycle.cxx:39
void add_uint16(PN_uint16 value)
Adds an unsigned 16-bit integer to the datagram.
Definition: datagram.I:181
A class to retrieve the individual data elements previously stored in a Datagram. ...
double get_real_time() const
Returns the actual number of seconds elapsed since the ClockObject was created, or since it was last ...
Definition: clockObject.I:68
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43