dungeon_crawler

diff prototype/src/light.cc @ 21:0588f8a1a351

converting LIGHT meshes to lights
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 21 Aug 2012 06:33:36 +0300
parents 158de53b4e18
children fa8f89d06f6f
line diff
     1.1 --- a/prototype/src/light.cc	Tue Aug 21 04:57:33 2012 +0300
     1.2 +++ b/prototype/src/light.cc	Tue Aug 21 06:33:36 2012 +0300
     1.3 @@ -19,6 +19,11 @@
     1.4  	color = col;
     1.5  }
     1.6  
     1.7 +Color Light::get_color(bool with_intensity) const
     1.8 +{
     1.9 +	return with_intensity ? color * intensity : color;
    1.10 +}
    1.11 +
    1.12  void Light::use(int id) const
    1.13  {
    1.14  	glLightfv(GL_LIGHT0 + id, GL_DIFFUSE, &color.x);
    1.15 @@ -31,6 +36,7 @@
    1.16  	atten[0] = 1.0f;
    1.17  	atten[1] = 0.0f;
    1.18  	atten[2] = 0.0f;
    1.19 +	radius = 1.0;
    1.20  }
    1.21  
    1.22  PointLight::PointLight(const Vector3 &pos, const Color &col)
    1.23 @@ -40,6 +46,7 @@
    1.24  	atten[0] = 1.0f;
    1.25  	atten[1] = 0.0f;
    1.26  	atten[2] = 0.0f;
    1.27 +	radius = 1.0;
    1.28  }
    1.29  
    1.30  void PointLight::set_position(const Vector3 &pos)
    1.31 @@ -54,6 +61,16 @@
    1.32  	atten[2] = att_quad;
    1.33  }
    1.34  
    1.35 +void PointLight::set_radius(float rad)
    1.36 +{
    1.37 +	radius = rad;
    1.38 +}
    1.39 +
    1.40 +float PointLight::get_radius() const
    1.41 +{
    1.42 +	return radius;
    1.43 +}
    1.44 +
    1.45  void PointLight::use(int id) const
    1.46  {
    1.47  	float lpos[] = {pos.x, pos.y, pos.z, 1.0f};