Panda3D
|
00001 // Filename: fltVertex.h 00002 // Created by: drose (25Aug00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef FLTVERTEX_H 00016 #define FLTVERTEX_H 00017 00018 #include "pandatoolbase.h" 00019 00020 #include "fltRecord.h" 00021 #include "fltPackedColor.h" 00022 00023 #include "luse.h" 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Class : FltVertex 00027 // Description : Represents a single vertex in the vertex palette. 00028 // Flt files index vertices by their byte offset in the 00029 // vertex palette; within this library, we map those 00030 // byte offsets to pointers automatically. 00031 // 00032 // This may represent a vertex with or without a normal 00033 // or texture coordinates. 00034 //////////////////////////////////////////////////////////////////// 00035 class FltVertex : public FltRecord { 00036 public: 00037 FltVertex(FltHeader *header); 00038 00039 FltOpcode get_opcode() const; 00040 int get_record_length() const; 00041 00042 enum Flags { 00043 F_hard_edge = 0x8000, 00044 F_normal_frozen = 0x4000, 00045 F_no_color = 0x2000, 00046 F_packed_color = 0x1000 00047 }; 00048 00049 int _color_name_index; 00050 unsigned int _flags; 00051 LPoint3d _pos; 00052 LPoint3 _normal; 00053 LPoint2 _uv; 00054 FltPackedColor _packed_color; 00055 int _color_index; 00056 00057 bool _has_normal; 00058 bool _has_uv; 00059 00060 public: 00061 INLINE bool has_color() const; 00062 LColor get_color() const; 00063 INLINE void set_color(const LColor &color); 00064 LRGBColor get_rgb() const; 00065 void set_rgb(const LRGBColor &rgb); 00066 00067 00068 protected: 00069 virtual bool extract_record(FltRecordReader &reader); 00070 virtual bool build_record(FltRecordWriter &writer) const; 00071 00072 public: 00073 virtual TypeHandle get_type() const { 00074 return get_class_type(); 00075 } 00076 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00077 static TypeHandle get_class_type() { 00078 return _type_handle; 00079 } 00080 static void init_type() { 00081 FltRecord::init_type(); 00082 register_type(_type_handle, "FltVertex", 00083 FltRecord::get_class_type()); 00084 } 00085 00086 private: 00087 static TypeHandle _type_handle; 00088 00089 friend class FltHeader; 00090 }; 00091 00092 #include "fltVertex.I" 00093 00094 #endif 00095 00096