opennurbs_rendering.h
1 /* $NoKeywords: $ */
2 /*
3 //
4 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
5 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
6 // McNeel & Associates.
7 //
8 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
9 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
10 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
11 //
12 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
13 //
14 ////////////////////////////////////////////////////////////////
15 */
16 
17 #if !defined(OPENNURBS_RENDERING_INC_)
18 #define OPENNURBS_RENDERING_INC_
19 
20 
21 class ON_CLASS ON_RenderingAttributes
22 {
23 public:
25  void Default();
26  int Compare( const ON_RenderingAttributes& other ) const;
27  bool Write( ON_BinaryArchive& archive ) const;
28  bool Read( ON_BinaryArchive& archive );
29 
30  bool IsValid( ON_TextLog* text_log ) const;
31 
32 
33  const ON_MaterialRef* MaterialRef( const ON_UUID& plugin_id ) const;
34 
36 };
37 
39 {
40 public:
42  void Default();
43  int Compare( const ON_ObjectRenderingAttributes& other ) const;
44  bool Write( ON_BinaryArchive& archive ) const;
45  bool Read( ON_BinaryArchive& archive );
46 
47  bool IsValid( ON_TextLog* text_log ) const;
48 
49  /*
50  Description:
51  Update mapping channel transformations.
52  Parameters:
53  xform - [in]
54  Transformation applied to parent object.
55  Returns:
56  True is successful. False if there are mapping channels
57  and xform cannot be inverted.
58  */
59  bool Transform( const ON_Xform& xform );
60 
61  /*
62  Parameters:
63  plugin_id - [in]
64  Returns:
65  A pointer to the plug-in's mapping reference, if there
66  is one. Otherwise nullptr is returned.
67  */
68  const ON_MappingRef* MappingRef(
69  const ON_UUID& plugin_id
70  ) const;
71 
72  /*
73  Parameters:
74  plugin_id - [in]
75  Returns:
76  If a mapping ref exists, it is returned. Otherwise
77  one is added.
78  */
79  ON_MappingRef* AddMappingRef(
80  const ON_UUID& plugin_id
81  );
82 
83  /*
84  Parameters:
85  plugin_id - [in]
86  Returns:
87  If a mapping ref exists, it is returned. Otherwise
88  one is added.
89  */
90  bool DeleteMappingRef(
91  const ON_UUID& plugin_id
92  );
93 
94 
95  /*
96  Parameters:
97  plugin_id - [in]
98  mapping_channel_id - [in]
99  mapping_id - [in]
100  ON_TextureMapping id
101  Returns:
102  A pointer to the plug-in's mapping channel, if there
103  is one. Otherwise nullptr is returned.
104  */
105  const ON_MappingChannel* MappingChannel(
106  const ON_UUID& plugin_id,
107  int mapping_channel_id
108  ) const;
109 
110  const ON_MappingChannel* MappingChannel(
111  const ON_UUID& plugin_id,
112  const ON_UUID& mapping_id
113  ) const;
114 
115 
116  /*
117  Parameters:
118  plugin_id - [in]
119  mapping_channel_id - [in]
120  mapping_id - [in]
121  ON_TextureMapping id
122  Returns:
123  True if the mapping channel was added or a pefect
124  match already existed. False if a mapping channel
125  with a different mapping_id already exists for this
126  plug-in and channel.
127  */
128  bool AddMappingChannel(
129  const ON_UUID& plugin_id,
130  int mapping_channel_id,
131  const ON_UUID& mapping_id
132  );
133 
134  /*
135  Parameters:
136  plugin_id - [in]
137  mapping_channel_id - [in]
138  mapping_id - [in]
139  ON_TextureMapping id
140  Returns:
141  True if a matching mapping channel was deleted.
142  */
143  bool DeleteMappingChannel(
144  const ON_UUID& plugin_id,
145  int mapping_channel_id
146  );
147 
148  bool DeleteMappingChannel(
149  const ON_UUID& plugin_id,
150  const ON_UUID& mapping_id
151  );
152 
153  /*
154  Parameters:
155  plugin_id - [in]
156  old_mapping_channel_id - [in]
157  new_mapping_channel_id - [in]
158  Returns:
159  True if a matching mapping channel was found and changed.
160  */
161  bool ChangeMappingChannel(
162  const ON_UUID& plugin_id,
163  int old_mapping_channel_id,
164  int new_mapping_channel_id
165  );
166 
167  // Use AddMappingRef() or AddMappingChannel() if you
168  // want to add an element to this array.
169  //
170  // Every mapping ref in this array must have
171  // a distinct value of ON_MappingRef.m_plugin_id.
172  ON_ClassArray<ON_MappingRef> m_mappings;
173 
174  /*
175  Parameters:
176  bEnable - [in]
177  false - (default)
178  Do not generate bitmap textures that
179  approximate procedural textures.
180  true -
181  generate bitmap textures that approximate
182  procedural textures and use these for
183  quick previews.
184  Returns:
185  True if advancded texture preview is enabled.
186  */
187  void EnableAdvancedTexturePreview(bool b);
188 
189  /*
190  Returns:
191  True if advancded texture preview is enabled.
192  */
193  bool AdvancedTexturePreview() const;
194 
195  bool m_bCastsShadows; // default is true
196  bool m_bReceivesShadows; // default is true
197 
198 private:
199  // m_bits encodes 8 true/false settings
200  unsigned char m_bits; // (m_bits & 1) == AdvancedTexturePreview();
201 
202  unsigned char m_reserved1;
203 };
204 
205 #if defined(ON_DLL_TEMPLATE)
206 ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ON_RenderingAttributes>;
207 ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ON_ObjectRenderingAttributes>;
208 #endif
209 
210 
211 #endif
212 
ON_UUID is a 16 byte universally unique identifier.
Definition: opennurbs_uuid.h:32
Definition: opennurbs_mapchan.h:167
bool IsValid(ON_TextLog *text_log) const
ON_3dmObjectAttributes uses ON_MappingChannel to record which texture mapping function to use when ap...
Definition: opennurbs_mapchan.h:36
Definition: opennurbs_rendering.h:21
ON_ClassArray< ON_MaterialRef > m_materials
Definition: opennurbs_rendering.h:35
Definition: opennurbs_xform.h:28
ON_3dmObjectAttributes uses ON_MaterialRef to record which rendering material and mappings a renderin...
Definition: opennurbs_mapchan.h:89
bool Read(ON_BinaryArchive &archive)
Definition: opennurbs_rendering.h:38
Definition: opennurbs_textlog.h:20
Definition: opennurbs_archive.h:1783
int Compare(const ON_RenderingAttributes &other) const
bool Write(ON_BinaryArchive &archive) const