QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
opennurbs_mapchan.h
Go to the documentation of this file.
1/* $NoKeywords: $ */
2/*
3//
4// Copyright (c) 1993-2007 Robert McNeel & Associates. All rights reserved.
5// Rhinoceros is a registered trademark of Robert McNeel & Assoicates.
6//
7// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
8// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
9// MERCHANTABILITY ARE HEREBY DISCLAIMED.
10//
11// For complete openNURBS copyright information see <http://www.opennurbs.org>.
12//
14*/
15
16#if !defined(OPENNURBS_MAPPING_CHANNEL_INC_)
17#define OPENNURBS_MAPPING_CHANNEL_INC_
18
20//
21// Class ON_MappingChannel
22//
23// Description:
24// ON_3dmObjectAttributes uses ON_MappingChannel to record
25// which texture mapping function to use when applying a texture
26// with a matching mapping channel id.
27// When an object is rendered, if the material has textures and
28// ON_Texture::m_mapping_channel_id = ON_MappingChannel::m_mapping_channel_id,
29// then the mapping with id m_mapping_id is used to map the texture.
30// Otherwise, the mesh m_T[] texture coordinates are used to
31// apply the texture.
32//
34{
35public:
37 void Default();
38 int Compare( const ON_MappingChannel& other ) const;
39 bool Write( ON_BinaryArchive& archive ) const;
40 bool Read( ON_BinaryArchive& archive );
41
42 ON_UUID m_mapping_id; // Identifies an ON_TextureMapping
43
44 // RUNTIME textrure mapping table index.
45 // If -1, it needs to be set. This value is not saved int files.
47
48 // ON_Texture's with a matching m_mapping_channel_id value
49 // use the mapping identified by m_mapping_id. This id
50 // must be > 0 and <= 2147483647 (0x7FFFFFFF)
52
53 // The default value of m_object_xform is the identity.
54 // When an object that uses this mapping is transformed
55 // by "T", m_object_xform is updated using the formula
56 // m_object_xform = T*m_object_xform. If texture coordinates
57 // are lost and need to be recalculated and m_object_xform
58 // is not the identity, then m_object_xform should be passed
59 // to ON_TextureMapping::Evaluate() as the mesh_xform parameter.
60 // When validating mapping coordinates, m_object_xform itself
61 // be passed to HasMatchingTextureCoordinates() as the
62 // object_transform parameter.
64};
65
66#if defined(ON_DLL_TEMPLATE)
67// This stuff is here because of a limitation in the way Microsoft
68// handles templates and DLLs. See Microsoft's knowledge base
69// article ID Q168958 for details.
70#pragma warning( push )
71#pragma warning( disable : 4231 )
72ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_MappingChannel>;
73#pragma warning( pop )
74#endif
75
77//
78// Class ON_MaterialRef
79//
80// Description:
81// ON_3dmObjectAttributes uses ON_MaterialRef to record which
82// rendering material and mappings a rendering plug-in wants to
83// use. This allows different rendering plug-ins to have different
84// materials on the same object. The values of
85// ON_3dmObjectAttributes.m_material_index and
86// ON_3dmObjectAttributes.m_matrial_source reflect the settings
87// of the renderer that is currently active.
88//
89
91{
92public:
94 void Default();
95 int Compare( const ON_MappingRef& other ) const;
96 bool Write( ON_BinaryArchive& archive ) const;
97 bool Read( ON_BinaryArchive& archive );
98
99 bool IsValid( ON_TextLog* text_log ) const;
100
101
102 bool Transform( const ON_Xform& xform );
103
104 ON_UUID m_plugin_id; // Identifies a rendering plugin
105
106 /*
107 Parameters:
108 mapping_channel_id - [in]
109 mapping_id - [in]
110 ON_TextureMapping id
111 Returns:
112 A pointer to the plug-in's mapping channel, if there
113 is one. Otherwise NULL is returned.
114 */
115 const ON_MappingChannel* MappingChannel(
116 int mapping_channel_id
117 ) const;
118
119 const ON_MappingChannel* MappingChannel(
120 const ON_UUID& mapping_id
121 ) const;
122
123
124 /*
125 Parameters:
126 mapping_channel_id - [in]
127 mapping_id - [in]
128 ON_TextureMapping id
129 Returns:
130 True if the mapping channel was added or a pefect
131 match already existed. False if a mapping channel
132 with a different mapping_id already exists for this
133 plug-in and channel.
134 */
135 bool AddMappingChannel(
136 int mapping_channel_id,
137 const ON_UUID& mapping_id
138 );
139
140 /*
141 Parameters:
142 mapping_channel_id - [in]
143 mapping_id - [in]
144 ON_TextureMapping id
145 Returns:
146 True if a matching mapping channel was deleted.
147 */
148 bool DeleteMappingChannel(
149 int mapping_channel_id
150 );
151
152 bool DeleteMappingChannel(
153 const ON_UUID& mapping_id
154 );
155
156 /*
157 Parameters:
158 old_mapping_channel_id - [in]
159 new_mapping_channel_id - [in]
160 Returns:
161 True if a matching mapping channel was found and changed.
162 */
163 bool ChangeMappingChannel(
164 int old_mapping_channel_id,
165 int new_mapping_channel_id
166 );
167
168 // Use AddMappingChannel() if you want to add an
169 // element to this array.
170 //
171 // Every mapping channel in this array must have
172 // a distinct value of ON_MappingChannel.m_mapping_channel_id
174};
175
177{
178public:
179 // If m_material_id = ON_MaterialRef::material_from_layer,
180 // then the object's layer determine the material.
181 // See ON::material_from_layer.
182 //static const ON_UUID material_from_layer; // TOD0 - remove this
183
184 // If m_material_id = ON_MaterialRef::material_from_layer,
185 // then the object's parent determine the material.
186 // See ON::material_from_parent.
187 //static const ON_UUID material_from_parent; // TODO - remove this
188
190 void Default();
191 int Compare( const ON_MaterialRef& other ) const;
192 bool Write( ON_BinaryArchive& archive ) const;
193 bool Read( ON_BinaryArchive& archive );
194
195 ON_UUID m_plugin_id; // Identifies a rendering plugin
196
197 ON_UUID m_material_id; // Identifies an ON_Material
198
199 // If nil, then m_material_id is used for front and back faces
200 ON_UUID m_material_backface_id; // Identifies an ON_Material
201
202 ON::object_material_source MaterialSource() const;
203 unsigned char m_material_source; // ON::object_material_source values
204 unsigned char m_reserved1;
205 unsigned char m_reserved2;
206 unsigned char m_reserved3;
207
208 // RUNTIME material table index for m_material_id.
209 // This value is not saved in files. If -1, then it
210 // needs to be set.
212
213 // RUNTIME material table index for m_material_id.
214 // This value is not saved in files. If -1, then it
215 // needs to be set.
217};
218
219#if defined(ON_DLL_TEMPLATE)
220// This stuff is here because of a limitation in the way Microsoft
221// handles templates and DLLs. See Microsoft's knowledge base
222// article ID Q168958 for details.
223#pragma warning( push )
224#pragma warning( disable : 4231 )
225ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ON_MaterialRef>;
226ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ON_MappingRef>;
227#pragma warning( pop )
228#endif
229
230#endif
231
232
@ Transform
Definition RSMetaType.h:67
Definition opennurbs_archive.h:152
Definition opennurbs_array.h:760
Definition opennurbs_mapchan.h:34
ON_UUID m_mapping_id
Definition opennurbs_mapchan.h:42
ON_Xform m_object_xform
Definition opennurbs_mapchan.h:63
int m_mapping_channel_id
Definition opennurbs_mapchan.h:51
int m_mapping_index
Definition opennurbs_mapchan.h:46
Definition opennurbs_mapchan.h:91
ON_UUID m_plugin_id
Definition opennurbs_mapchan.h:104
bool IsValid(ON_TextLog *text_log) const
ON_SimpleArray< ON_MappingChannel > m_mapping_channels
Definition opennurbs_mapchan.h:173
Definition opennurbs_mapchan.h:177
unsigned char m_reserved3
Definition opennurbs_mapchan.h:206
ON_UUID m_material_backface_id
Definition opennurbs_mapchan.h:200
int m_material_index
Definition opennurbs_mapchan.h:211
ON_UUID m_material_id
Definition opennurbs_mapchan.h:197
int m_material_backface_index
Definition opennurbs_mapchan.h:216
unsigned char m_reserved2
Definition opennurbs_mapchan.h:205
ON_UUID m_plugin_id
Definition opennurbs_mapchan.h:195
unsigned char m_material_source
Definition opennurbs_mapchan.h:203
unsigned char m_reserved1
Definition opennurbs_mapchan.h:204
Definition opennurbs_array.h:46
Definition opennurbs_textlog.h:20
Definition opennurbs_uuid.h:31
Definition opennurbs_xform.h:28
#define ON_CLASS
Definition opennurbs_defines.h:91