DI-Guy SDK Documentation  13.5
diguyOsgGraphicsShape.h
Go to the documentation of this file.
1 #pragma once
2 
3 
4 #include <diguyGraphicsShape.h>
5 
6 #include <osg/Switch>
7 #include <osg/LOD>
8 #include <osg/Geode>
9 #include <osg/Texture2D>
10 
12 
25 {
26 
27 public:
28 
29  diguyOsgGraphicsShape(void* internal_data);
30 
31  virtual void build();
32 
33  virtual void unbuild();
34  virtual void show();
35  virtual void hide();
36 
37  virtual void instancing_state_changed(int val);
38 
39  virtual void set_graphics_lod_ranges(float* lod_ranges);
40  virtual void set_graphics_lod(int lod);
41 
42 
43  static void set_use_pixel_lods(bool use_pixel_lods) {s_use_pixel_lods = use_pixel_lods;}
44 
45  /*
46  * Overrides the base class and gives an opportunity to feed per shape
47  * matrix data to shader.
48  */
49  virtual void update();
50  virtual void update_variation_texture(int num_pixels, unsigned char * pixel_data);
51  virtual void update_name_texture();
52 
53  /*
54  * String to use for the uniform array of bones.
55  */
56  static char* s_ufrm_link_matrices_string;
57  static char* s_ufrm_link_colors_string;
58 
59  std::vector<osg::Geode*> m_geodes;
60 
61  osg::StateSet* get_state_set() { return m_state_set.get(); }
62  friend class diguyNameTextureDrawCallback;
63 
64 protected:
65  void create_shared_variation_texture();
66  void create_variation_texture(unsigned char * variation_texture_data);
67  void create_name_texture();
68 
69  osg::ref_ptr<osg::Switch> m_switch_node;
70 
71  /*
72  * One and only one of m_lod_node and m_manual_lod_switch_node
73  * should be non-NULL.
74  */
75  osg::ref_ptr<osg::LOD> m_lod_node;
76 
77  static bool s_use_pixel_lods;
78  // this is a proxy we just use it to push down to the geode, we could share
79  // these but we need the geodes to be unique to support different shader LOD programs.
80  osg::ref_ptr<osg::StateSet> m_state_set;
81  osg::ref_ptr<osg::Uniform> m_ufrm_link_matrices;
82  osg::ref_ptr<osg::Uniform> m_ufrm_link_colors;
83  osg::ref_ptr<osg::Uniform> m_ufrm_component_map_row;
84  osg::ref_ptr<osg::Uniform> m_ufrm_decal_index;
85  osg::ref_ptr<osg::Uniform> m_ufrm_lod_fade;
86 
87  unsigned int m_name_texture_object;
88  bool m_needs_texture_update;
89  diguyOsgTextureAttribute * m_name_attribute;
90 public:
91  static osg::ref_ptr<osg::Texture2D> sm_variation_texture;
92 };
93 
94 
101 
102 
virtual void unbuild()
This function will be called by DI-Guy when it is time for the renderer-specific shape objects create...
Definition: diguyOsgGraphicsShape.cpp:725
static char * s_ufrm_link_colors_string
Definition: diguyOsgGraphicsShape.h:55
virtual void show()
This function will be called by DI-Guy when the shape should be shown, typically due to a change in t...
Definition: diguyOsgGraphicsShape.cpp:792
diguyOsgGraphicsShape(void *internal_data)
Definition: diguyOsgGraphicsShape.cpp:169
diguyGraphicsShape * diguyOsgGraphicsShape_create_func(void *internal_data)
Create function declaration.
Definition: diguyOsgGraphicsShape.cpp:1014
virtual void build()
This function will be called by DI-Guy when it is time for renderer-specific shape objects to be crea...
Definition: diguyOsgGraphicsShape.cpp:455
static void set_use_pixel_lods(bool use_pixel_lods)
Definition: diguyOsgGraphicsShape.h:41
virtual void hide()
This function will be called by DI-Guy when the shape should be hidden, typically due to a change in ...
Definition: diguyOsgGraphicsShape.cpp:816
virtual void update_variation_texture(int num_pixels, unsigned char *pixel_data)
Pushes a char * pixel buffer of length num_pixels that represents the unique per shape texture...
Definition: diguyOsgGraphicsShape.cpp:999
Shapes are the high-level containers of visible geometry.
Definition: diguyOsgGraphicsShape.h:23
virtual void set_graphics_lod(int lod)
This function will be called by DI-Guy when the LOD of this link is "manually" set by a diguyCharacte...
Definition: diguyOsgGraphicsShape.cpp:992
static char * s_ufrm_link_matrices_string
Definition: diguyOsgGraphicsShape.h:54
virtual void update()
This function will be called by DI-Guy when it is time for renderer-specific shape objects created du...
Definition: diguyOsgGraphicsShape.cpp:846
A class that represents the unique per-character non-shared mesh object. DI-Guy encapsulates its text...
Definition: diguyGraphicsShape.h:51
virtual void update_name_texture()
creates a decal texture with a name (accessed by get_decal_text()) see sample implementation for a re...
Definition: diguyOsgGraphicsShape.cpp:261
virtual void set_graphics_lod_ranges(float *lod_ranges)
This function will be called by DI-Guy when the LOD ranges of this shape need to be updated after the...
Definition: diguyOsgGraphicsShape.cpp:962
Definition: diguyOsgGraphicsShape.cpp:103
virtual void instancing_state_changed(int val)
Definition: diguyOsgGraphicsShape.cpp:828
Definition: diguyOsgGraphicsShape.cpp:25