21 TypeHandle FltTransformRotateScale::_type_handle;
26 FltTransformRotateScale::
28 _center.set(0.0, 0.0, 0.0);
29 _reference_point.set(0.0, 0.0, 0.0);
30 _to_point.set(0.0, 0.0, 0.0);
44 set(
const LPoint3d ¢er,
const LPoint3d &reference_point,
45 const LPoint3d &to_point,
bool axis_scale) {
47 _reference_point = reference_point;
50 LVector3d v1 = _reference_point - _center;
51 LVector3d v2 = _to_point - _center;
54 acos(dot(normalize(v1), normalize(v2))) * 180.0 / MathNumbers::pi;
57 _axis_scale = length(v1);
60 _overall_scale = length(v1);
70 const LPoint3d &FltTransformRotateScale::
78 const LPoint3d &FltTransformRotateScale::
79 get_reference_point()
const {
80 return _reference_point;
86 const LPoint3d &FltTransformRotateScale::
87 get_to_point()
const {
96 return _overall_scale;
118 void FltTransformRotateScale::
120 LVector3d v1 = _reference_point - _center;
121 LVector3d v2 = _to_point - _center;
122 LVector3d rotate_axis = normalize(cross(v1, v2));
127 look_at(r1, v1, rotate_axis, CS_zup_right);
130 LMatrix4d::translate_mat(-_center) *
132 LMatrix4d::scale_mat(1.0, _axis_scale, 1.0) *
133 LMatrix4d::scale_mat(_overall_scale) *
135 LMatrix4d::rotate_mat(_angle, rotate_axis, CS_zup_right) *
136 LMatrix4d::translate_mat(_center);
144 bool FltTransformRotateScale::
146 if (!FltTransformRecord::extract_record(reader)) {
150 nassertr(reader.
get_opcode() == FO_rotate_and_scale,
false);
155 _center[0] = iterator.get_be_float64();
156 _center[1] = iterator.get_be_float64();
157 _center[2] = iterator.get_be_float64();
158 _reference_point[0] = iterator.get_be_float64();
159 _reference_point[1] = iterator.get_be_float64();
160 _reference_point[2] = iterator.get_be_float64();
161 _to_point[0] = iterator.get_be_float64();
162 _to_point[1] = iterator.get_be_float64();
163 _to_point[2] = iterator.get_be_float64();
164 _overall_scale = iterator.get_be_float32();
165 _axis_scale = iterator.get_be_float32();
166 _angle = iterator.get_be_float32();
168 iterator.skip_bytes(4);
181 bool FltTransformRotateScale::
183 if (!FltTransformRecord::build_record(writer)) {
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...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void check_remaining_size(const DatagramIterator &di, const std::string &name=std::string()) const
Checks that the iterator has no bytes left, as it should at the end of a successfully read record.
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.
void add_be_float64(PN_float64 value)
Adds a 64-bit big-endian floating-point number to the datagram.
void add_be_float32(PN_float32 value)
Adds a 32-bit single-precision big-endian floating-point number to the datagram.
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.
FltOpcode get_opcode() const
Returns the opcode associated with the current record.
A class to retrieve the individual data elements previously stored in a Datagram.
TypeHandle is the identifier used to differentiate C++ class types.
void set_opcode(FltOpcode opcode)
Sets the opcode associated with the current record.
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 ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.