Example: Changed glyph-outline.shape for use with FontConfig.
[shapes.git] / source / lighttypes.h
blob4259b26387fc7e46d69f3808f01ade190f13ce39
1 /* This file is part of Shapes.
3 * Shapes is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * any later version.
8 * Shapes is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with Shapes. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright 2008 Henrik Tidefelt
19 #pragma once
21 #include "Shapes_Lang_decls.h"
23 #include "refcount.h"
24 #include "shapesvalue.h"
25 #include "statetypes.h"
26 #include "functiontypes.h"
27 #include "elementarycoords.h"
29 namespace Shapes
31 namespace Lang
34 class SpecularReflection : public Lang::Value
36 public:
37 SpecularReflection( );
38 virtual ~SpecularReflection( );
39 virtual double weight( ) const = 0;
40 virtual RefCountPtr< const Lang::SpecularReflection > multiply( double scalar ) const = 0;
41 virtual Concrete::Gray illuminate( const Concrete::Coords3D & point, const Concrete::Length eyez, const Concrete::UnitFloatTriple & unitNormal, const Lang::GrayLight & light ) const = 0;
42 virtual Concrete::RGB illuminate( const Concrete::Coords3D & point, const Concrete::Length eyez, const Concrete::UnitFloatTriple & unitNormal, const Lang::RGBLight & light ) const = 0;
43 virtual Concrete::Gray illuminate( const Concrete::Coords3D & point, const Concrete::Length eyez, const Concrete::UnitFloatTriple & unitNormal, const Concrete::Gray & autoIntensity ) const = 0;
44 virtual Concrete::RGB illuminate( const Concrete::Coords3D & point, const Concrete::Length eyez, const Concrete::UnitFloatTriple & unitNormal, const Concrete::RGB & autoIntensity ) const = 0;
45 TYPEINFODECL;
46 DISPATCHDECL;
47 virtual void gcMark( Kernel::GCMarkedSet & marked ); // This method resides here since we know (that today) no sub classes need to do gcMark.
50 class SpecularReflectionTerm : public Lang::SpecularReflection
52 double weight_;
53 double exponent_;
54 public:
55 SpecularReflectionTerm( double weight, double exponent );
56 virtual ~SpecularReflectionTerm( );
57 virtual double weight( ) const;
58 virtual RefCountPtr< const Lang::SpecularReflection > multiply( double scalar ) const;
59 virtual Concrete::Gray illuminate( const Concrete::Coords3D & point, const Concrete::Length eyez, const Concrete::UnitFloatTriple & unitNormal, const Lang::GrayLight & light ) const;
60 virtual Concrete::RGB illuminate( const Concrete::Coords3D & point, const Concrete::Length eyez, const Concrete::UnitFloatTriple & unitNormal, const Lang::RGBLight & light ) const;
61 virtual Concrete::Gray illuminate( const Concrete::Coords3D & point, const Concrete::Length eyez, const Concrete::UnitFloatTriple & unitNormal, const Concrete::Gray & autoIntensity ) const;
62 virtual Concrete::RGB illuminate( const Concrete::Coords3D & point, const Concrete::Length eyez, const Concrete::UnitFloatTriple & unitNormal, const Concrete::RGB & autoIntensity ) const;
63 double exponent( ) const;
66 class SpecularReflectionPair : public Lang::SpecularReflection
68 RefCountPtr< const Lang::SpecularReflection > car_;
69 RefCountPtr< const Lang::SpecularReflection > cdr_;
70 public:
71 SpecularReflectionPair( const RefCountPtr< const Lang::SpecularReflection > & car, const RefCountPtr< const Lang::SpecularReflection > & cdr );
72 ~SpecularReflectionPair( );
73 virtual double weight( ) const;
74 virtual RefCountPtr< const Lang::SpecularReflection > multiply( double scalar ) const;
75 virtual Concrete::Gray illuminate( const Concrete::Coords3D & point, const Concrete::Length eyez, const Concrete::UnitFloatTriple & unitNormal, const Lang::GrayLight & light ) const;
76 virtual Concrete::RGB illuminate( const Concrete::Coords3D & point, const Concrete::Length eyez, const Concrete::UnitFloatTriple & unitNormal, const Lang::RGBLight & light ) const;
77 virtual Concrete::Gray illuminate( const Concrete::Coords3D & point, const Concrete::Length eyez, const Concrete::UnitFloatTriple & unitNormal, const Concrete::Gray & autoIntensity ) const;
78 virtual Concrete::RGB illuminate( const Concrete::Coords3D & point, const Concrete::Length eyez, const Concrete::UnitFloatTriple & unitNormal, const Concrete::RGB & autoIntensity ) const;
81 class SpecularReflectionNull : public Lang::SpecularReflection
83 public:
84 SpecularReflectionNull( );
85 ~SpecularReflectionNull( );
86 virtual double weight( ) const;
87 virtual RefCountPtr< const Lang::SpecularReflection > multiply( double scalar ) const;
88 virtual Concrete::Gray illuminate( const Concrete::Coords3D & point, const Concrete::Length eyez, const Concrete::UnitFloatTriple & unitNormal, const Lang::GrayLight & light ) const;
89 virtual Concrete::RGB illuminate( const Concrete::Coords3D & point, const Concrete::Length eyez, const Concrete::UnitFloatTriple & unitNormal, const Lang::RGBLight & light ) const;
90 virtual Concrete::Gray illuminate( const Concrete::Coords3D & point, const Concrete::Length eyez, const Concrete::UnitFloatTriple & unitNormal, const Concrete::Gray & autoIntensity ) const;
91 virtual Concrete::RGB illuminate( const Concrete::Coords3D & point, const Concrete::Length eyez, const Concrete::UnitFloatTriple & unitNormal, const Concrete::RGB & autoIntensity ) const;
94 class LightSource : public Lang::Geometric3D
96 protected:
97 bool shadows_;
98 public:
99 LightSource( bool shadows );
100 virtual ~LightSource( );
101 virtual bool shadows( ) const { return shadows_; }
102 virtual RefCountPtr< const Lang::Geometric3D > transformed( const Lang::Transform3D & tf, const RefCountPtr< const Lang::Geometric3D > & self ) const;
103 virtual RefCountPtr< const Lang::Geometric2D > to2D( const Kernel::PassedDyn & dyn, const RefCountPtr< const Lang::Geometric3D > & self ) const;
104 virtual RefCountPtr< const Lang::LightSource > typed_transformed( const Lang::Transform3D & tf ) const = 0;
105 virtual bool isGray( ) const = 0;
106 TYPEINFODECL;
107 virtual void gcMark( Kernel::GCMarkedSet & marked ); // This method resides here since we know (that today) no sub classes need to do gcMark.
108 DISPATCHDECL;
111 class GrayLight : public Lang::LightSource
113 public:
114 GrayLight( bool shadows );
115 virtual ~GrayLight( );
116 virtual bool isGray( ) const { return true; };
117 virtual Concrete::RGB illuminateRGB( const Concrete::Coords3D & point, const Concrete::Length eyez, const Concrete::UnitFloatTriple & unitNormal, const Lang::SpecularReflectionTerm & refl ) const = 0;
118 virtual Concrete::Gray illuminateGray( const Concrete::Coords3D & point, const Concrete::Length eyez, const Concrete::UnitFloatTriple & unitNormal, const Lang::SpecularReflectionTerm & refl ) const = 0;
121 class RGBLight : public Lang::LightSource
123 public:
124 RGBLight( bool shadows );
125 virtual ~RGBLight( );
126 virtual bool isGray( ) const { return false; };
127 virtual Concrete::RGB illuminateRGB( const Concrete::Coords3D & point, const Concrete::Length eyez, const Concrete::UnitFloatTriple & unitNormal, const Lang::SpecularReflectionTerm & refl ) const = 0;
130 class AmbientLightGray : public GrayLight
132 Concrete::Gray intensity_;
133 public:
134 AmbientLightGray( const Concrete::Gray & intensity );
135 virtual ~AmbientLightGray( );
136 virtual RefCountPtr< const Lang::LightSource > typed_transformed( const Lang::Transform3D & tf ) const;
137 virtual Concrete::RGB illuminateRGB( const Concrete::Coords3D & point, const Concrete::Length eyez, const Concrete::UnitFloatTriple & unitNormal, const Lang::SpecularReflectionTerm & refl ) const;
138 virtual Concrete::Gray illuminateGray( const Concrete::Coords3D & point, const Concrete::Length eyez, const Concrete::UnitFloatTriple & unitNormal, const Lang::SpecularReflectionTerm & refl ) const;
141 class AmbientLightRGB : public RGBLight
143 Concrete::RGB intensity_;
144 public:
145 AmbientLightRGB( const Concrete::RGB & intensity );
146 virtual ~AmbientLightRGB( );
147 virtual RefCountPtr< const Lang::LightSource > typed_transformed( const Lang::Transform3D & tf ) const;
148 virtual Concrete::RGB illuminateRGB( const Concrete::Coords3D & point, const Concrete::Length eyez, const Concrete::UnitFloatTriple & unitNormal, const Lang::SpecularReflectionTerm & refl ) const;
151 class SpecularLightGray : public GrayLight
153 Concrete::Coords3D p_;
154 Concrete::Gray intensity_;
155 Concrete::Length intensityRadius_;
156 public:
157 SpecularLightGray( const Concrete::Coords3D & p, const Concrete::Gray & intensity, Concrete::Length intensityRadius, bool shadows );
158 virtual ~SpecularLightGray( );
159 virtual RefCountPtr< const Lang::LightSource > typed_transformed( const Lang::Transform3D & tf ) const;
160 virtual Concrete::RGB illuminateRGB( const Concrete::Coords3D & point, const Concrete::Length eyez, const Concrete::UnitFloatTriple & unitNormal, const Lang::SpecularReflectionTerm & refl ) const;
161 virtual Concrete::Gray illuminateGray( const Concrete::Coords3D & point, const Concrete::Length eyez, const Concrete::UnitFloatTriple & unitNormal, const Lang::SpecularReflectionTerm & refl ) const;
164 class SpecularLightRGB : public RGBLight
166 Concrete::Coords3D p_;
167 Concrete::RGB intensity_;
168 Concrete::Length intensityRadius_;
169 public:
170 SpecularLightRGB( const Concrete::Coords3D & p, const Concrete::RGB & intensity, Concrete::Length intensityRadius, bool shadows );
171 virtual ~SpecularLightRGB( );
172 virtual RefCountPtr< const Lang::LightSource > typed_transformed( const Lang::Transform3D & tf ) const;
173 virtual Concrete::RGB illuminateRGB( const Concrete::Coords3D & point, const Concrete::Length eyez, const Concrete::UnitFloatTriple & unitNormal, const Lang::SpecularReflectionTerm & refl ) const;
176 class DistantLightGray : public GrayLight
178 Concrete::UnitFloatTriple rHatLight_;
179 Concrete::Gray intensity_;
180 public:
181 DistantLightGray( const Concrete::UnitFloatTriple & rHatLight, const Concrete::Gray & intensity, bool shadows );
182 virtual ~DistantLightGray( );
183 virtual RefCountPtr< const Lang::LightSource > typed_transformed( const Lang::Transform3D & tf ) const;
184 virtual Concrete::RGB illuminateRGB( const Concrete::Coords3D & point, const Concrete::Length eyez, const Concrete::UnitFloatTriple & unitNormal, const Lang::SpecularReflectionTerm & refl ) const;
185 virtual Concrete::Gray illuminateGray( const Concrete::Coords3D & point, const Concrete::Length eyez, const Concrete::UnitFloatTriple & unitNormal, const Lang::SpecularReflectionTerm & refl ) const;
188 class DistantLightRGB : public RGBLight
190 Concrete::UnitFloatTriple rHatLight_;
191 Concrete::RGB intensity_;
192 public:
193 DistantLightRGB( const Concrete::UnitFloatTriple & rHatLight, const Concrete::RGB & intensity, bool shadows );
194 virtual ~DistantLightRGB( );
195 virtual RefCountPtr< const Lang::LightSource > typed_transformed( const Lang::Transform3D & tf ) const;
196 virtual Concrete::RGB illuminateRGB( const Concrete::Coords3D & point, const Concrete::Length eyez, const Concrete::UnitFloatTriple & unitNormal, const Lang::SpecularReflectionTerm & refl ) const;
199 class LightGroup : public Geometric3D
201 public:
202 LightGroup( );
203 virtual ~LightGroup( );
204 virtual RefCountPtr< const Lang::LightGroup > typed_transformed( const Lang::Transform3D & tf, const RefCountPtr< const Lang::LightGroup > & self ) const = 0;
205 virtual RefCountPtr< const Lang::Geometric3D > transformed( const Lang::Transform3D & tf, const RefCountPtr< const Lang::Geometric3D > & self ) const;
206 virtual RefCountPtr< const Lang::Geometric2D > to2D( const Kernel::PassedDyn & dyn, const RefCountPtr< const Lang::Geometric3D > & self ) const;
207 virtual bool isNull( ) const = 0;
208 virtual bool containsRGB( ) const = 0;
209 TYPEINFODECL;
210 DISPATCHDECL;
213 class LightNull : public LightGroup
215 public:
216 LightNull( );
217 virtual ~LightNull( );
218 virtual RefCountPtr< const Lang::LightGroup > typed_transformed( const Lang::Transform3D & tf, const RefCountPtr< const Lang::LightGroup > & self ) const;
219 virtual bool isNull( ) const;
220 virtual bool containsRGB( ) const;
221 virtual void gcMark( Kernel::GCMarkedSet & marked );
224 class LightPair : public LightGroup
226 RefCountPtr< const Lang::LightSource > car_;
227 RefCountPtr< const Lang::LightGroup > cdr_;
228 public:
229 LightPair( const RefCountPtr< const Lang::LightSource > & car, const RefCountPtr< const Lang::LightGroup > & cdr );
230 virtual ~LightPair( );
231 RefCountPtr< const Lang::LightSource > car( ) const;
232 RefCountPtr< const Lang::LightGroup > cdr( ) const;
233 virtual RefCountPtr< const Lang::LightGroup > typed_transformed( const Lang::Transform3D & tf, const RefCountPtr< const Lang::LightGroup > & self ) const;
234 virtual bool isNull( ) const;
235 virtual bool containsRGB( ) const;
236 virtual void gcMark( Kernel::GCMarkedSet & marked );