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