/* Copyright (C) 1997, 1998, 1999, 2000 by Alex Pfaffe (Digital Dawn Graphics Inc) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _ddgLightModel_Class_ #define _ddgLightModel_Class_ #include "struct/ddgcolor.h" #include "struct/ddggroup.h" class WEXP ddgLightModel: public ddgGroup { typedef ddgGroup super; bool _state; ddgColor4 _lightmodel_ambient; bool _twosided; bool _local; bool _colorMaterial; public: ddgLightModel( ddgColor4 *a = NULL, bool t = false, bool l = false, bool c = false ) { _state = true; _twosided = t; _local = l; _colorMaterial = c; _lightmodel_ambient.set( a ? a : (ddgColor4*)ddgColor4(100,100,100,255)); } bool draw( ddgContext *ctx ); void ambient( ddgColor4 *col) { _lightmodel_ambient.set(col); } void ambient( ddgColor3 *col, unsigned char a = 255) { _lightmodel_ambient.set(col->v[0],col->v[1],col->v[2],a); } void ambient( unsigned char r, unsigned char g, unsigned char b, unsigned char a = 255) { _lightmodel_ambient.set(r,g,b,a); } void local( bool l) { _local = l; } void twosided( bool t) { _twosided = t; } void colormaterial( bool t) { _colorMaterial = t; } void state( bool s) { _state = s; } }; class WEXP ddgLight: public ddgNode { typedef ddgNode super; static unsigned int lightid; unsigned int _id; float _spotlight; ddgVector4 _pos; ddgVector3 _direction; ddgColor4 _colour_ambient; ddgColor4 _colour_diffuse; ddgColor4 _colour_specular; bool _fixed:1; bool _fspotlight:1; bool _fdirection:1; bool _fpos:1; bool _fambient:1; bool _fdiffuse:1; bool _fspecular:1; public: ddgLight(void); // int update(void); // void activate(void); // void deactivate(void); bool draw( ddgContext *ctx); // Set/Get methods. void ambient( ddgColor4 *c ) { _colour_ambient.set(c); _fambient = true;} void ambient( unsigned char r, unsigned char g, unsigned char b ) { _colour_ambient.set(r,g,b,255); _fambient = true; } ddgColor4 *ambient(void) { return &_colour_ambient; } void diffuse( ddgColor4 *c ) { _colour_diffuse.set(c); _fdiffuse = true; } void diffuse( float r, float g, float b ) { _colour_diffuse.set(r,g,b,255); _fdiffuse = true; } ddgColor4 *diffuse(void) { return &_colour_diffuse; } void specular( ddgColor4 *c ) { _colour_specular.set(c); _fspecular = true; } void specular( unsigned char r, unsigned char g, unsigned char b ) { _colour_specular.set(r,g,b,255); _fspecular = true; } ddgColor4 *specular(void) { return &_colour_specular; } void pos( ddgVector3 *p ) { _pos.set(p->v[0],p->v[1],p->v[2],_pos[3]); _fpos = true; } void pos( float i, float j, float k ) { _pos.set(i,j,k,_pos[3]); _fpos = true; } ddgVector4 *pos( void ) { return &_pos; } void direction( ddgVector3 *d ) { _direction.set(d); _fdirection = true; } void direction( float i, float j, float k ) { _direction.set(i,j,k); _fdirection = true; } void direction( float theta, float phi ); ddgVector3 *direction(void ) { return &_direction; } void distance( float d ) { _pos.v[3] = d; _fpos = true; } float distance(void) { return _pos[3]; } void fixed(bool f) { _fixed = f; } bool fixed(void) { return _fixed; } void spotlight(float size) { _spotlight = size; if (size) _fspotlight = true;} float spotlight(void) { return _spotlight; } }; #endif