#include "Stdafx.h" #include "ObjectLightFolder.h" #include "ObjectLightDir.h" #include "ObjectLightPoint.h" #include "ObjectLightSpot.h" #include "GlobalValue.h" CObjectLightFolder::CObjectLightFolder() { m_Type = CActionBase::LIGHTFOLDER; } CObjectLightFolder::~CObjectLightFolder() { } void CObjectLightFolder::InitPropertyInfo() { SAFE_DELETE_PVEC( m_pVecPropertyList ); PropertyGridBaseDefine Default[] = { { "Common", "Total", CUnionValueProperty::Integer, "Light Count", FALSE }, { "Common", "Directional", CUnionValueProperty::Integer, "Directional Light Count", FALSE }, { "Common", "Point", CUnionValueProperty::Integer, "Point Light Count", FALSE }, { "Common", "Spot", CUnionValueProperty::Integer, "Spot Light Count", FALSE }, { "Common", "Ambient", CUnionValueProperty::Vector4Color, "Ambient Light", TRUE }, { "All", "Disable All Cast Shadow", CUnionValueProperty::Boolean, "¸ðµç ¶óÀÌÆ®ÀÇ Ä³½ºÆÃ ½¦µµ¿ì ¿É¼ÇÀ» ²ö´Ù.", TRUE }, NULL, }; AddPropertyInfo( Default ); } void CObjectLightFolder::OnSetPropertyValue( DWORD dwIndex, CUnionValueProperty *pVariable ) { int nDir = 0, nPoint = 0, nSpot = 0; for( DWORD i=0; iGetType() ) { case CActionBase::LIGHTDIR: nDir++; break; case CActionBase::LIGHTPOINT: nPoint++; break; case CActionBase::LIGHTSPOT: nSpot++; break; } } switch( dwIndex ) { case 0: pVariable->SetVariable( nDir + nPoint + nSpot ); break; case 1: pVariable->SetVariable( nDir ); break; case 2: pVariable->SetVariable( nPoint ); break; case 3: pVariable->SetVariable( nSpot ); break; case 4: { EtColor Color = EternityEngine::GetGlobalAmbient(); pVariable->SetVariable( (D3DXVECTOR4)Color ); } break; case 5: { pVariable->SetVariable( FALSE ); } break; }; } void CObjectLightFolder::OnChangePropertyValue( DWORD dwIndex, CUnionValueProperty *pVariable ) { switch( dwIndex ) { case 4: { EtVector4 vColor = pVariable->GetVariableVector4(); EternityEngine::SetGlobalAmbient( (EtColor*)&vColor ); } break; case 5: { for( DWORD i=0; iGetType() ) { case CActionBase::LIGHTDIR: ((CObjectLightDir*)m_pVecChild[i])->OnChangePropertyValue( 3, pVariable ); break; case CActionBase::LIGHTPOINT: ((CObjectLightPoint*)m_pVecChild[i])->OnChangePropertyValue( 4, pVariable ); break; case CActionBase::LIGHTSPOT: ((CObjectLightSpot*)m_pVecChild[i])->OnChangePropertyValue( 8, pVariable ); break; } } } break; } } void CObjectLightFolder::SaveLightSetting( CString szStr ) { std::vector VecDir; std::vector VecPoint; std::vector VecSpot; for( DWORD i=0; iGetType() ) { case LIGHTDIR: VecDir.push_back( ((CObjectLightDir*)pChild)->GetLightInfo() ); break; case LIGHTPOINT: VecPoint.push_back( ((CObjectLightPoint*)pChild)->GetLightInfo() ); break; case LIGHTSPOT: VecSpot.push_back( ((CObjectLightSpot*)pChild)->GetLightInfo() ); break; } } if( szStr.IsEmpty() == true ) { CString szSubKey = REG_SUBKEY; szSubKey += "\\Light"; // ÀÏ´Ü ¸ðµç ¶óÀÌÆ® Á¤º¸¸¦ ÀüºÎ Áö¿öÁÖ±¸ RegDeleteKey( HKEY_CURRENT_USER, szSubKey ); // ÀúÀå ´Ù½Ã ÇÑ´Ù. EtColor Color = EternityEngine::GetGlobalAmbient(); SetRegistryBinary( HKEY_CURRENT_USER, szSubKey.GetBuffer(), "Ambient", &Color, sizeof(EtColor) ); SetRegistryNumber( HKEY_CURRENT_USER, szSubKey.GetBuffer(), "Directional", (DWORD)VecDir.size() ); SetRegistryNumber( HKEY_CURRENT_USER, szSubKey.GetBuffer(), "Point", (DWORD)VecPoint.size() ); SetRegistryNumber( HKEY_CURRENT_USER, szSubKey.GetBuffer(), "Spot", (DWORD)VecSpot.size() ); CString szStr; for( DWORD i=0; iGetTreeItemID() ); i--; } std::vector VecDir; std::vector VecPoint; std::vector VecSpot; if( szStr.IsEmpty() == true ) { CString szSubKey = REG_SUBKEY; szSubKey += "\\Light"; DWORD dwDir = 0, dwPoint = 0, dwSpot = 0; EtColor Ambient = 0xFFFFFFFF; int nSize = sizeof(EtColor); GetRegistryBinary( HKEY_CURRENT_USER, szSubKey.GetBuffer(), "Ambient", &Ambient, nSize ); EternityEngine::SetGlobalAmbient( &Ambient ); GetRegistryNumber( HKEY_CURRENT_USER, szSubKey.GetBuffer(), "Directional", dwDir ); GetRegistryNumber( HKEY_CURRENT_USER, szSubKey.GetBuffer(), "Point", dwPoint ); GetRegistryNumber( HKEY_CURRENT_USER, szSubKey.GetBuffer(), "Spot", dwSpot ); CString szStr; SLightInfo Info; nSize = sizeof(SLightInfo); for( DWORD i=0; iSetName( CGlobalValue::GetInstance().GetUniqueName( CActionBase::LIGHTDIR ) ); CGlobalValue::GetInstance().AddLight( pBase ); ((CObjectLightDir*)pBase)->SetLightInfo( VecDir[i] ); } for( DWORD i=0; iSetName( CGlobalValue::GetInstance().GetUniqueName( CActionBase::LIGHTPOINT ) ); CGlobalValue::GetInstance().AddLight( pBase ); ((CObjectLightPoint*)pBase)->SetLightInfo( VecPoint[i] ); } for( DWORD i=0; iSetName( CGlobalValue::GetInstance().GetUniqueName( CActionBase::LIGHTSPOT ) ); CGlobalValue::GetInstance().AddLight( pBase ); ((CObjectLightSpot*)pBase)->SetLightInfo( VecSpot[i] ); } }