SCM Library
Spherical Cube Map rendering library
 All Classes Files Functions Variables Friends Pages
scm-scene.hpp
1 // Copyright (C) 2011-2012 Robert Kooima
2 //
3 // LIBSCM is free software; you can redistribute it and/or modify it under the
4 // terms of the GNU General Public License as published by the Free Software
5 // Foundation; either version 2 of the License, or (at your option) any later
6 // version.
7 //
8 // This program is distributed in the hope that it will be useful, but WITH-
9 // OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 // more details.
12 
13 #ifndef SCM_SCENE_HPP
14 #define SCM_SCENE_HPP
15 
16 #include <vector>
17 #include <string>
18 
19 #include "util3d/glsl.h"
20 
21 //------------------------------------------------------------------------------
22 
23 class scm_system;
24 class scm_label;
25 class scm_image;
26 
27 typedef std::vector<scm_image *> scm_image_v;
28 typedef std::vector<scm_image *>::iterator scm_image_i;
29 typedef std::vector<scm_image *>::const_iterator scm_image_c;
30 
31 //------------------------------------------------------------------------------
32 
39 
40 class scm_scene
41 {
42 public:
43 
45  ~scm_scene();
46 
49 
50  int add_image(int i);
51  void del_image(int i);
52  scm_image *get_image(int i);
53  int get_image_count() const;
54 
58 
59  void set_color(GLuint c);
60  void set_name (const std::string &s);
61  void set_label(const std::string &s);
62  void set_vert (const std::string &s);
63  void set_frag (const std::string &s);
64 
68 
69  GLuint get_color() const { return color; }
70  const std::string& get_name () const { return name; }
71  const std::string& get_label() const { return label_file; }
72  const std::string& get_vert () const { return vert_file; }
73  const std::string& get_frag () const { return frag_file; }
74 
78 
79  void init_uniforms();
80  void draw_label();
81 
82  void bind(int) const;
83  void unbind(int) const;
84 
85  void bind_page(int, int, int, long long) const;
86  void unbind_page(int, int) const;
87  void touch_page(int, int, long long) const;
88 
89  float get_minimum_ground() const;
90  float get_current_ground(const double *) const;
91 
92  void get_page_bounds(int, long long, float&, float &) const;
93  bool get_page_status(int, long long) const;
94 
96 
97 private:
98 
99  scm_system *sys;
100 
101  std::string name;
102  std::string label_file;
103  std::string vert_file;
104  std::string frag_file;
105 
106  scm_label *label;
107  scm_image_v images;
108  glsl render;
109  GLuint color;
110 
111  // Uniform locations must be visible to the scm_sphere.
112 
113  friend class scm_sphere;
114 
115  GLint uA[16];
116  GLint uB[16];
117  GLint uM;
118  GLint uzoomv;
119  GLint uzoomk;
120 };
121 
122 //------------------------------------------------------------------------------
123 
124 #endif
void set_label(const std::string &s)
Set the label text.
Definition: scm-scene.cpp:110
void get_page_bounds(int, long long, float &, float &) const
Determine the minimum and maximum values of one page of the height image.
Definition: scm-scene.cpp:287
void set_frag(const std::string &s)
Set the fragment shader and reinitialize the uniforms.
Definition: scm-scene.cpp:139
scm_image * get_image(int i)
Return a pointer to the image at index i.
Definition: scm-scene.cpp:74
void draw_label()
Render the labels for this scene, if any.
Definition: scm-scene.cpp:175
An scm_image represents an SCM data file in use by an scm_scene.
Definition: scm-image.hpp:34
An scm_scene encapsulates the definition of a sphere and its parameters.
Definition: scm-scene.hpp:40
void bind_page(int, int, int, long long) const
Bind a page in each image matching a channel.
Definition: scm-scene.cpp:230
An scm_label renders annotations on the sphere.
Definition: scm-label.hpp:52
void init_uniforms()
Request and store the uniform locations for the current program.
Definition: scm-scene.cpp:155
An scm_sphere generates the adaptive rendered geometry of the 3D sphere.
Definition: scm-sphere.hpp:30
int get_image_count() const
Return the number of images in the collection.
Definition: scm-scene.cpp:81
void set_name(const std::string &s)
Set the scene name.
Definition: scm-scene.cpp:99
void set_color(GLuint c)
Set the label color.
Definition: scm-scene.cpp:92
bool get_page_status(int, long long) const
Return true if any one of the images has page i in cache.
Definition: scm-scene.cpp:304
void set_vert(const std::string &s)
Set the vertex shader and reinitialize the uniforms.
Definition: scm-scene.cpp:123
float get_minimum_ground() const
Return the smallest value in the height image.
Definition: scm-scene.cpp:274
void unbind_page(int, int) const
Unbind a page in each image matching a channel.
Definition: scm-scene.cpp:239
void bind(int) const
Bind the program and all image textures matching the given channel.
Definition: scm-scene.cpp:197
~scm_scene()
Finalize all SCM scene state.
Definition: scm-scene.cpp:33
scm_scene(scm_system *)
Create a new SCM scene for use in the given SCM system.
Definition: scm-scene.cpp:24
float get_current_ground(const double *) const
Sample the height image at the given location.
Definition: scm-scene.cpp:262
int add_image(int i)
Allocate and insert a new image before index i. Return its index.
Definition: scm-scene.cpp:48
void unbind(int) const
Unbind the program and all image textures matching the given channel.
Definition: scm-scene.cpp:213
void touch_page(int, int, long long) const
Touch a page in each image matching a channel.
Definition: scm-scene.cpp:248
An scm_system encapsulates all of the state of an SCM renderer. Its interface is the primary API of t...
Definition: scm-system.hpp:175
void del_image(int i)
Delete the image at index i.
Definition: scm-scene.cpp:64