Logo Search packages:      
Sourcecode: yafray version File versions

light.h

/****************************************************************************
 *
 *                light.h: Generic light api 
 *      This is part of the yafray package
 *      Copyright (C) 2002  Alejandro Conty EstÚvez
 *
 *      This library is free software; you can redistribute it and/or
 *      modify it under the terms of the GNU Lesser General Public
 *      License as published by the Free Software Foundation; either
 *      version 2.1 of the License, or (at your option) any later version.
 *
 *      This library is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *      Lesser General Public License for more details.
 *
 *      You should have received a copy of the GNU Lesser General Public
 *      License along with this library; if not, write to the Free Software
 *      Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *      
 */
#ifndef __LIGHT_H
#define __LIGHT_H

#ifdef HAVE_CONFIG_H
#include<config.h>
#endif


__BEGIN_YAFRAY
class light_t;
__END_YAFRAY
#include"vector3d.h"
#include"scene.h"
#include"color.h"


__BEGIN_YAFRAY

class YAFRAYCORE_EXPORT emitter_t
{
      public:
            virtual ~emitter_t() {};
            virtual void numSamples(int n) {};
            virtual void getDirection(int num,point3d_t &p,vector3d_t &dir,color_t &c)const=0;
            virtual bool storeDirect()const {return false;};
};

/** Abstract interface for light rendering.
 * 
 * This is the interface the render will use to handle lights.
 * If you implement a light, you have to inherit from this
 * and cover the virtual methods
 *
 */

00057 class YAFRAYCORE_EXPORT light_t
{
      public:
            /// Constructor common for all lights
00061             light_t() {use_in_render=true;use_in_indirect=true;};
            virtual ~light_t() {};
            /** Returns the color for a given point.
             *
             * It takes a surface point, and taking its assigned shader must
             * compute the reflected color
             * @param s is the scene being rendered.
             * @param sp is the surface point being shaded.
             * @param eye is a vector pointing to the viewer.
             * @see surfacePoint_t
             *
             */
            virtual color_t illuminate(renderState_t &state,const scene_t &s,
                        const surfacePoint_t sp, const vector3d_t &eye)const=0;
            /// Returns the position if it's possible.
            virtual point3d_t position() const=0;
            virtual emitter_t * getEmitter(int maxsamples)const {return NULL;};

            /** Light initialization.
             * 
             * Sometimes a light has to precompute data from the scene before
             * the render starts. It happens with shadow map lights or photon
             * lights. This method is called before the render.
             * 
             * @param scene is the scene that will be rendered.
             *
             */
            virtual void init(scene_t &scene)=0;
            virtual void postInit(scene_t &scene) {};

            bool useInRender()const {return use_in_render;};
            void useInRender(bool u) {use_in_render=u;};
            bool useInIndirect()const {return use_in_indirect;};
            void useInIndirect(bool u) {use_in_indirect=u;};

      protected:
            bool use_in_render;
            bool use_in_indirect;
};

__END_YAFRAY

#endif

Generated by  Doxygen 1.6.0   Back to index