1 /*******************************************************
2       Lightwave Object Loader for OSG
3 
4   Copyright (C) 2004 Marco Jez <marco.jez@poste.it>
5   OpenSceneGraph is (C) 2004 Robert Osfield
6 ********************************************************/
7 
8 #ifndef LWOSG_SURFACE_
9 #define LWOSG_SURFACE_
10 
11 #include "lwo2chunks.h"
12 
13 #include "VertexMap.h"
14 #include "Block.h"
15 #include "Clip.h"
16 
17 #include <osg/ref_ptr>
18 #include <osg/Vec3>
19 #include <osg/StateSet>
20 #include <osg/Geometry>
21 
22 #include <osgDB/ReaderWriter>
23 
24 #include <string>
25 #include <map>
26 
27 namespace lwosg
28 {
29 
30     class Surface {
31     public:
32 
33         enum Sidedness {
34             NONE           = 0,
35             FRONT_ONLY     = 1,
36             BACK_ONLY      = 2,
37             FRONT_AND_BACK = 3
38         };
39 
40         typedef std::multimap<std::string, Block> Block_map;
41 
42         Surface();
43         Surface(const lwo2::FORM::SURF *surf, const Clip_map &clips);
44 
45         void compile(const lwo2::FORM::SURF *surf, const Clip_map &clips);
46 
47         osg::Group *apply(osg::Geometry *geo, const VertexMap_map *texture_maps, const VertexMap_map *rgb_maps, const VertexMap_map *rgba_maps, int max_tex_units, bool use_osgfx, bool force_arb_compression, const VertexMap_binding_map &texmap_bindings, const osgDB::ReaderWriter::Options *db_options) const;
48 
49         void generate_stateset(unsigned int max_tex_units, bool force_arb_compression, const osgDB::ReaderWriter::Options* options) const;
50 
get_name()51         inline const std::string &get_name() const { return name_; }
set_name(const std::string & n)52         inline void set_name(const std::string &n) { name_ = n; }
53 
get_base_color()54         inline const osg::Vec3 &get_base_color() const { return base_color_; }
55 
get_diffuse()56         inline float get_diffuse() const { return diffuse_; }
get_luminosity()57         inline float get_luminosity() const { return luminosity_; }
get_specularity()58         inline float get_specularity() const { return specularity_; }
get_reflection()59         inline float get_reflection() const { return reflection_; }
get_transparency()60         inline float get_transparency() const { return transparency_; }
get_translucency()61         inline float get_translucency() const { return translucency_; }
get_glossiness()62         inline float get_glossiness() const { return glossiness_; }
63 
get_sidedness()64         inline Sidedness get_sidedness() const { return sidedness_; }
65 
get_max_smoothing_angle()66         inline float get_max_smoothing_angle() const { return max_smoothing_angle_; }
67 
get_color_map_type()68         inline const std::string &get_color_map_type() const { return color_map_type_; }
get_color_map_name()69         inline const std::string &get_color_map_name() const { return color_map_name_; }
get_color_map_intensity()70         inline float get_color_map_intensity() const { return color_map_intensity_; }
71 
blocks()72         inline Block_map &blocks() { return blocks_; }
blocks()73         inline const Block_map &blocks() const { return blocks_; }
74 /*
75         inline const std::string &get_uv_map_name() const { return uv_map_name_; }
76 
77         inline bool has_clip() const { return clip_ != 0; }
78         inline const Clip *get_clip() const { return clip_; }
79         inline void set_clip(const Clip *c) { clip_ = c; }
80 */
81     private:
82         std::string name_;
83         osg::Vec3 base_color_;
84         float diffuse_;
85         float luminosity_;
86         float specularity_;
87         float reflection_;
88         float transparency_;
89         float translucency_;
90         float glossiness_;
91         Sidedness sidedness_;
92         float max_smoothing_angle_;
93         std::string color_map_type_;
94         std::string color_map_name_;
95         float color_map_intensity_;
96 
97         Block_map blocks_;
98 /*
99         std::string uv_map_name_;
100         const Clip *clip_;
101 */
102         mutable osg::ref_ptr<osg::StateSet> stateset_;
103     };
104 
105 }
106 
107 #endif
108