opennurbs_mapchan.h
Go to the documentation of this file.
00001 /* $NoKeywords: $ */
00002 /*
00003 //
00004 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
00005 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
00006 // McNeel & Associates.
00007 //
00008 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
00009 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
00010 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
00011 //                              
00012 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
00013 //
00015 */
00016 
00017 #if !defined(OPENNURBS_MAPPING_CHANNEL_INC_)
00018 #define OPENNURBS_MAPPING_CHANNEL_INC_
00019 
00021 //
00022 // Class ON_MappingChannel
00023 // 
00024 // Description:
00025 //   ON_3dmObjectAttributes uses ON_MappingChannel to record 
00026 //   which texture mapping function to use when applying a texture
00027 //   with a matching mapping channel id.
00028 //   When an object is rendered, if the material has textures and
00029 //   ON_Texture::m_mapping_channel_id = ON_MappingChannel::m_mapping_channel_id,
00030 //   then the mapping with id m_mapping_id is used to map the texture.
00031 //   Otherwise, the mesh m_T[] texture coordinates are used to
00032 //   apply the texture.
00033 //
00034 class ON_CLASS ON_MappingChannel
00035 {
00036 public:
00037   ON_MappingChannel();
00038   void Default();
00039   int Compare( const ON_MappingChannel& other ) const;
00040   bool Write( ON_BinaryArchive& archive ) const;
00041   bool Read( ON_BinaryArchive& archive );
00042 
00043   ON_UUID m_mapping_id;  // Identifies an ON_TextureMapping
00044 
00045   // RUNTIME textrure mapping table index.
00046   // If -1, it needs to be set.  This value is not saved int files.
00047   int m_mapping_index;
00048 
00049   // ON_Texture's with a matching m_mapping_channel_id value
00050   // use the mapping identified by m_mapping_id.  This id
00051   // must be > 0 and <= 2147483647 (0x7FFFFFFF)
00052   int m_mapping_channel_id;
00053 
00054   // The default value of m_object_xform is the identity.
00055   // When an object that uses this mapping is transformed
00056   // by "T", m_object_xform is updated using the formula
00057   // m_object_xform = T*m_object_xform.  If texture coordinates
00058   // are lost and need to be recalculated and m_object_xform
00059   // is not the identity, then m_object_xform should be passed
00060   // to ON_TextureMapping::Evaluate() as the mesh_xform parameter.
00061   // When validating mapping coordinates, m_object_xform itself 
00062   // be passed to HasMatchingTextureCoordinates() as the
00063   // object_transform parameter.
00064   ON_Xform m_object_xform;
00065 };
00066 
00067 #if defined(ON_DLL_TEMPLATE)
00068 // This stuff is here because of a limitation in the way Microsoft
00069 // handles templates and DLLs.  See Microsoft's knowledge base 
00070 // article ID Q168958 for details.
00071 #pragma warning( push )
00072 #pragma warning( disable : 4231 )
00073 ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_MappingChannel>;
00074 #pragma warning( pop )
00075 #endif
00076 
00078 //
00079 // Class ON_MaterialRef
00080 // 
00081 // Description:
00082 //   ON_3dmObjectAttributes uses ON_MaterialRef to record which
00083 //   rendering material and mappings a rendering plug-in wants to 
00084 //   use.  This allows different rendering plug-ins to have different 
00085 //   materials on the same object.  The values of
00086 //   ON_3dmObjectAttributes.m_material_index and 
00087 //   ON_3dmObjectAttributes.m_matrial_source reflect the settings
00088 //   of the renderer that is currently active.
00089 //
00090 
00091 class ON_CLASS ON_MappingRef
00092 {
00093 public:
00094   ON_MappingRef();
00095   void Default();
00096   int Compare( const ON_MappingRef& other ) const;
00097   bool Write( ON_BinaryArchive& archive ) const;
00098   bool Read( ON_BinaryArchive& archive );
00099 
00100   bool IsValid( ON_TextLog* text_log ) const;
00101 
00102 
00103   bool Transform( const ON_Xform& xform );
00104 
00105   ON_UUID m_plugin_id;   // Identifies a rendering plugin
00106 
00107   /*
00108   Parameters:
00109     mapping_channel_id - [in]
00110     mapping_id - [in]
00111       ON_TextureMapping id
00112   Returns:
00113     A pointer to the plug-in's mapping channel, if there
00114     is one. Otherwise NULL is returned.
00115   */
00116   const ON_MappingChannel* MappingChannel( 
00117     int mapping_channel_id
00118     ) const;
00119 
00120   const ON_MappingChannel* MappingChannel( 
00121     const ON_UUID& mapping_id
00122     ) const;
00123 
00124 
00125   /*
00126   Parameters:
00127     mapping_channel_id - [in]
00128     mapping_id - [in]
00129       ON_TextureMapping id
00130   Returns:
00131     True if the mapping channel was added or a pefect
00132     match already existed.  False if a mapping channel 
00133     with a different mapping_id already exists for this
00134     plug-in and channel.
00135   */
00136   bool AddMappingChannel(
00137     int mapping_channel_id,
00138     const ON_UUID& mapping_id
00139     );
00140 
00141   /*
00142   Parameters:
00143     mapping_channel_id - [in]
00144     mapping_id - [in]
00145       ON_TextureMapping id
00146   Returns:
00147     True if a matching mapping channel was deleted.
00148   */
00149   bool DeleteMappingChannel(
00150     int mapping_channel_id
00151     );
00152 
00153   bool DeleteMappingChannel(
00154     const ON_UUID& mapping_id
00155     );
00156 
00157   /*
00158   Parameters:
00159     old_mapping_channel_id - [in]
00160     new_mapping_channel_id - [in]
00161   Returns:
00162     True if a matching mapping channel was found and changed.
00163   */
00164   bool ChangeMappingChannel(
00165     int old_mapping_channel_id,
00166     int new_mapping_channel_id
00167     );
00168 
00169   // Use AddMappingChannel() if you  want to add an 
00170   // element to this array.
00171   //
00172   // Every mapping channel in this array must have
00173   // a distinct value of ON_MappingChannel.m_mapping_channel_id
00174   ON_SimpleArray<ON_MappingChannel> m_mapping_channels;
00175 };
00176 
00177 class ON_CLASS ON_MaterialRef
00178 {
00179 public:
00180   // If m_material_id = ON_MaterialRef::material_from_layer,
00181   // then the object's layer determine the material.
00182   // See ON::material_from_layer.
00183   //static const ON_UUID material_from_layer; // TOD0 - remove this
00184 
00185   // If m_material_id = ON_MaterialRef::material_from_layer,
00186   // then the object's parent determine the material.
00187   // See ON::material_from_parent.
00188   //static const ON_UUID material_from_parent; // TODO - remove this
00189 
00190   ON_MaterialRef();
00191   void Default();
00192   int Compare( const ON_MaterialRef& other ) const;
00193   bool Write( ON_BinaryArchive& archive ) const;
00194   bool Read( ON_BinaryArchive& archive );
00195 
00196   ON_UUID m_plugin_id;   // Identifies a rendering plugin
00197 
00198   ON_UUID m_material_id; // Identifies an ON_Material
00199   
00200   // If nil, then m_material_id is used for front and back faces
00201   ON_UUID m_material_backface_id; // Identifies an ON_Material
00202 
00203   ON::object_material_source MaterialSource() const;
00204   unsigned char m_material_source; // ON::object_material_source values
00205   unsigned char m_reserved1;
00206   unsigned char m_reserved2;
00207   unsigned char m_reserved3;
00208 
00209   // RUNTIME material table index for m_material_id.
00210   // This value is not saved in files.  If -1, then it
00211   // needs to be set.
00212   int m_material_index;
00213 
00214   // RUNTIME material table index for m_material_id.
00215   // This value is not saved in files.  If -1, then it
00216   // needs to be set.
00217   int m_material_backface_index;
00218 };
00219 
00220 #if defined(ON_DLL_TEMPLATE)
00221 // This stuff is here because of a limitation in the way Microsoft
00222 // handles templates and DLLs.  See Microsoft's knowledge base 
00223 // article ID Q168958 for details.
00224 #pragma warning( push )
00225 #pragma warning( disable : 4231 )
00226 ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ON_MaterialRef>;
00227 ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ON_MappingRef>;
00228 #pragma warning( pop )
00229 #endif
00230 
00231 #endif
00232 
00233 


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:27:01