Panda3D
|
00001 // Filename: rescaleNormalAttrib.h 00002 // Created by: drose (30Dec04) 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 RESCALENORMALATTRIB_H 00016 #define RESCALENORMALATTRIB_H 00017 00018 #include "pandabase.h" 00019 00020 #include "renderAttrib.h" 00021 00022 class FactoryParams; 00023 00024 //////////////////////////////////////////////////////////////////// 00025 // Class : RescaleNormalAttrib 00026 // Description : Specifies how polygons are to be drawn. 00027 //////////////////////////////////////////////////////////////////// 00028 class EXPCL_PANDA_PGRAPH RescaleNormalAttrib : public RenderAttrib { 00029 PUBLISHED: 00030 enum Mode { 00031 // No adjustments are made to normals. 00032 M_none, 00033 00034 // Normals are counterscaled by the transform's uniform scale, if 00035 // supported by the graphics API. 00036 M_rescale, 00037 00038 // Normals are scaled to unit length; potentially expensive. 00039 M_normalize, 00040 00041 // Normals are counterscaled in the presence of a uniform scale 00042 // transform, or normalized in the presence of a non-uniform scale 00043 // transform. 00044 M_auto, 00045 }; 00046 00047 private: 00048 INLINE RescaleNormalAttrib(Mode mode); 00049 00050 PUBLISHED: 00051 static CPT(RenderAttrib) make(Mode mode); 00052 static CPT(RenderAttrib) make_default(); 00053 00054 INLINE Mode get_mode() const; 00055 00056 public: 00057 virtual void output(ostream &out) const; 00058 00059 protected: 00060 virtual int compare_to_impl(const RenderAttrib *other) const; 00061 virtual size_t get_hash_impl() const; 00062 00063 private: 00064 Mode _mode; 00065 00066 PUBLISHED: 00067 static int get_class_slot() { 00068 return _attrib_slot; 00069 } 00070 virtual int get_slot() const { 00071 return get_class_slot(); 00072 } 00073 00074 public: 00075 static void register_with_read_factory(); 00076 virtual void write_datagram(BamWriter *manager, Datagram &dg); 00077 00078 protected: 00079 static TypedWritable *make_from_bam(const FactoryParams ¶ms); 00080 void fillin(DatagramIterator &scan, BamReader *manager); 00081 00082 public: 00083 static TypeHandle get_class_type() { 00084 return _type_handle; 00085 } 00086 static void init_type() { 00087 RenderAttrib::init_type(); 00088 register_type(_type_handle, "RescaleNormalAttrib", 00089 RenderAttrib::get_class_type()); 00090 _attrib_slot = register_slot(_type_handle, 100, make_default); 00091 } 00092 virtual TypeHandle get_type() const { 00093 return get_class_type(); 00094 } 00095 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00096 00097 private: 00098 static TypeHandle _type_handle; 00099 static int _attrib_slot; 00100 }; 00101 00102 EXPCL_PANDA_PGRAPH ostream &operator << (ostream &out, RescaleNormalAttrib::Mode mode); 00103 EXPCL_PANDA_PGRAPH istream &operator >> (istream &in, RescaleNormalAttrib::Mode &mode); 00104 00105 #include "rescaleNormalAttrib.I" 00106 00107 #endif 00108