HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FBX_Translator.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: FBX_Translator.h (FBX Library, C++)
7  *
8  * COMMENTS:
9  *
10  */
11 
12 #ifndef __FBX_Translator_h__
13 #define __FBX_Translator_h__
14 
15 #include "FBX_Common.h"
16 #include "FBX_ErrorManager.h"
17 
18 #include <UT/UT_StringArray.h>
19 
20 
21 class FBX_IntTranslator;
22 class GU_Detail;
23 class OP_Node;
24 class OP_Network;
25 /********************************************************************************************************/
27 {
28 public:
29  virtual ~FBX_LoadCallbacks() { }
30  virtual int onFbxFileLoaded(GU_Detail *gdp, FBX_IntTranslator *ptranslator) = 0;
31 };
32 /********************************************************************************************************/
34 {
35 public:
36  ~FBX_CookGeoCallback() override { }
37  int onFbxFileLoaded(GU_Detail *gdp,
38  FBX_IntTranslator *ptranslator) override;
39 };
40 /********************************************************************************************************/
42 {
43 public:
45  {
46  myTargetHdNode = NULL;
47  myHdParmIndex = 0;
48  myFbxComponent = -1;
49  myResampleAnimation = false;
50  myResampleInterval = 1.0;
51  }
52  ~FBX_LoadAnimCallback() override {}
53  int onFbxFileLoaded(GU_Detail *gdp,
54  FBX_IntTranslator *ptranslator) override;
55 
56  void setHdNode(OP_Node* node) { myTargetHdNode = node; }
57  void setTargetParm(const char* parm_name, int idx)
58  {
59  if(!parm_name)
60  return;
61 
62  myHdParmName = parm_name;
63  myHdParmIndex = idx;
64  }
65  void setFbxProperty(const char* pname, int icomp)
66  {
67  if(pname)
68  myFbxPropertyName = pname;
69  myFbxComponent = icomp;
70  }
71 
72  void setFbxTakeName(const char* pname)
73  { myFbxTakeName = pname; }
75  { myResampleAnimation = value; }
76  void setResampleInterval(double freq)
77  { myResampleInterval = freq; }
78 
79 private:
80  OP_Node* myTargetHdNode;
81  std::string myHdParmName;
82  int myHdParmIndex;
83  std::string myFbxPropertyName;
84  int myFbxComponent;
85 
86  std::string myFbxTakeName;
87 
88  bool myResampleAnimation;
89  double myResampleInterval;
90 };
91 /********************************************************************************************************/
92 #ifdef FBX_ENABLED
93 
95 {
96 public:
97  /// Constructor.
99 
100  /// Destructor.
101  virtual ~FBX_Translator();
102 
103  /// Initializes the Filmbox translator's environment.
104  /// It should be called once at startup.
105  static void init(void);
106 
107  /// Uninitializes the Filmbox translator's environment.
108  /// It should be called once at termination.
109  static void uninit(void);
110 
111  const FBX_ErrorManager* getErrorManager(void) const;
112 
113  /// Imports the Filmbox scene into the current Houdini session or into a new scene.
114  /// @param fileURI A path to the FBX file to import. Please note that network (UNC)
115  /// paths are currently not supported.
116  /// @param is_merging If true, the file will be merged with the current scene, if
117  /// false, a new scene will be created and the file will be imported
118  /// there.
119  /// @param options Various options that determine how a file is to be imported. See
120  /// FBX_ImportOptions for more details. If not set, the defaults for
121  /// every option will be used.
122  /// @param filter Object type filter settings which determine what types of objects
123  /// (cameras, geometry, lights, etc.) are to be imported. If not set,
124  /// the defaults are used, which import everything.
125  /// @param password A password to use if the FBX file is password-protected. Currently
126  /// not used.
127  bool importScene( const char *fileURI, bool is_merging,
128  FBX_ImportOptions *options = NULL,
130  const char* password = NULL,
131  OP_Network** parent_net = NULL);
132 
133  /// Imports a single FBX geometry node to a File SOP
134  /// @param gdp The GU_Detail that will hold the geometry
135  /// @param fileURI A path to the FBX file to import. Please note that network (UNC)
136  /// paths are currently not supported.
137  /// @param fbx_node_name Name of the FBX node to be imported
138  /// @param convert_surfaces Wether or not sirfaces should be converted too
139  static int importGeo( GU_Detail *gdp,
140  const char *fileURI,
141  const char* fbx_node_name,
142  bool convert_surfaces);
143 
144  /// Imports all geometry found in the FBX file to a File SOP
145  /// @param gdp The GU_Detail that will hold the geometry
146  /// @param fileURI A path to the FBX file to import. Please note that network (UNC)
147  /// paths are currently not supported.
148  /// @param convert_surfaces Wether or not sirfaces should be converted too
149  static int importAllGeos( GU_Detail *gdp,
150  const char *fileURI,
151  bool convert_surfaces);
152 
153  /// Appends geometry found in a FBX Node to a detail
154  /// @param gdp The GU_Detail that will hold the geometry
155  /// @param translator The FBX Translator to be used for the import
156  /// @param current_fbx_node_as_void The fbx node we want to import the geometry
157  /// Due to header non-sense, the FBXNode* is casted to a void*
158  static int importGeoInFbxNode( GU_Detail *gdp,
159  FBX_IntTranslator *translator,
160  void* current_fbx_node_as_void);
161 
162  /// Adds the custom attributes found on the fbx node as primitive attributes
163  /// @param current_fbx_node_as_void The fbx node we want to import the geometry
164  /// Due to header non-sense, the FBXNode* is casted to a void*
165  /// @param gdp The GU_Detail that will hold the geometry
166  static void addCustomAttributesFromNode( void* current_fbx_node_as_void, GU_Detail *gdp );
167 
168  static int ensureFileLoaded( GU_Detail *gdp,
169  const char *fileURI,
170  const char* fbx_node_name,
171  bool convert_surfaces,
172  FBX_LoadCallbacks* pcallbacks);
173 
174  static int exportGeo( const GU_Detail *gdp,
175  const char *fileURI);
176 
177  static bool isSupported(void)
178  { return true; }
179 
180 private:
181  static void installCommands();
182 
183 private:
184 
185  FBX_ErrorManager myErrorManager;
186 
187 };
188 
189 #else
190 
192 {
193 public:
194  /// Constructor.
195  FBX_Translator() { }
196 
197  /// Destructor.
198  virtual ~FBX_Translator() { }
199 
200  /// Initializes the Filmbox translator's environment.
201  /// It should be called once at startup.
202  static void init(void) { }
203 
204  /// Uninitializes the Filmbox translator's environment.
205  /// It should be called once at termination.
206  static void uninit(void) { }
207 
208  const FBX_ErrorManager* getErrorManager(void) const
209  { return NULL; }
210 
211  /// Imports the Filmbox scene into the current Houdini session or into a new scene.
212  /// @param fileURI A path to the FBX file to import. Please note that network (UNC)
213  /// paths are currently not supported.
214  /// @param is_merging If true, the file will be merged with the current scene, if
215  /// false, a new scene will be created and the file will be imported
216  /// there.
217  /// @param options Various options that determine how a file is to be imported. See
218  /// FBX_ImportOptions for more details. If not set, the defaults for
219  /// every option will be used.
220  /// @param filter Object type filter settings which determine what types of objects
221  /// (cameras, geometry, lights, etc.) are to be imported. If not set,
222  /// the defaults are used, which import everything.
223  /// @param password A password to use if the FBX file is password-protected. Currently
224  /// not used.
225  bool importScene( const char *fileURI, bool is_merging,
226  FBX_ImportOptions *options = NULL,
228  const char* password = NULL,
229  OP_Network** parent_net = NULL)
230  { return true; }
231 
232  static int importGeo( GU_Detail *gdp,
233  const char *fileURI,
234  const char* fbx_node_name,
235  bool convert_surfaces)
236  { return 0; }
237 
238  static int importAllGeos( GU_Detail *gdp,
239  const char *fileURI,
240  bool convert_surfaces)
241  { return 0; }
242 
243  static int ensureFileLoaded(GU_Detail *gdp, const char *fileURI,
244  const char* fbx_node_name, bool convert_surfaces,
245  FBX_LoadCallbacks* pcallbacks) { return false; }
246 
247  static int exportGeo( const GU_Detail *gdp,
248  const char *fileURI)
249  { return 0; }
250 
251  static bool isSupported(void)
252  { return false; }
253 private:
254  static void installCommands() { }
255 };
256 #endif
257 /********************************************************************************************************/
258 
259 #endif // __FBX_Translator_h__
260 
void setTargetParm(const char *parm_name, int idx)
void setResampleInterval(double freq)
GLenum pname
Definition: glew.h:1688
void setFbxProperty(const char *pname, int icomp)
void setResampleAnimation(bool value)
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glew.h:2981
void setHdNode(OP_Node *node)
#define FBX_API
Definition: FBX_API.h:10
~FBX_CookGeoCallback() override
GLsizei const GLchar *const * string
Definition: glew.h:1844
static bool isSupported(void)
void setFbxTakeName(const char *pname)
~FBX_LoadAnimCallback() override
virtual ~FBX_LoadCallbacks()
virtual int onFbxFileLoaded(GU_Detail *gdp, FBX_IntTranslator *ptranslator)=0
GLsizei const GLfloat * value
Definition: glew.h:1849