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 00062 private: 00063 Mode _mode; 00064 00065 PUBLISHED: 00066 static int get_class_slot() { 00067 return _attrib_slot; 00068 } 00069 virtual int get_slot() const { 00070 return get_class_slot(); 00071 } 00072 00073 public: 00074 static void register_with_read_factory(); 00075 virtual void write_datagram(BamWriter *manager, Datagram &dg); 00076 00077 protected: 00078 static TypedWritable *make_from_bam(const FactoryParams ¶ms); 00079 void fillin(DatagramIterator &scan, BamReader *manager); 00080 00081 public: 00082 static TypeHandle get_class_type() { 00083 return _type_handle; 00084 } 00085 static void init_type() { 00086 RenderAttrib::init_type(); 00087 register_type(_type_handle, "RescaleNormalAttrib", 00088 RenderAttrib::get_class_type()); 00089 _attrib_slot = register_slot(_type_handle, 100, make_default); 00090 } 00091 virtual TypeHandle get_type() const { 00092 return get_class_type(); 00093 } 00094 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00095 00096 private: 00097 static TypeHandle _type_handle; 00098 static int _attrib_slot; 00099 }; 00100 00101 EXPCL_PANDA_PGRAPH ostream &operator << (ostream &out, RescaleNormalAttrib::Mode mode); 00102 EXPCL_PANDA_PGRAPH istream &operator >> (istream &in, RescaleNormalAttrib::Mode &mode); 00103 00104 #include "rescaleNormalAttrib.I" 00105 00106 #endif 00107