00001 // Filename: spheretexReflector.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 SPHERETEXREFLECTOR_H 00019 #define SPHERETEXREFLECTOR_H 00020 // 00021 //////////////////////////////////////////////////////////////////// 00022 // Includes 00023 //////////////////////////////////////////////////////////////////// 00024 #include <pandabase.h> 00025 00026 #include "shader.h" 00027 #include "spheretexShader.h" 00028 #include "casterShader.h" 00029 00030 //////////////////////////////////////////////////////////////////// 00031 // Defines 00032 //////////////////////////////////////////////////////////////////// 00033 00034 //////////////////////////////////////////////////////////////////// 00035 // Class : SpheretexReflector 00036 // Description : Creates a reflection texture map for a given object 00037 //////////////////////////////////////////////////////////////////// 00038 class EXPCL_SHADER SpheretexReflector : public CasterShader 00039 { 00040 public: 00041 00042 SpheretexReflector(int size = 256); 00043 ~SpheretexReflector(void); 00044 00045 virtual void pre_apply(Node *node, const AllAttributesWrapper &init_state, 00046 const AllTransitionsWrapper &net_trans, 00047 GraphicsStateGuardian *gsg); 00048 virtual void apply(Node *node, const AllAttributesWrapper &init_state, 00049 const AllTransitionsWrapper &net_trans, 00050 GraphicsStateGuardian *gsg); 00051 00052 // MPG - should we make this check for powers of 2? 00053 INLINE void set_size(int size) { _size = size; } 00054 INLINE int get_size(void) const { return _size; } 00055 00056 INLINE bool is_reflector(void) const { return _is_reflector; } 00057 INLINE void make_reflector(void) { _is_reflector = true; } 00058 INLINE void make_refractor(void) { _is_reflector = false; } 00059 00060 INLINE void set_near(float fnear) { _fnear = fnear; } 00061 INLINE float get_near(void) const { return _fnear; } 00062 INLINE void set_far(float ffar) { _ffar = ffar; } 00063 INLINE float get_far(void) const { return _ffar; } 00064 00065 //Override base class shader's set_priority to allow 00066 //us to set the priority of the contained projtex_shader at 00067 //the same time 00068 virtual void set_priority(int priority); 00069 virtual void set_multipass(bool on); 00070 00071 protected: 00072 00073 SpheretexShader _spheretex_shader; 00074 int _size; 00075 bool _is_reflector; 00076 float _fnear; 00077 float _ffar; 00078 00079 public: 00080 00081 static TypeHandle get_class_type() { 00082 return _type_handle; 00083 } 00084 static void init_type() { 00085 CasterShader::init_type(); 00086 register_type(_type_handle, "SpheretexReflector", 00087 CasterShader::get_class_type()); 00088 } 00089 virtual TypeHandle get_type() const { 00090 return get_class_type(); 00091 } 00092 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00093 00094 private: 00095 00096 static TypeHandle _type_handle; 00097 }; 00098 00099 #endif