HRESULT CEditorScene::CreateBox(LPCWSTR pFileName) { HANDLE hFile = CreateFile(pFileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if(INVALID_HANDLE_VALUE == hFile) return E_FAIL; int* pData = new int; DWORD dwBytes; ReadFile(hFile, pData, sizeof(int), &dwBytes, NULL); int iBoxCount = *pData; Safe_Delete(pData); string* pName = new string; for(int i = 0; i < iBoxCount; ++i) { D3DXVECTOR3* pPos = new D3DXVECTOR3; //*pName = string("PickingBox" + i); //*pPos = D3DXVECTOR3(10.f, 0.f, 10.f); //string strName = "PickBox"; //D3DXVECTOR3 vPos = D3DXVECTOR3(10.f, 0.f, 10.f); ReadFile(hFile, pName, sizeof(string), &dwBytes, NULL); ReadFile(hFile, pPos, sizeof(D3DXVECTOR3), &dwBytes, NULL); CEntity* pBox = _SINGLE(CObjectManager)->CreateEntity( MT_BOX, RTYPE_ENTITY, *pName, MN_BOX); pBox->SetPos(D3DXVECTOR3(pPos->x, 0.f, pPos->z)); //CEntity* pBox = _SINGLE(CObjectManager)->CreateEntity( // MT_BOX, RTYPE_ENTITY, strName, MN_BOX); //pBox->SetPos(D3DXVECTOR3(vPos.x, 0.f, vPos.z)); pBox->SetScale(1, 1, 1); pBox->SetShader(SHADER_DEFAULT); pBox->SetTechKey("DefaultTech"); pBox->SetPass(PASS_NOTEXTURE); Safe_Delete(pPos); m_listBox.push_back(pBox); } m_iBoxCnt = iBoxCount; CloseHandle(hFile); return S_OK; }
HRESULT CEditorScene::CreateEntity() { //_SINGLE(CResourceManager)->Load(MT_STATIC, "Tiger", _T("tiger.x")); CEntity* pSylva = _SINGLE(CObjectManager)->CreateEntity( MT_STATIC, RTYPE_ENTITY, "Tiger", MN_TIGER, _T("tiger.x")); pSylva->SetPos(D3DXVECTOR3(-5.f, 0.f, 0.f)); pSylva->SetShader(SHADER_DEFAULT); pSylva->SetTechKey("DefaultTech"); pSylva->SetPass(PASS_DEFAULT); pSylva->SetRotation(AT_Y, D3DX_PI); //CEntity* pSylvas[2]; //테스트용 NPC생성 for ( int i = 1; i <= 10; ++i) { string str = "Npc"; str += i; pSylva = _SINGLE(CObjectManager)->CreateEntity( MT_STATIC, RTYPE_ENTITY, str, MN_ZOMBIE, _T("tiger.x")); pSylva->SetPos(D3DXVECTOR3(-3.f + (i * 5.f), 0.0f, sin(i) * 5.f) ); pSylva->SetShader(SHADER_DEFAULT); pSylva->SetTechKey("DefaultTech"); pSylva->SetPass(PASS_DEFAULT); } //* CEntity* pTerrain = _SINGLE(CObjectManager)->CreateEntity( MT_TERRAIN, RTYPE_TERRAIN, "MainTerrain", MN_TERRAIN, _T("MainTerrain")); pTerrain->SetShader(SHADER_DEFAULT); pTerrain->SetTechKey("DefaultTech"); pTerrain->SetPass(PASS_DEFAULT); //*/ CEntity* pEnvi = _SINGLE(CObjectManager)->CreateEntity( MT_STATIC, RTYPE_ENVIRONMENT, "Envi", MN_ENVIRONMENT, _T("Environment.X")); pEnvi->SetPos(D3DXVECTOR3(0.f, 10.f, 0.f)); pEnvi->SetScale(5.f, 5.f, 5.f); pEnvi->SetShader(SHADER_DEFAULT); pEnvi->SetTechKey("DefaultTech"); pEnvi->SetPass(PASS_DEFAULT/*PASS_NOTEXTURE*/); #ifdef _DEBUG CEntity* pGrid = _SINGLE(CObjectManager)->CreateEntity( MT_GRID, RTYPE_GRID, "DebugGrid", MN_GRID, _T("Grid")); pGrid->SetShader(SHADER_DEFAULT); pGrid->SetTechKey("DefaultTech"); pGrid->SetPass(PASS_NOTEXTURE); #endif //박스로 빌딩 역할 (임시) CEntity* pBox; srand(0); for(int i = 0; i < 1; ++i) { int iScale = 1; int iPosX = -5; int iPosZ = -5; string strName = "Box"; strName += i; pBox = _SINGLE(CObjectManager)->CreateEntity( MT_BOX, RTYPE_ENTITY, strName, MN_BOX); pBox->SetPos(D3DXVECTOR3(iPosX, 0.f, iPosZ)); pBox->SetScale(iScale, iScale, iScale); pBox->SetShader(SHADER_DEFAULT); pBox->SetTechKey("DefaultTech"); pBox->SetPass(PASS_NOTEXTURE); } CEntity* pMainButton= _SINGLE(CObjectManager)->CreateEntity(MT_UI, RTYPE_UI, "ChangeMainSceneBtn", MN_SCENEBUTTON, L"ChangeMainButton"); pMainButton->SetPos(D3DXVECTOR3(820.f, 650.f, 0.f)); pMainButton->SetViewType(VIEW_ORTHOGONAL); pMainButton->SetShader(SHADER_DEFAULT); pMainButton->SetTechKey("DefaultTech"); pMainButton->SetPass(PASS_DEFAULT); pMainButton->SetScale(100.f, 100.f, 0.f); pMainButton->SetDrawSphere(false); RECT rc; rc.left = 820.f; rc.right = 920.f; rc.top = 650.f; rc.bottom = 750.f; ((CBaseButton*)pMainButton)->SetRectData(rc); ((CSceneButton*)pMainButton)->SetSceneType(STYPE_MAIN1); ((CSceneButton*)pMainButton)->SetScene(this); CEntity* pSaveButton = _SINGLE(CObjectManager)->CreateEntity(MT_UI, RTYPE_UI, "SaveDataButton", MN_SAVEBUTTON, L"SaveDataButton"); pSaveButton->SetPos(D3DXVECTOR3(820.f, 540.f, 0.f)); pSaveButton->SetViewType(VIEW_ORTHOGONAL); pSaveButton->SetShader(SHADER_DEFAULT); pSaveButton->SetTechKey("DefaultTech"); pSaveButton->SetPass(PASS_DEFAULT); pSaveButton->SetScale(100.f, 100.f, 0.f); pSaveButton->SetDrawSphere(false); rc.left = 820.f; rc.right = 920.f; rc.top = 540.f; rc.bottom = 640.f; ((CBaseButton*)pSaveButton)->SetRectData(rc); ((CSaveButton*)pSaveButton)->SetScene(this); if(FAILED(CreateBox(L"Data\\BoxPos.txt"))) { return E_FAIL; } return S_OK; }