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();
106 
107  /// Uninitializes the Filmbox translator's environment.
108  /// It should be called once at termination.
109  static void uninit();
110 
111  const FBX_ErrorManager* getErrorManager() 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  bool convert_units,
153  bool import_anim,
154  double frame);
155 
156  /// Appends geometry found in a FBX Node to a detail
157  /// @param gdp The GU_Detail that will hold the geometry
158  /// @param translator The FBX Translator to be used for the import
159  /// @param current_fbx_node_as_void The fbx node we want to import the geometry
160  /// Due to header non-sense, the FBXNode* is casted to a void*
161  static int importGeoInFbxNode( GU_Detail *gdp,
162  FBX_IntTranslator *translator,
163  void* current_fbx_node_as_void);
164 
165  /// Adds the custom attributes found on the fbx node as primitive attributes
166  /// @param current_fbx_node_as_void The fbx node we want to import the geometry
167  /// Due to header non-sense, the FBXNode* is casted to a void*
168  /// @param gdp The GU_Detail that will hold the geometry
169  static void addCustomAttributesFromNode( void* current_fbx_node_as_void, GU_Detail *gdp );
170 
171  static int ensureFileLoaded( GU_Detail *gdp,
172  const char *fileURI,
173  const char* fbx_node_name,
174  bool convert_surfaces,
175  FBX_LoadCallbacks* pcallbacks);
176 
177  static int exportGeo( const GU_Detail *gdp,
178  const char *fileURI);
179 
180  static bool isSupported()
181  { return true; }
182 
183 private:
184  static void installCommands();
185 
186 private:
187 
188  FBX_ErrorManager myErrorManager;
189 
190 };
191 
192 #else
193 
195 {
196 public:
197  /// Constructor.
198  FBX_Translator() { }
199 
200  /// Destructor.
201  virtual ~FBX_Translator() { }
202 
203  /// Initializes the Filmbox translator's environment.
204  /// It should be called once at startup.
205  static void init(void) { }
206 
207  /// Uninitializes the Filmbox translator's environment.
208  /// It should be called once at termination.
209  static void uninit(void) { }
210 
211  const FBX_ErrorManager* getErrorManager(void) const
212  { return NULL; }
213 
214  /// Imports the Filmbox scene into the current Houdini session or into a new scene.
215  /// @param fileURI A path to the FBX file to import. Please note that network (UNC)
216  /// paths are currently not supported.
217  /// @param is_merging If true, the file will be merged with the current scene, if
218  /// false, a new scene will be created and the file will be imported
219  /// there.
220  /// @param options Various options that determine how a file is to be imported. See
221  /// FBX_ImportOptions for more details. If not set, the defaults for
222  /// every option will be used.
223  /// @param filter Object type filter settings which determine what types of objects
224  /// (cameras, geometry, lights, etc.) are to be imported. If not set,
225  /// the defaults are used, which import everything.
226  /// @param password A password to use if the FBX file is password-protected. Currently
227  /// not used.
228  bool importScene( const char *fileURI, bool is_merging,
229  FBX_ImportOptions *options = NULL,
231  const char* password = NULL,
232  OP_Network** parent_net = NULL)
233  { return true; }
234 
235  static int importGeo( GU_Detail *gdp,
236  const char *fileURI,
237  const char* fbx_node_name,
238  bool convert_surfaces)
239  { return 0; }
240 
241  static int importAllGeos( GU_Detail *gdp,
242  const char *fileURI,
243  bool convert_surfaces)
244  { return 0; }
245 
246  static int ensureFileLoaded(GU_Detail *gdp, const char *fileURI,
247  const char* fbx_node_name, bool convert_surfaces,
248  FBX_LoadCallbacks* pcallbacks) { return false; }
249 
250  static int exportGeo( const GU_Detail *gdp,
251  const char *fileURI)
252  { return 0; }
253 
254  static bool isSupported(void)
255  { return false; }
256 private:
257  static void installCommands() { }
258 };
259 #endif
260 /********************************************************************************************************/
261 
262 #endif // __FBX_Translator_h__
263 
void setTargetParm(const char *parm_name, int idx)
void setResampleInterval(double freq)
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
GLsizei const GLfloat * value
Definition: glcorearb.h:824
void setFbxProperty(const char *pname, int icomp)
void setResampleAnimation(bool value)
static bool isSupported()
void setHdNode(OP_Node *node)
#define FBX_API
Definition: FBX_API.h:10
~FBX_CookGeoCallback() override
GLenum pname
Definition: glcorearb.h:104
void setFbxTakeName(const char *pname)
~FBX_LoadAnimCallback() override
virtual ~FBX_LoadCallbacks()
Definition: core.h:1131
virtual int onFbxFileLoaded(GU_Detail *gdp, FBX_IntTranslator *ptranslator)=0
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glcorearb.h:1297