Alphabetical Class Index  Class Hierarchy   File Members   Compound Members   File List  

HU3DHelper.h
Go to the documentation of this file.
1 //***************************************************************************
2 //
3 // Copyright (c) 1999 - 2005 Intel Corporation
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 //***************************************************************************
18 
28 #ifndef HU3D_SCENE_HELPER_H
29 #define HU3D_SCENE_HELPER_H
30 
31 #ifndef _HU3DHelper_H
32 #define _HU3DHelper_H
33 
34 #ifdef H_PACK_8
35 #pragma pack(push)
36 #pragma pack(8)
37 #endif
38 
39 
40 //***************************************************************************
41 // Includes
42 //***************************************************************************
43 
44 #pragma warning( push, 3 )
45 #pragma warning( disable : 4311 ) // IFXVoidStar.h
46 
47 #include "IFXString.h"
48 #include "IFXCOM.h"
49 #include "IFXCoreCIDs.h"
50 #include "IFXAutoRelease.h"
51 
52 #include "IFXSceneGraph.h"
53 #include "IFXLight.h"
54 #include "IFXMaterialResource.h"
55 #include "IFXModel.h"
56 #include "IFXModifier.h"
57 #include "IFXNode.h"
58 #include "IFXShader.h"
59 #include "IFXShaderLitTexture.h"
60 #include "IFXView.h"
61 #include "IFXPalette.h"
62 #include "IFXMatrix4x4.h"
63 
64 #include "IFXAnimationModifier.h"
65 #include "IFXBoneWeightsModifier.h"
66 #include "IFXSkeleton.h"
67 
68 #include "IFXMotionResource.h"
69 #include "IFXMixerConstruct.h"
70 
71 #include "IFXImportingCIDs.h"
72 #include "IFXExportingCIDs.h"
73 
74 #include "IFXScheduler.h"
75 
76 #include "IFXAuthorGeomCompiler.h"
77 #include "IFXSubdivModifier.h"
78 #include "IFXCLODModifier.h"
79 #include "IFXShadingModifier.h"
80 #include "IFXGlyph2DModifier.h"
81 #include "IFXGlyphCommandList.h"
82 
83 #include "IFXAuthorMesh.h"
84 #include "IFXAuthorMeshScrub.h"
85 #include "IFXAuthorLineSet.h"
86 #include "IFXAuthorLineSetResource.h"
87 #include "IFXAuthorPointSet.h"
88 #include "IFXAuthorPointSetResource.h"
89 
90 #include "IFXModifierChain.h"
91 
92 #include "IFXSimulationTask.h"
93 
94 #include "IFXCLODManagerInterface.h"
95 #include "IFXNeighborResControllerIntfc.h"
96 
97 #include "IFXImageCodec.h"
98 #include "IFXLoadManager.h"
99 #include "IFXWriteManager.h"
100 #include "IFXBoundSphereDataElement.h"
101 #include "IFXDids.h"
102 #include "IFXStdio.h"
103 #include "IFXCheckX.h"
104 
105 #pragma warning( pop )
106 
107 namespace U3D_IDTF
108 {
109 
110 //***************************************************************************
111 // Classes, structures and types
112 //***************************************************************************
113 
118 {
119 public:
120  // constructors/destructors
121  SceneUtilities();
122  virtual ~SceneUtilities(); // Scene destroyed here.
123 
124  // Scenegraph initialization
125  //IFXRESULT InitializeScene( U32 profile );
126  IFXRESULT InitializeScene( IFXCoreServices* pCoreServicesMain );
127 
128  // Debugging
129  IFXRESULT WriteDebugInfo( const char* pFile );
130 
131  // Disk I/O
132  IFXRESULT WriteSceneToFile( const IFXCHAR* pFileName,
133  IFXExportOptions ExportOptions );
134 
135  IFXRESULT LoadU3DFile( const IFXCHAR* pFileName );
136 
137  IFXRESULT CreateFileReference(
138  const IFXString& rName,
139  IFXFileReference** ppFileReference );
140 
141  // Node utilities: creation and finding
142  IFXRESULT CreateNodePlaceholder(
143  const IFXString& rNodeName,
144  U32* pNodeId = NULL );
145 
146  IFXRESULT CreateNode(
147  const IFXString& rNodeName,
148  const IFXCID& rComponentId,
149  IFXNode** ppNode,
150  U32* pNodeId = NULL );
151 
152  IFXRESULT CreateViewNode(
153  const IFXString& rNodeName,
154  const IFXString& rResourceName,
155  IFXView** ppView );
156 
157  IFXRESULT CreateGroupNode(
158  const IFXString& rNodeName,
159  IFXNode** ppNode );
160 
161  IFXRESULT CreateLightNode(
162  const IFXString& rNodeName,
163  const IFXString& rResourceName,
164  IFXLight** ppLight );
165 
166  IFXRESULT CreateModelNode(
167  const IFXString& rName,
168  const IFXString& rResourceName,
169  IFXModel** ppModel,
170  U32* pModelNodeId = NULL);
171 
172  IFXRESULT FindNode(
173  const IFXString& rName,
174  IFXNode** ppNode,
175  U32* pNodeId = NULL );
176 
177  // Resource utilities: creation and finding
178  IFXRESULT CreateResourcePlaceholder(
179  const IFXString& rName,
180  IFXSceneGraph::EIFXPalette palette,
181  U32* pId = NULL );
182 
183  IFXRESULT CreateViewResource(
184  const IFXString& rName,
185  IFXViewResource** ppViewResource );
186 
187  IFXRESULT CreateLightResource(
188  const IFXString& rName,
189  IFXLightResource** ppLightResource );
190 
191  IFXRESULT CreateMeshResource(
192  const IFXString& rName,
193  IFXAuthorMesh* pMesh,
194  IFXAuthorGeomCompilerParams& rParams,
195  IFXAuthorCLODResource** ppModel,
196  U32* pResourceId = NULL );
197 
198  IFXRESULT CreatePointSetResource(
199  const IFXString& rName,
200  IFXAuthorPointSet* pLineSet,
201  U32 modelPriority,
202  IFXAuthorPointSetResource** ppModel );
203 
204  IFXRESULT CreateLineSetResource(
205  const IFXString& rName,
206  IFXAuthorLineSet* pLineSet,
207  U32 uModelPriority,
208  IFXAuthorLineSetResource** ppModel );
209 
210  IFXRESULT CreateModelResource(
211  const IFXString& rName,
212  IFXREFCID ComponentId,
213  U32 uPrimitivePriority,
214  IFXGenerator** ppPrimitive );
215 
216  IFXRESULT CreateMotionResource(
217  const IFXString& rMotionName,
218  const U32 motionQuality,
219  const U32 motionPriority,
220  U32* motionID,
221  IFXMotionResource** pMotionResource);
222 
223  IFXRESULT FindPaletteEntry(
224  const IFXString& rName,
225  IFXSceneGraph::EIFXPalette palette,
226  IFXUnknown** ppResource,
227  U32* pPaletteId );
228 
229  IFXRESULT FindTexture(
230  const IFXString& rName,
231  IFXTextureObject** ppResource,
232  U32* pTextureId );
233 
234  IFXRESULT FindMaterial(
235  const IFXString& rName,
236  IFXMaterialResource** ppResource,
237  U32* pMaterialId );
238 
239  IFXRESULT FindShader(
240  const IFXString& rName,
241  IFXShaderLitTexture** ppResource,
242  U32* pShaderId );
243 
244  IFXRESULT FindMotionResource(
245  const IFXString& rName,
246  IFXMotionResource** ppResource );
247 
248  IFXRESULT FindResourceByModelName(
249  const IFXString& rModelName,
250  IFXAuthorCLODResource** ppAuthorCLODResource);
251 
252  IFXRESULT FindModelResource(
253  const IFXString& rResourceName,
254  IFXGenerator** ppModelResource,
255  U32* pModelResourceId = NULL);
256 
257  IFXRESULT FindModel(
258  const IFXString& rModelName,
259  IFXModel** ppModel);
260 
261  // Surface properties
262  IFXRESULT CreateShader(
263  const IFXString& rShaderName,
264  const IFXString& rMaterialName,
265  IFXShaderLitTexture** ppShader );
266 
267  IFXRESULT GetMaterialFromShader(
268  IFXShaderLitTexture* pShaderLitTexture,
269  IFXMaterialResource** ppMaterial );
270 
271  IFXRESULT GetTextureFromShader(
272  IFXShaderLitTexture* pShaderLitTexture,
273  IFXTextureObject** ppTexture,
274  U32 layer );
275 
276  IFXRESULT CreateMaterial(
277  const IFXString& rMaterial,
278  IFXMaterialResource** ppMaterial );
279 
280  IFXRESULT AddTexturePaletteEntry(
281  const IFXString& rName,
282  U32* pTextureId );
283 
284  IFXRESULT CreateTexture(
285  const IFXString& rName,
286  const U32 priority,
287  IFXTextureObject** ppTextureObject );
288 
289  IFXRESULT SetRenderWire( const IFXString& rShaderName, BOOL onOff );
290 
291  // Modifiers
292 
293  IFXRESULT AddModifier(
294  const IFXString& rModName,
295  const IFXString& rModChainType,
296  IFXModifier* pModifier );
297 
298  IFXRESULT AddBoneWeightModifier(
299  const IFXString& rModName,
300  const IFXString& rModChainType,
301  IFXBoneWeightsModifier** ppBoneWeightModifier );
302 
303  IFXRESULT AddShadingModifier(
304  const IFXString& rModName,
305  const IFXString& rModChainType,
306  IFXShadingModifier** ppShadingModifier );
307 
308  IFXRESULT AddGlyphModifier(
309  const IFXString& rModName,
310  const IFXString& rModChainType,
311  F64 defaultWidth,
312  F64 defaultSpacing,
313  F64 defaultHeight,
314  IFXGlyphCommandList* pCommandList,
315  IFXGlyph2DModifier** ppGlyph2DModifier );
316 
317  IFXRESULT AddCLODModifier(
318  const IFXString& rModName,
319  const IFXString& rModChainType,
320  IFXCLODModifier** ppCLODModifier );
321 
322  IFXRESULT AddSubdivisionModifier(
323  const IFXString& rModName,
324  const IFXString& rModChainType,
325  IFXSubdivModifier** ppSubDiv );
326 
327  // -- Animation and its utilities.
328  IFXRESULT AddAnimationModifier(
329  const IFXString& rModName,
330  const IFXString& rModChainType,
331  BOOL isKeyFrameModifier,
332  IFXAnimationModifier** ppAnimationModifier );
333 
348  IFXRESULT AssignAnimationToModifier(
349  IFXAnimationModifier* pAnimationModifer,
350  const IFXString& rMotionName,
351  F32 rTimeOffset = 0.0, F32 rTimeScale = 1.0,
352  BOOL loop = TRUE, BOOL sync = FALSE );
353 
354  IFXRESULT CompressMotionTracks( IFXMotionResource* MotionResource );
355 
356  // Misc utilities
357  IFXRESULT TestModifierResourceChain(
358  IFXAuthorCLODResource* pCLODResource,
359  IFXREFIID ModifierID,
360  U32* pFound );
361 
362  IFXRESULT TestModifierNodeChain(
363  IFXNode* pNode,
364  IFXREFIID ModifierID,
365  U32* pFound );
366 
367  IFXRESULT ResetPalettes( BOOL bRebuildDefaultEntries );
368 
369  IFXRESULT ClearPalette(
370  IFXSceneGraph::EIFXPalette paletteType,
371  IFXPalette* pPalette,
372  BOOL bClearDefaultEntryAlso );
373 
374  IFXRESULT GetWorldTransform(
375  IFXNode* pNode,
376  IFXMatrix4x4* pWorldTransform );
377 
381  IFXRESULT GetSceneMetaData( IFXMetaDataX** ppMetaData );
382 
383 private:
385  SceneUtilities& operator= ( SceneUtilities& );
386 
387  //IFXDECLAREMEMBER(IFXCoreServices,m_pCoreServicesMain);/// IFX core services object
388  IFXDECLAREMEMBER(IFXCoreServices,m_pCoreServices);
389  IFXDECLAREMEMBER(IFXSceneGraph,m_pSceneGraph);
390 
391  IFXDECLAREMEMBER( IFXPalette, m_pShaderPalette );
392  IFXDECLAREMEMBER(IFXPalette,m_pGeneratorPalette);
393  IFXDECLAREMEMBER(IFXPalette,m_pNodePalette);
394 
395  BOOL m_bInit;
396 };
397 
398 //***************************************************************************
399 // Defines
400 //***************************************************************************
401 
402 #define IFXDBGINDENT_AMT 3
403 #define DISCARD (void)
404 //#define PURE = 0
405 
406 //---------------------------------------------------------------------------
407 // Debug output routines.
408 //---------------------------------------------------------------------------
409 #ifdef _DEBUG
410 #define DBGOUT(x) {IFXTRACE_GENERIC(L"*** MESSAGE -- from: %s at %d\n",__FILE__, __LINE__); IFXTRACE_GENERIC(L"*** %s\n", (x));};
411 #define DBGOUTFMT(x,y) {IFXTRACE_GENERIC(L"*** MESSAGE -- from: %s at %d\n",__FILE__, __LINE__); IFXTRACE_GENERIC(x,y);} // must look like DBGOUTFMT("Format", Args);
412 #define DBGOUTIFERR(x,y) if(IFXFAILURE(x)){ DBGOUT(y); }
413 #else
414 #define DBGOUT(x)
415 #define DBGOUTFMT(x,y)
416 #define DBGOUTIFERR(x,y)
417 #endif
418 
425 {
426 public:
434  {
435  IFX_EDI_ENABLE,
436  IFX_EDI_DUMP, // Is DebugInfo currently writing info, if off no out put is
437  // written, can be used to progamatically enable and disable logging.
438  IFX_EDI_SKELETON, // Dump Skeletons
439  IFX_EDI_SKELETON_VERTEXWEIGHTS, // Dump the vertex weights off of the Skeleton
440  IFX_EDI_BONES, // Write random comments from the Bone converter.
441  IFX_EDI_MESHGROUP, // Dump Mesh Groups.
442  IFX_EDI_MESH, // Dump Meshes
443  IFX_EDI_LIGHT, // Dump Lights.
444  IFX_EDI_TEXTUREOBJECT,
445  IFX_EDI_MOTIONRESOURCE,
446  IFX_EDI_SHADER,
447  IFX_EDI_KEYFRAME,
448  IFX_EDI_GENERATOR,
449  IFX_EDI_MODIFIER,
450  IFX_EDI_PALETTE,
451  IFX_EDI_NODE_PALETTE,
452  IFX_EDI_MODEL_PALETTE,
453  IFX_EDI_LIGHT_PALETTE,
454  IFX_EDI_VIEW_PALETTE,
455  IFX_EDI_MATERIAL_PALETTE,
456  IFX_EDI_SHADER_PALETTE,
457  IFX_EDI_TEXTURE_PALETTE,
458  IFX_EDI_SIMTASK_PALETTE,
459  IFX_EDI_MOTION_PALETTE,
460  IFX_EDI_DUMP_PALETTE_ENTRIES,
461  IFX_EDI_COUNT
462  };
463 
464  DebugInfo();
465  virtual ~DebugInfo();
466 
467  IFXRESULT SetFlag(U32 in_Id, U32 in_value);
468  IFXRESULT Init(const char* pFileName);
469  void Close();
470  void WriteIf(U32 in_Flag, const char* in_Format, ...);
471 
472  void Write(const char*, ...);
473  void Write(IFXShaderLitTexture* pShader);
474  void Write(IFXShaderLitTexture* pShader, U32 channel);
475 
476  void Write(IFXAnimationModifier*);
477  void Write(IFXSubdivModifier*);
478  void Write(IFXCLODModifier*);
479 
480  void Write(IFXAuthorCLODResource*);
481  void Write(IFXAuthorLineSetResource*);
482  void Write(IFXGenerator*);
483  void WriteBoneWeightGenerator(IFXSkeleton *);
484 
485  void Write(IFXMotionResource*);
486  void Write(IFXMixerConstruct*, IFXPalette *pMixerPalette, IFXPalette *pMotionPalette);
487  void Write(IFXMaterialResource*);
488 
489  void Write(IFXBoneInfo * pData);
490  void Write(IFXQuaternion * pData);
491  void Write(IFXKeyFrame*);
492 
493  void Write(IFXTextureObject*);
494 
495  void Write(IFXSimulationTask*);
496 
497  void Write(IFXModifierChain*);
498  void Write(IFXModifierDataPacket*);
499  void Write(IFXRenderable*);
500  void Write(IFXMeshGroup*);
501  void Write(IFXMesh*);
502  void Write(IFXView*);
503  void Write(IFXModel*);
504  void Write(IFXLight*);
505  void Write(IFXNode*);
506 
507  void Write(IFXVector3 * pData);
508  void Write(IFXVector4 * pData);
509  void Write(IFXMatrix4x4 * pData, const char* pTabchars);
510 
511  void Write(IFXString* pData);
512  void Write(F32 * pData);
513  void WriteColor(IFXVector4 * pData);
514  void WriteColor(IFXVector3 * pData);
515 
516  void Write(IFXPalette * pData);
517  void WriteNodePalette(IFXPalette * pData);
518  void WriteLightPalette(IFXPalette * pData);
519  void WriteViewPalette(IFXPalette * pData);
520  void WriteModelPalette(IFXPalette * pData);
521  void WriteMaterialPalette(IFXPalette * pData);
522  void WriteShaderPalette(IFXPalette * pData);
523  void WriteMotionPalette(IFXPalette * pData);
524  void WriteMixerPalette(IFXPalette * pData, IFXPalette *pMotionPalette);
525  void WriteTexturePalette(IFXPalette * pData);
526  void WriteSimulationTaskPalette(IFXPalette * pData);
527 
528  IFXRESULT DumpChildNodes(IFXPalette *pNodePalette, IFXNode *pNode, U32 indent);
529 
530 private:
537  FILE* m_DbgFile;
538 
545  U32 m_Flags[IFX_EDI_COUNT];
546 };
547 
548 }
549 
550 #ifdef H_PACK_8
551 #pragma pack(pop)
552 #endif
553 
554 #endif // _HU3DHelper_H
555 #endif // HU3D_SCENE_HELPER_H
556 
557 
IFX_EDI_FLAGS
Debug Flags.
Definition: HU3DHelper.h:433
This is the implementation of a class that is used to create U3D scene objects.
Definition: HU3DHelper.h:117
IFXRESULT AssignAnimationToModifier(IFXAnimationModifier *pAnimationModifer, const IFXString &rMotionName, F32 rTimeOffset=0.0, F32 rTimeScale=1.0, BOOL loop=TRUE, BOOL sync=FALSE)
Queues up a named motion into an animation modifier.
Provides runtime debugging info to a text file.
Definition: HU3DHelper.h:424
Is the DebugInfo Enabled.
Definition: HU3DHelper.h:436
IFXRESULT GetSceneMetaData(IFXMetaDataX **ppMetaData)
Returns file meta data interface.