1/****************************************************************************************
2
3 Copyright (C) 2015 Autodesk, Inc.
4 All rights reserved.
5
6 Use of this software is subject to the terms of the Autodesk license agreement
7 provided at the time of installation or download, or which otherwise accompanies
8 this software in either electronic or hard copy form.
9
10****************************************************************************************/
11
12//! \file fbxlayercontainer.h
13#ifndef _FBXSDK_SCENE_GEOMETRY_LAYER_CONTAINER_H_
14#define _FBXSDK_SCENE_GEOMETRY_LAYER_CONTAINER_H_
15
16#include <fbxsdk/fbxsdk_def.h>
17
18#include <fbxsdk/scene/geometry/fbxnodeattribute.h>
19#include <fbxsdk/scene/geometry/fbxlayer.h>
20
21#include <fbxsdk/fbxsdk_nsbegin.h>
22
23/** \brief Contains a collection of FbxLayer objects.
24 * This class is used for managing layers construction, destruction and access.
25 * See FbxLayerElement for more details.
26 * \nosubgrouping
27 * \see FbxLayer
28 */
29class FBXSDK_DLL FbxLayerContainer : public FbxNodeAttribute
30{
31 FBXSDK_OBJECT_DECLARE(FbxLayerContainer,FbxNodeAttribute);
32public:
33
34 /** Returns the type of node attribute.
35 */
36 virtual FbxNodeAttribute::EType GetAttributeType() const;
37
38 /**
39 * \name Layer Management
40 */
41 //@{
42
43 /** Creates a new layer on top of existing layers.
44 * \return Index of created layer or -1 if an error occurs.
45 */
46 int CreateLayer();
47
48 //! Deletes all layers.
49 void ClearLayers();
50
51 /** Returns the number of layers.
52 * \return The number of layers.
53 */
54 int GetLayerCount() const;
55
56 /** Returns the number of layers that contain the specified layer element type.
57 * \param pType The specified Layer Element type.
58 * \param pUVCount When \c true, requests the UV layer element corresponding to the specified texture type.
59 * \return The number of layers containing the specified layer element type.
60 */
61 int GetLayerCount(FbxLayerElement::EType pType, bool pUVCount=false) const;
62
63 /** Returns the layer at the specified index.
64 * \param pIndex Layer index.
65 * \return Pointer to the layer, or \c NULL if pIndex is out of range.
66 */
67 FbxLayer* GetLayer(int pIndex);
68
69 /** Returns the layer at the specified index.
70 * \param pIndex Layer index.
71 * \return Pointer to the layer, or \c NULL if pIndex is out of range.
72 */
73 const FbxLayer* GetLayer(int pIndex) const;
74
75 /** Returns the n'th layer as specified by pIndex that contains the specified layer element type.
76 * If the pType is FbxLayerElement::eUV, this method will return the n'th layer as specified by pIndex that contains the diffuse UV.
77 * For example, GetLayer(int pIndex, FbxLayerElement::eUV) is same as GetLayer(int pIndex, FbxLayerElement::eTextureDiffuse, true).
78 * \param pIndex Layer index.
79 * \param pType The specified layer element type.
80 * \param pIsUV When \c true, requests the UV layer element that corresponds with the specified texture type.
81 * \return Pointer to the layer, or \c NULL if pIndex is out of range.
82 */
83 FbxLayer* GetLayer(int pIndex, FbxLayerElement::EType pType, bool pIsUV=false);
84
85 /** Returns the n'th layer as specified by pIndex that contains the specified layer element type.
86 * If the pType is FbxLayerElement::eUV, this method will return the n'th layer as specified by pIndex that contains the diffuse UV.
87 * For example, GetLayer(int pIndex, FbxLayerElement::eUV) is same as GetLayer(int pIndex, FbxLayerElement::eTextureDiffuse, true).
88 * \param pIndex Layer index.
89 * \param pType The specified layer element type.
90 * \param pIsUV When \c true, requests the UV layer element that corresponds with the specified texture type.
91 * \return Pointer to the layer, or \c NULL if pIndex is out of range.
92 */
93 const FbxLayer* GetLayer(int pIndex, FbxLayerElement::EType pType, bool pIsUV=false) const;
94
95 /** Returns the global index of the n'th layer as specified by pIndex that contains the specified layer element type.
96 * \param pIndex Layer index of the specified type.
97 * \param pType The specified layer element type.
98 * \param pIsUV When \c true, requests the UV layer element that corresponds with the specified texture type.
99 * \return Global index of the n'th layer as specified by pIndex that contains the specified layer element type, or -1 if the layer is not found.
100 * \remarks The returned index is the position of the layer in the global array of layers.
101 * You can use the returned index to call GetLayer(int pIndex).
102 */
103 int GetLayerIndex(int pIndex, FbxLayerElement::EType pType, bool pIsUV=false) const;
104
105 /** Converts the layer's global index to a type-specific index.
106 * \param pGlobalIndex The index of the layer in the global array of layers.
107 * \param pType The type upon which the type-specific index will be returned.
108 * \param pIsUV When \c true, requests the UV layer element that corresponds with the specified texture type.
109 * \return Layer index of the specified layer element type, or -1 if the layer element type is not found on the layer.
110 */
111 int GetLayerTypedIndex(int pGlobalIndex, FbxLayerElement::EType pType, bool pIsUV=false) const;
112 //@}
113
114 /** Converts the reference mode from eDirect to eIndexToDirect.
115 * \param pLayer The Layer to convert.
116 * \return \c True if conversion is successful, or \c false otherwise.
117 * \remarks For the time being, this method only applies to the LayerLementType eMaterial
118 */
119 bool ConvertDirectToIndexToDirect(int pLayer);
120
121/*****************************************************************************************************************************
122** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
123*****************************************************************************************************************************/
124#ifndef DOXYGEN_SHOULD_SKIP_THIS
125 virtual FbxObject& Copy(const FbxObject& pObject);
126
127 int GTC(FbxUInt i, int j);
128 void* GT (int i, FbxUInt l, int j);
129 int AT (void* t, FbxUInt l, int j);
130 int GTI(const char* n, FbxUInt l, int j);
131 int GMC(FbxUInt i, void* n = NULL);
132 void* GM (int i, FbxUInt l, void* n = NULL);
133 int AM (void* m, FbxUInt l, void* n = NULL, bool b = false);
134 int GMI(const char* n, FbxUInt l, void* d = NULL);
135
136 int AddToLayerElementsList(FbxLayerElement* pLEl);
137 void RemoveFromLayerElementsList(FbxLayerElement* pLEl);
138
139protected:
140 virtual void Destruct(bool pRecursive);
141
142 void CopyLayers(const FbxLayerContainer* pLayerContainer);
143
144 virtual void SetDocument(FbxDocument* pDocument);
145 virtual bool ConnectNotify (FbxConnectEvent const &pEvent);
146
147 FbxArray<FbxLayer*> mLayerArray;
148 FbxArray<FbxLayerElement*> mLayerElementsList;
149#endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
150};
151
152#include <fbxsdk/fbxsdk_nsend.h>
153
154#endif /* _FBXSDK_SCENE_GEOMETRY_LAYER_CONTAINER_H_ */
155