本文整理汇总了C++中CModelViewerCamera::SetRadius方法的典型用法代码示例。如果您正苦于以下问题:C++ CModelViewerCamera::SetRadius方法的具体用法?C++ CModelViewerCamera::SetRadius怎么用?C++ CModelViewerCamera::SetRadius使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CModelViewerCamera
的用法示例。
在下文中一共展示了CModelViewerCamera::SetRadius方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnResetDevice
//--------------------------------------------------------------------------------------
// This callback function will be called immediately after the Direct3D device has been
// reset, which will happen after a lost device scenario. This is the best location to
// create D3DPOOL_DEFAULT resources since these resources need to be reloaded whenever
// the device is lost. Resources created here should be released in the OnLostDevice
// callback.
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnResetDevice( IDirect3DDevice9* pd3dDevice,
const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext )
{
HRESULT hr;
V_RETURN( g_DialogResourceManager.OnD3D9ResetDevice() );
V_RETURN( g_SettingsDlg.OnD3D9ResetDevice() );
if( g_pFont )
V_RETURN( g_pFont->OnResetDevice() );
if( g_pEffect )
V_RETURN( g_pEffect->OnResetDevice() );
g_LightControl.OnD3D9ResetDevice( pBackBufferSurfaceDesc );
g_Skybox.OnResetDevice( pBackBufferSurfaceDesc );
// Create a sprite to help batch calls when drawing many lines of text
V_RETURN( D3DXCreateSprite( pd3dDevice, &g_pTextSprite ) );
// Setup the camera's projection parameters
float fAspectRatio = pBackBufferSurfaceDesc->Width / ( FLOAT )pBackBufferSurfaceDesc->Height;
g_Camera.SetProjParams( D3DX_PI / 4, fAspectRatio, 0.001f, 1000.0f );
g_Camera.SetWindow( pBackBufferSurfaceDesc->Width, pBackBufferSurfaceDesc->Height );
g_Camera.SetButtonMasks( MOUSE_LEFT_BUTTON, MOUSE_WHEEL, MOUSE_RIGHT_BUTTON );
g_Camera.SetAttachCameraToModel( true );
g_Camera.SetRadius( 5.0f, 0.1f, 20.0f );
g_HUD.SetLocation( pBackBufferSurfaceDesc->Width - 170, 0 );
g_HUD.SetSize( 170, 170 );
g_SampleUI.SetLocation( pBackBufferSurfaceDesc->Width - 300, pBackBufferSurfaceDesc->Height - 245 );
g_SampleUI.SetSize( 300, 300 );
return S_OK;
}
示例2: vecEye
//--------------------------------------------------------------------------------------
// Create any D3D11 resources that aren't dependant on the back buffer
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D11CreateDevice(ID3D11Device* pd3dDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext)
{
HRESULT hr;
DXUTTRACE(L"OnD3D11CreateDevice called\n");
SetCursor(LoadCursor(0, IDC_ARROW));
ID3D11DeviceContext* pd3dImmediateContext = DXUTGetD3D11DeviceContext(); // does not addref
V_RETURN( g_DialogResourceManager.OnD3D11CreateDevice(pd3dDevice, pd3dImmediateContext) );
V_RETURN( g_SettingsDlg.OnD3D11CreateDevice(pd3dDevice) );
g_pTxtHelper = new CDXUTTextHelper(pd3dDevice, pd3dImmediateContext, &g_DialogResourceManager, g_TextLineHeight);
// Setup orbital camera
D3DXVECTOR3 vecEye(0.0f, 2.0f, 0.0f);
D3DXVECTOR3 vecAt (0.0f, 0.0f, 0.0f);
g_OrbitalCamera.SetViewParams(&vecEye, &vecAt);
g_OrbitalCamera.SetRadius(1.5f, 0.01f);
// Setup first-person camera
D3DXVECTOR3 sibenikVecEye(0.0960150138f, 0.0273544509f, -0.0185411610f);
D3DXVECTOR3 sibenikVecAt (-0.623801112f, -0.649074197f, -0.174454257f);
g_FirstPersonCamera.SetViewParams(&sibenikVecEye, &sibenikVecAt);
g_FirstPersonCamera.SetEnablePositionMovement(1);
g_FirstPersonCamera.SetScalers(0.001f, 0.05f);
// Load Scene3D.fx
g_pSceneRenderer.OnCreateDevice(pd3dDevice);
// Load meshes and bin files
LoadScenes(pd3dDevice);
GFSDK_SSAO_Status status;
status = g_AORenderer.Create(pd3dDevice);
assert(status == GFSDK_SSAO_OK);
return S_OK;
}
示例3: vCenter
//--------------------------------------------------------------------------------------
// Create any D3D resources that aren't dependant on the back buffer
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D11CreateDevice( ID3D11Device* pd3dDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc,
void* pUserContext )
{
HRESULT hr = S_OK;
auto pd3dImmediateContext = DXUTGetD3D11DeviceContext();
V_RETURN( g_DialogResourceManager.OnD3D11CreateDevice( pd3dDevice, pd3dImmediateContext ) );
V_RETURN( g_D3DSettingsDlg.OnD3D11CreateDevice( pd3dDevice ) );
g_pTxtHelper = new CDXUTTextHelper( pd3dDevice, pd3dImmediateContext, &g_DialogResourceManager, 15 );
XMFLOAT3 vCenter( 0.25767413f, -28.503521f, 111.00689f );
FLOAT fObjectRadius = 378.15607f;
g_mCenterMesh = XMMatrixTranslation( -vCenter.x, -vCenter.y, -vCenter.z );
XMMATRIX m;
m = XMMatrixRotationY( XM_PI );
g_mCenterMesh *= m;
m = XMMatrixRotationX( XM_PI / 2.0f );
g_mCenterMesh *= m;
// Init the UI widget for directional lighting
V_RETURN( CDXUTDirectionWidget::StaticOnD3D11CreateDevice( pd3dDevice, pd3dImmediateContext ) );
g_LightControl.SetRadius( fObjectRadius );
// Compile and create the effect.
DWORD dwShaderFlags = D3DCOMPILE_ENABLE_STRICTNESS;
#ifdef _DEBUG
// Set the D3DCOMPILE_DEBUG flag to embed debug information in the shaders.
// Setting this flag improves the shader debugging experience, but still allows
// the shaders to be optimized and to run exactly the way they will run in
// the release configuration of this program.
dwShaderFlags |= D3DCOMPILE_DEBUG;
// Disable optimizations to further improve shader debugging
dwShaderFlags |= D3DCOMPILE_SKIP_OPTIMIZATION;
#endif
#if D3D_COMPILER_VERSION >= 46
WCHAR str[MAX_PATH];
V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"DynamicShaderLinkageFX11.fx" ) );
ID3DBlob* pErrorBlob = nullptr;
hr = D3DX11CompileEffectFromFile( str, nullptr, D3D_COMPILE_STANDARD_FILE_INCLUDE, dwShaderFlags, D3DCOMPILE_EFFECT_ALLOW_SLOW_OPS, pd3dDevice, &g_pEffect, &pErrorBlob );
if ( pErrorBlob )
{
OutputDebugStringA( reinterpret_cast<const char*>( pErrorBlob->GetBufferPointer() ) );
pErrorBlob->Release();
}
if( FAILED(hr) )
{
return hr;
}
#else
ID3DBlob* pEffectBuffer = nullptr;
V_RETURN( DXUTCompileFromFile( L"DynamicShaderLinkageFX11.fx", nullptr, "none", "fx_5_0", dwShaderFlags, D3DCOMPILE_EFFECT_ALLOW_SLOW_OPS, &pEffectBuffer ) );
hr = D3DX11CreateEffectFromMemory( pEffectBuffer->GetBufferPointer(), pEffectBuffer->GetBufferSize(), 0, pd3dDevice, &g_pEffect );
SAFE_RELEASE( pEffectBuffer );
if ( FAILED(hr) )
return hr;
#endif
// Get the light Class Interfaces for setting values
// and as potential binding sources.
g_pAmbientLightClass = g_pEffect->GetVariableByName( "g_ambientLight" )->AsClassInstance();
g_pAmbientLightColor = g_pAmbientLightClass->GetMemberByName( "m_vLightColor" )->AsVector();
g_pAmbientLightEnable = g_pAmbientLightClass->GetMemberByName( "m_bEnable" )->AsScalar();
g_pHemiAmbientLightClass = g_pEffect->GetVariableByName( "g_hemiAmbientLight" )->AsClassInstance();
g_pHemiAmbientLightColor = g_pHemiAmbientLightClass->GetMemberByName( "m_vLightColor" )->AsVector();
g_pHemiAmbientLightEnable = g_pHemiAmbientLightClass->GetMemberByName( "m_bEnable" )->AsScalar();
g_pHemiAmbientLightGroundColor = g_pHemiAmbientLightClass->GetMemberByName( "m_vGroundColor" )->AsVector();
g_pHemiAmbientLightDirUp = g_pHemiAmbientLightClass->GetMemberByName( "m_vDirUp" )->AsVector();
g_pDirectionalLightClass = g_pEffect->GetVariableByName( "g_directionalLight")->AsClassInstance();
g_pDirectionalLightColor = g_pDirectionalLightClass->GetMemberByName( "m_vLightColor" )->AsVector();
g_pDirectionalLightEnable = g_pDirectionalLightClass->GetMemberByName( "m_bEnable" )->AsScalar();
g_pDirectionalLightDir = g_pDirectionalLightClass->GetMemberByName( "m_vLightDir" )->AsVector();
g_pEnvironmentLightClass = g_pEffect->GetVariableByName( "g_environmentLight")->AsClassInstance();
g_pEnvironmentLightColor = g_pEnvironmentLightClass->GetMemberByName( "m_vLightColor" )->AsVector();
g_pEnvironmentLightEnable = g_pEnvironmentLightClass->GetMemberByName( "m_bEnable" )->AsScalar();
g_pEyeDir = g_pEffect->GetVariableByName( "g_vEyeDir" )->AsVector();
// Acquire the material Class Instances for all possible material settings
for( UINT i=0; i < MATERIAL_TYPE_COUNT; i++)
{
char pTechName[50];
sprintf_s( pTechName, sizeof(pTechName),
"FeatureLevel11_%s",
g_pMaterialClassNames[ i ] );
g_MaterialClasses[i].pTechnique = g_pEffect->GetTechniqueByName( pTechName );
//.........这里部分代码省略.........
示例4: colorMtrlDiffuse
//--------------------------------------------------------------------------------------
// Create any D3D9 resources that will live through a device reset (D3DPOOL_MANAGED)
// and aren't tied to the back buffer size
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D9CreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc,
void* pUserContext )
{
MessageBox(0, L"We aren't using DirectX9", L"We aren't using DirectX9", 0);
exit(1);
HRESULT hr;
V_RETURN( g_DialogResourceManager.OnD3D9CreateDevice( pd3dDevice ) );
V_RETURN( g_D3DSettingsDlg.OnD3D9CreateDevice( pd3dDevice ) );
// Initialize the font
V_RETURN( D3DXCreateFont( pd3dDevice, 15, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
L"Arial", &g_pFont9 ) );
// Load the mesh
V_RETURN( LoadMesh( pd3dDevice, L"tiny\\tiny.x", &g_pMesh9 ) );
D3DXVECTOR3* pData;
D3DXVECTOR3 vCenter;
FLOAT fObjectRadius;
V( g_pMesh9->LockVertexBuffer( 0, ( LPVOID* )&pData ) );
V( D3DXComputeBoundingSphere( pData, g_pMesh9->GetNumVertices(),
D3DXGetFVFVertexSize( g_pMesh9->GetFVF() ), &vCenter, &fObjectRadius ) );
V( g_pMesh9->UnlockVertexBuffer() );
D3DXMatrixTranslation( &g_mCenterMesh, -vCenter.x, -vCenter.y, -vCenter.z );
D3DXMATRIXA16 m;
D3DXMatrixRotationY( &m, D3DX_PI );
g_mCenterMesh *= m;
D3DXMatrixRotationX( &m, D3DX_PI / 2.0f );
g_mCenterMesh *= m;
V_RETURN( CDXUTDirectionWidget::StaticOnD3D9CreateDevice( pd3dDevice ) );
g_LightControl.SetRadius( fObjectRadius );
// Read the D3DX effect file
WCHAR str[MAX_PATH];
DWORD dwShaderFlags = D3DXFX_NOT_CLONEABLE | D3DXSHADER_NO_PRESHADER | D3DXFX_LARGEADDRESSAWARE;
#ifdef DEBUG_VS
dwShaderFlags |= D3DXSHADER_FORCE_VS_SOFTWARE_NOOPT;
#endif
#ifdef DEBUG_PS
dwShaderFlags |= D3DXSHADER_FORCE_PS_SOFTWARE_NOOPT;
#endif
V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"BasicHLSL.fx" ) );
V_RETURN( D3DXCreateEffectFromFile( pd3dDevice, str, NULL, NULL, dwShaderFlags, NULL, &g_pEffect9, NULL ) );
// Create the mesh texture from a file
V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"tiny\\tiny_skin.dds" ) );
V_RETURN( D3DXCreateTextureFromFileEx( pd3dDevice, str, D3DX_DEFAULT, D3DX_DEFAULT,
D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED,
D3DX_DEFAULT, D3DX_DEFAULT, 0,
NULL, NULL, &g_pMeshTexture9 ) );
// Set effect variables as needed
D3DXCOLOR colorMtrlDiffuse( 1.0f, 1.0f, 1.0f, 1.0f );
D3DXCOLOR colorMtrlAmbient( 0.35f, 0.35f, 0.35f, 0 );
D3DXHANDLE hMaterialAmbientColor = g_pEffect9->GetParameterByName( NULL, "g_MaterialAmbientColor" );
D3DXHANDLE hMaterialDiffuseColor = g_pEffect9->GetParameterByName( NULL, "g_MaterialDiffuseColor" );
D3DXHANDLE hMeshTexture = g_pEffect9->GetParameterByName( NULL, "g_MeshTexture" );
V_RETURN( g_pEffect9->SetValue( hMaterialAmbientColor, &colorMtrlAmbient, sizeof( D3DXCOLOR ) ) );
V_RETURN( g_pEffect9->SetValue( hMaterialDiffuseColor, &colorMtrlDiffuse, sizeof( D3DXCOLOR ) ) );
V_RETURN( g_pEffect9->SetTexture( hMeshTexture, g_pMeshTexture9 ) );
g_hLightDir = g_pEffect9->GetParameterByName( NULL, "g_LightDir" );
g_hLightDiffuse = g_pEffect9->GetParameterByName( NULL, "g_LightDiffuse" );
g_hmWorldViewProjection = g_pEffect9->GetParameterByName( NULL, "g_mWorldViewProjection" );
g_hmWorld = g_pEffect9->GetParameterByName( NULL, "g_mWorld" );
g_hMaterialDiffuseColor = g_pEffect9->GetParameterByName( NULL, "g_MaterialDiffuseColor" );
g_hfTime = g_pEffect9->GetParameterByName( NULL, "g_fTime" );
g_hnNumLights = g_pEffect9->GetParameterByName( NULL, "g_nNumLights" );
g_hRenderSceneWithTexture1Light = g_pEffect9->GetTechniqueByName( "RenderSceneWithTexture1Light" );
g_hRenderSceneWithTexture2Light = g_pEffect9->GetTechniqueByName( "RenderSceneWithTexture2Light" );
g_hRenderSceneWithTexture3Light = g_pEffect9->GetTechniqueByName( "RenderSceneWithTexture3Light" );
// Setup the camera's view parameters
D3DXVECTOR3 vecEye( 0.0f, 0.0f, -15.0f );
D3DXVECTOR3 vecAt ( 0.0f, 0.0f, -0.0f );
g_Camera.SetViewParams( &vecEye, &vecAt );
g_Camera.SetRadius( fObjectRadius * 3.0f, fObjectRadius * 0.5f, fObjectRadius * 10.0f );
return S_OK;
}
示例5: OnCreateDevice
//--------------------------------------------------------------------------------------
// This callback function will be called immediately after the Direct3D device has been
// created, which will happen during application initialization and windowed/full screen
// toggles. This is the best location to create D3DPOOL_MANAGED resources since these
// resources need to be reloaded whenever the device is destroyed. Resources created
// here should be released in the OnDestroyDevice callback.
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnCreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc,
void* pUserContext )
{
HRESULT hr;
V_RETURN( g_DialogResourceManager.OnD3D9CreateDevice( pd3dDevice ) );
V_RETURN( g_SettingsDlg.OnD3D9CreateDevice( pd3dDevice ) );
// Initialize the font
V_RETURN( D3DXCreateFont( pd3dDevice, 15, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
L"Arial", &g_pFont ) );
// Load the mesh
V_RETURN( LoadMesh( pd3dDevice, L"tiny\\tiny.x", &g_pMesh ) );
D3DXVECTOR3* pData;
D3DXVECTOR3 vCenter;
FLOAT fObjectRadius;
V( g_pMesh->LockVertexBuffer( 0, ( LPVOID* )&pData ) );
V( D3DXComputeBoundingSphere( pData, g_pMesh->GetNumVertices(),
D3DXGetFVFVertexSize( g_pMesh->GetFVF() ), &vCenter, &fObjectRadius ) );
V( g_pMesh->UnlockVertexBuffer() );
D3DXMatrixTranslation( &g_mCenterWorld, -vCenter.x, -vCenter.y, -vCenter.z );
D3DXMATRIXA16 m;
D3DXMatrixRotationY( &m, D3DX_PI );
g_mCenterWorld *= m;
D3DXMatrixRotationX( &m, D3DX_PI / 2.0f );
g_mCenterWorld *= m;
V_RETURN( CDXUTDirectionWidget::StaticOnD3D9CreateDevice( pd3dDevice ) );
for( int i = 0; i < MAX_LIGHTS; i++ )
g_LightControl[i].SetRadius( fObjectRadius );
// Define DEBUG_VS and/or DEBUG_PS to debug vertex and/or pixel shaders with the
// shader debugger. Debugging vertex shaders requires either REF or software vertex
// processing, and debugging pixel shaders requires REF. The
// D3DXSHADER_FORCE_*_SOFTWARE_NOOPT flag improves the debug experience in the
// shader debugger. It enables source level debugging, prevents instruction
// reordering, prevents dead code elimination, and forces the compiler to compile
// against the next higher available software target, which ensures that the
// unoptimized shaders do not exceed the shader model limitations. Setting these
// flags will cause slower rendering since the shaders will be unoptimized and
// forced into software. See the DirectX documentation for more information about
// using the shader debugger.
DWORD dwShaderFlags = D3DXFX_NOT_CLONEABLE;
#if defined( DEBUG ) || defined( _DEBUG )
// Set the D3DXSHADER_DEBUG flag to embed debug information in the shaders.
// Setting this flag improves the shader debugging experience, but still allows
// the shaders to be optimized and to run exactly the way they will run in
// the release configuration of this program.
dwShaderFlags |= D3DXSHADER_DEBUG;
#endif
#ifdef DEBUG_VS
dwShaderFlags |= D3DXSHADER_FORCE_VS_SOFTWARE_NOOPT;
#endif
#ifdef DEBUG_PS
dwShaderFlags |= D3DXSHADER_FORCE_PS_SOFTWARE_NOOPT;
#endif
// Preshaders are parts of the shader that the effect system pulls out of the
// shader and runs on the host CPU. They should be used if you are GPU limited.
// The D3DXSHADER_NO_PRESHADER flag disables preshaders.
if( !g_bEnablePreshader )
dwShaderFlags |= D3DXSHADER_NO_PRESHADER;
// Read the D3DX effect file
WCHAR str[MAX_PATH];
V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"BasicHLSL.fx" ) );
// If this fails, there should be debug output as to
// why the .fx file failed to compile
V_RETURN( D3DXCreateEffectFromFile( pd3dDevice, str, NULL, NULL, dwShaderFlags, NULL, &g_pEffect, NULL ) );
// Create the mesh texture from a file
V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"tiny\\tiny_skin.dds" ) );
V_RETURN( D3DXCreateTextureFromFileEx( pd3dDevice, str, D3DX_DEFAULT, D3DX_DEFAULT,
D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED,
D3DX_DEFAULT, D3DX_DEFAULT, 0,
NULL, NULL, &g_pMeshTexture ) );
// Set effect variables as needed
D3DXCOLOR colorMtrlDiffuse( 1.0f, 1.0f, 1.0f, 1.0f );
D3DXCOLOR colorMtrlAmbient( 0.35f, 0.35f, 0.35f, 0 );
V_RETURN( g_pEffect->SetValue( "g_MaterialAmbientColor", &colorMtrlAmbient, sizeof( D3DXCOLOR ) ) );
V_RETURN( g_pEffect->SetValue( "g_MaterialDiffuseColor", &colorMtrlDiffuse, sizeof( D3DXCOLOR ) ) );
V_RETURN( g_pEffect->SetTexture( "g_MeshTexture", g_pMeshTexture ) );
// Setup the camera's view parameters
//.........这里部分代码省略.........
示例6: OnCreateDevice
//--------------------------------------------------------------------------------------
// 디바이스 생성 함수
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnCreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc,
void* pUserContext )
{
HRESULT hr;
//mesh 불러와서 g_pMesh에 저장
V_RETURN( LoadMesh( pd3dDevice, L"tiny\\tiny.x", &g_pMesh ) );
D3DXVECTOR3* pData;
D3DXVECTOR3 vCenter;
FLOAT fObjectRadius;
//메쉬를 쓸 buffer에 대한 lock
//lock은 버텍스 버퍼의 위치 값을 불러줌(어디에 있는지 상관 없이 리턴)
//첫 번째 인자가 버퍼 옵션(3= readonly)
V( g_pMesh->LockVertexBuffer( 3, ( LPVOID* )&pData ) );
//메쉬 경계값 산출 = 모든 vertex 순회
//모든 vertex순회 후 평균 계산= 중점, 가장 먼거리의 vertex가 반지름
V( D3DXComputeBoundingSphere( pData, g_pMesh->GetNumVertices(),
D3DXGetFVFVertexSize( g_pMesh->GetFVF() ), &vCenter, &fObjectRadius ) );
//buffer unlock
V( g_pMesh->UnlockVertexBuffer() );
//월드 좌표 초기 세팅
//mesh에서 받은 중앙값을 기준으로 세팅
D3DXMatrixTranslation( &g_mCenterWorld, -vCenter.x, -vCenter.y, -vCenter.z );
D3DXMATRIXA16 m;
D3DXMatrixRotationY( &m, D3DX_PI );
g_mCenterWorld *= m;
D3DXMatrixRotationX( &m, D3DX_PI / 2.0f );
g_mCenterWorld *= m;
//warping된 device객체 생성
V_RETURN( CDXUTDirectionWidget::StaticOnD3D9CreateDevice( pd3dDevice ) );
//조명 이동 형태가 구를 이루고 있는데, 해당 이동 좌표를 결정
for( int i = 0; i < MAX_LIGHTS; i++ )
g_LightControl[i].SetRadius( fObjectRadius );
//셰이더의 데이터를 메모리에 보존하지 않아 이펙트의 메모리 사용량을 50% 줄임
DWORD dwShaderFlags = D3DXFX_NOT_CLONEABLE;
//컴파일러에 미리 알려주는 preshading 옵션 추가
//그런데 우리는 init에서 g_bEnablePreshader를 true로 했으니 거치지 않음
if( !g_bEnablePreshader )
dwShaderFlags |= D3DXSHADER_NO_PRESHADER;
//이펙트 파일의 파일명을 찾고, 받아서 str에 저장(방어코드 개념)
WCHAR str[MAX_PATH];
V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"BasicHLSL.fx" ) );
//str을 이용해서 실제 shader를 g_pEffect에 넣음
V_RETURN( D3DXCreateEffectFromFile( pd3dDevice, str, NULL, NULL, dwShaderFlags, NULL, &g_pEffect, NULL ) );
// 텍스쳐 파일명을 찾고, 받아서 str에 저장(방어코드 개념)
V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"tiny\\tiny_skin.dds" ) );
//텍스쳐 불러와서 g_pMeshTexture에 저장
V_RETURN( D3DXCreateTextureFromFileEx( pd3dDevice, str, D3DX_DEFAULT, D3DX_DEFAULT,
D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED,
D3DX_DEFAULT, D3DX_DEFAULT, 0,
NULL, NULL, &g_pMeshTexture ) );
//쓸데없는 코드 같아 보임
//렌더에서 프레임마다 설정해주는 중
// //shader material에 조명 수치 적용 값(예정)
// D3DXCOLOR colorMtrlDiffuse( 1.0f, 1.0f, 1.0f, 1.0f );
// D3DXCOLOR colorMtrlAmbient( 0.35f, 0.35f, 0.35f, 0 );
//
// //shader와 준비된 설정값 바인딩 과정
// //material 조명 수치, texture 등
// V_RETURN( g_pEffect->SetValue( "g_MaterialAmbientColor", &colorMtrlAmbient, sizeof( D3DXCOLOR ) ) );
// V_RETURN( g_pEffect->SetValue( "g_MaterialDiffuseColor", &colorMtrlDiffuse, sizeof( D3DXCOLOR ) ) );
V_RETURN( g_pEffect->SetTexture( "g_MeshTexture", g_pMeshTexture ) );
//카메라 위치를 설정하는 코드
D3DXVECTOR3 vecEye( 0.0f, 0.0f, -15.0f );
D3DXVECTOR3 vecAt ( 0.0f, 0.0f, -0.0f );
g_Camera.SetViewParams( &vecEye, &vecAt );
//카메라가 이동할 수 있는 경로(구형, 경계면) 설정
g_Camera.SetRadius( fObjectRadius * 3.0f, fObjectRadius * 0.5f, fObjectRadius * 10.0f );
return S_OK;
}