loadfile.cpp
上传用户:garry_shen
上传日期:2015-04-15
资源大小:45647k
文件大小:13k
源码类别:

游戏引擎

开发平台:

Visual C++

  1. //-----------------------------------------------------------------------------
  2. // File: loadfile.cpp
  3. //
  4. // Desc:
  5. //
  6. // Copyright (C) 1998-1999 Microsoft Corporation. All Rights Reserved.
  7. //-----------------------------------------------------------------------------
  8. #include <d3drmwin.h>
  9. #define SAFE_RELEASE(x) if (x != NULL) {x->Release(); x = NULL;}
  10. #define MSG(str) MessageBox( NULL, str, "Application Message", MB_OK)
  11. void __cdecl loadXFileCallback(LPDIRECT3DRM3 g_lpD3DRM,LPDIRECT3DRMOBJECT pObj, REFIID guidObj, LPVOID pArg);
  12. HRESULT __cdecl loadTextures(LPDIRECT3DRM3 g_lpD3DRM,char *name, void *arg, LPDIRECT3DRMTEXTURE3 *tex);   
  13. extern LPDIRECT3DRMMESHBUILDER3 pMeshBuilder1;
  14. extern LPDIRECT3DRMMESHBUILDER3 pMeshBuilderBase1;
  15. extern LPDIRECT3DRMFRAME3       pMeshFrame1;
  16. extern LPDIRECT3DRMFRAME3       pMeshFrameExit1[10];
  17. extern LPDIRECT3DRMMESHBUILDER3 pMeshBuilderExit1[10];
  18. extern LPDIRECT3DRMMESHBUILDER3 pMeshBuilder2;
  19. extern LPDIRECT3DRMMESHBUILDER3 pMeshBuilderBase2;
  20. extern LPDIRECT3DRMFRAME3       pMeshFrame2;
  21. extern LPDIRECT3DRMFRAME3       pMeshFrameExit2[10];
  22. extern LPDIRECT3DRMMESHBUILDER3 pMeshBuilderExit2[10];
  23. //-----------------------------------------------------------------------------
  24. // Name: BuildScene()
  25. // Desc: Initializes the scene.
  26. //-----------------------------------------------------------------------------
  27. BOOL BuildScene( LPDIRECT3DRM3 pD3DRM,
  28.  LPDIRECT3DRMDEVICE3 pDevice,
  29.  LPDIRECT3DRMFRAME3 pScene, LPDIRECT3DRMFRAME3 pCamera )
  30. {
  31.     LPDIRECT3DRMFRAME3      pLightsFrame = NULL;
  32.     LPDIRECT3DRMLIGHT       pLight1      = NULL;
  33.     LPDIRECT3DRMLIGHT       pLight2      = NULL;
  34.     // Add some lights to the scene
  35.     if( FAILED( pD3DRM->CreateFrame( pScene, &pLightsFrame ) ) )
  36. goto generic_error;
  37.     if( FAILED( pLightsFrame->SetPosition( pScene, 5.0f, 5.0f, -1.0f ) ) )
  38. goto generic_error;
  39.     if( FAILED( pD3DRM->CreateLightRGB( D3DRMLIGHT_DIRECTIONAL, 0.9f,0.9f, 0.9f, &pLight1 ) ) )
  40. goto generic_error;
  41.     if( FAILED( pLightsFrame->AddLight( pLight1 ) ) )
  42.     goto generic_error;
  43.     if( FAILED( pD3DRM->CreateLightRGB( D3DRMLIGHT_AMBIENT, 0.9f,0.9f, 0.9f, &pLight2 ) ) )
  44. goto generic_error;
  45.     if( FAILED( pScene->AddLight( pLight2 ) ) )
  46. goto generic_error;
  47.     // Set up the frames position, orientation and rotation 
  48.     pCamera->SetPosition( pScene,8.0f,-6.0f,8.0f);
  49.     pCamera->SetOrientation( pScene,0.0f,-0.4f,1.0f,0.0f,0.1f,0.0f);
  50.     //pCamera->SetOrientation( pScene, 0.0f, -0.5f, 0.0f, 0.0f, 4.0f, 0.0f );
  51.     
  52.     SAFE_RELEASE( pLightsFrame );
  53.     SAFE_RELEASE( pLight1 );
  54.     SAFE_RELEASE( pLight2 );
  55.     return TRUE;
  56. generic_error:
  57.     MSG("A failure occured while building the scene.n");
  58.     return FALSE;
  59. }
  60. //-----------------------------------------------------------------------------
  61. // Name: OverrideDefualts()
  62. // Desc: Let's the sample customize default behavior.
  63. //-----------------------------------------------------------------------------
  64. VOID OverrideDefaults( BOOL* pbNoTextures, BOOL* pbResizingDisabled, 
  65.    BOOL* pbConstRenderQuality, CHAR** pstrName )
  66. {
  67. (*pbNoTextures) = TRUE;
  68.     (*pstrName)     = "