loadfile.cpp
上传用户:garry_shen
上传日期:2015-04-15
资源大小:45647k
文件大小:13k
- //-----------------------------------------------------------------------------
- // File: loadfile.cpp
- //
- // Desc:
- //
- // Copyright (C) 1998-1999 Microsoft Corporation. All Rights Reserved.
- //-----------------------------------------------------------------------------
- #include <d3drmwin.h>
- #define SAFE_RELEASE(x) if (x != NULL) {x->Release(); x = NULL;}
- #define MSG(str) MessageBox( NULL, str, "Application Message", MB_OK)
- void __cdecl loadXFileCallback(LPDIRECT3DRM3 g_lpD3DRM,LPDIRECT3DRMOBJECT pObj, REFIID guidObj, LPVOID pArg);
- HRESULT __cdecl loadTextures(LPDIRECT3DRM3 g_lpD3DRM,char *name, void *arg, LPDIRECT3DRMTEXTURE3 *tex);
- extern LPDIRECT3DRMMESHBUILDER3 pMeshBuilder1;
- extern LPDIRECT3DRMMESHBUILDER3 pMeshBuilderBase1;
- extern LPDIRECT3DRMFRAME3 pMeshFrame1;
- extern LPDIRECT3DRMFRAME3 pMeshFrameExit1[10];
- extern LPDIRECT3DRMMESHBUILDER3 pMeshBuilderExit1[10];
- extern LPDIRECT3DRMMESHBUILDER3 pMeshBuilder2;
- extern LPDIRECT3DRMMESHBUILDER3 pMeshBuilderBase2;
- extern LPDIRECT3DRMFRAME3 pMeshFrame2;
- extern LPDIRECT3DRMFRAME3 pMeshFrameExit2[10];
- extern LPDIRECT3DRMMESHBUILDER3 pMeshBuilderExit2[10];
- //-----------------------------------------------------------------------------
- // Name: BuildScene()
- // Desc: Initializes the scene.
- //-----------------------------------------------------------------------------
- BOOL BuildScene( LPDIRECT3DRM3 pD3DRM,
- LPDIRECT3DRMDEVICE3 pDevice,
- LPDIRECT3DRMFRAME3 pScene, LPDIRECT3DRMFRAME3 pCamera )
- {
- LPDIRECT3DRMFRAME3 pLightsFrame = NULL;
- LPDIRECT3DRMLIGHT pLight1 = NULL;
- LPDIRECT3DRMLIGHT pLight2 = NULL;
- // Add some lights to the scene
- if( FAILED( pD3DRM->CreateFrame( pScene, &pLightsFrame ) ) )
- goto generic_error;
- if( FAILED( pLightsFrame->SetPosition( pScene, 5.0f, 5.0f, -1.0f ) ) )
- goto generic_error;
- if( FAILED( pD3DRM->CreateLightRGB( D3DRMLIGHT_DIRECTIONAL, 0.9f,0.9f, 0.9f, &pLight1 ) ) )
- goto generic_error;
- if( FAILED( pLightsFrame->AddLight( pLight1 ) ) )
- goto generic_error;
- if( FAILED( pD3DRM->CreateLightRGB( D3DRMLIGHT_AMBIENT, 0.9f,0.9f, 0.9f, &pLight2 ) ) )
- goto generic_error;
- if( FAILED( pScene->AddLight( pLight2 ) ) )
- goto generic_error;
- // Set up the frames position, orientation and rotation
- pCamera->SetPosition( pScene,8.0f,-6.0f,8.0f);
- pCamera->SetOrientation( pScene,0.0f,-0.4f,1.0f,0.0f,0.1f,0.0f);
- //pCamera->SetOrientation( pScene, 0.0f, -0.5f, 0.0f, 0.0f, 4.0f, 0.0f );
-
- SAFE_RELEASE( pLightsFrame );
- SAFE_RELEASE( pLight1 );
- SAFE_RELEASE( pLight2 );
-
- return TRUE;
- generic_error:
- MSG("A failure occured while building the scene.n");
- return FALSE;
- }
- //-----------------------------------------------------------------------------
- // Name: OverrideDefualts()
- // Desc: Let's the sample customize default behavior.
- //-----------------------------------------------------------------------------
- VOID OverrideDefaults( BOOL* pbNoTextures, BOOL* pbResizingDisabled,
- BOOL* pbConstRenderQuality, CHAR** pstrName )
- {
- (*pbNoTextures) = TRUE;
- (*pstrName) = "