//*****************************************************************************************
// Truevision - a 3d modeler for gnome and povray
//
// lights.cc
//
// Vincent LE PRINCE <vincentleprince@users.sourceforge.net>
// Copyright (C) 2000-2001 Vincent LE PRINCE
// This file is part of the TRUEVISION Package

//   This program is free software; you can redistribute it and/or modify
//   it under the terms of the GNU General Public License as published by
//   the Free Software Foundation; either version 2 of the License, or
//   (at your option) any later version.
//
//   This program 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 General Public License for more details.
//
//   You should have received a copy of the GNU General Public License
//   along with this program; if not, write to the Free Software
//   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */ 
//*******************************************************************************************
#ifndef TV_LIGHTS_H
#define TV_LIGHTS_H
using namespace std;
#include "object3d.h"

// Définition
class PointLight : public Object3D {
	protected:
		ObjParam_point *location;
		ObjParam_bool *media_attenuation;
		ObjParam_bool *media_interaction;
		ObjParam_color *color;

		ObjParam_bool_activator *fade;
		ObjParam_float *fade_distance, *fade_power;
		int light_id;

	public:
		PointLight( app_objs *appref );
		PointLight( PointLight & ref );
		~PointLight();
		Object3D *duplicate_yourself() { PointLight *res = new PointLight( *this ); return res; }
		
		void add_to_tree( GtkWidget *tree, GtkCTreeNode *node, GtkCTreeNode *sibling, const gchar *pix ) { Object3D::add_to_tree( tree, node, sibling, "object_light.xpm" ); }

		virtual void display( glview *view );
		virtual void edit_widget( GtkWidget *wid );
		virtual void destroy_editor();
		virtual void pref_changed();
		virtual void mouse_drag( struct drag_info *drag );
		
		virtual void output_to_povray( ofstream & file );
		virtual void save( ofstream & file );
		virtual bool load( ifstream & file, char *tag );
};

class AreaLight : public  PointLight {
	private:
		ObjParam_point *size;
		ObjParam_rotation *rotation;
		ObjParam_int *sizex;
		ObjParam_int *sizez;
		ObjParam_bool  *jitter;
		ObjParam_int *adaptive;
		
	public:
		AreaLight( app_objs *app_ref );
		AreaLight( AreaLight & ref );
		~AreaLight();
		Object3D *duplicate_yourself() { AreaLight *res = new AreaLight( *this ); return res; }
		
		void display( glview *view );
		void edit_widget( GtkWidget *wid );
		void destroy_editor();
		void pref_changed();
		void mouse_drag( struct drag_info *drag );
		
		void output_to_povray( ofstream & file );
		void save( ofstream & file );
		bool load( ifstream & file, char *tag );			
};


// SpotLight
class SpotLight : public Object3D {
	protected:
		ObjParam_point *location;
		ObjParam_bool *media_attenuation;
		ObjParam_bool *media_interaction;
		ObjParam_color *color;
		ObjParam_float *radius;
		ObjParam_float *falloff;
		ObjParam_int *tightness;
		ObjParam_point *pointat;
		ObjParam_bool *frustum;

		ObjParam_bool_activator *fade;
		ObjParam_float *fade_distance, *fade_power;
		int light_id;

	public:
		SpotLight( app_objs *appref );
		SpotLight( SpotLight & ref );
		~SpotLight();
		Object3D *duplicate_yourself() { SpotLight *res = new SpotLight( *this ); return res; }
		
		void add_to_tree( GtkWidget *tree, GtkCTreeNode *node, GtkCTreeNode *sibling, const gchar *pix ) { Object3D::add_to_tree( tree, node, sibling, "object_light.xpm" ); }
		void display( glview *view );
		void edit_widget( GtkWidget *wid );
		void destroy_editor();
		void pref_changed();
		void mouse_drag( struct drag_info *drag );	
		void output_to_povray( ofstream & file );
		virtual void save( ofstream & file );
		virtual bool load( ifstream & file, char *tag );

};

// Cylindrical light
class CylindricalLight : public SpotLight {
	public:
		CylindricalLight( app_objs *app_ref );
		CylindricalLight( CylindricalLight & ref ) : SpotLight( ref ) {}
		void display( glview *view );
		void output_to_povray( ofstream & file );		
		void save( ofstream & file );
		bool load( ifstream & file, char *tag );
};

#endif
