Panda3D
fltTrackplane.cxx
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file fltTrackplane.cxx
10  * @author drose
11  * @date 2000-08-26
12  */
13 
14 #include "fltTrackplane.h"
15 #include "fltRecordReader.h"
16 #include "fltRecordWriter.h"
17 
18 /**
19  *
20  */
21 FltTrackplane::
22 FltTrackplane() {
23  _origin.set(0.0, 0.0, 0.0);
24  _alignment.set(0.0, 0.0, 0.0);
25  _plane.set(0.0, 0.0, 1.0);
26  _grid_state = false;
27  _grid_under = false;
28  _grid_angle = 0.0;
29  _grid_spacing_x = 1;
30  _grid_spacing_y = 1;
31  _snap_to_grid = false;
32  _grid_size = 10.0;
33  _grid_spacing_direction = 0;
34  _grid_mask = 0;
35 }
36 
37 /**
38  *
39  */
40 bool FltTrackplane::
41 extract_record(FltRecordReader &reader) {
42  DatagramIterator &iterator = reader.get_iterator();
43 
44  _origin[0] = iterator.get_be_float64();
45  _origin[1] = iterator.get_be_float64();
46  _origin[2] = iterator.get_be_float64();
47  _alignment[0] = iterator.get_be_float64();
48  _alignment[1] = iterator.get_be_float64();
49  _alignment[0] = iterator.get_be_float64();
50  _plane[0] = iterator.get_be_float64();
51  _plane[1] = iterator.get_be_float64();
52  _plane[2] = iterator.get_be_float64();
53  _grid_state = (iterator.get_be_int32() != 0);
54  _grid_under = (iterator.get_be_int32() != 0);
55  _grid_angle = iterator.get_be_float32();
56  iterator.skip_bytes(4);
57  _grid_spacing_x = iterator.get_be_float64();
58  _grid_spacing_y = iterator.get_be_float64();
59  _snap_to_grid = (iterator.get_be_int32() != 0);
60  _grid_size = iterator.get_be_float64();
61  _grid_spacing_direction = iterator.get_be_int32();
62  _grid_mask = iterator.get_be_int32();
63  iterator.skip_bytes(4);
64 
65  return true;
66 }
67 
68 /**
69  *
70  */
71 bool FltTrackplane::
72 build_record(FltRecordWriter &writer) const {
73  Datagram &datagram = writer.update_datagram();
74 
75  datagram.add_be_float64(_origin[0]);
76  datagram.add_be_float64(_origin[1]);
77  datagram.add_be_float64(_origin[2]);
78  datagram.add_be_float64(_alignment[0]);
79  datagram.add_be_float64(_alignment[1]);
80  datagram.add_be_float64(_alignment[2]);
81  datagram.add_be_float64(_plane[0]);
82  datagram.add_be_float64(_plane[1]);
83  datagram.add_be_float64(_plane[2]);
84  datagram.add_be_int32(_grid_state);
85  datagram.add_be_int32(_grid_under);
86  datagram.add_be_float32(_grid_angle);
87  datagram.pad_bytes(4);
88  datagram.add_be_float64(_grid_spacing_x);
89  datagram.add_be_float64(_grid_spacing_y);
90  datagram.add_be_int32(_snap_to_grid);
91  datagram.add_be_float64(_grid_size);
92  datagram.add_be_int32(_grid_spacing_direction);
93  datagram.add_be_int32(_grid_mask);
94  datagram.pad_bytes(4);
95 
96  return true;
97 }
This class writes a sequence of FltRecords to an ostream, handling opcode and size counts properly.
This class turns an istream into a sequence of FltRecords by reading a sequence of Datagrams and extr...
PN_float64 get_be_float64()
Extracts a 64-bit big-endian floating-point number.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int32_t get_be_int32()
Extracts a signed 32-bit big-endian integer.
PN_float32 get_be_float32()
Extracts a 32-bit big-endian single-precision floating-point number.
DatagramIterator & get_iterator()
Returns an iterator suitable for extracting data from the current record.
void pad_bytes(size_t size)
Adds the indicated number of zero bytes to the datagram.
Definition: datagram.cxx:99
void add_be_float64(PN_float64 value)
Adds a 64-bit big-endian floating-point number to the datagram.
Definition: datagram.I:209
void add_be_float32(PN_float32 value)
Adds a 32-bit single-precision big-endian floating-point number to the datagram.
Definition: datagram.I:200
void skip_bytes(size_t size)
Skips over the indicated number of bytes in the datagram.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A class to retrieve the individual data elements previously stored in a Datagram.
void add_be_int32(int32_t value)
Adds a signed 32-bit big-endian integer to the datagram.
Definition: datagram.I:154
Datagram & update_datagram()
Returns a modifiable reference to the datagram associated with the current record.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38