fbmaterial.h

Go to the documentation of this file.
00001 #ifndef __FBMATERIAL_H__
00002 #define __FBMATERIAL_H__
00003 /**************************************************************************
00004  Copyright (c) 1994 - 2009 Autodesk, Inc. and/or its licensors.
00005  All Rights Reserved.
00006  
00007  The coded instructions, statements, computer programs, and/or related 
00008  material (collectively the "Data") in these files contain unpublished 
00009  information proprietary to Autodesk, Inc. and/or its licensors, which is 
00010  protected by Canada and United States of America federal copyright law 
00011  and by international treaties.
00012  
00013  The Data may not be disclosed or distributed to third parties, in whole 
00014  or in part, without the prior written consent of Autodesk, Inc. 
00015  ("Autodesk").
00016  
00017  THE DATA IS PROVIDED "AS IS" AND WITHOUT WARRANTY.
00018  ALL WARRANTIES ARE EXPRESSLY EXCLUDED AND DISCLAIMED. AUTODESK MAKES NO 
00019  WARRANTY OF ANY KIND WITH RESPECT TO THE DATA, EXPRESS, IMPLIED OR 
00020  ARISING BY CUSTOM OR TRADE USAGE, AND DISCLAIMS ANY IMPLIED WARRANTIES 
00021  OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR 
00022  PURPOSE OR USE. WITHOUT LIMITING THE FOREGOING, AUTODESK DOES NOT 
00023  WARRANT THAT THE OPERATION OF THE DATA WILL BE UNINTERRUPTED OR ERROR 
00024  FREE.
00025  
00026  IN NO EVENT SHALL AUTODESK, ITS AFFILIATES, PARENT COMPANIES, LICENSORS 
00027  OR SUPPLIERS ("AUTODESK GROUP") BE LIABLE FOR ANY LOSSES, DAMAGES OR 
00028  EXPENSES OF ANY KIND (INCLUDING WITHOUT LIMITATION PUNITIVE OR MULTIPLE 
00029  DAMAGES OR OTHER SPECIAL, DIRECT, INDIRECT, EXEMPLARY, INCIDENTAL, LOSS 
00030  OF PROFITS, REVENUE OR DATA, COST OF COVER OR CONSEQUENTIAL LOSSES OR 
00031  DAMAGES OF ANY KIND), HOWEVER CAUSED, AND REGARDLESS OF THE THEORY OF 
00032  LIABILITY, WHETHER DERIVED FROM CONTRACT, TORT (INCLUDING, BUT NOT 
00033  LIMITED TO, NEGLIGENCE), OR OTHERWISE, ARISING OUT OF OR RELATING TO THE 
00034  DATA OR ITS USE OR ANY OTHER PERFORMANCE, WHETHER OR NOT AUTODESK HAS 
00035  BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
00036  
00037 **************************************************************************/
00038 
00043 #include <kaydaradef.h>
00044 #ifndef FBSDK_DLL 
00045 
00048     #define FBSDK_DLL K_DLLIMPORT
00049 #endif
00050 
00051 #include <fbsdk/fbcore.h>
00052 #include <fbsdk/fbcomponent.h>
00053 #include <fbsdk/fbtexture.h>
00054 
00055 #ifdef FBSDKUseNamespace
00056     namespace FBSDKNamespace {
00057 #endif
00058 
00060 // FBMaterial
00062 __FB_FORWARD( FBMaterial );
00063 
00065 enum FBMaterialTextureType {        
00066     kFBMaterialTextureEmissive,
00067     kFBMaterialTextureEmissiveFactor,
00068     kFBMaterialTextureAmbient,
00069     kFBMaterialTextureAmbientFactor,
00070     kFBMaterialTextureDiffuse,
00071     kFBMaterialTextureDiffuseFactor,
00072     kFBMaterialTextureSpecular,
00073     kFBMaterialTextureSpecularFactor,
00074     kFBMaterialTextureShiness,
00075     kFBMaterialTextureBump,
00076     kFBMaterialTextureNormalMap,
00077     kFBMaterialTextureTransparent,
00078     kFBMaterialTextureTransparentFactor,
00079     kFBMaterialTextureReflection,
00080     kFBMaterialTextureReflectionFactor,
00081     kFBMaterialTextureDisplacementColor
00082 };
00083 
00084 FB_DEFINE_COMPONENT( FBSDK_DLL, Material         );
00085 
00087 class FBSDK_DLL FBMaterial : public FBBox {
00088     __FBClassDeclare( FBMaterial,FBBox );
00089 public:
00094     FBMaterial(const char* pName, HIObject pObject=NULL);
00095 
00100     FBMaterial* Clone();
00101 
00102     FBPropertyAnimatableColor    Ambient;            
00103     FBPropertyAnimatableDouble   AmbientFactor;        
00104     
00105     FBPropertyAnimatableColor    Emissive;            
00106     FBPropertyAnimatableDouble   EmissiveFactor;        
00107     
00108     FBPropertyAnimatableColor    Diffuse;            
00109     FBPropertyAnimatableDouble   DiffuseFactor;      
00110     
00111     FBPropertyAnimatableColor    TransparentColor;   
00112     FBPropertyAnimatableDouble   TransparencyFactor; 
00113     
00114     FBPropertyAnimatableColor    Bump;                
00115     FBPropertyAnimatableColor    NormalMap;            
00116     FBPropertyAnimatableDouble   BumpFactor;            
00117 
00118     FBPropertyAnimatableColor    Specular;            
00119     FBPropertyAnimatableDouble   SpecularFactor;        
00120     FBPropertyAnimatableDouble   Shininess;            
00121     
00122     FBPropertyAnimatableColor    Reflection;            
00123     FBPropertyAnimatableDouble   ReflectionFactor;    
00124 
00125     FBPropertyAnimatableColor    DisplacementColor;    
00126     FBPropertyAnimatableDouble   DisplacementFactor;    
00127 
00131     FBTexture* GetTexture(FBMaterialTextureType pType = kFBMaterialTextureDiffuse);
00132 
00137     void SetTexture(FBTexture* pTexture, FBMaterialTextureType pType = kFBMaterialTextureDiffuse);
00138 
00140     void OGLInit();
00141 
00143     virtual const char* GetMaterialName() const;
00144 
00146     virtual const char* GetMaterialDesc() const;
00147 
00152     virtual bool FbxStore(FBFbxObject* pFbxObject, kFbxObjectStore pStoreWhat);
00153     virtual bool FbxRetrieve(FBFbxObject* pFbxObject, kFbxObjectStore pStoreWhat);
00154 
00157     virtual const char*    FbxGetObjectType() override;
00158 
00161     virtual const char*    FbxGetObjectSubType() override;
00162 
00163 protected:
00172     FBProperty* CreateTextureConnectableUserProperty(const char* pName, FBPropertyType pType, const char* pDataType, bool pAnimatable);
00173 };
00174 
00176 // FBPropertyListMaterial
00179 class FBSDK_DLL FBPropertyListMaterial : public FBPropertyListComponent
00180 {
00181 public:
00182     FBPropertyListMaterial();
00187     FBMaterial* operator[](int pIndex);
00188 };
00189 
00194 #define FBStorableCustomMaterialImplementation(ClassName, Type)\
00195     const char* ClassName::FbxGetObjectSubType(){ return #ClassName; }\
00196     HIObject RegisterStorable##ClassName##Create(HIObject /*pOwner*/, const char* pName, void* /*pData*/){\
00197     ClassName* Class = new ClassName(pName);\
00198     Class->mAllocated = true;\
00199     if( Class->FBCreate() ){\
00200     return Class->GetHIObject();\
00201     } else {\
00202     delete Class;\
00203     return NULL;}}\
00204     FBLibraryModule(ClassName##Storable){\
00205     FBString lGroup = "FbxStorable/";\
00206     lGroup += #Type;\
00207     FBRegisterObject(ClassName##R2, lGroup, #ClassName, "", RegisterStorable##ClassName##Create, true, NULL);\
00208     FBSetStoreableCustomMaterialRegistered();}\
00209 
00210 
00211 #ifdef FBSDKUseNamespace
00212     }
00213 #endif
00214 #endif