CFx SDK Documentation  2022 SP0
GiProceduralGenerator.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2017, Open Design Alliance (the "Alliance").
3 // All rights reserved.
4 //
5 // This software and its documentation and related materials are owned by
6 // the Alliance. The software may only be incorporated into application
7 // programs owned by members of the Alliance, subject to a signed
8 // Membership Agreement and Supplemental Software License Agreement with the
9 // Alliance. The structure and organization of this software are the valuable
10 // trade secrets of the Alliance and its suppliers. The software is also
11 // protected by copyright law and international treaty provisions. Application
12 // programs incorporating this software must include the following statement
13 // with their copyright notices:
14 //
15 // This application incorporates Teigha(R) software pursuant to a license
16 // agreement with Open Design Alliance.
17 // Teigha(R) Copyright (C) 2002-2017 by Open Design Alliance.
18 // All rights reserved.
19 //
20 // By use of this software, its documentation or related materials, you
21 // acknowledge and accept the above terms.
23 
24 // Procedural textures generator.
25 
26 #ifndef __ODGIPROCEDURALGENERATOR_H__
27 #define __ODGIPROCEDURALGENERATOR_H__
28 
29 #include "RootExport.h"
30 #include "GiExport.h"
31 #include "UInt32Array.h"
32 #include "GiImage.h"
33 #include "GiMaterial.h"
34 
35 #include "RxObject.h"
36 
37 #include "TD_PackPush.h"
38 
45 {
46  public:
48 
50 
60  OdGiImageBGRA32 &image, double renderCoef = 1.0) = 0;
61 };
62 
69 
79 {
80  public:
85  {
86  kLinearInterpolation = 0,
89  kCosInterpolation
90  };
98  {
99  kClampMode = 0,
100  kWrapMode
101  };
102  protected:
105  public:
109 
114  void createColorArray(OdUInt32 nColors);
125  void copyGradient(const OdUInt32Array &other);
131  void copyGradient(const ODCOLORREF *colors, OdUInt32 nColors);
139  void createGradient(ODCOLORREF color1, ODCOLORREF color2, OdUInt32 nColors,
149  void createGradient(ODCOLORREF color1, ODCOLORREF color2, ODCOLORREF color3, OdUInt32 nColors,
160  void createGradient(ODCOLORREF color1, ODCOLORREF color2, ODCOLORREF color3, OdUInt32 nColors,
171  void createGradient(ODCOLORREF color1, ODCOLORREF color2, ODCOLORREF color3, ODCOLORREF color4, OdUInt32 nColors,
184  void createGradient(ODCOLORREF color1, ODCOLORREF color2, ODCOLORREF color3, ODCOLORREF color4, OdUInt32 nColors,
197  void createGradient(ODCOLORREF color1, ODCOLORREF color2, ODCOLORREF color3, ODCOLORREF color4, ODCOLORREF color5, OdUInt32 nColors,
212  void createGradient(ODCOLORREF color1, ODCOLORREF color2, ODCOLORREF color3, ODCOLORREF color4, ODCOLORREF color5, OdUInt32 nColors,
215 
222  void fillInterval(ODCOLORREF color, double from = 0.0, double to = 1.0);
229  void fillInterval(ODCOLORREF color, OdUInt32 from, OdUInt32 to);
238  void generateInterval(ODCOLORREF color1, ODCOLORREF color2, double from = 0.0, double to = 1.0,
248  void generateInterval(ODCOLORREF color1, ODCOLORREF color2, OdUInt32 from, OdUInt32 to,
250 
259  ODCOLORREF colorAt(OdUInt32 nColor) const;
264  ODCOLORREF colorAt(double at) const;
268  bool isInitialized() const;
272  const OdUInt32Array &asArray() const;
273 
283 
293  static ODCOLORREF interpolateColor(ODCOLORREF color1, ODCOLORREF color2, double at,
296 
297  const OdGiGradientGenerator &operator =(const OdGiGradientGenerator &other);
298 
300 
302  void operator +=(const OdGiGradientGenerator &other);
303  friend OdGiGradientGenerator operator +(const OdGiGradientGenerator &g1, const OdGiGradientGenerator &g2);
304  protected:
312  OdUInt32 clampToRange(double inVal) const;
316  double toDoubleRange(OdUInt32 inVal) const;
317 
321  static double linterp(double a, double b, double t);
325  static double einterp(double a, double b, double t);
329  static double cinterp(double a, double b, double t);
333  static double ieinterp(double a, double b, double t);
334 };
335 
345 {
346  public:
348 
349  // High-level functions
350 
360  OdGiImageBGRA32 &image, double renderCoef = 1.0) = 0;
361 
373  virtual void generateProceduralWood(OdGiPixelBGRA32 color1, OdGiPixelBGRA32 color2, double radialNoise, double axialNoise, double grainThickness,
374  OdGiImageBGRA32 &image, double renderCoef = 1.0) = 0;
384  virtual void generateProceduralMarble(OdGiPixelBGRA32 stoneColor, OdGiPixelBGRA32 veinColor, double veinSpacing, double veinWidth,
385  OdGiImageBGRA32 &image, double renderCoef = 1.0) = 0;
386 
387  // Low-level functions
388 
397  virtual void setColorGradient(const OdGiGradientGenerator &gradient) = 0;
401  virtual const OdGiGradientGenerator &colorGradient() const = 0;
402 };
403 
410 
411 #include "TD_PackPop.h"
412 
413 #endif // __ODGIPROCEDURALGENERATOR_H__
#define ODGI_EXPORT
Definition: GiExport.h:35
OdSmartPtr< OdGiProceduralGeneratorPE > OdGiProceduralGeneratorPEPtr
OdSmartPtr< OdGiProceduralGenerator > OdGiProceduralGeneratorPtr
#define ODCOLORREF
Definition: OdPlatform.h:883
unsigned int OdUInt32
unsigned char OdUInt8
void createGradient(ODCOLORREF color1, ODCOLORREF color2, OdUInt32 nColors, OdGiGradientGenerator::InterpolationType ipl=OdGiGradientGenerator::kLinearInterpolation)
OdUInt32 colorsCount() const
void fillInterval(ODCOLORREF color, double from=0.0, double to=1.0)
double toDoubleRange(OdUInt32 inVal) const
void createColorArrayFilled(ODCOLORREF color, OdUInt32 nColors)
static double cinterp(double a, double b, double t)
void generateInterval(ODCOLORREF color1, ODCOLORREF color2, OdUInt32 from, OdUInt32 to, OdGiGradientGenerator::InterpolationType ipl=OdGiGradientGenerator::kLinearInterpolation)
void copyGradient(const ODCOLORREF *colors, OdUInt32 nColors)
void createColorArray(OdUInt32 nColors)
const OdUInt32Array & asArray() const
static double linterp(double a, double b, double t)
void copyGradient(const OdUInt32Array &other)
ODCOLORREF colorAt(double at) const
OdGiGradientGenerator::AddressMode addressMode() const
void generateInterval(ODCOLORREF color1, ODCOLORREF color2, double from=0.0, double to=1.0, OdGiGradientGenerator::InterpolationType ipl=OdGiGradientGenerator::kLinearInterpolation)
static OdGiGradientGenerator createSpectrumGradient(OdUInt32 nColors, OdUInt8 alpha=0)
void createGradient(ODCOLORREF color1, ODCOLORREF color2, ODCOLORREF color3, ODCOLORREF color4, OdUInt32 nColors, OdGiGradientGenerator::InterpolationType ipl=OdGiGradientGenerator::kLinearInterpolation)
static double einterp(double a, double b, double t)
void createGradient(ODCOLORREF color1, ODCOLORREF color2, ODCOLORREF color3, OdUInt32 nColors, OdGiGradientGenerator::InterpolationType ipl1, OdGiGradientGenerator::InterpolationType ipl2)
bool isInitialized() const
void createGradient(ODCOLORREF color1, ODCOLORREF color2, ODCOLORREF color3, ODCOLORREF color4, ODCOLORREF color5, OdUInt32 nColors, OdGiGradientGenerator::InterpolationType ipl=OdGiGradientGenerator::kLinearInterpolation)
void appendGradient(const OdGiGradientGenerator &other)
OdUInt32 clampToRange(OdUInt32 inVal) const
ODCOLORREF colorAt(OdUInt32 nColor) const
void createGradient(ODCOLORREF color1, ODCOLORREF color2, ODCOLORREF color3, OdUInt32 nColors, OdGiGradientGenerator::InterpolationType ipl=OdGiGradientGenerator::kLinearInterpolation)
static ODCOLORREF interpolateColor(ODCOLORREF color1, ODCOLORREF color2, double at, OdGiGradientGenerator::InterpolationType ipl=OdGiGradientGenerator::kLinearInterpolation, OdGiGradientGenerator::AddressMode mode=OdGiGradientGenerator::kWrapMode)
void createGradient(ODCOLORREF color1, ODCOLORREF color2, ODCOLORREF color3, ODCOLORREF color4, OdUInt32 nColors, OdGiGradientGenerator::InterpolationType ipl1, OdGiGradientGenerator::InterpolationType ipl2, OdGiGradientGenerator::InterpolationType ipl3)
void createGradient(ODCOLORREF color1, ODCOLORREF color2, ODCOLORREF color3, ODCOLORREF color4, ODCOLORREF color5, OdUInt32 nColors, OdGiGradientGenerator::InterpolationType ipl1, OdGiGradientGenerator::InterpolationType ipl2, OdGiGradientGenerator::InterpolationType ipl3, OdGiGradientGenerator::InterpolationType ipl4)
static double ieinterp(double a, double b, double t)
OdGiGradientGenerator(const OdGiGradientGenerator &other)
void setAddressMode(OdGiGradientGenerator::AddressMode mode)
OdUInt32 clampToRange(double inVal) const
void fillInterval(ODCOLORREF color, OdUInt32 from, OdUInt32 to)
virtual void setColorGradient(const OdGiGradientGenerator &gradient)=0
virtual void generateProceduralWood(OdGiPixelBGRA32 color1, OdGiPixelBGRA32 color2, double radialNoise, double axialNoise, double grainThickness, OdGiImageBGRA32 &image, double renderCoef=1.0)=0
ODRX_DECLARE_MEMBERS(OdGiProceduralGenerator)
virtual void generateProceduralMarble(OdGiPixelBGRA32 stoneColor, OdGiPixelBGRA32 veinColor, double veinSpacing, double veinWidth, OdGiImageBGRA32 &image, double renderCoef=1.0)=0
virtual const OdGiGradientGenerator & colorGradient() const =0
virtual bool generateProceduralTexture(OdGiProceduralTexturePtr pTexture, OdGiImageBGRA32 &image, double renderCoef=1.0)=0
ODRX_DECLARE_MEMBERS(OdGiProceduralGeneratorPE)
virtual bool generateProceduralTexture(OdGiProceduralTexturePtr pTexture, OdGiImageBGRA32 &image, double renderCoef=1.0)=0
GLfloat GLfloat GLfloat alpha
Definition: gles2_ext.h:147