Alphabetical Class Index  Class Hierarchy   File Members   Compound Members   File List  

HU3DHelper.h
Go to the documentation of this file.
00001 //***************************************************************************
00002 //
00003 //  Copyright (c) 1999 - 2005 Intel Corporation
00004 //
00005 //  Licensed under the Apache License, Version 2.0 (the "License");
00006 //  you may not use this file except in compliance with the License.
00007 //  You may obtain a copy of the License at
00008 //
00009 //     http://www.apache.org/licenses/LICENSE-2.0
00010 //
00011 //  Unless required by applicable law or agreed to in writing, software
00012 //  distributed under the License is distributed on an "AS IS" BASIS,
00013 //  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014 //  See the License for the specific language governing permissions and
00015 //  limitations under the License.
00016 //
00017 //***************************************************************************
00018 
00028 #ifndef HU3D_SCENE_HELPER_H
00029 #define HU3D_SCENE_HELPER_H
00030 
00031 #ifndef _HU3DHelper_H
00032 #define _HU3DHelper_H
00033 
00034 #ifdef H_PACK_8
00035 #pragma pack(push)
00036 #pragma pack(8)
00037 #endif
00038 
00039 
00040 //***************************************************************************
00041 //  Includes
00042 //***************************************************************************
00043 
00044 #pragma warning( push, 3 )
00045 #pragma warning( disable : 4311 ) // IFXVoidStar.h
00046 
00047 #include "IFXString.h"
00048 #include "IFXCOM.h"
00049 #include "IFXCoreCIDs.h"
00050 #include "IFXAutoRelease.h"
00051 
00052 #include "IFXSceneGraph.h"
00053 #include "IFXLight.h"
00054 #include "IFXMaterialResource.h"
00055 #include "IFXModel.h"
00056 #include "IFXModifier.h"
00057 #include "IFXNode.h"
00058 #include "IFXShader.h"
00059 #include "IFXShaderLitTexture.h"
00060 #include "IFXView.h"
00061 #include "IFXPalette.h"
00062 #include "IFXMatrix4x4.h"
00063 
00064 #include "IFXAnimationModifier.h"
00065 #include "IFXBoneWeightsModifier.h"
00066 #include "IFXSkeleton.h"
00067 
00068 #include "IFXMotionResource.h"
00069 #include "IFXMixerConstruct.h"
00070 
00071 #include "IFXImportingCIDs.h"
00072 #include "IFXExportingCIDs.h"
00073 
00074 #include "IFXScheduler.h"
00075 
00076 #include "IFXAuthorGeomCompiler.h"
00077 #include "IFXSubdivModifier.h"
00078 #include "IFXCLODModifier.h"
00079 #include "IFXShadingModifier.h"
00080 #include "IFXGlyph2DModifier.h"
00081 #include "IFXGlyphCommandList.h"
00082 
00083 #include "IFXAuthorMesh.h"
00084 #include "IFXAuthorMeshScrub.h"
00085 #include "IFXAuthorLineSet.h"
00086 #include "IFXAuthorLineSetResource.h"
00087 #include "IFXAuthorPointSet.h"
00088 #include "IFXAuthorPointSetResource.h"
00089 
00090 #include "IFXModifierChain.h"
00091 
00092 #include "IFXSimulationTask.h"
00093 
00094 #include "IFXCLODManagerInterface.h"
00095 #include "IFXNeighborResControllerIntfc.h"
00096 
00097 #include "IFXImageCodec.h"
00098 #include "IFXLoadManager.h"
00099 #include "IFXWriteManager.h"
00100 #include "IFXBoundSphereDataElement.h"
00101 #include "IFXDids.h"
00102 #include "IFXStdio.h"
00103 #include "IFXCheckX.h"
00104 
00105 #pragma warning( pop )
00106 
00107 namespace U3D_IDTF
00108 {
00109 
00110 //***************************************************************************
00111 //  Classes, structures and types
00112 //***************************************************************************
00113 
00117 class SceneUtilities
00118 {
00119 public:
00120     // constructors/destructors
00121     SceneUtilities();
00122     virtual ~SceneUtilities();  // Scene destroyed here.
00123 
00124     // Scenegraph initialization
00125     //IFXRESULT InitializeScene( U32 profile );
00126     IFXRESULT InitializeScene( IFXCoreServices* pCoreServicesMain );
00127 
00128     // Debugging
00129     IFXRESULT WriteDebugInfo(  const char* pFile );
00130 
00131     // Disk I/O
00132     IFXRESULT WriteSceneToFile( const IFXCHAR* pFileName,
00133         IFXExportOptions ExportOptions );
00134 
00135     IFXRESULT LoadU3DFile(  const IFXCHAR* pFileName );
00136 
00137     IFXRESULT CreateFileReference( 
00138         const IFXString& rName,
00139         IFXFileReference** ppFileReference );
00140 
00141     // Node utilities:  creation and finding
00142     IFXRESULT CreateNodePlaceholder( 
00143         const IFXString& rNodeName,
00144         U32* pNodeId = NULL );
00145 
00146     IFXRESULT CreateNode(
00147         const IFXString& rNodeName,
00148         const IFXCID& rComponentId,
00149         IFXNode** ppNode, 
00150         U32* pNodeId = NULL );
00151 
00152     IFXRESULT CreateViewNode(
00153         const IFXString& rNodeName,
00154         const IFXString& rResourceName,
00155         IFXView** ppView );
00156 
00157     IFXRESULT CreateGroupNode(
00158         const IFXString& rNodeName,
00159         IFXNode** ppNode );
00160 
00161     IFXRESULT CreateLightNode(
00162         const IFXString& rNodeName,
00163         const IFXString& rResourceName,
00164         IFXLight** ppLight );
00165 
00166     IFXRESULT CreateModelNode(
00167         const IFXString& rName,
00168         const IFXString& rResourceName,
00169         IFXModel** ppModel,
00170         U32* pModelNodeId = NULL);
00171 
00172     IFXRESULT FindNode( 
00173         const IFXString& rName, 
00174         IFXNode** ppNode, 
00175         U32* pNodeId = NULL );
00176 
00177     // Resource utilities: creation and finding
00178     IFXRESULT CreateResourcePlaceholder( 
00179         const IFXString& rName,
00180         IFXSceneGraph::EIFXPalette palette,
00181         U32* pId = NULL );
00182 
00183     IFXRESULT CreateViewResource(
00184         const IFXString& rName,
00185         IFXViewResource** ppViewResource );
00186 
00187     IFXRESULT CreateLightResource(
00188         const IFXString& rName,
00189         IFXLightResource** ppLightResource );
00190 
00191     IFXRESULT CreateMeshResource(
00192         const IFXString& rName,
00193         IFXAuthorMesh*  pMesh,
00194         IFXAuthorGeomCompilerParams& rParams,
00195         IFXAuthorCLODResource** ppModel,
00196         U32* pResourceId = NULL );
00197 
00198     IFXRESULT CreatePointSetResource(
00199         const IFXString& rName,
00200         IFXAuthorPointSet* pLineSet,
00201         U32 modelPriority,
00202         IFXAuthorPointSetResource** ppModel );
00203 
00204     IFXRESULT CreateLineSetResource(
00205         const IFXString& rName,
00206         IFXAuthorLineSet*  pLineSet,
00207         U32 uModelPriority,
00208         IFXAuthorLineSetResource** ppModel );
00209 
00210     IFXRESULT CreateModelResource(
00211         const IFXString& rName,
00212         IFXREFCID ComponentId,
00213         U32 uPrimitivePriority,
00214         IFXGenerator** ppPrimitive );
00215 
00216     IFXRESULT CreateMotionResource(
00217         const IFXString& rMotionName,
00218         const U32 motionQuality,
00219         const U32 motionPriority,
00220         U32*  motionID,
00221         IFXMotionResource** pMotionResource);
00222 
00223     IFXRESULT FindPaletteEntry(
00224         const IFXString& rName,
00225         IFXSceneGraph::EIFXPalette palette,
00226         IFXUnknown** ppResource,
00227         U32* pPaletteId );
00228 
00229     IFXRESULT FindTexture(
00230         const IFXString& rName,
00231         IFXTextureObject** ppResource,
00232         U32* pTextureId );
00233 
00234     IFXRESULT FindMaterial(
00235         const IFXString& rName,
00236         IFXMaterialResource** ppResource,
00237         U32* pMaterialId );
00238 
00239     IFXRESULT FindShader(
00240         const IFXString& rName,
00241         IFXShaderLitTexture** ppResource,
00242         U32* pShaderId );
00243 
00244     IFXRESULT FindMotionResource(
00245         const IFXString& rName,
00246         IFXMotionResource** ppResource );
00247 
00248     IFXRESULT FindResourceByModelName(
00249         const IFXString& rModelName,
00250         IFXAuthorCLODResource** ppAuthorCLODResource);
00251 
00252     IFXRESULT FindModelResource(
00253         const IFXString& rResourceName,
00254         IFXGenerator** ppModelResource,
00255         U32* pModelResourceId = NULL);
00256 
00257     IFXRESULT FindModel(
00258         const IFXString& rModelName,
00259         IFXModel** ppModel);
00260 
00261     // Surface properties
00262     IFXRESULT CreateShader(
00263         const IFXString& rShaderName,
00264         const IFXString& rMaterialName,
00265         IFXShaderLitTexture** ppShader );
00266 
00267     IFXRESULT GetMaterialFromShader(
00268         IFXShaderLitTexture* pShaderLitTexture,
00269         IFXMaterialResource** ppMaterial );
00270 
00271     IFXRESULT GetTextureFromShader(
00272         IFXShaderLitTexture* pShaderLitTexture,
00273         IFXTextureObject** ppTexture,
00274         U32 layer );
00275 
00276     IFXRESULT CreateMaterial(
00277         const IFXString& rMaterial,
00278         IFXMaterialResource** ppMaterial );
00279 
00280     IFXRESULT AddTexturePaletteEntry(
00281         const IFXString& rName,
00282         U32* pTextureId );
00283 
00284     IFXRESULT CreateTexture(
00285         const IFXString& rName,
00286         const U32 priority,
00287         IFXTextureObject** ppTextureObject );
00288 
00289     IFXRESULT SetRenderWire( const IFXString& rShaderName, BOOL onOff );
00290 
00291     // Modifiers
00292 
00293     IFXRESULT AddModifier(
00294         const IFXString& rModName,
00295         const IFXString& rModChainType,
00296         IFXModifier* pModifier );
00297 
00298     IFXRESULT AddBoneWeightModifier(
00299         const IFXString& rModName,
00300         const IFXString& rModChainType,
00301         IFXBoneWeightsModifier** ppBoneWeightModifier );
00302 
00303     IFXRESULT AddShadingModifier(
00304         const IFXString& rModName,
00305         const IFXString& rModChainType,
00306         IFXShadingModifier** ppShadingModifier );
00307 
00308     IFXRESULT AddGlyphModifier(
00309         const IFXString& rModName,
00310         const IFXString& rModChainType,
00311         F64 defaultWidth,
00312         F64 defaultSpacing,
00313         F64 defaultHeight,
00314         IFXGlyphCommandList* pCommandList,
00315         IFXGlyph2DModifier** ppGlyph2DModifier );
00316 
00317     IFXRESULT AddCLODModifier(
00318         const IFXString& rModName,
00319         const IFXString& rModChainType,
00320         IFXCLODModifier** ppCLODModifier );
00321 
00322     IFXRESULT AddSubdivisionModifier(
00323         const IFXString& rModName,
00324         const IFXString& rModChainType,
00325         IFXSubdivModifier** ppSubDiv );
00326 
00327     // -- Animation and its utilities.
00328     IFXRESULT AddAnimationModifier(
00329         const IFXString& rModName,
00330         const IFXString& rModChainType,
00331         BOOL isKeyFrameModifier,
00332         IFXAnimationModifier** ppAnimationModifier );
00333 
00348     IFXRESULT AssignAnimationToModifier(
00349         IFXAnimationModifier* pAnimationModifer,
00350         const IFXString& rMotionName,
00351         F32 rTimeOffset = 0.0, F32 rTimeScale = 1.0,
00352         BOOL loop = TRUE, BOOL sync = FALSE );
00353 
00354     IFXRESULT CompressMotionTracks( IFXMotionResource* MotionResource );
00355 
00356     // Misc utilities
00357     IFXRESULT TestModifierResourceChain(
00358         IFXAuthorCLODResource* pCLODResource,
00359         IFXREFIID ModifierID,
00360         U32* pFound );
00361 
00362     IFXRESULT TestModifierNodeChain(
00363         IFXNode*  pNode,
00364         IFXREFIID ModifierID,
00365         U32* pFound );
00366 
00367     IFXRESULT ResetPalettes( BOOL bRebuildDefaultEntries );
00368 
00369     IFXRESULT ClearPalette(
00370         IFXSceneGraph::EIFXPalette paletteType,
00371         IFXPalette* pPalette,
00372         BOOL bClearDefaultEntryAlso );
00373 
00374     IFXRESULT GetWorldTransform(
00375         IFXNode* pNode,
00376         IFXMatrix4x4* pWorldTransform );
00377 
00381     IFXRESULT GetSceneMetaData( IFXMetaDataX** ppMetaData );
00382 
00383 private:
00384     SceneUtilities( SceneUtilities& );
00385     SceneUtilities& operator= ( SceneUtilities& );
00386 
00387     //IFXDECLAREMEMBER(IFXCoreServices,m_pCoreServicesMain);/// IFX core services object
00388     IFXDECLAREMEMBER(IFXCoreServices,m_pCoreServices);  
00389     IFXDECLAREMEMBER(IFXSceneGraph,m_pSceneGraph);    
00390 
00391     IFXDECLAREMEMBER( IFXPalette, m_pShaderPalette );     
00392     IFXDECLAREMEMBER(IFXPalette,m_pGeneratorPalette);  
00393     IFXDECLAREMEMBER(IFXPalette,m_pNodePalette);    
00394 
00395     BOOL m_bInit; 
00396 };
00397 
00398 //***************************************************************************
00399 //  Defines
00400 //***************************************************************************
00401 
00402 #define IFXDBGINDENT_AMT 3
00403 #define DISCARD (void)
00404 //#define PURE   = 0
00405 
00406 //---------------------------------------------------------------------------
00407 //  Debug output routines.
00408 //---------------------------------------------------------------------------
00409 #ifdef _DEBUG
00410 #define DBGOUT(x) {IFXTRACE_GENERIC(L"*** MESSAGE -- from: %s at %d\n",__FILE__, __LINE__); IFXTRACE_GENERIC(L"*** %s\n", (x));};
00411 #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);
00412 #define DBGOUTIFERR(x,y) if(IFXFAILURE(x)){  DBGOUT(y); }
00413 #else
00414 #define DBGOUT(x)
00415 #define DBGOUTFMT(x,y)
00416 #define DBGOUTIFERR(x,y)
00417 #endif
00418 
00424 class DebugInfo
00425 {
00426 public:
00433     enum IFX_EDI_FLAGS
00434     {
00435         IFX_EDI_ENABLE,     
00436         IFX_EDI_DUMP,     // Is DebugInfo currently writing info, if off no out put is
00437         // written, can be used to progamatically enable and disable logging.
00438         IFX_EDI_SKELETON,   // Dump Skeletons
00439         IFX_EDI_SKELETON_VERTEXWEIGHTS,  // Dump the vertex weights off of the Skeleton
00440         IFX_EDI_BONES,      // Write random comments from the Bone converter.
00441         IFX_EDI_MESHGROUP,    // Dump Mesh Groups.
00442         IFX_EDI_MESH,     // Dump Meshes
00443         IFX_EDI_LIGHT,      // Dump Lights.
00444         IFX_EDI_TEXTUREOBJECT,
00445         IFX_EDI_MOTIONRESOURCE,
00446         IFX_EDI_SHADER,
00447         IFX_EDI_KEYFRAME,
00448         IFX_EDI_GENERATOR,
00449         IFX_EDI_MODIFIER,
00450         IFX_EDI_PALETTE,
00451         IFX_EDI_NODE_PALETTE,
00452         IFX_EDI_MODEL_PALETTE,
00453         IFX_EDI_LIGHT_PALETTE,
00454         IFX_EDI_VIEW_PALETTE,
00455         IFX_EDI_MATERIAL_PALETTE,
00456         IFX_EDI_SHADER_PALETTE,
00457         IFX_EDI_TEXTURE_PALETTE,
00458         IFX_EDI_SIMTASK_PALETTE,
00459         IFX_EDI_MOTION_PALETTE,
00460         IFX_EDI_DUMP_PALETTE_ENTRIES,
00461         IFX_EDI_COUNT
00462     };
00463 
00464     DebugInfo();
00465     virtual ~DebugInfo();
00466 
00467     IFXRESULT SetFlag(U32 in_Id, U32 in_value);
00468     IFXRESULT Init(const char* pFileName);
00469     void Close();
00470     void WriteIf(U32 in_Flag, const char* in_Format, ...);
00471 
00472     void Write(const char*, ...);
00473     void Write(IFXShaderLitTexture* pShader);
00474     void Write(IFXShaderLitTexture* pShader, U32 channel);
00475 
00476     void Write(IFXAnimationModifier*);
00477     void Write(IFXSubdivModifier*);
00478     void Write(IFXCLODModifier*);
00479 
00480     void Write(IFXAuthorCLODResource*);
00481     void Write(IFXAuthorLineSetResource*);
00482     void Write(IFXGenerator*);
00483     void WriteBoneWeightGenerator(IFXSkeleton *);
00484 
00485     void Write(IFXMotionResource*);
00486     void Write(IFXMixerConstruct*, IFXPalette *pMixerPalette, IFXPalette *pMotionPalette);
00487     void Write(IFXMaterialResource*);
00488 
00489     void Write(IFXBoneInfo * pData);
00490     void Write(IFXQuaternion * pData);
00491     void Write(IFXKeyFrame*);
00492 
00493     void Write(IFXTextureObject*);
00494 
00495     void Write(IFXSimulationTask*);
00496 
00497     void Write(IFXModifierChain*);
00498     void Write(IFXModifierDataPacket*);
00499     void Write(IFXRenderable*);
00500     void Write(IFXMeshGroup*);
00501     void Write(IFXMesh*);
00502     void Write(IFXView*);
00503     void Write(IFXModel*);
00504     void Write(IFXLight*);
00505     void Write(IFXNode*);
00506 
00507     void Write(IFXVector3 * pData);
00508     void Write(IFXVector4 * pData);
00509     void Write(IFXMatrix4x4 * pData, const char* pTabchars);
00510 
00511     void Write(IFXString* pData);
00512     void Write(F32 * pData);
00513     void WriteColor(IFXVector4 * pData);
00514     void WriteColor(IFXVector3 * pData);
00515 
00516     void Write(IFXPalette * pData);
00517     void WriteNodePalette(IFXPalette * pData);
00518     void WriteLightPalette(IFXPalette * pData);
00519     void WriteViewPalette(IFXPalette * pData);
00520     void WriteModelPalette(IFXPalette * pData);
00521     void WriteMaterialPalette(IFXPalette * pData);
00522     void WriteShaderPalette(IFXPalette * pData);
00523     void WriteMotionPalette(IFXPalette * pData);
00524     void WriteMixerPalette(IFXPalette * pData, IFXPalette *pMotionPalette);
00525     void WriteTexturePalette(IFXPalette * pData);
00526     void WriteSimulationTaskPalette(IFXPalette * pData);
00527 
00528     IFXRESULT DumpChildNodes(IFXPalette *pNodePalette, IFXNode *pNode, U32 indent);
00529 
00530 private:
00537     FILE* m_DbgFile;
00538 
00545     U32 m_Flags[IFX_EDI_COUNT];
00546 };
00547 
00548 }
00549 
00550 #ifdef H_PACK_8
00551 #pragma pack(pop)
00552 #endif
00553 
00554 #endif // _HU3DHelper_H
00555 #endif // HU3D_SCENE_HELPER_H
00556 
00557