DI-Guy SDK Documentation  13.6
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 
13 
18 {
19  osg::ref_ptr<osg::Uniform> m_ufrm_link_matrix;
20  osg::Matrixf m_offset;
21 };
22 
35 {
36 
37 public:
38 
39  diguyOsgGraphicsShape(void* internal_data);
40  virtual~diguyOsgGraphicsShape();
41 
42  virtual void build() override;
43 
44 
45  virtual void unbuild() override;
46  virtual void show() override;
47  virtual void hide() override;
48 
49  virtual void instancing_state_changed(int val) override;
50 
51  virtual void set_graphics_lod_ranges(float* lod_ranges) override;
52  virtual void set_graphics_lod(int lod) override;
53 
54 
55  static void set_use_pixel_lods(bool use_pixel_lods) {s_use_pixel_lods = use_pixel_lods;}
56 
57  /*
58  * Overrides the base class and gives an opportunity to feed per shape
59  * matrix data to shader.
60  */
61  virtual void update() override;
62 
63 
64  virtual void update_variation_texture(int num_pixels, unsigned char* pixel_data) override;
65  virtual void update_name_texture() override;
66 
67  /*
68  * String to use for the uniform array of bones.
69  */
70  static char* s_ufrm_link_matrices_string;
71  static char* s_ufrm_link_colors_string;
72 
73  std::vector<osg::Geode*> m_geodes;
74 
75  osg::StateSet* get_state_set() { return m_state_set.get(); }
76  friend class diguyNameTextureDrawCallback;
77 
78 protected:
79  void create_shared_variation_texture();
80  void create_variation_texture(unsigned char * variation_texture_data);
81  void create_name_texture();
82 
83  // helper functions for building geodes.
84  osg::Geode* create_geode(int lod, diguyGraphicsShaderTechnique* pTechnique, int max_quality_level);
85 
86  osg::ref_ptr<osg::Switch> m_switch_node;
87 
88  /*
89  * One and only one of m_lod_node and m_manual_lod_switch_node
90  * should be non-NULL.
91  */
92  osg::ref_ptr<osg::LOD> m_lod_node;
93 
94  static bool s_use_pixel_lods;
95  // this is a proxy we just use it to push down to the geode, we could share
96  // these but we need the geodes to be unique to support different shader LOD programs.
97  osg::ref_ptr<osg::StateSet> m_state_set;
98  osg::ref_ptr<osg::Uniform> m_ufrm_link_matrix;
99  osg::ref_ptr<osg::Uniform> m_ufrm_link_matrices;
100  osg::ref_ptr<osg::Uniform> m_ufrm_link_colors;
101  osg::ref_ptr<osg::Uniform> m_ufrm_component_map_row;
102  osg::ref_ptr<osg::Uniform> m_ufrm_decal_index;
103  osg::ref_ptr<osg::Uniform> m_ufrm_lod_fade;
104  osg::ref_ptr<osg::Uniform> m_ufrm_blend_weights;
105  osg::ref_ptr<osg::Uniform> m_ufrm_blend_indecies;
106  std::vector< diguyOsgMeshOffsets> m_offset_array;
107  unsigned int m_name_texture_object;
108  bool m_needs_texture_update;
109  diguyOsgTextureAttribute * m_name_attribute;
110 
111 public:
112  static osg::ref_ptr<osg::Texture2D> sm_variation_texture;
113 
114 };
115 
116 
123 
124 
virtual void unbuild() override
This function will be called by DI-Guy when it is time for the renderer-specific shape objects create...
Definition: diguyOsgGraphicsShape.cpp:798
static char * s_ufrm_link_colors_string
Definition: diguyOsgGraphicsShape.h:67
osg::Matrixf m_offset
Definition: diguyOsgGraphicsShape.h:19
virtual void set_graphics_lod(int lod) override
This function will be called by DI-Guy when the LOD of this link is "manually" set by a diguyCharacte...
Definition: diguyOsgGraphicsShape.cpp:1113
virtual void update() override
This function will be called by DI-Guy when it is time for renderer-specific shape objects created du...
Definition: diguyOsgGraphicsShape.cpp:921
diguyOsgGraphicsShape(void *internal_data)
Definition: diguyOsgGraphicsShape.cpp:173
diguyGraphicsShape * diguyOsgGraphicsShape_create_func(void *internal_data)
Create function declaration.
Definition: diguyOsgGraphicsShape.cpp:1135
virtual void show() override
This function will be called by DI-Guy when the shape should be shown, typically due to a change in t...
Definition: diguyOsgGraphicsShape.cpp:865
virtual void build() override
This function will be called by DI-Guy when it is time for renderer-specific shape objects to be crea...
Definition: diguyOsgGraphicsShape.cpp:520
virtual void update_variation_texture(int num_pixels, unsigned char *pixel_data) override
Pushes a char * pixel buffer of length num_pixels that represents the unique per shape texture...
Definition: diguyOsgGraphicsShape.cpp:1120
virtual void set_graphics_lod_ranges(float *lod_ranges) override
This function will be called by DI-Guy when the LOD ranges of this shape need to be updated after the...
Definition: diguyOsgGraphicsShape.cpp:1083
static void set_use_pixel_lods(bool use_pixel_lods)
Definition: diguyOsgGraphicsShape.h:52
Shapes are the high-level containers of visible geometry.
Definition: diguyOsgGraphicsShape.h:33
virtual ~diguyOsgGraphicsShape()
Definition: diguyOsgGraphicsShape.cpp:187
virtual void update_name_texture() override
creates a decal texture with a name (accessed by get_decal_text()) see sample implementation for a re...
Definition: diguyOsgGraphicsShape.cpp:270
static char * s_ufrm_link_matrices_string
Definition: diguyOsgGraphicsShape.h:66
Helper struct for storing offsets for more complex meshes.
Definition: diguyOsgGraphicsShape.h:16
A class that represents the unique per-character non-shared mesh object. DI-Guy encapsulates its text...
Definition: diguyGraphicsShape.h:49
virtual void instancing_state_changed(int val) override
Definition: diguyOsgGraphicsShape.cpp:903
osg::ref_ptr< osg::Uniform > m_ufrm_link_matrix
Definition: diguyOsgGraphicsShape.h:18
virtual void hide() override
This function will be called by DI-Guy when the shape should be hidden, typically due to a change in ...
Definition: diguyOsgGraphicsShape.cpp:891
This class implements shader lod system for use with DI-Guy character graphics.
Definition: diguyGraphicsShaderTechnique.h:154
Definition: diguyOsgGraphicsShape.cpp:107
Definition: diguyOsgGraphicsShape.cpp:25