Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/shader/spotlightShader.cxx

Go to the documentation of this file.
00001 // Filename: spotlightShader.cxx
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 #include "spotlightShader.h"
00019 #include "config_shader.h"
00020 
00021 #include <spotlight.h>
00022 
00023 ////////////////////////////////////////////////////////////////////
00024 // Static variables
00025 ////////////////////////////////////////////////////////////////////
00026 TypeHandle SpotlightShader::_type_handle;
00027 
00028 ////////////////////////////////////////////////////////////////////
00029 //     Function: SpotlightShader::constructor
00030 //       Access:
00031 //  Description:
00032 ////////////////////////////////////////////////////////////////////
00033 SpotlightShader::SpotlightShader(int size, float radius) : ProjtexShader(NULL, ColorBlendProperty::M_multiply_add)
00034 {
00035   Texture* texture = new Texture;
00036   texture->set_minfilter(Texture::FT_linear);
00037   texture->set_magfilter(Texture::FT_linear);
00038   texture->set_wrapu(Texture::WM_clamp);
00039   texture->set_wrapv(Texture::WM_clamp);
00040   texture->_pbuffer = new PixelBuffer(PixelBuffer::rgb_buffer(size, size));
00041   set_texture(texture);
00042   _radius = radius;
00043 }
00044 
00045 ////////////////////////////////////////////////////////////////////
00046 //     Function: SpotlightShader::config
00047 //       Access:
00048 //  Description:
00049 ////////////////////////////////////////////////////////////////////
00050 void SpotlightShader::config(void)
00051 {
00052   Configurable::config();
00053 
00054   if (get_num_frusta() == 0) {
00055     shader_cat.error()
00056       << "SpotlightShader::config() - no lights in frusta list" << endl;
00057     return;
00058   } else if (get_num_frusta() > 1) {
00059     shader_cat.warning()
00060       << "SpotlightShader::config() - frusta list has more than one "
00061       << "frustum - ignore all but the first one for now..." << endl;
00062   }
00063   if (_frusta[0]->get_type() != Spotlight::get_class_type()) {
00064     shader_cat.error()
00065       << "SpotlightShader::config() - frusta is not a spotlight" << endl;
00066     return;
00067   }
00068   Spotlight* spotlight = (Spotlight *)_frusta[0];
00069 
00070   spotlight->make_image(_texture, _radius);
00071 }
00072 
00073 
00074 
00075 
00076 

Generated on Fri May 2 00:44:06 2003 for Panda by doxygen1.3