Point Cloud Library (PCL)  1.14.1-dev
opennurbs_mapchan.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_MAPPING_CHANNEL_INC_)
18 #define OPENNURBS_MAPPING_CHANNEL_INC_
19 
20 ///////////////////////////////////////////////////////////////////////////////
21 //
22 // Class ON_MappingChannel
23 //
24 // Description:
25 // ON_3dmObjectAttributes uses ON_MappingChannel to record
26 // which texture mapping function to use when applying a texture
27 // with a matching mapping channel id.
28 // When an object is rendered, if the material has textures and
29 // ON_Texture::m_mapping_channel_id = ON_MappingChannel::m_mapping_channel_id,
30 // then the mapping with id m_mapping_id is used to map the texture.
31 // Otherwise, the mesh m_T[] texture coordinates are used to
32 // apply the texture.
33 //
34 class ON_CLASS ON_MappingChannel
35 {
36 public:
38  void Default();
39  int Compare( const ON_MappingChannel& other ) const;
40  bool Write( ON_BinaryArchive& archive ) const;
41  bool Read( ON_BinaryArchive& archive );
42 
43  ON_UUID m_mapping_id; // Identifies an ON_TextureMapping
44 
45  // RUNTIME textrure mapping table index.
46  // If -1, it needs to be set. This value is not saved int files.
48 
49  // ON_Texture's with a matching m_mapping_channel_id value
50  // use the mapping identified by m_mapping_id. This id
51  // must be > 0 and <= 2147483647 (0x7FFFFFFF)
53 
54  // The default value of m_object_xform is the identity.
55  // When an object that uses this mapping is transformed
56  // by "T", m_object_xform is updated using the formula
57  // m_object_xform = T*m_object_xform. If texture coordinates
58  // are lost and need to be recalculated and m_object_xform
59  // is not the identity, then m_object_xform should be passed
60  // to ON_TextureMapping::Evaluate() as the mesh_xform parameter.
61  // When validating mapping coordinates, m_object_xform itself
62  // be passed to HasMatchingTextureCoordinates() as the
63  // object_transform parameter.
65 };
66 
67 #if defined(ON_DLL_TEMPLATE)
68 // This stuff is here because of a limitation in the way Microsoft
69 // handles templates and DLLs. See Microsoft's knowledge base
70 // article ID Q168958 for details.
71 #pragma warning( push )
72 #pragma warning( disable : 4231 )
73 ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_MappingChannel>;
74 #pragma warning( pop )
75 #endif
76 
77 ///////////////////////////////////////////////////////////////////////////////
78 //
79 // Class ON_MaterialRef
80 //
81 // Description:
82 // ON_3dmObjectAttributes uses ON_MaterialRef to record which
83 // rendering material and mappings a rendering plug-in wants to
84 // use. This allows different rendering plug-ins to have different
85 // materials on the same object. The values of
86 // ON_3dmObjectAttributes.m_material_index and
87 // ON_3dmObjectAttributes.m_matrial_source reflect the settings
88 // of the renderer that is currently active.
89 //
90 
91 class ON_CLASS ON_MappingRef
92 {
93 public:
95  void Default();
96  int Compare( const ON_MappingRef& other ) const;
97  bool Write( ON_BinaryArchive& archive ) const;
98  bool Read( ON_BinaryArchive& archive );
99 
100  bool IsValid( ON_TextLog* text_log ) const;
101 
102 
103  bool Transform( const ON_Xform& xform );
104 
105  ON_UUID m_plugin_id; // Identifies a rendering plugin
106 
107  /*
108  Parameters:
109  mapping_channel_id - [in]
110  mapping_id - [in]
111  ON_TextureMapping id
112  Returns:
113  A pointer to the plug-in's mapping channel, if there
114  is one. Otherwise NULL is returned.
115  */
117  int mapping_channel_id
118  ) const;
119 
121  const ON_UUID& mapping_id
122  ) const;
123 
124 
125  /*
126  Parameters:
127  mapping_channel_id - [in]
128  mapping_id - [in]
129  ON_TextureMapping id
130  Returns:
131  True if the mapping channel was added or a pefect
132  match already existed. False if a mapping channel
133  with a different mapping_id already exists for this
134  plug-in and channel.
135  */
137  int mapping_channel_id,
138  const ON_UUID& mapping_id
139  );
140 
141  /*
142  Parameters:
143  mapping_channel_id - [in]
144  mapping_id - [in]
145  ON_TextureMapping id
146  Returns:
147  True if a matching mapping channel was deleted.
148  */
150  int mapping_channel_id
151  );
152 
154  const ON_UUID& mapping_id
155  );
156 
157  /*
158  Parameters:
159  old_mapping_channel_id - [in]
160  new_mapping_channel_id - [in]
161  Returns:
162  True if a matching mapping channel was found and changed.
163  */
165  int old_mapping_channel_id,
166  int new_mapping_channel_id
167  );
168 
169  // Use AddMappingChannel() if you want to add an
170  // element to this array.
171  //
172  // Every mapping channel in this array must have
173  // a distinct value of ON_MappingChannel.m_mapping_channel_id
175 };
176 
177 class ON_CLASS ON_MaterialRef
178 {
179 public:
180  // If m_material_id = ON_MaterialRef::material_from_layer,
181  // then the object's layer determine the material.
182  // See ON::material_from_layer.
183  //static const ON_UUID material_from_layer; // TOD0 - remove this
184 
185  // If m_material_id = ON_MaterialRef::material_from_layer,
186  // then the object's parent determine the material.
187  // See ON::material_from_parent.
188  //static const ON_UUID material_from_parent; // TODO - remove this
189 
191  void Default();
192  int Compare( const ON_MaterialRef& other ) const;
193  bool Write( ON_BinaryArchive& archive ) const;
194  bool Read( ON_BinaryArchive& archive );
195 
196  ON_UUID m_plugin_id; // Identifies a rendering plugin
197 
198  ON_UUID m_material_id; // Identifies an ON_Material
199 
200  // If nil, then m_material_id is used for front and back faces
201  ON_UUID m_material_backface_id; // Identifies an ON_Material
202 
203  ON::object_material_source MaterialSource() const;
204  unsigned char m_material_source; // ON::object_material_source values
205  unsigned char m_reserved1;
206  unsigned char m_reserved2;
207  unsigned char m_reserved3;
208 
209  // RUNTIME material table index for m_material_id.
210  // This value is not saved in files. If -1, then it
211  // needs to be set.
213 
214  // RUNTIME material table index for m_material_id.
215  // This value is not saved in files. If -1, then it
216  // needs to be set.
218 };
219 
220 #if defined(ON_DLL_TEMPLATE)
221 // This stuff is here because of a limitation in the way Microsoft
222 // handles templates and DLLs. See Microsoft's knowledge base
223 // article ID Q168958 for details.
224 #pragma warning( push )
225 #pragma warning( disable : 4231 )
226 ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ON_MaterialRef>;
227 ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ON_MappingRef>;
228 #pragma warning( pop )
229 #endif
230 
231 #endif
232 
233 
bool Read(ON_BinaryArchive &archive)
bool Write(ON_BinaryArchive &archive) const
int Compare(const ON_MappingChannel &other) const
bool AddMappingChannel(int mapping_channel_id, const ON_UUID &mapping_id)
bool IsValid(ON_TextLog *text_log) const
bool ChangeMappingChannel(int old_mapping_channel_id, int new_mapping_channel_id)
int Compare(const ON_MappingRef &other) const
bool DeleteMappingChannel(int mapping_channel_id)
const ON_MappingChannel * MappingChannel(const ON_UUID &mapping_id) const
bool Read(ON_BinaryArchive &archive)
ON_SimpleArray< ON_MappingChannel > m_mapping_channels
bool DeleteMappingChannel(const ON_UUID &mapping_id)
const ON_MappingChannel * MappingChannel(int mapping_channel_id) const
bool Transform(const ON_Xform &xform)
bool Write(ON_BinaryArchive &archive) const
unsigned char m_reserved3
bool Write(ON_BinaryArchive &archive) const
ON::object_material_source MaterialSource() const
ON_UUID m_material_backface_id
unsigned char m_reserved2
int Compare(const ON_MaterialRef &other) const
bool Read(ON_BinaryArchive &archive)
unsigned char m_material_source
unsigned char m_reserved1