Ocean
PrimitiveAttribute.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_RENDERING_PRIMITIVE_ATTRIBUTE_H
9 #define META_OCEAN_RENDERING_PRIMITIVE_ATTRIBUTE_H
10 
13 
14 namespace Ocean
15 {
16 
17 namespace Rendering
18 {
19 
20 // Forward declaration
21 class PrimitiveAttribute;
22 
23 /**
24  * Definition of a smart object reference holding a primitive attribute.
25  * @see SmartObjectRef, PrimitiveAttribute.
26  * @ingroup rendering
27  */
29 
30 /**
31  * This class implements an attribute specifying face and culling properties of primitives.
32  * @ingroup rendering
33  */
34 class OCEAN_RENDERING_EXPORT PrimitiveAttribute : virtual public Attribute
35 {
36  public:
37 
38  /**
39  * Defines different face rendering modes.
40  */
41  enum FaceMode
42  {
43  /// Face rendering mode rendering the entire face, which is the default mode.
45  /// Line rendering mode rendering the face outlines only.
47  /// Point rendering mode rendering the face vertices only.
49  /// Default face mode.
50  MODE_DEFAULT
51  };
52 
53  /**
54  * Defines different face culling modes.
55  */
57  {
58  /// Neither front nor back faces culling which results in front and back face rendering.
59  CULLING_NONE = 0,
60  /// Back face culling mode rendering front faces only, which is the default mode.
61  CULLING_BACK = 1,
62  /// Front face culling mode rendering back faces only.
63  CULLING_FRONT = 2,
64  /// Front and back face culling mode rendering neither front nor back faces.
65  CULLING_BOTH = CULLING_BACK | CULLING_FRONT,
66  /// Default culling mode.
67  CULLING_DEFAULT
68  };
69 
70  /**
71  * Definition of different lighting modes.
72  */
74  {
75  /// Front face is lighted.
77  /// Both faces are lighted.
79  /// Default lighting.
80  LM_DEFAULT
81  };
82 
83  public:
84 
85  /**
86  * Returns the face mode of this attribute.
87  * The default is MODE_FACE.
88  * @return Face mode
89  * @see setFaceMode(), Framebuffer::faceMode().
90  * @exception NotSupportedException Is thrown if this function is not supported
91  */
92  virtual FaceMode faceMode() const;
93 
94  /**
95  * Returns the culling mode of this attribute.
96  * The default is CULLLING_BACK.
97  * @return Culling mode
98  * @see setCullingMode(), Framebuffer::cullingMode().
99  * @exception NotSupportedException Is thrown if this function is not supported
100  */
101  virtual CullingMode cullingMode() const;
102 
103  /**
104  * Returns the lighting mode of this attribute.
105  * If both sides are lighted the back face is lighted using the inversed normal.<br>
106  * The default is LM_SINGLE_LIGHTING.
107  * @return Lighting mode
108  * @see setLightingMode(), Framebuffer::lightingMode().
109  * @exception NotSupportedException Is thrown if this function is not supported
110  */
111  virtual LightingMode lightingMode() const;
112 
113  /**
114  * Sets the face mode for this attribute.
115  * @param mode Face mode to set
116  * @see faceMode(), Framebuffer::setFaceMode().
117  * @exception NotSupportedException Is thrown if this function is not supported
118  */
119  virtual void setFaceMode(const FaceMode mode);
120 
121  /**
122  * Sets the culling mode for this attribute.
123  * @param culling Culling mode to set
124  * @see cullingMode(), Framebuffer::setCullingMode().
125  * @exception NotSupportedException Is thrown if this function is not supported
126  */
127  virtual void setCullingMode(const CullingMode culling);
128 
129  /**
130  * Sets the lighting mode for this attribute.
131  * @param lighting Lighting mode to set
132  * @see lightingMode(), Framebuffer::setLightingMode().
133  * @exception NotSupportedException Is thrown if this function is not supported
134  */
135  virtual void setLightingMode(const LightingMode lighting);
136 
137  /**
138  * Returns the type of this object.
139  * @see Object::type().
140  */
141  ObjectType type() const override;
142 
143  protected:
144 
145  /**
146  * Creates a new primitive attribute.
147  */
149 };
150 
151 }
152 
153 }
154 
155 #endif // META_OCEAN_RENDERING_PRIMITIVE_ATTRIBUTE_H
This class is the base class for all rendering attribute objects.
Definition: Attribute.h:39
ObjectType
Definition of different object type.
Definition: Object.h:63
This class implements an attribute specifying face and culling properties of primitives.
Definition: PrimitiveAttribute.h:35
ObjectType type() const override
Returns the type of this object.
virtual FaceMode faceMode() const
Returns the face mode of this attribute.
virtual void setCullingMode(const CullingMode culling)
Sets the culling mode for this attribute.
virtual void setFaceMode(const FaceMode mode)
Sets the face mode for this attribute.
virtual void setLightingMode(const LightingMode lighting)
Sets the lighting mode for this attribute.
FaceMode
Defines different face rendering modes.
Definition: PrimitiveAttribute.h:42
@ MODE_FACE
Face rendering mode rendering the entire face, which is the default mode.
Definition: PrimitiveAttribute.h:44
@ MODE_LINE
Line rendering mode rendering the face outlines only.
Definition: PrimitiveAttribute.h:46
@ MODE_POINT
Point rendering mode rendering the face vertices only.
Definition: PrimitiveAttribute.h:48
CullingMode
Defines different face culling modes.
Definition: PrimitiveAttribute.h:57
virtual CullingMode cullingMode() const
Returns the culling mode of this attribute.
virtual LightingMode lightingMode() const
Returns the lighting mode of this attribute.
PrimitiveAttribute()
Creates a new primitive attribute.
LightingMode
Definition of different lighting modes.
Definition: PrimitiveAttribute.h:74
@ LM_SINGLE_SIDE_LIGHTING
Front face is lighted.
Definition: PrimitiveAttribute.h:76
@ LM_TWO_SIDED_LIGHTING
Both faces are lighted.
Definition: PrimitiveAttribute.h:78
This class implements a smart rendering object reference.
Definition: rendering/ObjectRef.h:34
SmartObjectRef< PrimitiveAttribute > PrimitiveAttributeRef
Definition of a smart object reference holding a primitive attribute.
Definition: PrimitiveAttribute.h:21
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15