goat3dgfx

changeset 30:07c08d970cb4

added a rudimentary light class
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 02 Mar 2014 03:56:47 +0200
parents 9d581abd0bfb
children 3ba80928b530
files src/light.cc src/light.h src/xform_node.h
diffstat 3 files changed, 71 insertions(+), 3 deletions(-) [+]
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/light.cc	Sun Mar 02 03:56:47 2014 +0200
     1.3 @@ -0,0 +1,38 @@
     1.4 +#include "light.h"
     1.5 +
     1.6 +using namespace goatgfx;
     1.7 +
     1.8 +Light::Light()
     1.9 +{
    1.10 +	cast_shadows = false;
    1.11 +}
    1.12 +
    1.13 +void Light::set_color(const Vector3 &color)
    1.14 +{
    1.15 +	this->color = color;
    1.16 +}
    1.17 +
    1.18 +const Vector3 &Light::get_color() const
    1.19 +{
    1.20 +	return color;
    1.21 +}
    1.22 +
    1.23 +void Light::set_attenuation(const Vector3 &att)
    1.24 +{
    1.25 +	attenuation = att;
    1.26 +}
    1.27 +
    1.28 +const Vector3 &Light::get_attenuation() const
    1.29 +{
    1.30 +	return attenuation;
    1.31 +}
    1.32 +
    1.33 +void Light::set_shadow_caster(bool s)
    1.34 +{
    1.35 +	cast_shadows = s;
    1.36 +}
    1.37 +
    1.38 +bool Light::is_shadow_caster() const
    1.39 +{
    1.40 +	return cast_shadows;
    1.41 +}
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/src/light.h	Sun Mar 02 03:56:47 2014 +0200
     2.3 @@ -0,0 +1,30 @@
     2.4 +#ifndef GOATGFX_LIGHT_H_
     2.5 +#define GOATGFX_LIGHT_H_
     2.6 +
     2.7 +#include "xform_node.h"
     2.8 +
     2.9 +namespace goatgfx {
    2.10 +
    2.11 +class Light : public XFormNode {
    2.12 +private:
    2.13 +	Vector3 color;
    2.14 +	Vector3 attenuation;
    2.15 +
    2.16 +	bool cast_shadows;
    2.17 +
    2.18 +public:
    2.19 +	Light();
    2.20 +
    2.21 +	void set_color(const Vector3 &color);
    2.22 +	const Vector3 &get_color() const;
    2.23 +
    2.24 +	void set_attenuation(const Vector3 &att);
    2.25 +	const Vector3 &get_attenuation() const;
    2.26 +
    2.27 +	void set_shadow_caster(bool s);
    2.28 +	bool is_shadow_caster() const;
    2.29 +};
    2.30 +
    2.31 +}	// namespace goatgfx
    2.32 +
    2.33 +#endif	// GOATGFX_LIGHT_H_
     3.1 --- a/src/xform_node.h	Sun Mar 02 02:18:15 2014 +0200
     3.2 +++ b/src/xform_node.h	Sun Mar 02 03:56:47 2014 +0200
     3.3 @@ -1,5 +1,5 @@
     3.4 -#ifndef XFORM_NODE_H_
     3.5 -#define XFORM_NODE_H_
     3.6 +#ifndef GOATGFX_XFORM_NODE_H_
     3.7 +#define GOATGFX_XFORM_NODE_H_
     3.8  
     3.9  #include <vector>
    3.10  #include "vmath/vector.h"
    3.11 @@ -155,4 +155,4 @@
    3.12  
    3.13  }	// namespace goatgfx
    3.14  
    3.15 -#endif	/* XFORM_NODE_H_ */
    3.16 +#endif	/* GOATGFX_XFORM_NODE_H_ */