00001 // Filename: lwoPoints.cxx 00002 // Created by: drose (24Apr01) 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 "lwoPoints.h" 00020 #include "lwoInputFile.h" 00021 00022 #include "dcast.h" 00023 #include "indent.h" 00024 00025 TypeHandle LwoPoints::_type_handle; 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Function: LwoPoints::get_num_points 00029 // Access: Public 00030 // Description: Returns the number of points of this group. 00031 //////////////////////////////////////////////////////////////////// 00032 int LwoPoints:: 00033 get_num_points() const { 00034 return _points.size(); 00035 } 00036 00037 //////////////////////////////////////////////////////////////////// 00038 // Function: LwoPoints::get_point 00039 // Access: Public 00040 // Description: Returns the nth point of this group. 00041 //////////////////////////////////////////////////////////////////// 00042 const LPoint3f &LwoPoints:: 00043 get_point(int n) const { 00044 nassertr(n >= 0 && n < (int)_points.size(), LPoint3f::zero()); 00045 return _points[n]; 00046 } 00047 00048 //////////////////////////////////////////////////////////////////// 00049 // Function: LwoPoints::read_iff 00050 // Access: Public, Virtual 00051 // Description: Reads the data of the chunk in from the given input 00052 // file, if possible. The ID and length of the chunk 00053 // have already been read. stop_at is the byte position 00054 // of the file to stop at (based on the current position 00055 // at in->get_bytes_read()). Returns true on success, 00056 // false otherwise. 00057 //////////////////////////////////////////////////////////////////// 00058 bool LwoPoints:: 00059 read_iff(IffInputFile *in, size_t stop_at) { 00060 LwoInputFile *lin = DCAST(LwoInputFile, in); 00061 00062 while (lin->get_bytes_read() < stop_at && !lin->is_eof()) { 00063 LPoint3f point = lin->get_vec3(); 00064 _points.push_back(point); 00065 } 00066 00067 return (lin->get_bytes_read() == stop_at); 00068 } 00069 00070 //////////////////////////////////////////////////////////////////// 00071 // Function: LwoPoints::write 00072 // Access: Public, Virtual 00073 // Description: 00074 //////////////////////////////////////////////////////////////////// 00075 void LwoPoints:: 00076 write(ostream &out, int indent_level) const { 00077 indent(out, indent_level) 00078 << get_id() << " { " << _points.size() << " points }\n"; 00079 }