DrawModes.hh 25.2 KB
Newer Older
Jan Möbius's avatar
Jan Möbius committed
1
2
3
/*===========================================================================*\
 *                                                                           *
 *                              OpenFlipper                                  *
Jan Möbius's avatar
Jan Möbius committed
4
5
6
7
 *           Copyright (c) 2001-2015, RWTH-Aachen University                 *
 *           Department of Computer Graphics and Multimedia                  *
 *                          All rights reserved.                             *
 *                            www.openflipper.org                            *
Jan Möbius's avatar
Jan Möbius committed
8
9
 *                                                                           *
 *---------------------------------------------------------------------------*
Jan Möbius's avatar
Jan Möbius committed
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
 * This file is part of OpenFlipper.                                         *
 *---------------------------------------------------------------------------*
 *                                                                           *
 * Redistribution and use in source and binary forms, with or without        *
 * modification, are permitted provided that the following conditions        *
 * are met:                                                                  *
 *                                                                           *
 * 1. Redistributions of source code must retain the above copyright notice, *
 *    this list of conditions and the following disclaimer.                  *
 *                                                                           *
 * 2. Redistributions in binary form must reproduce the above copyright      *
 *    notice, this list of conditions and the following disclaimer in the    *
 *    documentation and/or other materials provided with the distribution.   *
 *                                                                           *
 * 3. Neither the name of the copyright holder nor the names of its          *
 *    contributors may be used to endorse or promote products derived from   *
 *    this software without specific prior written permission.               *
 *                                                                           *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS       *
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A           *
 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,  *
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,       *
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR        *
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    *
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING      *
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS        *
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              *
Jan Möbius's avatar
Jan Möbius committed
39
40
41
42
43
 *                                                                           *
\*===========================================================================*/

/*===========================================================================*\
 *                                                                           *
Jan Möbius's avatar
Jan Möbius committed
44
 *   $Revision$                                                       *
Jan Möbius's avatar
Jan Möbius committed
45
46
47
48
 *   $Author$                                                      *
 *   $Date$                   *
 *                                                                           *
\*===========================================================================*/
Jan Möbius's avatar
 
Jan Möbius committed
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79




//=============================================================================
//
//  CLASS DrawModes
//
//=============================================================================

#ifndef ACG_DRAWMODES_HH
#define ACG_DRAWMODES_HH


//== FORWARD DECLARATIONS =====================================================


namespace ACG 
{
  namespace SceneGraph 
  {
    class BaseNode;
  }
}


//== INCLUDES =================================================================

#include <string>
#include <vector>
#include "../Config/ACGDefines.hh"
Jan Möbius's avatar
Jan Möbius committed
80
#include <bitset>
Jan Möbius's avatar
 
Jan Möbius committed
81

82
83
84
85
86
// Avoid compiler warning in MSC
#if defined (_MSC_VER)
#   pragma warning (disable:4251)
#endif

Jan Möbius's avatar
 
Jan Möbius committed
87
88
89
90
91
92
93
94
95
96
97
//== NAMESPACES ===============================================================


namespace ACG {
namespace SceneGraph {

/** This namespace consists of the definition of all available draw modes,  
    function to get their name (description()) and to include them in a
    QPopupMenu.
*/

98

Jan Möbius's avatar
 
Jan Möbius committed
99
100
namespace DrawModes {

101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143

  /** \brief Lighting stage of a mesh: unlit, smooth, phong
   *
   *   Don't confuse this with the interpolation mode of vertex attributes.
   *   This only says where to apply lighting, and nothing else.
   *
   *   Instead the interpolation mode is customizable for each attribute,
   *   making DrawModeProperties more flexible.
   *
   *   flat shading can be achieved by using LIGHTSTAGE_SMOOTH
   *   and setting the normal source to NORMAL_PER_FACE
   */
  enum DrawModeLightStage
  {
    LIGHTSTAGE_UNLIT,  /**< No lighting,  normals may be used by user defined shaders */
    LIGHTSTAGE_SMOOTH, /**< Perform lighting in vertex shader   */
    LIGHTSTAGE_PHONG   /**< Perform lighting in fragment shader */
  };

  /** \brief Primitive mode of a mesh.
   *
   *  Example: PRIMITIVE_EDGE on a polygon mesh renders only edges of the mesh.
   */
  enum DrawModePrimitive
  {
    PRIMITIVE_POINT,
    PRIMITIVE_EDGE,
    PRIMITIVE_HALFEDGE,
    PRIMITIVE_WIREFRAME,
    PRIMITIVE_HIDDENLINE,
    PRIMITIVE_POLYGON,
    PRIMITIVE_CELL
  };

  /** \brief Source of Primitive Colors.
   *
   *   This is interpreted as a per vertex diffuse and ambient color and multiplied with
   *   the material diffuse/ambient colors.
   */
  enum DrawModeColorSource
  {
    COLOR_NONE,         /**< Use material colors only */
    COLOR_PER_VERTEX,   /**< Load per vertex colors and modulate with material color */
144
    COLOR_PER_EDGE, /**< Load per edge colors and modulate with material color */
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
    COLOR_PER_HALFEDGE, /**< Load per halfedge colors and modulate with material color */
    COLOR_PER_FACE      /**< Load per face colors and modulate with material color */
  };

  /** \brief Source of Texture Coordinates.
   *
   *   This must be specified for a textured draw.
   */
  enum DrawModeTexCoordSource
  {
    TEXCOORD_NONE,         /**< Disable texture mapping */
    TEXCOORD_PER_VERTEX,   /**< Use per vertex texcoords for texture mapping */
    TEXCOORD_PER_HALFEDGE, /**< Use per halfedge texcoords for texture mapping */
    //  TEXCOORD_PER_FACE // TODO: discuss texcoords per face? is it useful?
  };

  /** \brief Source of Normals.
   *
   *   This must be specified if lighting is enabled.
   */
  enum DrawModeNormalSource
  {
    NORMAL_NONE,          /**< Disable lighting */
    NORMAL_PER_VERTEX,    /**< Use per vertex normals */
    NORMAL_PER_HALFEDGE,  /**< Use per halfedge normals */
    NORMAL_PER_FACE       /**< Use per face normals \note per face is implicitly used in SHADE_FLAT mode  */
  };

173
  typedef std::bitset<128> ModeFlagSet;
Jan Möbius's avatar
Jan Möbius committed
174

175
  /** \brief DrawModeProperties stores a set of properties that defines, how to render an object.
176
   *
177
178
179
180
181
   * A property may be the primitive type, normal source, color source ...
   * Each property is atomic, i.e. it can not be combined with other properties of the same type.
   *  Example:  primitive may be PRIMITIVE_POLYGON or PRIMITIVE_POINTS, but not both at the same time.
   *  This restriction makes a property set well defined; it is always a valid set of properties.
   *  To have combined DrawModes i.e. flat + wireframe you have to use the layer approach of DrawMode.
182
183
   */
  class ACGDLLEXPORT DrawModeProperties {
184

185
  public:
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
    DrawModeProperties(
      DrawModePrimitive _primitive = PRIMITIVE_POLYGON,
      DrawModeLightStage _lightStage = LIGHTSTAGE_UNLIT,
      DrawModeNormalSource _normalSource = NORMAL_NONE,
      DrawModeColorSource _colorSource = COLOR_NONE,
      DrawModeTexCoordSource _texcoordSource = TEXCOORD_NONE,
      bool _envMapping = false);

    //===========================================================================
      /** @name Getter/Setter of all properties
      * @{ */
    //===========================================================================

    DrawModePrimitive primitive() const { return primitive_; }
    void primitive(DrawModePrimitive _val) { primitive_ = _val; }

    DrawModeLightStage lightStage() const { return lightStage_; }
    void lightStage(DrawModeLightStage _val) { lightStage_ = _val; }

    DrawModeColorSource colorSource() const { return colorSource_; }
    void colorSource(DrawModeColorSource _val) { colorSource_ = _val; }

    DrawModeNormalSource normalSource() const { return normalSource_; }
    void normalSource(DrawModeNormalSource _val) { normalSource_ = _val; }

    DrawModeTexCoordSource texcoordSource() const { return texcoordSource_; }
    void texcoordSource(DrawModeTexCoordSource _val) { texcoordSource_ = _val; }

    /** @} */

    //===========================================================================
      /** @name Helper functions for more convenient use in renderer
      * @{ */
    //===========================================================================

    /// Is lighting enabled?
    bool lighting() const { return lightStage_ != LIGHTSTAGE_UNLIT && normalSource_ != NORMAL_NONE; }

    /// Is texturing enabled?
    bool textured() const { return texcoordSource_ != TEXCOORD_NONE; }

    /// Are colors used?
    bool colored() const { return colorSource_ != COLOR_NONE; }

    /// Is flat shading used (Normals per face)?
    bool flatShaded() const { return normalSource_ == NORMAL_PER_FACE; }
232
233
234
235
236
237
238
239
240
241
242
    /** @} */

    //===========================================================================
      /** @name Comparison functions
      * @{ */
    //===========================================================================

    /** \brief compare two properties
     *
     * @param _other Right hand side
     */
Jan Möbius's avatar
Jan Möbius committed
243
    bool operator!=( const DrawModeProperties& _other ) const {
244
245
246
247
248
249
250
251
      return ( (envMapped_      != _other.envMapped_)      ||
               (primitive_      != _other.primitive_)      ||
               (lightStage_     != _other.lightStage_)     ||
               (colorSource_    != _other.colorSource_)    ||
               (texcoordSource_ != _other.texcoordSource_) ||
               (normalSource_   != _other.normalSource_)
              );
    }
252
253
254
255
256
257
258
259
260
261
262
263
264
265
    
    /** \brief compare two properties
     *
     * @param _other Right hand side
     */
    bool operator==( const DrawModeProperties& _other ) const {
      return ( (envMapped_      == _other.envMapped_)      &&
               (primitive_      == _other.primitive_)      &&
               (lightStage_     == _other.lightStage_)     &&
               (colorSource_    == _other.colorSource_)    &&
               (texcoordSource_ == _other.texcoordSource_) &&
               (normalSource_   == _other.normalSource_)
              );
    }
266
267

    /** @} */
268
269
270

  private:

271
272
273
274
    bool envMapped_;

    /// Specify which type of primitives will get uploaded to the graphics card
    DrawModePrimitive primitive_;
275

276
277
278
279
280
281
282
    DrawModeLightStage lightStage_;

    DrawModeColorSource colorSource_;

    DrawModeTexCoordSource texcoordSource_;

    DrawModeNormalSource normalSource_;
283
284
285
286
287

    // TODO: Shaders

  };

288
289
290
291
292
293
  /** \brief Specifies a DrawMode
   *
   * This class specifies a DrawMode. It can contain several properties and layers
   * that define, how objects will be rendered.
   *
   */
Mike Kremer's avatar
Mike Kremer committed
294
  class ACGDLLEXPORT DrawMode {
Jan Möbius's avatar
Jan Möbius committed
295
296
297
298
299
300
301
    public:
      
      DrawMode(); 
      
      /** \brief constructor for unsigned int. 
      *
      * This constructor creates a DrawMode with the given drawMode index.
302
      * Be CareFull! this constructor can only be used to construct atomic draw modes!
Jan Möbius's avatar
Jan Möbius committed
303
      * The int will not be handled like an bitset but really as an index.
Jan Möbius's avatar
Jan Möbius committed
304
305
306
      * See the list of draw modes below to check for the right numbers.
      * You should use the predefined drawModes or create new ones using the other functions
      * and ignore this constructor!
307
308
      *
      * @param _index Index of the new DrawMode
Jan Möbius's avatar
Jan Möbius committed
309
      */
Jan Möbius's avatar
Jan Möbius committed
310
      DrawMode(size_t _index);
Jan Möbius's avatar
Jan Möbius committed
311
312
313
314
315
      
      /** \brief constructor for ModeFlags. 
      *
      * This constructor creates a DrawMode from a bitset.
      * This makes it easier to predefine draw modes using a bitset.
316
317
      *
      * @param _flags Flags for the new drawmode defined by a bitset
Jan Möbius's avatar
Jan Möbius committed
318
319
      */      
      DrawMode( ModeFlagSet _flags );
320

321
322
323
324
325
326
      /* \brief Returns a registered draw mode based on the description passed or if none could be found the default one.
       *
       * @param _description A description created by description().
       */
      static DrawMode getFromDescription(std::string _description);

327
328
329
330
331

      //===========================================================================
      /** @name Operators
       * @{ */
      //===========================================================================
Jan Möbius's avatar
Jan Möbius committed
332
      DrawMode & operator = (const DrawMode& _mode );
333

Jan Möbius's avatar
Jan Möbius committed
334
      bool operator==(const DrawMode& _mode) const;
335

336
      DrawMode operator&(const DrawMode& _mode) const;
Jan Möbius's avatar
Jan Möbius committed
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
      
      DrawMode& operator++();
      
      DrawMode& operator|=( const DrawMode& _mode2  );
      
      DrawMode& operator&=( const DrawMode& _mode2  );
      
      bool operator!=( const DrawMode& _mode2  ) const;
      
      DrawMode operator|( const DrawMode& _mode2  ) const;
      
      DrawMode operator^( const DrawMode& _mode2  ) const;
      
      DrawMode operator~( ) const;
      
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
      operator bool() const;

      /** @} */

      //===========================================================================
      /** @name Layer Management
       * @{ */
      //===========================================================================

      /** \brief add another layer on top of this drawmode
       *
       * This allows for combinations of DrawModes.
       * The renderer will iterator over all layers of the drawmode
       *  and issue a new draw call for each layer.
       * Example:
       *  layer 0 : flat shading properties
       *  layer 1 : edge drawing properties
       *
       * The result will be a flat shaded object with it's wireframe on top of it.
       * Does duplicate check, in case the property set is already in the layer list.
       *
       * addLayer is also called in bitwise | operator for backwards compatibility with bitset DrawModes
       *
       * @param _props Property that should be added
       */
      void addLayer(const DrawModeProperties* _props); // same as bitwise or operator

      /** \brief returns the layer count
       */
Jan Möbius's avatar
Jan Möbius committed
381
      size_t getNumLayers() const;
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400

      /** \brief returns the property set at layer i
       *
       * @param _i Layer that is requested
       */
      const DrawModeProperties* getLayer(unsigned int _i) const;

      /** \brief remove layer at index i
       *
       * @param _i Layer that is requested
       */
      bool removeLayer(unsigned int _i);

      /** \brief remove layer if it is in list
       *
       * @param _prop Property that should be removed if it's available
       */
      bool removeLayer(const DrawModeProperties* _prop);

401
402
403
404
405
406
407

      /** \brief returns layer index of a property, -1 if not in list
       *
       * @param _prop Property to be searched for
       */
      int getLayerIndex(const DrawModeProperties* _prop) const;

408
409
410
      /** @} */


Jan Möbius's avatar
Jan Möbius committed
411
412
413
414
415
      /** \brief get an index of the current drawMode
      *
      * If this drawMode is a combination of different drawModes, the returned value will be 0.
      * Otherwise the internal flag index will be returned
      */
Jan Möbius's avatar
Jan Möbius committed
416
      size_t getIndex() const;
417
418
419
420
421
422
423
424
425
426
427

      /** \brief filter out one drawmode
      *
      * This removes one or more drawmodes if this drawode is not atomic.
      */
      void filter( DrawMode _filter );


      /** \brief combine with another drawmode
      */
      void combine( DrawMode _mode );
Jan Möbius's avatar
Jan Möbius committed
428
429
430
431
432
      
      /** Get a description string for this DrawMode
      * An empty string is returned if this is not a valid draw mode.
      * this list has the format DrawModeName+DrawMOdeName+...
      */
433
      std::string description() const;
Jan Möbius's avatar
Jan Möbius committed
434
435
436
      
      /** \brief Check if this is an atomic draw Mode
      *
437
      * This function checks, if this is a atomic draw mode ( no combination of multiple draw modes )
Jan Möbius's avatar
Jan Möbius committed
438
      */
Jan Möbius's avatar
Jan Möbius committed
439
      bool isAtomic() const;
Jan Möbius's avatar
Jan Möbius committed
440
441
442
      
      /** \brief Check whether an Atomic DrawMode is active in this draw Mode
      */ 
443
      bool containsAtomicDrawMode( DrawMode _atomicDrawMode ) const;
Jan Möbius's avatar
Jan Möbius committed
444
      
445
      /** \brief Separates this drawMode into a list of all separate atomic draw modes
Jan Möbius's avatar
Jan Möbius committed
446
      *
447
448
      * A drawMode can consist of several atomic draw modes. This function returns a list of the separated
      * atomic draw modes.
Jan Möbius's avatar
Jan Möbius committed
449
      */
450
      std::vector< DrawMode > getAtomicDrawModes() const;
Jan Möbius's avatar
Jan Möbius committed
451
452
453
      
      /** \brief Get the number of maximum Modes which could be handled by the current implementation
      */
Jan Möbius's avatar
Jan Möbius committed
454
      size_t maxModes() const;
Jan Möbius's avatar
Jan Möbius committed
455
      
456

457
458
459
460
461
462
463
464
465
466
467
468
469
470
      /** \brief returns the base properties of this draw mode
       *
       * Base properties are the original properties that defined the DrawMode before any merge operation.
       * They are located at layer 0, so actually this function has the same effect as getLayer(0).
       * 
       * Every DrawMode is property based with only two exceptions:
       *  - NONE
       *  - DEFAULT
       *
       * getDrawModeProperties returns 0 for these.
       */
      const DrawModeProperties* getDrawModeProperties() const;

      /** \brief set the base properties of this draw mode
471
       *
472
       * @param _props Properties to be set
473
       */
474
      void setDrawModeProperties(const DrawModeProperties* _props);
475

476
      /** \brief set the base properties of this draw mode
477
       *
478
       * @param _props Properties to be set
479
       */
480
481
482
      void setDrawModeProperties(const DrawModeProperties& _props);


483
484
485
486
487
488
      /** \brief checks consistency of property layers
       *
       * There should only be at most one layer for each primitive type for example
       */
      bool checkConsistency() const;

489
490
491
492
493
494
495
496
497

      /** \brief search for layer with specified primitive
       *
       * @param _type primitive type
       * @return layer id if layer exists, -1 otherwise
       */
      int getLayerIndexByPrimitive(DrawModePrimitive _type) const;


Jan Möbius's avatar
Jan Möbius committed
498
499
    private:
      ModeFlagSet modeFlags_;
500
501
502
503
504
505

      /** vector for combined DrawModes
      * -> holds DrawModeProperties for each layer
      * -> original layer at index 0
      */
      std::vector<DrawModeProperties> layers_;
Jan Möbius's avatar
 
Jan Möbius committed
506
  };
Jan Möbius's avatar
Jan Möbius committed
507
  
508
    
Jan Möbius's avatar
Jan Möbius committed
509
  /// not a valid draw mode
Jan Möbius's avatar
Jan Möbius committed
510
  extern ACGDLLEXPORT DrawMode NONE;
Jan Möbius's avatar
Jan Möbius committed
511
  /// use the default (global) draw mode and not the node's own.
Jan Möbius's avatar
Jan Möbius committed
512
  extern ACGDLLEXPORT DrawMode DEFAULT;
Jan Möbius's avatar
Jan Möbius committed
513
514
515
516
517
  
  //======================================================================
  //  Point Based Rendering Modes
  //======================================================================
  /// draw unlighted points using the default base color
Jan Möbius's avatar
Jan Möbius committed
518
  extern ACGDLLEXPORT DrawMode POINTS;
519

Jan Möbius's avatar
Jan Möbius committed
520
  /// draw colored, but not lighted points (requires point colors)
Jan Möbius's avatar
Jan Möbius committed
521
  extern ACGDLLEXPORT DrawMode POINTS_COLORED;
Jan Möbius's avatar
Jan Möbius committed
522
  /// draw shaded points (requires point normals)
Jan Möbius's avatar
Jan Möbius committed
523
  extern ACGDLLEXPORT DrawMode POINTS_SHADED;
Jan Möbius's avatar
Jan Möbius committed
524
525
526
527
  
  //======================================================================
  //  Edge Based Rendering Modes
  //======================================================================
528
  /// draw edges
Jan Möbius's avatar
Jan Möbius committed
529
  extern ACGDLLEXPORT DrawMode EDGES;
530
531

  /// draw edges with colors (without shading)
Jan Möbius's avatar
Jan Möbius committed
532
  extern ACGDLLEXPORT DrawMode EDGES_COLORED;
Jan Möbius's avatar
Jan Möbius committed
533
  /// draw wireframe
Jan Möbius's avatar
Jan Möbius committed
534
  extern ACGDLLEXPORT DrawMode WIREFRAME;
Jan Möbius's avatar
Jan Möbius committed
535
536
537
538
  
  //======================================================================
  //  Face Based Rendering Modes
  //======================================================================  
539
  // draw faces
Jan Möbius's avatar
Jan Möbius committed
540
  extern ACGDLLEXPORT DrawMode FACES;
Jan Möbius's avatar
Jan Möbius committed
541
542

  /// draw hidden line (2 rendering passes needed)
Jan Möbius's avatar
Jan Möbius committed
543
  extern ACGDLLEXPORT DrawMode HIDDENLINE;
Jan Möbius's avatar
Jan Möbius committed
544
  /// draw flat shaded faces (requires face normals)
Jan Möbius's avatar
Jan Möbius committed
545
  extern ACGDLLEXPORT DrawMode SOLID_FLAT_SHADED;
Jan Möbius's avatar
Jan Möbius committed
546
  /// draw smooth shaded (Gouraud shaded) faces (requires halfedge normals)  
Jan Möbius's avatar
Jan Möbius committed
547
  extern ACGDLLEXPORT DrawMode SOLID_SMOOTH_SHADED;
Jan Möbius's avatar
Jan Möbius committed
548
  /// draw phong shaded faces
Jan Möbius's avatar
Jan Möbius committed
549
  extern ACGDLLEXPORT DrawMode SOLID_PHONG_SHADED;
Jan Möbius's avatar
Jan Möbius committed
550
  /// draw colored, but not lighted faces using face colors
Jan Möbius's avatar
Jan Möbius committed
551
  extern ACGDLLEXPORT DrawMode SOLID_FACES_COLORED;
552
  /// draw colored, but not lighted faces using interpolated vertex colors
Jan Möbius's avatar
Jan Möbius committed
553
  extern ACGDLLEXPORT DrawMode SOLID_POINTS_COLORED;
554
555
  /// draw faces, but use Gouraud shading to interpolate vertex colors
  extern ACGDLLEXPORT DrawMode SOLID_POINTS_COLORED_SHADED;
Jan Möbius's avatar
Jan Möbius committed
556
  /// draw environment mapped  
Jan Möbius's avatar
Jan Möbius committed
557
  extern ACGDLLEXPORT DrawMode SOLID_ENV_MAPPED;
Jan Möbius's avatar
Jan Möbius committed
558
  /// draw textured faces
Jan Möbius's avatar
Jan Möbius committed
559
  extern ACGDLLEXPORT DrawMode SOLID_TEXTURED;
Jan Möbius's avatar
Jan Möbius committed
560
  /// draw smooth shaded textured faces
Jan Möbius's avatar
Jan Möbius committed
561
  extern ACGDLLEXPORT DrawMode SOLID_TEXTURED_SHADED;
Jan Möbius's avatar
Jan Möbius committed
562
  /// draw textured faces
Jan Möbius's avatar
Jan Möbius committed
563
  extern ACGDLLEXPORT DrawMode SOLID_1DTEXTURED;
Jan Möbius's avatar
Jan Möbius committed
564
  /// draw smooth shaded textured faces
Jan Möbius's avatar
Jan Möbius committed
565
  extern ACGDLLEXPORT DrawMode SOLID_1DTEXTURED_SHADED;
Jan Möbius's avatar
Jan Möbius committed
566
  /// draw textured faces
Jan Möbius's avatar
Jan Möbius committed
567
  extern ACGDLLEXPORT DrawMode SOLID_3DTEXTURED;
Jan Möbius's avatar
Jan Möbius committed
568
  /// draw smooth shaded textured faces
Jan Möbius's avatar
Jan Möbius committed
569
  extern ACGDLLEXPORT DrawMode SOLID_3DTEXTURED_SHADED;
Jan Möbius's avatar
Jan Möbius committed
570
  /// draw flat shaded and colored faces (requires face normals and colors)
Jan Möbius's avatar
Jan Möbius committed
571
  extern ACGDLLEXPORT DrawMode SOLID_FACES_COLORED_FLAT_SHADED;
572
573
  /// draw smooth shaded and colored faces (requires vertex normals and face colors)
  extern ACGDLLEXPORT DrawMode SOLID_FACES_COLORED_SMOOTH_SHADED;
574
575
  /// draw per halfedge texture faces modulated with face colors with smooth shading
  extern ACGDLLEXPORT DrawMode SOLID_FACES_COLORED_2DTEXTURED_FACE_SMOOTH_SHADED;
Jan Möbius's avatar
Jan Möbius committed
576
  /// draw per halfedge textured faces
Jan Möbius's avatar
Jan Möbius committed
577
  extern ACGDLLEXPORT DrawMode SOLID_2DTEXTURED_FACE;
Jan Möbius's avatar
Jan Möbius committed
578
  /// draw per halfedge textured faces
Jan Möbius's avatar
Jan Möbius committed
579
  extern ACGDLLEXPORT DrawMode SOLID_2DTEXTURED_FACE_SHADED;
Jan Möbius's avatar
Jan Möbius committed
580
581
  /// drawing is controlled by shaders
  /// ( Use shadernodes to set them before the actual object to render)
Jan Möbius's avatar
Jan Möbius committed
582
  extern ACGDLLEXPORT DrawMode SOLID_SHADER;
583
584
  /// draw smooth shaded (Gouraud shaded) faces (requires halfedge normals)
  extern ACGDLLEXPORT DrawMode SOLID_SMOOTH_SHADED_FEATURES;
585
586
587
588
589

  //======================================================================
  //  Face Based Rendering Modes
  //======================================================================  
  // draw cells
Jan Möbius's avatar
Jan Möbius committed
590
  extern ACGDLLEXPORT DrawMode CELLS;
591
592

  /// draw cells with colors (without shading)
Jan Möbius's avatar
Jan Möbius committed
593
  extern ACGDLLEXPORT DrawMode CELLS_COLORED;
594
595


596
597
598
599
  //======================================================================
  //  Halfedge Based Rendering Modes
  //======================================================================
  /// draw halfedges
Jan Möbius's avatar
Jan Möbius committed
600
  extern ACGDLLEXPORT DrawMode HALFEDGES;
601
602

  /// draw halfedges with colors (without shading)
Jan Möbius's avatar
Jan Möbius committed
603
  extern ACGDLLEXPORT DrawMode HALFEDGES_COLORED;
604

605

Jan Möbius's avatar
Jan Möbius committed
606
  /// marks the last used ID
Jan Möbius's avatar
Jan Möbius committed
607
  extern ACGDLLEXPORT DrawMode UNUSED;
Jan Möbius's avatar
Jan Möbius committed
608
  
Jan Möbius's avatar
 
Jan Möbius committed
609

Jan Möbius's avatar
Jan Möbius committed
610
611
612
  //=======================================================================
  // Non Member Functions
  //=======================================================================
Jan Möbius's avatar
 
Jan Möbius committed
613
614
615
616
617
618
619
  
  /** Initialize the default modes.
      This function has to be called at least once at application startup.
  */
  ACGDLLEXPORT 
  void initializeDefaultDrawModes( void );

620
621
622
623
624
  /** \brief Add a custom DrawMode.
   *
      The id of the new draw mode is returned. If it already exists, the id of the existing one
      is returned.

Jan Möbius's avatar
Jan Möbius committed
625
626
627
628
629
      Property based draw modes consist of various flags, which define which primitives and
      additional information are send to the gpu.

      @param _name Name of the draw mode to add
      @param _propertyBased If set to true a property based draw mode is created.
630
      @return Id of the new draw mode
Jan Möbius's avatar
 
Jan Möbius committed
631
  */
632
633
  ACGDLLEXPORT
  const DrawMode& addDrawMode( const std::string & _name, bool _propertyBased = false);
634

635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
  /** \brief Add a custom property based DrawMode.
   *
   * The id of the new draw mode is returned. If it already exists, the id of the existing one
   * is returned.
   *
   * \note If the DrawMode already exists, the properties will be applied to the existing mode!!
   *
   * Property based draw modes consist of various flags, which define which primitives and
   * additional information are send to the gpu.
   *
   * @param _name       Name of the draw mode to add
   * @param _properties Properties of the drawmode
   * @return Id of the new draw mode
  */
  ACGDLLEXPORT
Jan Möbius's avatar
Jan Möbius committed
650
  const DrawMode& addDrawMode( const std::string & _name, const DrawModeProperties& _properties);
651

652
653
654
655
  /** \brief Get a custom DrawMode.
   *
      The id of the draw mode is returned or if it does not exist, DrawMode::NONE is returned.

656
      @param _name Name of the DrawMode
657
      @return Id of the draw mode or DrawModes::NONE
658
659
  */
  ACGDLLEXPORT 
660
661
  const DrawMode& getDrawMode( const std::string & _name);

Jan Möbius's avatar
Jan Möbius committed
662
663
664
  
  /** \brief Check if the given draw mode exists
  *
Jan Möbius's avatar
 
Jan Möbius committed
665
  */
Jan Möbius's avatar
Jan Möbius committed
666
667
668
669
  ACGDLLEXPORT   
  bool drawModeExists(const std::string & _name);
  
  /** \brief given an index of an atomic draw mode, return the drawmode
Jan Möbius's avatar
 
Jan Möbius committed
670
671
  */
  ACGDLLEXPORT 
Jan Möbius's avatar
Jan Möbius committed
672
  DrawMode getDrawModeFromIndex( unsigned int _index );
Jan Möbius's avatar
 
Jan Möbius committed
673
674
675
676
677
678
679
680
681

//=============================================================================
} // namespace DrawModes
} // namespace SceneGraph
} // namespace ACG
//=============================================================================
#endif // ACG_DRAWMODES_HH defined
//=============================================================================