Panda3D
|
00001 // Filename: scissorAttrib.h 00002 // Created by: drose (29Jul08) 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 SCISSORATTRIB_H 00016 #define SCISSORATTRIB_H 00017 00018 #include "pandabase.h" 00019 00020 #include "renderAttrib.h" 00021 #include "luse.h" 00022 00023 class FactoryParams; 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Class : ScissorAttrib 00027 // Description : This restricts rendering to within a rectangular 00028 // region of the scene, without otherwise affecting the 00029 // viewport or lens properties. Geometry that falls 00030 // outside the scissor region is not rendered. It is 00031 // akin to the OpenGL glScissor() function. 00032 // 00033 // The ScissorAttrib always specifies its region 00034 // relative to its enclosing DisplayRegion, in screen 00035 // space, and performs no culling. 00036 // 00037 // See ScissorEffect if you wish to define a 00038 // region relative to 2-D or 3-D coordinates in the 00039 // scene graph, with culling. 00040 //////////////////////////////////////////////////////////////////// 00041 class EXPCL_PANDA_PGRAPH ScissorAttrib : public RenderAttrib { 00042 private: 00043 ScissorAttrib(const LVecBase4f &frame); 00044 00045 PUBLISHED: 00046 static CPT(RenderAttrib) make_off(); 00047 INLINE static CPT(RenderAttrib) make(float left, float right, float bottom, float top); 00048 static CPT(RenderAttrib) make(const LVecBase4f &frame); 00049 static CPT(RenderAttrib) make_default(); 00050 00051 INLINE const LVecBase4f &get_frame() const; 00052 00053 public: 00054 virtual void output(ostream &out) const; 00055 00056 protected: 00057 virtual int compare_to_impl(const RenderAttrib *other) const; 00058 virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const; 00059 00060 private: 00061 LVecBase4f _frame; 00062 static CPT(RenderAttrib) _off; 00063 00064 PUBLISHED: 00065 static int get_class_slot() { 00066 return _attrib_slot; 00067 } 00068 virtual int get_slot() const { 00069 return get_class_slot(); 00070 } 00071 00072 public: 00073 static void register_with_read_factory(); 00074 virtual void write_datagram(BamWriter *manager, Datagram &dg); 00075 00076 protected: 00077 static TypedWritable *make_from_bam(const FactoryParams ¶ms); 00078 void fillin(DatagramIterator &scan, BamReader *manager); 00079 00080 public: 00081 static TypeHandle get_class_type() { 00082 return _type_handle; 00083 } 00084 static void init_type() { 00085 RenderAttrib::init_type(); 00086 register_type(_type_handle, "ScissorAttrib", 00087 RenderAttrib::get_class_type()); 00088 _attrib_slot = register_slot(_type_handle, 100, make_default); 00089 } 00090 virtual TypeHandle get_type() const { 00091 return get_class_type(); 00092 } 00093 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00094 00095 private: 00096 static TypeHandle _type_handle; 00097 static int _attrib_slot; 00098 }; 00099 00100 #include "scissorAttrib.I" 00101 00102 #endif 00103