ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
TextureRendererBase.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <vtkSmartPointer.h>
11 
12 #include <memory>
13 #include <string>
14 #include <vector>
15 
16 class vtkActor;
17 class vtkLODActor;
18 class vtkPolyData;
19 class vtkRenderer;
20 class vtkRenderWindow;
21 
22 // Forward declarations
23 class ccMaterialSet;
24 class ccMaterial;
25 
26 namespace PclUtils {
27 namespace renders {
28 
29 // Forward declarations
30 class MaterialConverter;
31 
35 enum class RenderingMode {
36  PBR, // Physically Based Rendering (VTK 9+)
37  MULTI_TEXTURE, // Traditional multi-texture rendering
38  MATERIAL_ONLY // Material properties only, no textures
39 };
40 
49 public:
50  TextureRendererBase() = default;
51  virtual ~TextureRendererBase() = default;
52 
60  virtual bool CanHandle(size_t material_count,
61  bool has_pbr_textures,
62  bool has_multiple_map_kd) const = 0;
63 
67  virtual RenderingMode GetMode() const = 0;
68 
77  virtual bool Apply(vtkLODActor* actor,
78  const class ccMaterialSet* materials,
79  vtkPolyData* polydata,
80  vtkRenderer* renderer) = 0;
81 
90  virtual bool Update(vtkActor* actor,
91  const class ccMaterialSet* materials,
92  vtkPolyData* polydata,
93  vtkRenderer* renderer) = 0;
94 
98  virtual std::string GetName() const = 0;
99 
100 protected:
104  void ClearTextures(vtkActor* actor);
105 
109  bool ValidateActor(vtkActor* actor) const;
110 
114  bool ValidateMaterials(const class ccMaterialSet* materials) const;
115 };
116 
117 } // namespace renders
118 } // namespace PclUtils
CVLog.h
PclUtils
Definition: CustomContextItem.cpp:18
PclUtils::renders::TextureRendererBase::GetMode
virtual RenderingMode GetMode() const =0
Get the rendering mode this renderer implements.
PclUtils::renders::TextureRendererBase::ValidateMaterials
bool ValidateMaterials(const class ccMaterialSet *materials) const
Helper: Validate materials.
Definition: TextureRendererBase.cpp:36
PclUtils::renders::RenderingMode::PBR
@ PBR
PclUtils::renders::TextureRendererBase::Apply
virtual bool Apply(vtkLODActor *actor, const class ccMaterialSet *materials, vtkPolyData *polydata, vtkRenderer *renderer)=0
Apply rendering to actor.
CVLog::Error
static bool Error(const char *format,...)
Display an error dialog with formatted message.
Definition: CVLog.cpp:143
PclUtils::renders::TextureRendererBase::GetName
virtual std::string GetName() const =0
Get renderer name for logging.
ccMaterial
Mesh (triangle) material.
Definition: ecvMaterial.h:28
PclUtils::renders::TextureRendererBase::TextureRendererBase
TextureRendererBase()=default
PclUtils::renders::RenderingMode::MULTI_TEXTURE
@ MULTI_TEXTURE
PclUtils::renders::RenderingMode
RenderingMode
Rendering mode enumeration.
Definition: TextureRendererBase.h:35
PclUtils::renders::TextureRendererBase::CanHandle
virtual bool CanHandle(size_t material_count, bool has_pbr_textures, bool has_multiple_map_kd) const =0
Check if this renderer can handle the given material.
CVLog::Warning
static bool Warning(const char *format,...)
Prints out a formatted warning message in console.
Definition: CVLog.cpp:133
ecvMaterialSet.h
PclUtils::renders::TextureRendererBase
Base class for all texture renderers.
Definition: TextureRendererBase.h:48
PclUtils::renders::TextureRendererBase::~TextureRendererBase
virtual ~TextureRendererBase()=default
ccMaterialSet
Mesh (triangle) material.
Definition: ecvMaterialSet.h:16
TextureRendererBase.h
PclUtils::renders::TextureRendererBase::ClearTextures
void ClearTextures(vtkActor *actor)
Helper: Clear all textures from actor.
Definition: TextureRendererBase.cpp:20
PclUtils::renders::TextureRendererBase::ValidateActor
bool ValidateActor(vtkActor *actor) const
Helper: Validate actor.
Definition: TextureRendererBase.cpp:28
PclUtils::renders::RenderingMode::MATERIAL_ONLY
@ MATERIAL_ONLY
PclUtils::renders::TextureRendererBase::Update
virtual bool Update(vtkActor *actor, const class ccMaterialSet *materials, vtkPolyData *polydata, vtkRenderer *renderer)=0
Update existing actor with new materials.