DI-Guy SDK Documentation  13.8
diguyOsgGraphicsShape.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (c) 2025 MAK Technologies, Inc.
3  * All rights reserved.
4  ****************************************************************************/
5 
6 #pragma once
7 
8 #include <diguyGraphicsShape.h>
9 
10 #include <osg/Switch>
11 #include <osg/LOD>
12 #include <osg/Geode>
13 #include <osg/Texture2D>
14 
15 class diguyOsgTextureAttribute;
17 
22 {
23  osg::ref_ptr<osg::Uniform> m_ufrm_link_matrix;
24  osg::Matrixf m_offset;
25 };
26 
39 {
40 
41 public:
42 
43  diguyOsgGraphicsShape(void* internal_data);
44  virtual~diguyOsgGraphicsShape();
45 
46  virtual void build() override;
47 
48 
49  virtual void unbuild() override;
50  virtual void show() override;
51  virtual void hide() override;
52 
53  virtual void instancing_state_changed(int val) override;
54 
55  virtual void set_graphics_lod_ranges(float* lod_ranges) override;
56  virtual void set_graphics_lod(int lod) override;
57 
58 
59  static void set_use_pixel_lods(bool use_pixel_lods) {s_use_pixel_lods = use_pixel_lods;}
60 
61  /*
62  * Overrides the base class and gives an opportunity to feed per shape
63  * matrix data to shader.
64  */
65  virtual void update() override;
66 
67 
68  virtual void update_variation_texture(int num_pixels, unsigned char* pixel_data) override;
69  virtual void update_name_texture() override;
70 
71  /*
72  * String to use for the uniform array of bones.
73  */
74  static const char* s_ufrm_link_matrices_string;
75  static const char* s_ufrm_link_colors_string;
76 
77  std::vector<osg::Geode*> m_geodes;
78 
79  osg::StateSet* get_state_set() { return m_state_set.get(); }
80  friend class diguyNameTextureDrawCallback;
81 
82 protected:
83 
84  void create_shared_variation_texture();
85  void create_variation_texture(unsigned char * variation_texture_data);
86  void create_name_texture();
87 
88  // helper functions for building geodes.
89  osg::Geode* create_geode(int lod, diguyGraphicsShaderTechnique* pTechnique, int max_quality_level);
90 
91  osg::ref_ptr<osg::Switch> m_switch_node;
92 
93  /*
94  * One and only one of m_lod_node and m_manual_lod_switch_node
95  * should be non-NULL.
96  */
97  osg::ref_ptr<osg::LOD> m_lod_node;
98 
99  static bool s_use_pixel_lods;
100  // this is a proxy we just use it to push down to the geode, we could share
101  // these but we need the geodes to be unique to support different shader LOD programs.
102  osg::ref_ptr<osg::StateSet> m_state_set;
103  osg::ref_ptr<osg::Uniform> m_ufrm_link_matrix;
104  osg::ref_ptr<osg::Uniform> m_ufrm_link_matrices;
105  osg::ref_ptr<osg::Uniform> m_ufrm_link_colors;
106  osg::ref_ptr<osg::Uniform> m_ufrm_component_map_row;
107  osg::ref_ptr<osg::Uniform> m_ufrm_decal_index;
108  osg::ref_ptr<osg::Uniform> m_ufrm_lod_fade;
109  osg::ref_ptr<osg::Uniform> m_ufrm_blend_weights;
110  osg::ref_ptr<osg::Uniform> m_ufrm_blend_indices;
111  std::vector< diguyOsgMeshOffsets> m_offset_array;
112  unsigned int m_name_texture_object;
113  bool m_needs_texture_update;
114  diguyOsgTextureAttribute * m_name_attribute;
115 
116 public:
117 
118  static osg::ref_ptr<osg::Texture2D> sm_variation_texture;
119 
120 };
121 
122 
129 
130 
osg::Matrixf m_offset
Definition: diguyOsgGraphicsShape.h:24
diguyOsgGraphicsShape(void *internal_data)
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...
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...
diguyGraphicsShape * diguyOsgGraphicsShape_create_func(void *internal_data)
Create function declaration.
virtual void update() override
This function will be called by DI-Guy when it is time for renderer-specific shape objects created du...
virtual void update_name_texture() override
creates a decal texture with a name (accessed by get_decal_text()) see sample implementation for a re...
virtual void unbuild() override
This function will be called by DI-Guy when it is time for the renderer-specific shape objects create...
virtual void instancing_state_changed(int val) override
static const char * s_ufrm_link_colors_string
Definition: diguyOsgGraphicsShape.h:72
virtual ~diguyOsgGraphicsShape()
static void set_use_pixel_lods(bool use_pixel_lods)
Definition: diguyOsgGraphicsShape.h:57
Shapes are the high-level containers of visible geometry.
Definition: diguyOsgGraphicsShape.h:38
virtual void build() override
This function will be called by DI-Guy when it is time for renderer-specific shape objects to be crea...
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...
static const char * s_ufrm_link_matrices_string
Definition: diguyOsgGraphicsShape.h:71
Helper struct for storing offsets for more complex meshes.
Definition: diguyOsgGraphicsShape.h:21
A class that represents the unique per-character non-shared mesh object. DI-Guy encapsulates its text...
Definition: diguyGraphicsShape.h:49
virtual void hide() override
This function will be called by DI-Guy when the shape should be hidden, typically due to a change in ...
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...
osg::ref_ptr< osg::Uniform > m_ufrm_link_matrix
Definition: diguyOsgGraphicsShape.h:23
This class implements shader lod system for use with DI-Guy character graphics.
Definition: diguyGraphicsShaderTechnique.h:153