Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

pandatool/src/flt/fltEyepoint.cxx

Go to the documentation of this file.
00001 // Filename: fltEyepoint.cxx
00002 // Created by:  drose (26Aug00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #include "fltEyepoint.h"
00020 #include "fltRecordReader.h"
00021 #include "fltRecordWriter.h"
00022 
00023 ////////////////////////////////////////////////////////////////////
00024 //     Function: FltEyepoint::Constructor
00025 //       Access: Public
00026 //  Description:
00027 ////////////////////////////////////////////////////////////////////
00028 FltEyepoint::
00029 FltEyepoint() {
00030   _rotation_center.set(0.0, 0.0, 0.0);
00031   _hpr.set(0.0, 0.0, 0.0);
00032   _rotation = LMatrix4f::ident_mat();
00033   _fov = 60.0;
00034   _scale = 1.0;
00035   _near_clip = 0.1;
00036   _far_clip = 10000.0;
00037   _fly_through = LMatrix4f::ident_mat();
00038   _eyepoint.set(0.0, 0.0, 0.0);
00039   _fly_through_yaw = 0.0;
00040   _fly_through_pitch = 0.0;
00041   _eyepoint_direction.set(0.0, 1.0, 0.0);
00042   _no_fly_through = true;
00043   _ortho_mode = false;
00044   _is_valid = true;
00045   _image_offset_x = 0;
00046   _image_offset_y = 0;
00047   _image_zoom = 1;
00048 }
00049 
00050 ////////////////////////////////////////////////////////////////////
00051 //     Function: FltEyepoint::extract_record
00052 //       Access: Public
00053 //  Description:
00054 ////////////////////////////////////////////////////////////////////
00055 bool FltEyepoint::
00056 extract_record(FltRecordReader &reader) {
00057   DatagramIterator &iterator = reader.get_iterator();
00058 
00059   _rotation_center[0] = iterator.get_be_float64();
00060   _rotation_center[1] = iterator.get_be_float64();
00061   _rotation_center[2] = iterator.get_be_float64();
00062   _hpr[0] = iterator.get_be_float32();
00063   _hpr[1] = iterator.get_be_float32();
00064   _hpr[2] = iterator.get_be_float32();
00065   int r;
00066   for (r = 0; r < 4; r++) {
00067     for (int c = 0; c < 4; c++) {
00068       _rotation(r, c) = iterator.get_be_float32();
00069     }
00070   }
00071   _fov = iterator.get_be_float32();
00072   _scale = iterator.get_be_float32();
00073   _near_clip = iterator.get_be_float32();
00074   _far_clip = iterator.get_be_float32();
00075   for (r = 0; r < 4; r++) {
00076     for (int c = 0; c < 4; c++) {
00077       _fly_through(r, c) = iterator.get_be_float32();
00078     }
00079   }
00080   _eyepoint[0] = iterator.get_be_float32();
00081   _eyepoint[1] = iterator.get_be_float32();
00082   _eyepoint[2] = iterator.get_be_float32();
00083   _fly_through_yaw = iterator.get_be_float32();
00084   _fly_through_pitch = iterator.get_be_float32();
00085   _eyepoint_direction[0] = iterator.get_be_float32();
00086   _eyepoint_direction[1] = iterator.get_be_float32();
00087   _eyepoint_direction[2] = iterator.get_be_float32();
00088   _no_fly_through = (iterator.get_be_int32() != 0);
00089   _ortho_mode = (iterator.get_be_int32() != 0);
00090   _is_valid = (iterator.get_be_int32() != 0);
00091   _image_offset_x = iterator.get_be_int32();
00092   _image_offset_y = iterator.get_be_int32();
00093   _image_zoom = iterator.get_be_int32();
00094   iterator.skip_bytes(4*9);
00095 
00096   return true;
00097 }
00098 
00099 ////////////////////////////////////////////////////////////////////
00100 //     Function: FltEyepoint::build_record
00101 //       Access: Public
00102 //  Description:
00103 ////////////////////////////////////////////////////////////////////
00104 bool FltEyepoint::
00105 build_record(FltRecordWriter &writer) const {
00106   Datagram &datagram = writer.update_datagram();
00107 
00108   datagram.add_be_float64(_rotation_center[0]);
00109   datagram.add_be_float64(_rotation_center[1]);
00110   datagram.add_be_float64(_rotation_center[2]);
00111   datagram.add_be_float32(_hpr[0]);
00112   datagram.add_be_float32(_hpr[1]);
00113   datagram.add_be_float32(_hpr[2]);
00114   int r;
00115   for (r = 0; r < 4; r++) {
00116     for (int c = 0; c < 4; c++) {
00117       datagram.add_be_float32(_rotation(r, c));
00118     }
00119   }
00120   datagram.add_be_float32(_fov);
00121   datagram.add_be_float32(_scale);
00122   datagram.add_be_float32(_near_clip);
00123   datagram.add_be_float32(_far_clip);
00124   for (r = 0; r < 4; r++) {
00125     for (int c = 0; c < 4; c++) {
00126       datagram.add_be_float32(_fly_through(r, c));
00127     }
00128   }
00129   datagram.add_be_float32(_eyepoint[0]);
00130   datagram.add_be_float32(_eyepoint[1]);
00131   datagram.add_be_float32(_eyepoint[2]);
00132   datagram.add_be_float32(_fly_through_yaw);
00133   datagram.add_be_float32(_fly_through_pitch);
00134   datagram.add_be_float32(_eyepoint_direction[0]);
00135   datagram.add_be_float32(_eyepoint_direction[1]);
00136   datagram.add_be_float32(_eyepoint_direction[2]);
00137   datagram.add_be_int32(_no_fly_through);
00138   datagram.add_be_int32(_ortho_mode);
00139   datagram.add_be_int32(_is_valid);
00140   datagram.add_be_int32(_image_offset_x);
00141   datagram.add_be_int32(_image_offset_y);
00142   datagram.add_be_int32(_image_zoom);
00143   datagram.pad_bytes(4*9);
00144 
00145   return true;
00146 }

Generated on Fri May 2 03:19:08 2003 for Panda-Tool by doxygen1.3