00001 // Filename: projtexShadower.h 00002 // Created by: mike (09Jan97) 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 #ifndef PROJTEXSHADOWER_H 00019 #define PROJTEXSHADOWER_H 00020 // 00021 //////////////////////////////////////////////////////////////////// 00022 // Includes 00023 //////////////////////////////////////////////////////////////////// 00024 #include <pandabase.h> 00025 00026 #include "casterShader.h" 00027 #include "projtexShader.h" 00028 00029 #include <pt_Node.h> 00030 00031 //////////////////////////////////////////////////////////////////// 00032 // Defines 00033 //////////////////////////////////////////////////////////////////// 00034 00035 //////////////////////////////////////////////////////////////////// 00036 // Class : ProjtexShadower 00037 // Description : Creates the shadow of a casting object(s) and projects 00038 // it onto a receiving object(s) from a given light 00039 // frustum 00040 //////////////////////////////////////////////////////////////////// 00041 class EXPCL_SHADER ProjtexShadower : public CasterShader 00042 { 00043 public: 00044 00045 ProjtexShadower(int size = 256); 00046 00047 virtual void pre_apply(Node *node, const AllAttributesWrapper &init_state, 00048 const AllTransitionsWrapper &net_trans, 00049 GraphicsStateGuardian *gsg); 00050 virtual void apply(Node *node, const AllAttributesWrapper &init_state, 00051 const AllTransitionsWrapper &net_trans, 00052 GraphicsStateGuardian *gsg); 00053 00054 // MPG - should we make this check for powers of 2? 00055 INLINE void set_size(int size) { _size = size; } 00056 INLINE int get_size(void) { return _size; } 00057 00058 //Override base class shader's set_priority to allow 00059 //us to set the priority of the contained projtex_shader at 00060 //the same time 00061 virtual void set_priority(int priority); 00062 virtual void set_multipass(bool on); 00063 00064 protected: 00065 00066 PT(ProjtexShader) _projtex_shader; 00067 int _size; 00068 00069 public: 00070 00071 static TypeHandle get_class_type() { 00072 return _type_handle; 00073 } 00074 static void init_type() { 00075 CasterShader::init_type(); 00076 register_type(_type_handle, "ProjtexShadower", 00077 CasterShader::get_class_type()); 00078 } 00079 virtual TypeHandle get_type() const { 00080 return get_class_type(); 00081 } 00082 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00083 00084 private: 00085 00086 static TypeHandle _type_handle; 00087 }; 00088 00089 #endif