Free Electron
DrawHydra.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __usd_DrawHydra_h__
8 #define __usd_DrawHydra_h__
9 namespace fe
10 {
11 namespace ext
12 {
13 
14 /**************************************************************************//**
15  @brief Hydra-specific replacements for DrawI
16 
17  @ingroup usd
18 
19  Features not implemented using Hydra may fall back on DrawOpenGL.
20 *//***************************************************************************/
21 class FE_DL_EXPORT DrawHydra: public DrawOpenGL,
22  public Initialize<DrawHydra>
23 {
24  public:
25  DrawHydra();
26 virtual ~DrawHydra();
27 
28  void initialize(void);
29 
30 virtual void flush(void);
31 virtual sp<DrawBufferI> createBuffer(void);
32 
33  using DrawOpenGL::drawPoints;
34 
35 virtual void drawPoints(const SpatialVector *vertex,
36  const SpatialVector *normal,U32 vertices,
37  BWORD multicolor,const Color *color,
38  sp<DrawBufferI> spDrawBuffer);
39 
40  using DrawOpenGL::drawTriangles;
41 
42 virtual void drawTriangles(const SpatialVector *vertex,
43  const SpatialVector *normal,
44  const Vector2 *texture,U32 vertices,
45  StripMode strip,BWORD multicolor,
46  const Color *color,
47  const Array<I32>* vertexMap,
48  const Array<I32>* hullPointMap,
49  const Array<Vector4i>* hullFacePoint,
50  sp<DrawBufferI> spDrawBuffer);
51 
52  //* NOTE can't use DrawOpenGL versions of
53  //* transformed draw that leverage glMultMatrix
54 
55  using DrawCommon::drawTransformedPoints;
56 
57 virtual void drawTransformedPoints(
58  const SpatialTransform &transform,
59  const SpatialVector *scale,
60  const SpatialVector *vertex,
61  const SpatialVector *normal,U32 vertices,
62  BWORD multicolor,const Color *color,
63  sp<DrawBufferI> spDrawBuffer);
64 
65  using DrawCommon::drawTransformedLines;
66 
67 virtual void drawTransformedLines(
68  const SpatialTransform &transform,
69  const SpatialVector *scale,
70  const SpatialVector *vertex,
71  const SpatialVector *normal,
72  U32 vertices,StripMode strip,
73  BWORD multicolor,const Color *color,
74  BWORD multiradius,const Real *radius,
75  const Vector3i *element,U32 elementCount,
76  sp<DrawBufferI> spDrawBuffer);
77 
78  using DrawCommon::drawTransformedTriangles;
79 
80 virtual void drawTransformedTriangles(
81  const SpatialTransform &transform,
82  const SpatialVector *scale,
83  const SpatialVector *vertex,
84  const SpatialVector *normal,
85  const Vector2 *texture,
86  U32 vertices,StripMode strip,BWORD multicolor,
87  const Color *color,
88  const Array<I32>* vertexMap,
89  const Array<I32>* hullPointMap,
90  const Array<Vector4i>* hullFacePoint,
91  sp<DrawBufferI> spDrawBuffer);
92 
93  protected:
94 
95 static GfMatrix4f convertToGfMatrix4f(
96  const SpatialTransform& rTransform);
97 static GfMatrix4d convertToGfMatrix4d(
98  const SpatialTransform& rTransform);
99 
100  void createMaterial1(void);
101  void createMaterial2(void);
102 
103 virtual void drawLinesInternal(const SpatialVector *vertex,
104  const SpatialVector *normal,
105  const Vector2 *texture,U32 vertices,
106  StripMode strip,
107  BWORD multicolor,const Color *color,
108  BWORD multiradius,const Real *radius,
109  const Vector3i *element,U32 elementCount,
110  sp<DrawBufferI> spDrawBuffer);
111 
112 virtual void drawPolys(U32 grain,const SpatialVector *vertex,
113  const SpatialVector *normal,
114  const Vector2 *texture,
115  U32 vertices,StripMode strip,
116  BWORD multicolor,const Color *color,
117  const Array<I32>* vertexMap,
118  const Array<I32>* hullPointMap,
119  const Array<Vector4i>* hullFacePoint,
120  sp<DrawBufferI> spDrawBuffer);
121 
122  class Buffer:
123  public DrawOpenGL::Buffer,
124  public CastableAs<Buffer>
125  {
126  public:
127  Buffer(void);
128  virtual ~Buffer(void);
129  void releaseAll(void);
130 
131  HydraDriver* m_pHydraDriver;
132  String m_nodeName;
133  BWORD m_current;
134  I32 m_recent;
135  I32 m_vertices;
136  BWORD m_multicolor;
137  Color m_firstColor;
138  };
139 
140  private:
141 
142 static String convertName(String a_name);
143  void ensureDriver(void);
144  void updateCameraAndLighting(void);
145  void updateNode(sp<Buffer> spDrawBuffer);
146  void drawNodes(void);
147 
148  HdEngine m_engine;
149  HydraDriver* m_pHydraDriver;
150  I32 m_refineLevel;
151  Real m_alphaMin;
152  I32 m_shadowResolution;
153  Real m_shadowBias;
154 
155  std::map<String, sp<Buffer> > m_bufferMap;
156 };
157 
158 } /* namespace ext */
159 } /* namespace fe */
160 
161 #endif /* __usd_DrawHydra_h__ */
kernel
Definition: namespace.dox:3
StripMode
Format of vertices for tri-stripping.
Definition: DrawI.h:26
Hydra-specific replacements for DrawI.
Definition: DrawHydra.h:21
Per-class participation in the Initialized <> mechanism.
Definition: Initialized.h:117
A unit test driver that exercises the core engine.
Definition: HydraDriver.h:49
Special vector for color (RGBA)
Definition: Color.h:21
Automatically reference-counted string container.
Definition: String.h:128
OpenGL-specific implementations for DrawI.
Definition: DrawOpenGL.h:25
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53
Per-class participation non-RTTI fallback dynamic casting mechanism.
Definition: Castable.h:192