Files
Client/GameTools/WORLDCREATOR/MainFrm.cpp
LGram16 dd97ddec92 Restructure repository to include all source folders
Move git root from Client/ to src/ to track all source code:
- Client: Game client source (moved to Client/Client/)
- Server: Game server source
- GameTools: Development tools
- CryptoSource: Encryption utilities
- database: Database scripts
- Script: Game scripts
- rylCoder_16.02.2008_src: Legacy coder tools
- GMFont, Game: Additional resources

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 20:17:20 +09:00

2121 lines
66 KiB
C++

// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "WorldCreator.h"
#include "MainFrm.h"
#include "MulFileDialog.h"
#include "SelectFolderDialog.h"
#include "WorldCreatorView.h"
#include <SceneManager.h>
#include <BaseDataDefine.h>
#include "ConvertTexture.h"
#include "DlgWeatherColor.h"
#include "DlgSectorMove.h"
#include "AmbienceList.h"
#include "Dds_container.h"
#include "DlgCamera.h"
#include "DlgBoid.h"
#include "DlgCharacterCreate.h"
#include "DlgEditName.h"
#include "DialogCharacterLodDist.h"
#include "RenderOption.h"
#include "CharEffect.h"
#include "SelectFolderDialog.h"
#include "FullSceneEffect.h"
#include "DlgCameraSet.h"
#include "DlgLightmapInfo.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CH3DTextureContainer g_ContTexture;
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
ON_COMMAND_EX(CG_ID_VIEW_SCENEEDITBAR, OnBarCheck)
ON_UPDATE_COMMAND_UI(CG_ID_VIEW_SCENEEDITBAR, OnUpdateControlBarMenu)
ON_WM_CREATE()
ON_COMMAND_EX(CG_ID_VIEW_MESHOBJECTCONTAINER, OnBarCheck)
ON_UPDATE_COMMAND_UI(CG_ID_VIEW_MESHOBJECTCONTAINER, OnUpdateControlBarMenu)
//{{AFX_MSG_MAP(CMainFrame)
ON_COMMAND(ID_FILE_NEW, OnFileNew)
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
ON_COMMAND(ID_APP_EXIT, OnAppExit)
ON_COMMAND(MENU_CONVERTTEXTURE, OnConverttexture)
ON_BN_CLICKED(IDC_CHECK_LIGHTMAP, OnCheckLightmap)
ON_BN_CLICKED(IDC_CHECK_OCTREE, OnCheckOctree)
ON_WM_DESTROY()
ON_BN_CLICKED(IDC_CHECK_EDITTERRAIN, OnCheckEditterrain)
ON_BN_CLICKED(IDC_CHECK_WEATHERTIME, OnCheckWeathertime)
ON_BN_CLICKED(IDC_BUTTON_FIXWEATHERCOLOR, OnButtonFixweathercolor)
ON_BN_CLICKED(IDC_BUTTON_MAKEWATER, OnButtonMakewater)
ON_BN_CLICKED(IDC_BUTTON_WATERFALL, OnButtonWaterfall)
ON_COMMAND(MENU_SCENESAVE, OnScenesave)
ON_BN_CLICKED(IDC_BUTTON_MAKETREE, OnButtonMaketree)
ON_BN_CLICKED(IDC_BUTTON_WALKMODE, OnButtonWalkmode)
ON_BN_CLICKED(IDC_CHECK_PICKHOUSE, OnCheckPickhouse)
ON_BN_CLICKED(IDC_CHECK_PICKOBJECT, OnCheckPickobect)
ON_BN_CLICKED(IDC_CHECK_PICKNONE, OnCheckPicknode)
ON_BN_CLICKED(IDC_CHECK_NOTMOVE, OnCheckNotmove)
ON_COMMAND(MENU_VERTEXOPTIMAZE, OnVertexoptimaze)
ON_COMMAND(MENU_SECTOR_SAVE, OnSectorSave)
ON_COMMAND(MENU_SECTOR_LOAD, OnSectorLoad)
ON_COMMAND(MEUN_SECTORMOVE, OnSectormove)
ON_BN_CLICKED(IDC_BUTTON_GENERATESECTORSHOAW, OnButtonGeneratesectorshoaw)
ON_COMMAND(MENU_OLDSCENELOAD, OnOldsceneload)
ON_BN_CLICKED(IDC_BUTTON_SECTORVIEW, OnButtonSectorview)
ON_COMMAND(MENU_INHOUSEMAPLOAD, OnInhousemapload)
ON_COMMAND(MENU_INHOUSEMAPSAVE, OnInhousemapsave)
ON_BN_CLICKED(IDC_BUTTON_INFO, OnButtonInfo)
ON_BN_CLICKED(IDC_BUTTON_CAMERA, OnButtonCamera)
ON_COMMAND(MENU_WEATHER, OnWeather)
ON_COMMAND(MENU_SHOWINFO, OnShowinfo)
ON_BN_CLICKED(IDC_BUTTON_GRASS, OnButtonGrass)
ON_COMMAND(MENU_SECTORLOADNOWPOS, OnSectorloadnowpos)
ON_COMMAND(MENE_GARBEGEDEL, OnGarbegedel)
ON_BN_CLICKED(IDC_BUTTON_EFFECT, OnButtonEffect)
ON_COMMAND(MENU_CAMERAVIEW, OnCameraview)
ON_COMMAND(MENU_SMOKEPARTICLE, OnSmokeparticle)
ON_COMMAND(MENU_WATERMAKE, OnWatermake)
ON_COMMAND(MENU_SOUNDMAPSAVE, OnSoundmapsave)
ON_COMMAND(MENU_SOUNDMAPLOAD, OnSoundmapload)
ON_BN_CLICKED(IDC_BUTTON_BOID, OnButtonBoid)
ON_COMMAND(MENU_WEATHERTIME, OnWeathertime)
ON_COMMAND(MENU_GF3SAVE, OnGf3save)
ON_COMMAND(MENU_GF3LOAD, OnGf3load)
ON_BN_CLICKED(IDC_CHECK_PICKFIX, OnCheckPickfix)
ON_BN_CLICKED(IDC_BUTTON_MESHOPTIMIZE, OnButtonMeshoptimize)
ON_COMMAND(MENU_RESAVE, OnResave)
ON_COMMAND(MENU_AMBIENCELIST, OnAmbiencelist)
ON_BN_CLICKED(IDC_BUTTON_BSPLIGHTMODE, OnButtonBsplightmode)
ON_BN_CLICKED(IDC_EFFECT, OnEffect)
ON_COMMAND(MENU_CLEARALL, OnClearall)
ON_BN_CLICKED(IDC_CHECK_TRIGGER, OnCheckTrigger)
ON_COMMAND(MENU_TERRAINTEXTUREAUTOINSERT, OnTerraintextureautoinsert)
ON_COMMAND(MENU_DDS, OnDds)
ON_BN_CLICKED(IDC_CHECK_TERRAINLIGHTMAP, OnCheckTerrainlightmap)
ON_BN_CLICKED(IDC_BUTTON_CHARACTERVIEWER, OnButtonCharacterviewer)
ON_BN_CLICKED(IDC_BUTTON_CHARACTERMOVE, OnButtonCharactermove)
ON_COMMAND(MENU_CHARACTERCONTROL, OnCharactercontrol)
ON_COMMAND(MENU_MAKECHARACTER, OnMakecharacter)
ON_BN_CLICKED(IDC_BUTTON_CHAREFFECT, OnButtonChareffect)
ON_BN_CLICKED(IDC_BUTTON_CAMERAMODECHANGE, OnButtonCameramodechange)
ON_COMMAND(MENU_ESF, OnEsf)
ON_COMMAND(ID_EFF_INTER, OnInterfaceEsf)
ON_COMMAND(IDD_TEXTESF, OnTextesf)
ON_COMMAND(IDD_TEXTINTERESF, OnTextinteresf)
ON_COMMAND(MENU_CHARACTERCAMERA, OnCharactercamera)
ON_COMMAND(MENU_MOUSESHOW, OnMouseshow)
ON_COMMAND(ID_CHARMOTION, OnCharmotion)
ON_COMMAND(ID_CHAREFF, OnChareff)
ON_BN_CLICKED(IDC_BSP, OnBsp)
ON_COMMAND(ID_SECTORLIGHTGEN, OnSectorlightgen)
ON_COMMAND(MENU_CHARACTERLOD, OnCharacterlod)
ON_COMMAND(MENU_CHRDIR, OnChrdir)
ON_COMMAND(MENU_CHRBUMDIR, OnChrbumdir)
ON_COMMAND(MENU_CHRENVDIR, OnChrenvdir)
ON_BN_CLICKED(IDC_TERRAINFIX, OnTerrainfix)
ON_BN_CLICKED(IDC_BUTTON_RELOAD, OnButtonReload)
ON_BN_CLICKED(IDC_BUTTON_MINIMAP, OnButtonMinimap)
ON_COMMAND(ID_MENU_Z3CLOAD, OnMenuZ3cload)
ON_COMMAND(ID_CAMERASET, OnCameraset)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
// TODO: add member initialization code here
m_dlgConvertTexture=new CDlgConvertTexture();
m_dlgConvertTexture->Create(IDD_DIALOG_TEXTURECONVERT);
m_dlgLightmap=new CDlgLightmap();
m_dlgLightmap->Create(IDD_DIALOG_MAKELIGHTMAP);
m_dlgMakeWater=new CDlgMakeWater();
m_dlgMakeWater->Create(IDD_DIALOG_WATER);
m_dlgMakeFall=new CDlgMakeFall();
m_dlgMakeFall->Create(IDD_DIALOG_WATERFALL);
m_dlgMakePlant=new CDlgMakePlant();
m_dlgMakePlant->Create(IDD_DIALOG_EDITPLANT);
m_dlgCamera=new CDlgCamera();
m_dlgCamera->Create(IDD_DIALOG_CAMERA);
m_dlgMakeGrass=new CDlgGrass();
m_dlgMakeGrass->Create(IDD_DIALOG_GRASS);
m_dlgEffect=new CDlgEffect();
m_dlgEffect->Create(IDD_DIALOG_EFFECTMAP);
m_dlgWeatherColor=new CDlgWeatherColor();
m_dlgWeatherColor->Create(IDD_DIALOG_WEATHER);
m_dlgBoid=new CDlgBoid();
m_dlgBoid->Create(IDD_DIALOG_BOID);
m_bShowDlgLightmap=FALSE;
m_PickMode=0;
m_NotMove=0;
}
CMainFrame::~CMainFrame()
{
delete m_dlgEffect;
delete m_dlgBoid;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
cs.style = WS_OVERLAPPED | WS_CAPTION | FWS_ADDTOTITLE
| WS_THICKFRAME | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_MAXIMIZE;
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
BOOL CMainFrame::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
}
void CMainFrame::OnFileNew()
{
// TODO: Add your command handler code here
}
void CMainFrame::OnFileOpen()
{
// TODO: Add your command handler code here
UpdateData();
CString strFilter = Z3SFILE;
CFileDialog filedia(TRUE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,strFilter,this);
filedia.DoModal();
CString filename=filedia.GetFileName();
if(filename=="")
return;
CWorldCreatorView *av=(CWorldCreatorView *)GetActiveView();
av->m_SceneManager->LoadMap(filename.LockBuffer());
//CMapStorage::Load(filename.LockBuffer());
//for(int cSector=0;cSector<LSIZEX*LSIZEY;cSector++)
for(int cSector=0;cSector<av->m_SceneManager->m_HeightField.GetLSizeX() * av->m_SceneManager->m_HeightField.GetLSizeY();cSector++)
{
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].m_MapDungeon=NULL;
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].m_MapEffect=NULL;
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].m_MapFall=NULL;
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].m_MapHeight=NULL;
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].m_MapHouse=NULL;
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].m_MapMash=NULL;
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].m_MapMesh=NULL;
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].m_MapPlant=NULL;
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateHeight();
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateWater();
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateWideMap();
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateFall();
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateHouseObject();
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GeneratePlant();
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateObject();
//CSceneManager::m_HeightField.m_SectorScene[cSector].GenerateWideMap();
}
ContainerLoad();
}
void CMainFrame::OnAppExit()
{
// TODO: Add your command handler code here
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
m_nMode=0;
if(m_nMode==0)
{
if(!m_MeshContainerBar.Create(this,IDD_DIALOGBAR_MESHCONTAINERBAR,CBRS_LEFT,IDD_DIALOGBAR_MESHCONTAINERBAR))
{
return -1;
}
m_MeshContainerBar.SetWindowText("Power by Rainbow's Creator");
m_MeshContainerBar.EnableDocking(CBRS_ALIGN_LEFT);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_MeshContainerBar);
if(!m_SectorViewerBar.Create(this,IDD_DIALOGBAR_SECTORVIEWER,CBRS_BOTTOM,IDD_DIALOGBAR_SECTORVIEWER))
{
return -1;
}
m_SectorViewerBar.SetWindowText("Sector Viewer Bar");
CRect rc;
//m_SectorViewerBar.GetWindowRect(rc);
//GetWindowRect( LPRECT lpRect )
//SetWindowPos( const CWnd* pWndInsertAfter, int x, int y, int cx, int cy, UINT nFlags );
//m_SectorViewerBar.
m_SectorViewerBar.EnableDocking(CBRS_ALIGN_BOTTOM);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_SectorViewerBar);
{
if (!m_wndSceneEditBar.Create(this, CG_IDD_SCENEEDITBAR,
CBRS_RIGHT | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_HIDE_INPLACE,
CG_ID_VIEW_SCENEEDITBAR))
{
TRACE0("Failed to create dialog bar m_wndSceneEditBar\n");
return -1; // fail to create
}
m_wndSceneEditBar.EnableDocking(CBRS_ALIGN_LEFT | CBRS_ALIGN_RIGHT);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndSceneEditBar);
}
}
return 0;
}
void CMainFrame::OnConverttexture()
{
/*
CSelectFolderDialog SelectFolderDlg(TRUE, "C:\\", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, NULL, this);
if(SelectFolderDlg.DoModal()!=IDOK)
return;
CString strFolderPath=SelectFolderDlg.GetSelectedPath();
CFileFind ff;
CString strFileName;
CString strPathFileName;
CString strPath=SelectFolderDlg.GetSelectedPath();
m_dlgConvertTexture->m_strPath=strFolderPath;
strFolderPath+="\\*.bmp";
int cListItem=m_dlgConvertTexture->m_filelist.GetCount();
for(int i=0;i<cListItem;i++)
{
m_dlgConvertTexture->m_filelist.DeleteString(0);
}
CConvertTexture ConvertTexture;
int curdot;
if(ff.FindFile(strFolderPath)==TRUE)
{
BOOL bFlag=TRUE;
while(bFlag)
{
bFlag=ff.FindNextFile();
strFileName=ff.GetFileName();
if(strFileName.Find("_mask",0)>=0)
continue;
strPathFileName=strPath;
strPathFileName+=strFileName;
ConvertTexture.LoadBMP(strPathFileName.LockBuffer());
CString alphafilename=strPathFileName;
curdot=alphafilename.ReverseFind('.');
alphafilename=alphafilename.Left(curdot)+"_mask.bmp";
CFileStatus status;
if (CFile::GetStatus(alphafilename, status))
{
/*
if(ConvertTexture.LoadAlphaIntoSurface(alphafilename,ConvertTexture.m_pddsOrig)!=S_OK)
{
AfxMessageBox("알파를 로딩하는데 실패했습니다.");
continue;
}
}
ConvertTexture.Compress(D3DFMT_DXT3);
ConvertTexture.GenerateMipMaps();
strPathFileName.SetAt(strPathFileName.GetLength()-1,'s');
strPathFileName.SetAt(strPathFileName.GetLength()-2,'d');
strPathFileName.SetAt(strPathFileName.GetLength()-3,'d');
ConvertTexture.SaveDDS(ConvertTexture.m_ptexNew,strPathFileName.LockBuffer());
m_dlgConvertTexture->m_filelist.AddString(strFileName);
}
}
ff.Close();
m_dlgConvertTexture->ShowWindow(SW_SHOW);
*/
}
void CMainFrame::OnCheckLightmap()
{
CDlgLightmapInfo Dlg;
Dlg.DoModal();
if(Dlg.m_bStart)
{
D3DXVECTOR3 vecSkyLightColor;
D3DXVECTOR3 vecDirectionColor;
D3DXVECTOR3 vecAmbientColor;
vecSkyLightColor.x = (float)GetRValue(Dlg.m_cSkyLightColor) / 255.0f;
vecSkyLightColor.y = (float)GetGValue(Dlg.m_cSkyLightColor) / 255.0f;
vecSkyLightColor.z = (float)GetBValue(Dlg.m_cSkyLightColor) / 255.0f;
vecDirectionColor.x = (float)GetRValue(Dlg.m_cDirectionColor) / 255.0f;
vecDirectionColor.y = (float)GetGValue(Dlg.m_cDirectionColor) / 255.0f;
vecDirectionColor.z = (float)GetBValue(Dlg.m_cDirectionColor) / 255.0f;
vecAmbientColor.x = (float)GetRValue(Dlg.m_cAmbientColor) / 255.0f;
vecAmbientColor.y = (float)GetGValue(Dlg.m_cAmbientColor) / 255.0f;
vecAmbientColor.z = (float)GetBValue(Dlg.m_cAmbientColor) / 255.0f;
bool bFlag[4];
bFlag[0] = Dlg.m_bDirectionLight;
bFlag[1] = Dlg.m_bGlobalShadow;
bFlag[2] = Dlg.m_bPointLight;
bFlag[3] = Dlg.m_bSkyLight;
char path[256];
GetCurrentDirectory(256,path);
sprintf(path,"%s\\CaldronLightmapInfo.dat",path);
FILE *fp = fopen(path,"wb");
fwrite(bFlag,sizeof(bool) * 4, 1,fp);
fwrite(&vecSkyLightColor,sizeof(D3DXVECTOR3),1,fp);
fwrite(&vecDirectionColor,sizeof(D3DXVECTOR3),1,fp);
fwrite(&vecAmbientColor,sizeof(D3DXVECTOR3),1,fp);
fwrite(&Dlg.m_fDirectionLightRandValue,sizeof(float),1,fp);
fwrite(&Dlg.m_iDirectionSampleCount,sizeof(int),1,fp);
fwrite(&Dlg.m_fExposeValue,sizeof(float),1,fp);
fwrite(&Dlg.m_iSkySampleCount,sizeof(int),1,fp);
fwrite(&Dlg.m_fGlobalRandValue,sizeof(float),1,fp);
fwrite(&Dlg.m_iGlobalSampleCount,sizeof(int),1,fp);
fwrite(&Dlg.m_fPointRandValue,sizeof(float),1,fp);
fwrite(&Dlg.m_iPointSampleCount,sizeof(int),1,fp);
fclose(fp);
m_bShowDlgLightmap=!m_bShowDlgLightmap;
switch(AfxMessageBox("내부 ?",MB_YESNO))
{
case IDNO:
CSceneManager::CalculateLightmap(0);
break;
case IDYES:
CSceneManager::CalculateLightmap(2);
break;
}
}
/* switch(AfxMessageBox("새로운 라이트 계산으로 하시겠습니까?",MB_YESNOCANCEL))
{
case 6:
CSceneManager::CalculateLightmap(1);
break;
case IDNO:
break;
case IDCANCEL:
break;
}*/
//CSceneManager::CalculateLightmap();
}
void CMainFrame::OnCheckOctree()
{
// TODO: Add your control notification handler code here
CSceneManager::CalculateOctree();
}
void CMainFrame::OnDestroy()
{
CFrameWnd::OnDestroy();
m_dlgConvertTexture->DestroyWindow();
m_dlgLightmap->DestroyWindow();
m_dlgMakeWater->DestroyWindow();
m_dlgMakeFall->DestroyWindow();
m_dlgMakePlant->DestroyWindow();
m_dlgCamera->DestroyWindow();
delete m_dlgMakeWater;
delete m_dlgConvertTexture;
delete m_dlgLightmap;
delete m_dlgMakeFall;
delete m_dlgMakePlant;
delete m_dlgCamera;
// TODO: Add your message handler code here
}
void CMainFrame::OnCheckEditterrain()
{
CButton *forIsShow=(CButton*)m_wndSceneEditBar.GetDlgItem(IDC_CHECK_EDITTERRAIN);
BOOL isShow=forIsShow->GetCheck();
CWorldCreatorView* av=(CWorldCreatorView*)GetActiveView();
av->m_MouseInterface=-2;
if(isShow==FALSE)
{
av->m_dlgEditTerrain->EndAndSave();
av->m_MouseInterface=-1;
}
av->m_SceneManager->m_PickHouseScene=NULL;
av->m_SceneManager->m_PickLightScene=NULL;
av->m_SceneManager->m_PickObjectScene=NULL;
av->ReArrangeDlg(0,isShow);
// TODO: Add your control notification handler code here
}
void CMainFrame::OnCheckWeathertime()
{
// TODO: Add your control notification handler code here
CWorldCreatorView* av=(CWorldCreatorView*)GetActiveView();
if(av->m_fWeatherTimeAdder==0.007f)
av->m_fWeatherTimeAdder=0.0f;
else
av->m_fWeatherTimeAdder=0.007f;
}
void CMainFrame::OnButtonFixweathercolor()
{
// TODO: Add your control notification handler code here
/*
CDlgWeatherColor dlgWeatherColor;
dlgWeatherColor.DoModal();
*/
m_dlgWeatherColor->SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOREPOSITION|SWP_NOSIZE);
m_dlgWeatherColor->ShowWindow(SW_SHOW);
}
void CMainFrame::OnButtonMakewater()
{
m_dlgMakeWater->SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOREPOSITION|SWP_NOSIZE);
m_dlgMakeWater->ShowWindow(SW_SHOW);
CWorldCreatorView *av=(CWorldCreatorView *)GetActiveView();
av->m_MouseInterface=30;
// TODO: Add your control notification handler code here
}
void CMainFrame::OnButtonWaterfall()
{
// TODO: Add your control notification handler code here
m_dlgMakeFall->SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOREPOSITION|SWP_NOSIZE);
m_dlgMakeFall->ShowWindow(SW_SHOW);
CWorldCreatorView *av=(CWorldCreatorView *)GetActiveView();
av->m_MouseInterface=40;
}
void CMainFrame::OnScenesave()
{
// TODO: Add your command handler code here
UpdateData();
CString filename;
if(m_strSaveFilename=="")
{
CString strFilter = Z3SFILE;
CFileDialog filedia(FALSE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,strFilter,this);
filedia.DoModal();
filename=filedia.GetFileName();
}
else
{
filename=m_strSaveFilename;
}
if(filename=="")
return;
//CMainFrame *mf=(CMainFrame*)AfxGetApp()->m_pMainWnd;
CWorldCreatorView *av=(CWorldCreatorView *)GetActiveView();
av->m_SceneManager->m_MapStorage.Save(filename.LockBuffer());
m_strSaveFilename=filename;
//CMapStorage::Save(filename.LockBuffer());
ContainerSave();
}
void CMainFrame::ContainerSave()
{
char strContainer[256] = {0};
if(!strcmp(CRenderOption::m_strBaseGraphicsDataPath,"Default"))
strcpy(strContainer,Z3DCONTAINERFILE);
else {
strncpy(strContainer,Z3DCONTAINERFILE,sizeof(char) * 26);
strcat(strContainer,"_");
strcat(strContainer,CRenderOption::m_strBaseGraphicsDataPath);
strcat(strContainer,".Z3C");
}
FILE *fp=fopen(strContainer,"wb");
m_MeshContainerBar.m_MeshContainerSheet->m_PageHouseContainer.Save(fp);
m_MeshContainerBar.m_MeshContainerSheet->m_PageObjectContainer.Save(fp);
m_MeshContainerBar.m_MeshContainerSheet->m_PageLightContainer.Save(fp);
m_MeshContainerBar.m_MeshContainerSheet->m_PageWideContainer.Save(fp);
// m_MeshContainerBar.m_MeshContainerSheet->m_PageSoundContainer.Save(fp);
fclose(fp);
}
void CMainFrame::ContainerLoad()
{
if(m_nMode==0)
{
char strContainer[256] = {0};
if(!strcmp(CRenderOption::m_strBaseGraphicsDataPath,"Default"))
strcpy(strContainer,Z3DCONTAINERFILE);
else {
strncpy(strContainer,Z3DCONTAINERFILE,sizeof(char) * 26);
strcat(strContainer,"_");
strcat(strContainer,CRenderOption::m_strBaseGraphicsDataPath);
strcat(strContainer,".Z3C");
}
FILE *fp=fopen(strContainer,"rb");
if(fp==NULL)
{
return;
}
m_MeshContainerBar.m_MeshContainerSheet->m_PageHouseContainer.Load(fp);
m_MeshContainerBar.m_MeshContainerSheet->SetActivePage(0);
m_MeshContainerBar.m_MeshContainerSheet->m_PageHouseContainer.UpdateHouseTree();
m_MeshContainerBar.m_MeshContainerSheet->SetActivePage(1);
m_MeshContainerBar.m_MeshContainerSheet->m_PageObjectContainer.Load(fp);
m_MeshContainerBar.m_MeshContainerSheet->m_PageObjectContainer.UpdateList();
m_MeshContainerBar.m_MeshContainerSheet->SetActivePage(2);
m_MeshContainerBar.m_MeshContainerSheet->m_PageLightContainer.Load(fp);
m_MeshContainerBar.m_MeshContainerSheet->m_PageLightContainer.UpdateList();
m_MeshContainerBar.m_MeshContainerSheet->SetActivePage(3);
m_MeshContainerBar.m_MeshContainerSheet->m_PageWideContainer.Load(fp);
m_MeshContainerBar.m_MeshContainerSheet->m_PageWideContainer.UpdateList();
m_MeshContainerBar.m_MeshContainerSheet->SetActivePage(4);
// m_MeshContainerBar.m_MeshContainerSheet->m_PageSoundContainer.Load(fp);
// m_MeshContainerBar.m_MeshContainerSheet->m_PageSoundContainer.UpdateList();
m_MeshContainerBar.m_MeshContainerSheet->SetActivePage(0);
fclose(fp);
}
}
void CMainFrame::OnButtonMaketree()
{
// TODO: Add your control notification handler code here
m_dlgMakePlant->SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOREPOSITION|SWP_NOSIZE);
m_dlgMakePlant->ShowWindow(SW_SHOW);
}
void CMainFrame::OnButtonWalkmode()
{
// TODO: Add your control notification handler code here
if(CSceneManager::m_isCollisionDetection)
{
CSceneManager::m_isCollisionDetection=false;
}
else
{
CSceneManager::m_isCollisionDetection=true;
}
if(CSceneManager::m_ViewerMode==0)
{
/*
CSceneManager::m_ViewerMode=1;
CSceneManager::m_ViewCamera->m_matExtraPosition=CSceneManager::m_ViewCamera->m_matPosition;
CSceneManager::m_ViewCamera->m_matExtraView=CSceneManager::m_ViewCamera->m_matView;
CSceneManager::m_pCharacter->SetPosition(CSceneManager::m_ViewCamera->m_matPosition._41,CSceneManager::m_ViewCamera->m_matPosition._42,CSceneManager::m_ViewCamera->m_matPosition._42);
CSceneManager::m_pCharacter->SetDirection(CSceneManager::m_ViewCamera->m_fRoty+3.14159f);
*/
//CSceneManager::m_pCharacter->Turn(CSceneManager::m_ViewCamera->m_fRoty);
}
else
CSceneManager::m_ViewerMode=0;
}
void CMainFrame::OnCheckPickhouse()
{
// TODO: Add your control notification handler code here
CButton *btHouse=(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_PICKHOUSE);
CButton *btObject=(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_PICKOBJECT);
CButton *btNone=(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_PICKNONE);
CButton *btEffect =(CButton*)m_MeshContainerBar.GetDlgItem(IDC_EFFECT);
CButton *btTrigger =(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_TRIGGER);
CButton *btBsp =(CButton*)m_MeshContainerBar.GetDlgItem(IDC_BSP);
btEffect->SetCheck(0);
btHouse->SetCheck(1);
btObject->SetCheck(0);
btNone->SetCheck(0);
btTrigger->SetCheck(0);
btBsp->SetCheck(0);
m_PickMode=1;
}
void CMainFrame::UnPickButton()
{
CButton *btHouse=(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_PICKHOUSE);
CButton *btObject=(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_PICKOBJECT);
CButton *btNone=(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_PICKNONE);
CButton *btEffect =(CButton*)m_MeshContainerBar.GetDlgItem(IDC_EFFECT);
CButton *btTrigger =(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_TRIGGER);
CButton *btBsp =(CButton*)m_MeshContainerBar.GetDlgItem(IDC_BSP);
CButton *btPickFix =(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_PICKFIX);
btHouse->SetCheck(0);
btObject->SetCheck(0);
btNone->SetCheck(0);
btEffect->SetCheck(0);
btTrigger->SetCheck(0);
btBsp->SetCheck(0);
////
btPickFix->SetCheck(0);
CSceneManager::m_bPickFix=false;
if(CSceneManager::m_bPickFix==false)
{
CSceneManager::m_PickHouseScene=NULL;
CSceneManager::m_PickLightScene=NULL;
CSceneManager::m_PickObjectScene=NULL;
}
////
m_PickMode= -1;
UpdateData(FALSE);
}
void CMainFrame::OnCheckPickobect()
{
CButton *btHouse=(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_PICKHOUSE);
CButton *btObject=(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_PICKOBJECT);
CButton *btNone=(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_PICKNONE);
CButton *btEffect =(CButton*)m_MeshContainerBar.GetDlgItem(IDC_EFFECT);
CButton *btTrigger =(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_TRIGGER);
CButton *btBsp =(CButton*)m_MeshContainerBar.GetDlgItem(IDC_BSP);
btHouse->SetCheck(0);
btObject->SetCheck(1);
btNone->SetCheck(0);
btEffect->SetCheck(0);
btTrigger->SetCheck(0);
btBsp->SetCheck(0);
m_PickMode=2;
// TODO: Add your control notification handler code here
}
void CMainFrame::OnCheckPicknode()
{
// TODO: Add your control notification handler code here
CButton *btHouse=(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_PICKHOUSE);
CButton *btObject=(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_PICKOBJECT);
CButton *btNone=(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_PICKNONE);
CButton *btTrigger =(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_TRIGGER);
CButton *btBsp =(CButton*)m_MeshContainerBar.GetDlgItem(IDC_BSP);
btHouse->SetCheck(0);
btObject->SetCheck(0);
btNone->SetCheck(1);
CButton *btEffect =(CButton*)m_MeshContainerBar.GetDlgItem(IDC_EFFECT);
btEffect->SetCheck(0);
btTrigger->SetCheck(0);
btBsp->SetCheck(0);
m_PickMode=-1;
}
void CMainFrame::OnEffect()
{
// TODO: Add your control notification handler code here
//MessageBox("준비중..^^;;");
m_PickMode = 7;
CButton *btHouse=(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_PICKHOUSE);
CButton *btObject=(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_PICKOBJECT);
CButton *btNone=(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_PICKNONE);
CButton *btEffect =(CButton*)m_MeshContainerBar.GetDlgItem(IDC_EFFECT);
CButton *btTrigger =(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_TRIGGER);
CButton *btBsp =(CButton*)m_MeshContainerBar.GetDlgItem(IDC_BSP);
btHouse->SetCheck(0);
btObject->SetCheck(0);
btNone->SetCheck(0);
btEffect->SetCheck(1);
btTrigger->SetCheck(0);
btBsp->SetCheck(0);
}
void CMainFrame::OnCheckTrigger()
{
m_PickMode = 8;
CButton *btHouse=(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_PICKHOUSE);
CButton *btObject=(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_PICKOBJECT);
CButton *btNone=(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_PICKNONE);
CButton *btEffect =(CButton*)m_MeshContainerBar.GetDlgItem(IDC_EFFECT);
CButton *btTrigger =(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_TRIGGER);
CButton *btBsp =(CButton*)m_MeshContainerBar.GetDlgItem(IDC_BSP);
btHouse->SetCheck(0);
btObject->SetCheck(0);
btNone->SetCheck(0);
btEffect->SetCheck(0);
btTrigger->SetCheck(1);
btBsp->SetCheck(0);
}
void CMainFrame::OnCheckNotmove()
{
// TODO: Add your control notification handler code here
m_NotMove=!m_NotMove;
}
void CMainFrame::OnVertexoptimaze()
{
// TODO: Add your command handler code here
CSelectFolderDialog SelectFolderDlg(TRUE, "C:\\", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, NULL, this);
if(SelectFolderDlg.DoModal()!=IDOK)
return;
CString strFolderPath=SelectFolderDlg.GetSelectedPath();
CFileFind ff;
CString strFileName;
CString strPathFileName;
CString strPath=SelectFolderDlg.GetSelectedPath();
m_dlgConvertTexture->m_strPath=strFolderPath;
strFolderPath+="\\*.r3s";
if(ff.FindFile(strFolderPath)==TRUE)
{
BOOL bFlag=TRUE;
{
while(bFlag)
{
COptimizeMesh Mesh;
bFlag=ff.FindNextFile();
strFileName=ff.GetFileName();
strPathFileName=strPath;
strPathFileName+=strFileName;
Mesh.Load(strPathFileName.LockBuffer(),1);
/*
CMeshObject OptimizeMesh;
bFlag=ff.FindNextFile();
strFileName=ff.GetFileName();
strPathFileName=strPath;
strPathFileName+=strFileName;
OptimizeMesh.Load(strPathFileName.LockBuffer());
OptimizeMesh.Optimize();
OptimizeMesh.Save(strPathFileName.LockBuffer());
*/
}
}
}
ff.Close();
}
void CMainFrame::OnSectorSave()
{
// TODO: Add your command handler code here
CWorldCreatorView* av=(CWorldCreatorView*)GetActiveView();
matrix *matPos=av->m_BaseGraphicLayer.m_ViewCamera.GetMatPosition();
CString strSectorPos;
strSectorPos.Format("%s\\Sector %d %d.z3m",SECTORMAPPATH,(int)(matPos->_41/(63.0f*500.0f)),(int)(matPos->_43/(63.0f*500.0f)));
//CWorldCreatorView *av=(CWorldCreatorView *)GetActiveView();
av->m_SceneManager->m_MapStorage.SaveSector(strSectorPos.LockBuffer(),(int)(matPos->_41/(63.0f*500.0f)),(int)(matPos->_43/(63.0f*500.0f)));
//CMapStorage::SaveSector(strSectorPos.LockBuffer(),(int)(matPos->_41/(63.0f*500.0f)),(int)(matPos->_43/(63.0f*500.0f)));
}
void CMainFrame::OnSectorLoad()
{
CString strFilter = Z3MFILE;
CFileDialog filedia(TRUE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,strFilter,this);
filedia.DoModal();
CString filename=filedia.GetFileName();
if(filename=="")
return;
long ReadSectorX,ReadSectorY;
sscanf(filename.LockBuffer(),"Sector %d %d.z3m",&ReadSectorX,&ReadSectorY);
//CMapStorage::LoadSector(filename.LockBuffer(),ReadSectorX,ReadSectorY);
//CWorldCreatorView *av=(CWorldCreatorView *)GetActiveView();
CWorldCreatorView *av=(CWorldCreatorView *)GetActiveView();
av->m_SceneManager->m_MapStorage.LoadSector(filename.LockBuffer(),ReadSectorX,ReadSectorY);
for(int cSector=0;cSector<LSIZEX*LSIZEY;cSector++)
{
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateHeight();
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateWater();
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateWideMap();
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateFall();
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateHouseObject();
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GeneratePlant();
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateObject();
//CSceneManager::m_HeightField.m_SectorScene[cSector].GenerateWideMap();
}
/*
CMapStorage::Load(filename.LockBuffer());
*/
// TODO: Add your command handler code here
}
//DEL void CMainFrame::OnButtonSectormove()
//DEL {
//DEL // TODO: Add your control notification handler code here
//DEL CDlgSectorMove dlgSectorMove;
//DEL dlgSectorMove.DoModal();
//DEL
//DEL matrix *ViewPos=CSceneManager::GetCamera()->GetMatPosition();
//DEL ViewPos->_41=SECTORSIZE*dlgSectorMove.m_ToMoveX;
//DEL ViewPos->_42=SECTORSIZE*dlgSectorMove.m_ToMoveY;
//DEL CWorldCreatorView *av=(CWorldCreatorView *)GetActiveView();
//DEL av->m_SceneManager->UpdateScene();
//DEL }
void CMainFrame::OnButtonSectormove()
{
// TODO: Add your control notification handler code here
CDlgSectorMove dlgSectorMove;
dlgSectorMove.DoModal();
}
void CMainFrame::OnSectormove()
{
// TODO: Add your command handler code here
CDlgSectorMove dlgSectorMove;
dlgSectorMove.DoModal();
matrix *ViewPos=CSceneManager::GetCamera()->GetMatPosition();
ViewPos->_41=SECTORSIZE*dlgSectorMove.m_ToMoveX;
ViewPos->_43=SECTORSIZE*dlgSectorMove.m_ToMoveY;
CWorldCreatorView *av=(CWorldCreatorView *)GetActiveView();
av->m_SceneManager->UpdateScene(0.0f);
}
void CMainFrame::OnButtonGeneratesectorshoaw()
{
// TODO: Add your control notification handler code here
CWorldCreatorView *av=(CWorldCreatorView *)GetActiveView();
for(int cSector=0;cSector<LSIZEX*LSIZEY;cSector++)
{
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].m_ShadowUsed=-1;
}
for(int cShadow=0;cShadow<9;cShadow++)
{
av->m_SceneManager->m_HeightField.m_SectorScene->m_UsedShadowTerrain[cShadow]=-1;
}
for(cSector=0;cSector<LSIZEX*LSIZEY;cSector++)
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateWideMap();
vector3 *ViewPos=CSceneManager::GetCamera()->GetPosition();
int UpdatePositionX=(int)(ViewPos->x/SECTORSIZE);
int UpdatePositionY=(int)(ViewPos->z/SECTORSIZE);
int sectorx,sectory;
for(cSector=0;cSector<LSIZEX*LSIZEY;cSector++)
{
sectorx=(int)(av->m_SceneManager->m_HeightField.m_SectorScene[cSector].m_TM._41/SECTORSIZE);
sectory=(int)(av->m_SceneManager->m_HeightField.m_SectorScene[cSector].m_TM._43/SECTORSIZE);
if( UpdatePositionX <= sectorx+1 &&
UpdatePositionX >= sectorx-1 &&
UpdatePositionY <= sectory+1 &&
UpdatePositionY >= sectory-1)
{
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateShadow(BaseGraphicsLayer::GetDevice());
}
else
{
if(av->m_SceneManager->m_HeightField.m_SectorScene[cSector].m_ShadowUsed!=-1)
{
/*av->m_SceneManager->m_HeightField.m_SectorScene[cSector].m_UsedShadowTerrain[av->m_SceneManager->m_HeightField.m_SectorScene[cSector].m_ShadowUsed]=-1;
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].m_ShadowUsed=-1;*/
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateWideMap();
}
}
}
}
void CMainFrame::OnOldsceneload()
{
// TODO: Add your command handler code here
CString strFilter = Z3SFILE;
CFileDialog filedia(TRUE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,strFilter,this);
filedia.DoModal();
CString filename=filedia.GetFileName();
if(filename=="")
return;
//CMapStorage::OldLoad(filename.LockBuffer());
//CWorldCreatorView *av=(CWorldCreatorView *)GetActiveView();
CWorldCreatorView *av=(CWorldCreatorView *)GetActiveView();
av->m_SceneManager->m_MapStorage.OldLoad(filename.LockBuffer());
for(int cSector=0;cSector<LSIZEX*LSIZEY;cSector++)
{
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateHeight();
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateWater();
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateWideMap();
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateFall();
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateHouseObject();
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GeneratePlant();
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateObject();
//CSceneManager::m_HeightField.m_SectorScene[cSector].GenerateWideMap();
}
ContainerLoad();
}
void CMainFrame::OnButtonSectorview()
{
// TODO: Add your control notification handler code here
CWorldCreatorView* av=(CWorldCreatorView*)GetActiveView();
matrix *matPos=av->m_BaseGraphicLayer.m_ViewCamera.GetMatPosition();
CString strSectorPos;
int sx,sy;
sx=(int)(matPos->_41/(63.0f*500.0f));
sy=(int)(matPos->_43/(63.0f*500.0f));
//=CMapStorage::FindHouseMap(matPos->_41,matPos->_43);
}
void CMainFrame::OnInhousemapload()
{
// TODO: Add your command handler code here
CString strFilter = Z3HFILE;
CFileDialog filedia(TRUE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,strFilter,this);
filedia.DoModal();
CString filename=filedia.GetPathName();
if(filename=="")
return;
//CMapStorage::LoadInHouseMap(filename.LockBuffer());
CWorldCreatorView *av=(CWorldCreatorView *)GetActiveView();
av->m_SceneManager->m_MapStorage.LoadInHouseMap(filename.LockBuffer());
}
void CMainFrame::OnInhousemapsave()
{
// TODO: Add your command handler code here
CString strFilter = Z3HFILE;
CFileDialog filedia(FALSE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,strFilter,this);
filedia.DoModal();
CString filename=filedia.GetPathName();
//tring filename=filedia.GetFileName();
if(filename=="")
return;
//CMapStorage::SaveInHouseMap(filename.LockBuffer());
CWorldCreatorView *av=(CWorldCreatorView *)GetActiveView();
av->m_SceneManager->m_MapStorage.SaveInHouseMap(filename.LockBuffer());
}
void CMainFrame::OnButtonInfo()
{
// TODO: Add your control notification handler code here
CWorldCreatorView *av=(CWorldCreatorView *)GetActiveView();
if(av->m_bInfoShow)
av->m_bInfoShow=false;
else
av->m_bInfoShow=true;
}
void CMainFrame::OnButtonCamera()
{
// TODO: Add your control notification handler code here
CSceneManager::GetCamera()->SaveViewMatrix();
CSceneManager::m_ViewerMode=2;
m_dlgCamera->SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOREPOSITION|SWP_NOSIZE);
m_dlgCamera->ShowWindow(SW_SHOW);
}
void CMainFrame::OnWeather()
{
// TODO: Add your command handler code here
CWorldCreatorView* av=(CWorldCreatorView*)GetActiveView();
if(av->m_SceneManager->GetWeatherTimeAdder()==0.001f)
av->m_SceneManager->SetWeatherTimeAdder(0.0f);
else
av->m_SceneManager->SetWeatherTimeAdder(0.001f);
/*
if(av->m_SceneManager->m_fWeatherTimeAdder==0.001f)
av->m_SceneManager->m_fWeatherTimeAdder=0.0f;`
else
av->m_SceneManager->m_fWeatherTimeAdder=0.001f;
*/
}
void CMainFrame::OnShowinfo()
{
// TODO: Add your command handler code here
CWorldCreatorView *av=(CWorldCreatorView *)GetActiveView();
if(av->m_bInfoShow)
av->m_bInfoShow=false;
else
av->m_bInfoShow=true;
}
void CMainFrame::OnButtonGrass()
{
// TODO: Add your control notification handler code here
m_dlgMakeGrass->ShowWindow(SW_SHOW);
CWorldCreatorView *av=(CWorldCreatorView *)GetActiveView();
av->m_MouseInterface=60;
}
void CMainFrame::OnSectorloadnowpos()
{
// TODO: Add your command handler code here
CString strFilter = Z3MFILE;
CFileDialog filedia(TRUE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,strFilter,this);
filedia.DoModal();
CString filename=filedia.GetFileName();
if(filename=="")
return;
long ReadSectorX,ReadSectorY;
sscanf(filename.LockBuffer(),"Sector %d %d.z3m",&ReadSectorX,&ReadSectorY);
//CMapStorage::LoadSector(filename.LockBuffer(),ReadSectorX,ReadSectorY);
CWorldCreatorView *av=(CWorldCreatorView *)GetActiveView();
av->m_SceneManager->m_MapStorage.LoadSector(filename.LockBuffer(),ReadSectorX,ReadSectorY);
for(int cSector=0;cSector<LSIZEX*LSIZEY;cSector++)
{
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateHeight();
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateWater();
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateWideMap();
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateFall();
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateHouseObject();
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GeneratePlant();
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateObject();
}
}
void CMainFrame::OnGarbegedel()
{
// TODO: Add your command handler code here
CDlgMapFileInfo dlgMapFileInfo;
dlgMapFileInfo.DoModal();
}
void CMainFrame::OnButtonEffect()
{
// TODO: Add your control notification handler code here
m_dlgEffect->ShowWindow(SW_SHOW);
m_dlgEffect->SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOREPOSITION|SWP_NOSIZE);
CWorldCreatorView *av=(CWorldCreatorView *)GetActiveView();
av->m_MouseInterface=70;
}
void CMainFrame::OnCameraview()
{
// TODO: Add your command handler code here
CSceneManager::GetCamera()->SaveViewMatrix();
CSceneManager::m_ViewerMode=2;
//m_dlgCamera->SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOREPOSITION|SWP_NOSIZE);
m_dlgCamera->ShowWindow(SW_SHOW);
}
void CMainFrame::OnSmokeparticle()
{
// TODO: Add your command handler code here
m_dlgEffect->ShowWindow(SW_SHOW);
CWorldCreatorView *av=(CWorldCreatorView *)GetActiveView();
av->m_MouseInterface=70;
}
void CMainFrame::OnWatermake()
{
// TODO: Add your command handler code here
m_dlgMakeWater->SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOREPOSITION|SWP_NOSIZE);
m_dlgMakeWater->ShowWindow(SW_SHOW);
CWorldCreatorView *av=(CWorldCreatorView *)GetActiveView();
av->m_MouseInterface=30;
}
void CMainFrame::OnSoundmapsave()
{
// TODO: Add your command handler code here
m_MeshContainerBar.m_MeshContainerSheet->SetActivePage(4);
CString strFilter = SOUNDMAPFILE;
CFileDialog filedia(FALSE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,strFilter,this);
filedia.DoModal();
CString filename=filedia.GetPathName();
if(filename!="")
m_MeshContainerBar.m_MeshContainerSheet->m_PageSoundContainer.Save( filename );
}
void CMainFrame::OnSoundmapload()
{
// TODO: Add your command handler code here
m_MeshContainerBar.m_MeshContainerSheet->SetActivePage(4);
CString strFilter = SOUNDMAPFILE;
CFileDialog filedia(TRUE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,strFilter,this);
filedia.DoModal();
CString filename=filedia.GetPathName();
if(filename!="")
m_MeshContainerBar.m_MeshContainerSheet->m_PageSoundContainer.Load( filename );
//av->m_SceneManager->m_MapStorage.SaveSoundMap(filename.LockBuffer());
}
void CMainFrame::OnClearall()
{
m_MeshContainerBar.m_MeshContainerSheet->m_PageSoundContainer.ClearAll();
}
void CMainFrame::OnAmbiencelist()
{
CAmbienceList ambList;
ambList.DoModal();
}
void CMainFrame::OnButtonBoid()
{
// TODO: Add your control notification handler code here
m_dlgBoid->SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOREPOSITION|SWP_NOSIZE);
m_dlgBoid->ShowWindow(SW_SHOW);
//dlgBoid.DoModal();
}
void CMainFrame::OnWeathertime()
{
// TODO: Add your command handler code here
m_dlgWeatherColor->SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOREPOSITION|SWP_NOSIZE);
m_dlgWeatherColor->ShowWindow(SW_SHOW);
}
void CMainFrame::OnGf3save()
{
// TODO: Add your command handler code here
UpdateData();
CString strFilter = Z3SFILE;
CFileDialog filedia(FALSE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,strFilter,this);
filedia.DoModal();
CString filename=filedia.GetFileName();
if(filename=="")
return;
//CMainFrame *mf=(CMainFrame*)AfxGetApp()->m_pMainWnd;
CWorldCreatorView *av=(CWorldCreatorView *)GetActiveView();
//av->m_SceneManager->m_MapStorage.Save(filename.LockBuffer());
av->m_SceneManager->m_MapStorage.SaveGF3(filename.LockBuffer());
//CMapStorage::Save(filename.LockBuffer());
ContainerSave();
}
void CMainFrame::OnGf3load()
{
// TODO: Add your command handler code here
UpdateData();
CString strFilter = Z3SFILE;
CFileDialog filedia(TRUE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,strFilter,this);
filedia.DoModal();
CString filename=filedia.GetFileName();
if(filename=="")
return;
CWorldCreatorView *av=(CWorldCreatorView *)GetActiveView();
//av->m_SceneManager->LoadMap(filename.LockBuffer());
av->m_SceneManager->m_MapStorage.LoadGF3(filename.LockBuffer());
//CMapStorage::Load(filename.LockBuffer());
av->m_SceneManager->m_HeightField.m_NowPositionX=-100000000;
av->m_SceneManager->m_HeightField.m_NowPositionY=-100000000;
av->m_SceneManager->m_HeightField.m_NowTessellatePosX=-100000000;
av->m_SceneManager->m_HeightField.m_NowTessellatePosY=-100000000;
int iX = av->m_SceneManager->m_HeightField.GetLSizeX();
int iY = av->m_SceneManager->m_HeightField.GetLSizeY();
//for(int cSector=0;cSector<LSIZEX*LSIZEY;cSector++)
for(int cSector=0;cSector<av->m_SceneManager->m_HeightField.GetLSizeX() * av->m_SceneManager->m_HeightField.GetLSizeY();cSector++)
{
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateHeight();
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateWater();
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateWideMap();
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateFall();
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateHouseObject();
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GeneratePlant();
av->m_SceneManager->m_HeightField.m_SectorScene[cSector].GenerateObject();
//CSceneManager::m_HeightField.m_SectorScene[cSector].GenerateWideMap();
}
ContainerLoad();
}
void CMainFrame::OnCheckPickfix()
{
// TODO: Add your control notification handler code here
CSceneManager::m_bPickFix=!CSceneManager::m_bPickFix;
if(CSceneManager::m_bPickFix==false)
{
CSceneManager::m_PickHouseScene=NULL;
CSceneManager::m_PickLightScene=NULL;
CSceneManager::m_PickObjectScene=NULL;
}
}
void CMainFrame::OnButtonMeshoptimize()
{
// TODO: Add your control notification handler code here
if(CSceneManager::m_PickHouseScene && CSceneManager::m_PickObjectScene)
{
CSceneManager::m_PickObjectScene->m_pObject->Optimize();
CSceneManager::m_PickObjectScene->m_pObject->Save(CSceneManager::m_PickObjectScene->m_pObject->m_strMeshName);
}
else if(CSceneManager::m_PickHouseScene)
{
if(CSceneManager::m_PickHouseScene->m_HouseObject->m_pLodHouseObject)
{
CSceneManager::m_PickHouseScene->m_HouseObject->m_pLodHouseObject->Optimize();
CSceneManager::m_PickHouseScene->m_HouseObject->m_pLodHouseObject->Save(CSceneManager::m_PickHouseScene->m_HouseObject->m_pLodHouseObject->m_strMeshName);
}
if(CSceneManager::m_PickHouseScene->m_HouseObject->m_pOutHouseObject)
{
CSceneManager::m_PickHouseScene->m_HouseObject->m_pOutHouseObject->Optimize();
CSceneManager::m_PickHouseScene->m_HouseObject->m_pOutHouseObject->Save(CSceneManager::m_PickHouseScene->m_HouseObject->m_pOutHouseObject->m_strMeshName);
}
if(CSceneManager::m_PickHouseScene->m_HouseObject->m_pMedHouseObject)
{
CSceneManager::m_PickHouseScene->m_HouseObject->m_pMedHouseObject->Optimize();
CSceneManager::m_PickHouseScene->m_HouseObject->m_pMedHouseObject->Save(CSceneManager::m_PickHouseScene->m_HouseObject->m_pMedHouseObject->m_strMeshName);
}
if(CSceneManager::m_PickHouseScene->m_HouseObject->m_pInHouseObject)
{
CSceneManager::m_PickHouseScene->m_HouseObject->m_pInHouseObject->Optimize();
CSceneManager::m_PickHouseScene->m_HouseObject->m_pInHouseObject->Save(CSceneManager::m_PickHouseScene->m_HouseObject->m_pInHouseObject->m_strMeshName);
}
}
}
void CMainFrame::OnResave()
{
// TODO: Add your command handler code here
UpdateData();
CString strFilter = Z3SFILE;
CFileDialog filedia(FALSE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,strFilter,this);
filedia.DoModal();
CString filename=filedia.GetFileName();
if(filename=="")
return;
//CMainFrame *mf=(CMainFrame*)AfxGetApp()->m_pMainWnd;
CWorldCreatorView *av=(CWorldCreatorView *)GetActiveView();
av->m_SceneManager->m_MapStorage.Save(filename.LockBuffer());
//CMapStorage::Save(filename.LockBuffer());
ContainerSave();
}
// BSP 추가
void CMainFrame::OnButtonBsplightmode()
{
// TODO: Add your control notification handler code here
CWorldCreatorView *av=(CWorldCreatorView *)GetActiveView();
// m_PickMode = 95;
/* CButton *btHouse=(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_PICKHOUSE);
CButton *btObject=(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_PICKOBJECT);
CButton *btNone=(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_PICKNONE);
CButton *btEffect =(CButton*)m_MeshContainerBar.GetDlgItem(IDC_EFFECT);
CButton *btTrigger =(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_TRIGGER);
CButton *btBsp =(CButton*)m_MeshContainerBar.GetDlgItem(IDC_BUTTON_BSPLIGHTMODE);
btHouse->SetCheck(0);
btObject->SetCheck(0);
btNone->SetCheck(0);
btEffect->SetCheck(0);
btTrigger->SetCheck(0);
btBsp->SetCheck(1);
*/
if(av->m_SceneManager->m_pBspScene)
{
av->m_SceneManager->m_pBspScene->m_HouseObject->m_pBspObject->LoadLightmapVector3();
}
else
{
AfxMessageBox("BSP가 선택되어있지 않습니다.");
}
}
void CMainFrame::PropertySetup()
{
CRect rc,MainRc;
m_SectorViewerBar.GetWindowRect(rc);
GetWindowRect(MainRc);
m_SectorViewerBar.SetWindowPos(&wndNoTopMost,rc.left,rc.top,MainRc.right-MainRc.left-30,rc.bottom-rc.top,SWP_NOMOVE|SWP_NOZORDER );
m_SectorViewerBar.m_SectorViewerSheet->GetWindowRect(rc);
m_SectorViewerBar.m_SectorViewerSheet->SetWindowPos(&wndNoTopMost,rc.left,rc.top,MainRc.right-MainRc.left-30,rc.bottom-rc.top,SWP_NOMOVE|SWP_NOZORDER );
}
void CMainFrame::OnTerraintextureautoinsert()
{
// TODO: Add your command handler code here
char strPathAll[256];
sprintf(strPathAll,"%s\\*.dds",WIDETEXTUREPATH);
WIN32_FIND_DATA wfd = {0};
HANDLE hFind = FindFirstFile(strPathAll, &wfd);
if(INVALID_HANDLE_VALUE == hFind)
return;
CString strFilePathname;
int IndexX,IndexY,DetailIndex;
char strDetailName[256];
CWorldCreatorView *av=(CWorldCreatorView *)GetActiveView();
CMapStorage *pMapStorage=&av->m_SceneManager->m_MapStorage;
char strDetailTextureName[256];
for(int i=0;i<pMapStorage->m_WideMap.num;i++)
{
for(int j = 0; j < 3; j++ ) {
memset(pMapStorage->m_WideMap[i]->m_strWidemapName[j],0,sizeof(char) * 256);
memset(pMapStorage->m_WideMap[i]->m_strDetailName[j],0,sizeof(char) * 256);
}
}
while(1)
{
strFilePathname.Format("%s",wfd.cFileName);
if(sscanf(strFilePathname.GetBuffer(0),"%d_%d_%d_%s.dds",&IndexX,&IndexY,&DetailIndex,strDetailName)==4)
{
if(DetailIndex>=3)
AfxMessageBox("sadfasdf");
if(strcmp(strDetailName,"Sand.dds")==0)
strcpy(strDetailTextureName,"SandDetail.dds");
if(strcmp(strDetailName,"Grass.dds")==0)
strcpy(strDetailTextureName,"GrassDetail.dds");
if(strcmp(strDetailName,"Land.dds")==0)
strcpy(strDetailTextureName,"LandDetail.dds");
if(strcmp(strDetailName,"Rock.dds")==0)
strcpy(strDetailTextureName,"RockDetail.dds");
if(strcmp(strDetailName,"Normal.dds")==0)
strcpy(strDetailTextureName,"Detail.dds");
bool bFound=false;
for(int i=0;i<pMapStorage->m_WideMap.num;i++)
{
if( pMapStorage->m_WideMap[i]->m_IndexX == IndexX&&
pMapStorage->m_WideMap[i]->m_IndexY == IndexY)
{
strcpy(pMapStorage->m_WideMap[i]->m_strWidemapName[DetailIndex],strFilePathname.GetBuffer(0));
strcpy(pMapStorage->m_WideMap[i]->m_strDetailName[DetailIndex],strDetailTextureName);
bFound=true;
break;
}
}
if(!bFound)
{
CSectorWideMap *AddWideMap=new CSectorWideMap();
memset(AddWideMap,0,sizeof(CSectorWideMap));
AddWideMap->m_IndexX=IndexX;
AddWideMap->m_IndexY=IndexY;
strcpy(AddWideMap->m_strWidemapName[DetailIndex],strFilePathname.GetBuffer(0));
strcpy(AddWideMap->m_strDetailName[DetailIndex],strDetailTextureName);
pMapStorage->m_WideMap.Add(AddWideMap);
}
}
if(FindNextFile(hFind, &wfd)==FALSE)
break;
}
}
void CMainFrame::OnDds()
{
// TODO: Add your command handler code here
CDds_container tmp;
tmp.DoModal();
}
void CMainFrame::OnCheckTerrainlightmap()
{
// TODO: Add your control notification handler code here
CWorldCreatorView* av=(CWorldCreatorView*)GetActiveView();
matrix *matPos=av->m_BaseGraphicLayer.m_ViewCamera.GetMatPosition();
vector3 vecViewPos=matPos->GetLoc();
CSectorScene *pCenterSectorScene=NULL;
for(int i=0;i<LSIZEX*LSIZEY;i++)
{
if( av->m_SceneManager->m_HeightField.m_SectorScene[i].m_AccumulateTM._41 <= vecViewPos.x &&
vecViewPos.x <= av->m_SceneManager->m_HeightField.m_SectorScene[i].m_AccumulateTM._41+SECTORSIZE &&
av->m_SceneManager->m_HeightField.m_SectorScene[i].m_AccumulateTM._43 <= vecViewPos.z &&
vecViewPos.z<= av->m_SceneManager->m_HeightField.m_SectorScene[i].m_AccumulateTM._43+SECTORSIZE )
{
pCenterSectorScene=&av->m_SceneManager->m_HeightField.m_SectorScene[i];
break;
}
}
int SectorPx=(int)(pCenterSectorScene->m_AccumulateTM._41/SECTORSIZE);
int SectorPy=(int)(pCenterSectorScene->m_AccumulateTM._43/SECTORSIZE);
CSectorScene *SelectNeighborScene[8];
for(int ix=0;ix<LSIZEX; ix++)
{
for(int iy=0;iy<LSIZEY;iy++)
{
int NowSectorPx=(int)(av->m_SceneManager->m_HeightField.m_SectorScene[ix+iy*LSIZEX].m_AccumulateTM._41/SECTORSIZE);
int NowSectorPy=(int)(av->m_SceneManager->m_HeightField.m_SectorScene[ix+iy*LSIZEX].m_AccumulateTM._43/SECTORSIZE);
if( SectorPx-1 == NowSectorPx && SectorPy-1 == NowSectorPy)
SelectNeighborScene[0]=&av->m_SceneManager->m_HeightField.m_SectorScene[ix+iy*LSIZEX];
if( SectorPx == NowSectorPx && SectorPy-1 == NowSectorPy)
SelectNeighborScene[1]=&av->m_SceneManager->m_HeightField.m_SectorScene[ix+iy*LSIZEX];
if( SectorPx+1 == NowSectorPx && SectorPy-1 == NowSectorPy)
SelectNeighborScene[2]=&av->m_SceneManager->m_HeightField.m_SectorScene[ix+iy*LSIZEX];
if( SectorPx-1 == NowSectorPx && SectorPy == NowSectorPy)
SelectNeighborScene[3]=&av->m_SceneManager->m_HeightField.m_SectorScene[ix+iy*LSIZEX];
if( SectorPx+1 == NowSectorPx && SectorPy == NowSectorPy)
SelectNeighborScene[4]=&av->m_SceneManager->m_HeightField.m_SectorScene[ix+iy*LSIZEX];
if( SectorPx-1 == NowSectorPx && SectorPy+1 == NowSectorPy)
SelectNeighborScene[5]=&av->m_SceneManager->m_HeightField.m_SectorScene[ix+iy*LSIZEX];
if( SectorPx == NowSectorPx && SectorPy+1 == NowSectorPy)
SelectNeighborScene[6]=&av->m_SceneManager->m_HeightField.m_SectorScene[ix+iy*LSIZEX];
if( SectorPx+1 == NowSectorPx && SectorPy+1 == NowSectorPy)
SelectNeighborScene[7]=&av->m_SceneManager->m_HeightField.m_SectorScene[ix+iy*LSIZEX];
}
}
pCenterSectorScene->GenerateTerrainLightmap(BaseGraphicsLayer::GetDevice(),SelectNeighborScene);
// OnSectorlightgen();
}
void CMainFrame::OnButtonCharacterviewer()
{
// TODO: Add your control notification handler code here
CWorldCreatorView* av=(CWorldCreatorView*)GetActiveView();
matrix *matPos=av->m_BaseGraphicLayer.m_ViewCamera.GetMatPosition();
vector3 vecViewPos=matPos->GetLoc();
CDlgCharacterCreate dlgChrCreate;
dlgChrCreate.DoModal();
/*
for(int i=0;i<10;i++)
{
av->m_ChrManager.AddCharacter("PC_MAN.GCMDS", "FACE01", "HAIR01",vecViewPos+vector3(rand()%1000,0.0f,rand()%1000));
}
*/
}
void CMainFrame::OnButtonCharactermove()
{
// TODO: Add your control notification handler code here
CWorldCreatorView* av=(CWorldCreatorView*)GetActiveView();
if(av->m_nCameraViewMode==0)
{
av->m_nCameraViewMode=1;
av->m_ChrManager.m_nFocusCharacter=0;
}
else
{
av->m_nCameraViewMode=0;
//av->m_ChrManager.m_nFocusCharacter=-1;
matrix *matPos=CSceneManager::GetCamera()->GetMatPosition();
vector3 vecPos=matPos->GetLoc();
matPos->Translation(vecPos);
matrix matInv;
matInv.Inverse(*matPos);
CSceneManager::GetCamera()->SetMatView(matInv);
CSceneManager::GetCamera()->SetRotaitionX(0.0f);
CSceneManager::GetCamera()->SetRotaitionY(0.0f);
CSceneManager::GetCamera()->SetRotaitionZ(0.0f);
}
}
void CMainFrame::OnCharactercontrol()
{
// TODO: Add your command handler code here
CWorldCreatorView* av=(CWorldCreatorView*)GetActiveView();
if(av->m_nCameraViewMode==0)
{
av->m_nCameraViewMode=1;
av->m_ChrManager.m_nFocusCharacter=0;
}
else
{
av->m_nCameraViewMode=0;
//av->m_ChrManager.m_nFocusCharacter=-1;
matrix *matPos=CSceneManager::GetCamera()->GetMatPosition();
vector3 vecPos=matPos->GetLoc();
matPos->Translation(vecPos);
matrix matInv;
matInv.Inverse(*matPos);
CSceneManager::GetCamera()->SetMatView(matInv);
CSceneManager::GetCamera()->SetRotaitionX(0.0f);
CSceneManager::GetCamera()->SetRotaitionY(0.0f);
CSceneManager::GetCamera()->SetRotaitionZ(0.0f);
}
}
void CMainFrame::OnMakecharacter()
{
// TODO: Add your command handler code here
CWorldCreatorView* av=(CWorldCreatorView*)GetActiveView();
matrix *matPos=av->m_BaseGraphicLayer.m_ViewCamera.GetMatPosition();
vector3 vecViewPos=matPos->GetLoc();
CDlgCharacterCreate dlgChrCreate;
dlgChrCreate.DoModal();
}
void CMainFrame::OnButtonChareffect()
{
// TODO: Add your control notification handler code here
}
void CMainFrame::OnButtonCameramodechange()
{
// TODO: Add your control notification handler code here
CWorldCreatorView* av=(CWorldCreatorView*)GetActiveView();
av->m_ChrManager.MouseModeChange();
}
void CMainFrame::OnEsf()
{
// TODO: Add your command handler code here
char str[] = "Esf 파일(*.esf) |*.esf| 모든파일(*.*)|*.*||";
CString strFilter = str;
CString t_name;
CMainFrame *mf=(CMainFrame*)AfxGetApp()->m_pMainWnd;
CWorldCreatorView* av=(CWorldCreatorView*)mf->GetActiveView();
CFileDialog filedia(TRUE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,strFilter,this);
filedia.DoModal();
t_name = filedia.GetFileName();
// strcpy((av->m_ChrManager.m_TestEsf),(t_name.LockBuffer()));
}
void CMainFrame::OnInterfaceEsf()
{
// TODO: Add your command handler code here
char str[] = "Esf 파일(*.esf) |*.esf| 모든파일(*.*)|*.*||";
CString strFilter = str;
CString t_name;
CMainFrame *mf=(CMainFrame*)AfxGetApp()->m_pMainWnd;
CWorldCreatorView* av=(CWorldCreatorView*)mf->GetActiveView();
CFileDialog filedia(TRUE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,strFilter,this);
filedia.DoModal();
t_name = filedia.GetFileName();
// strcpy((av->m_ChrManager.m_TestEsfInterface),(t_name.LockBuffer()));
}
void CMainFrame::OnTextesf()
{
// TODO: Add your command handler code here
// TODO: Add your command handler code here
char str[] = "Esf 파일(*.esf) |*.esf| 모든파일(*.*)|*.*||";
CString strFilter = str;
CString t_name;
CMainFrame *mf=(CMainFrame*)AfxGetApp()->m_pMainWnd;
CWorldCreatorView* av=(CWorldCreatorView*)mf->GetActiveView();
CFileDialog filedia(TRUE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,strFilter,this);
filedia.DoModal();
t_name = filedia.GetFileName();
strcpy((av->m_ChrManager.m_TextEsf),(t_name.LockBuffer()));
}
void CMainFrame::OnTextinteresf()
{
// TODO: Add your command handler code here
char str[] = "Esf 파일(*.esf) |*.esf| 모든파일(*.*)|*.*||";
CString strFilter = str;
CString t_name;
CMainFrame *mf=(CMainFrame*)AfxGetApp()->m_pMainWnd;
CWorldCreatorView* av=(CWorldCreatorView*)mf->GetActiveView();
CFileDialog filedia(TRUE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,strFilter,this);
filedia.DoModal();
t_name = filedia.GetFileName();
strcpy((av->m_ChrManager.m_TextEsfInterface),(t_name.LockBuffer()));
}
void CMainFrame::OnCharactercamera()
{
// TODO: Add your command handler code here
CWorldCreatorView* av=(CWorldCreatorView*)GetActiveView();
av->m_ChrManager.MouseModeChange();
}
void CMainFrame::OnMouseshow()
{
static int n=0;
if(n==0)
{
ShowCursor(FALSE);
n=1;
}
else
{
ShowCursor(TRUE);
n=0;
}
// TODO: Add your command handler code here
}
void CMainFrame::OnCharmotion()
{
// TODO: Add your command handler code here
CDlgEditName tmp;
tmp.DoModal();
strncpy(CCharacterControl::m_WCharMotion,tmp.m_EditName.LockBuffer(),49 * sizeof(char));
}
void CMainFrame::OnChareff()
{
// TODO: Add your command handler code here
CCharEffect tmp;
tmp.DoModal();
}
/*
void CMainFrame::OnButtonBsp()
{
// TODO: Add your control notification handler code here
}
*/
void CMainFrame::OnBsp()
{
// TODO: Add your control notification handler code here
CWorldCreatorView *av=(CWorldCreatorView *)GetActiveView();
m_PickMode = 95;
CButton *btHouse=(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_PICKHOUSE);
CButton *btObject=(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_PICKOBJECT);
CButton *btNone=(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_PICKNONE);
CButton *btEffect =(CButton*)m_MeshContainerBar.GetDlgItem(IDC_EFFECT);
CButton *btTrigger =(CButton*)m_MeshContainerBar.GetDlgItem(IDC_CHECK_TRIGGER);
CButton *btBsp =(CButton*)m_MeshContainerBar.GetDlgItem(IDC_BSP);
btHouse->SetCheck(0);
btObject->SetCheck(0);
btNone->SetCheck(0);
btEffect->SetCheck(0);
btTrigger->SetCheck(0);
btBsp->SetCheck(1);
}
// Sector 지형 light 제너레이트
void CMainFrame::OnSectorlightgen()
{
// TODO: Add your command handler code here
CWorldCreatorView* av=(CWorldCreatorView*)GetActiveView();
matrix *matPos = av->m_SceneManager->m_ViewCamera->GetMatPosition();
D3DXVECTOR3 vecCamera = D3DXVECTOR3(matPos->_41,matPos->_42,matPos->_43);
int indexx=(int)((vecCamera.x)/SECTORSIZE);
int indexy=(int)((vecCamera.z)/SECTORSIZE);
int iLSizeX = av->m_SceneManager->m_HeightField.GetLSizeX();
int iLSizeY = av->m_SceneManager->m_HeightField.GetLSizeY();
CSectorScene *pCurrentSector = NULL;
for(int ix=0;ix<iLSizeX;ix++)
{
for(int iy=0;iy<iLSizeY;iy++)
{
int iSectorx = (int)((av->m_SceneManager->m_HeightField.m_SectorScene[ix+iy*iLSizeX].m_TM._41)/SECTORSIZE);
int iSectory = (int)((av->m_SceneManager->m_HeightField.m_SectorScene[ix+iy*iLSizeX].m_TM._43)/SECTORSIZE);
// if(iSectorx == indexx && iSectory == indexy)
// {
pCurrentSector = &(av->m_SceneManager->m_HeightField.m_SectorScene[ix+iy*iLSizeX]);
if(pCurrentSector)
{
CSectorLightMap *pMapLight = av->m_SceneManager->m_MapStorage.FindLightMap(pCurrentSector->m_TM._41,pCurrentSector->m_TM._43);
if(pMapLight) {
for(int cLight = 0; cLight < pMapLight->m_lstLights.size(); cLight++)
{
D3DXVECTOR3 vecPos = pMapLight->m_lstLights[cLight].m_vecPos;
vector3 vecTarget = vector3(vecPos.x,vecPos.y,vecPos.z);
float fRange = pMapLight->m_lstLights[cLight].m_fRange;
float fTerrainHeight = CSceneManager::m_HeightField.GetHeight(vecTarget);
if(fTerrainHeight > vecPos.y)
{
pMapLight->m_lstLights[cLight].m_fExpose = -10.0;
continue;
}
vecTarget.y = fTerrainHeight;
float fLength = D3DXVec3Length(&(D3DXVECTOR3(vecPos.x - vecTarget.x,vecPos.y - vecTarget.y,vecPos.z - vecTarget.z)));
if(fLength < fRange) // 바닥에 glow 생성
{
pMapLight->m_lstLights[cLight].m_fExpose = fRange - fLength;
}
else
{
pMapLight->m_lstLights[cLight].m_fExpose = -10.0;
}
}
pCurrentSector->GenerateSectorLight();
}
}
// }
}
}
}
void CMainFrame::OnCharacterlod()
{
// TODO: Add your command handler code here
CDialogCharacterLodDist *pDialog;
pDialog = new CDialogCharacterLodDist;
pDialog->Create(IDD_DIALOG_CHARACTERLOD);
pDialog->SetWindowPos( NULL, 0, 100, 0, 0, SWP_NOSIZE | SWP_NOZORDER );
}
void CMainFrame::OnChrdir()
{
// TODO: Add your command handler code here
CSelectFolderDialog SelectFolderDlg(TRUE, "C:\\", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, NULL, this);
if(SelectFolderDlg.DoModal()!=IDOK)
{
return;
}
CString strPath = SelectFolderDlg.GetSelectedPath();
strcpy(WORLDCHRDIFF,strPath.GetBuffer(256));
char path[256];
GetCurrentDirectory(256,path);
sprintf(path,"%s\\CHRPATH.dat",path);
FILE *fp = fopen(path,"wt");
if(fp) {
fprintf(fp,"%s\n",WORLDCHRDIFF);
fprintf(fp,"%s\n",WORLDCHRBUM);
fprintf(fp,"%s\n",WORLDCHRENV);
fclose(fp);
}
}
void CMainFrame::OnChrbumdir()
{
// TODO: Add your command handler code here
CSelectFolderDialog SelectFolderDlg(TRUE, "C:\\", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, NULL, this);
if(SelectFolderDlg.DoModal()!=IDOK)
{
return;
}
CString strPath = SelectFolderDlg.GetSelectedPath();
strcpy(WORLDCHRBUM,strPath.GetBuffer(256));
char path[256];
GetCurrentDirectory(256,path);
sprintf(path,"%s\\CHRPATH.dat",path);
FILE *fp = fopen(path,"wt");
if(fp) {
fprintf(fp,"%s\n",WORLDCHRDIFF);
fprintf(fp,"%s\n",WORLDCHRBUM);
fprintf(fp,"%s\n",WORLDCHRENV);
fclose(fp);
}
}
void CMainFrame::OnChrenvdir()
{
// TODO: Add your command handler code here
CSelectFolderDialog SelectFolderDlg(TRUE, "C:\\", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, NULL, this);
if(SelectFolderDlg.DoModal()!=IDOK)
{
return;
}
CString strPath = SelectFolderDlg.GetSelectedPath();
strcpy(WORLDCHRENV,strPath.GetBuffer(256));
FILE *fp = fopen("c:\\MP-project\\CHRPATH.dat","wt");
if(fp) {
fprintf(fp,"%s\n",WORLDCHRDIFF);
fprintf(fp,"%s\n",WORLDCHRBUM);
fprintf(fp,"%s\n",WORLDCHRENV);
fclose(fp);
}
}
void CMainFrame::OnTerrainfix()
{
// TODO: Add your control notification handler code here
CWorldCreatorView* av=(CWorldCreatorView*)GetActiveView();
matrix *matPos=av->m_BaseGraphicLayer.m_ViewCamera.GetMatPosition();
vector3 vecViewPos=matPos->GetLoc();
CSectorScene *pCenterSectorScene=NULL;
for(int i=0;i<LSIZEX*LSIZEY;i++)
{
if( av->m_SceneManager->m_HeightField.m_SectorScene[i].m_AccumulateTM._41 <= vecViewPos.x &&
vecViewPos.x <= av->m_SceneManager->m_HeightField.m_SectorScene[i].m_AccumulateTM._41+SECTORSIZE &&
av->m_SceneManager->m_HeightField.m_SectorScene[i].m_AccumulateTM._43 <= vecViewPos.z &&
vecViewPos.z<= av->m_SceneManager->m_HeightField.m_SectorScene[i].m_AccumulateTM._43+SECTORSIZE )
{
pCenterSectorScene=&av->m_SceneManager->m_HeightField.m_SectorScene[i];
break;
}
}
int SectorPx=(int)(pCenterSectorScene->m_AccumulateTM._41/SECTORSIZE);
int SectorPy=(int)(pCenterSectorScene->m_AccumulateTM._43/SECTORSIZE);
CSectorScene *SelectNeighborScene[8];
for(int ix=0;ix<LSIZEX; ix++)
{
for(int iy=0;iy<LSIZEY;iy++)
{
int NowSectorPx=(int)(av->m_SceneManager->m_HeightField.m_SectorScene[ix+iy*LSIZEX].m_AccumulateTM._41/SECTORSIZE);
int NowSectorPy=(int)(av->m_SceneManager->m_HeightField.m_SectorScene[ix+iy*LSIZEX].m_AccumulateTM._43/SECTORSIZE);
if( SectorPx-1 == NowSectorPx && SectorPy-1 == NowSectorPy)
SelectNeighborScene[0]=&av->m_SceneManager->m_HeightField.m_SectorScene[ix+iy*LSIZEX];
if( SectorPx == NowSectorPx && SectorPy-1 == NowSectorPy)
SelectNeighborScene[1]=&av->m_SceneManager->m_HeightField.m_SectorScene[ix+iy*LSIZEX];
if( SectorPx+1 == NowSectorPx && SectorPy-1 == NowSectorPy)
SelectNeighborScene[2]=&av->m_SceneManager->m_HeightField.m_SectorScene[ix+iy*LSIZEX];
if( SectorPx-1 == NowSectorPx && SectorPy == NowSectorPy)
SelectNeighborScene[3]=&av->m_SceneManager->m_HeightField.m_SectorScene[ix+iy*LSIZEX];
if( SectorPx+1 == NowSectorPx && SectorPy == NowSectorPy)
SelectNeighborScene[4]=&av->m_SceneManager->m_HeightField.m_SectorScene[ix+iy*LSIZEX];
if( SectorPx-1 == NowSectorPx && SectorPy+1 == NowSectorPy)
SelectNeighborScene[5]=&av->m_SceneManager->m_HeightField.m_SectorScene[ix+iy*LSIZEX];
if( SectorPx == NowSectorPx && SectorPy+1 == NowSectorPy)
SelectNeighborScene[6]=&av->m_SceneManager->m_HeightField.m_SectorScene[ix+iy*LSIZEX];
if( SectorPx+1 == NowSectorPx && SectorPy+1 == NowSectorPy)
SelectNeighborScene[7]=&av->m_SceneManager->m_HeightField.m_SectorScene[ix+iy*LSIZEX];
}
}
pCenterSectorScene->FixedTerrainLightmap(BaseGraphicsLayer::GetDevice(),SelectNeighborScene);
// OnSectorlightgen();
}
void CMainFrame::OnButtonReload()
{
// TODO: Add your control notification handler code here
CWorldCreatorView* av=(CWorldCreatorView*)GetActiveView();
matrix *matPos=av->m_BaseGraphicLayer.m_ViewCamera.GetMatPosition();
vector3 vecViewPos=matPos->GetLoc();
CSectorScene *pCenterSectorScene=NULL;
for(int i=0;i<LSIZEX*LSIZEY;i++)
{
if( av->m_SceneManager->m_HeightField.m_SectorScene[i].m_AccumulateTM._41 <= vecViewPos.x &&
vecViewPos.x <= av->m_SceneManager->m_HeightField.m_SectorScene[i].m_AccumulateTM._41+SECTORSIZE &&
av->m_SceneManager->m_HeightField.m_SectorScene[i].m_AccumulateTM._43 <= vecViewPos.z &&
vecViewPos.z<= av->m_SceneManager->m_HeightField.m_SectorScene[i].m_AccumulateTM._43+SECTORSIZE )
{
pCenterSectorScene=&av->m_SceneManager->m_HeightField.m_SectorScene[i];
break;
}
}
pCenterSectorScene->ReloadWideMap();
}
void CMainFrame::OnButtonMinimap()
{
// TODO: Add your control notification handler code here
CWorldCreatorView* av=(CWorldCreatorView*)GetActiveView();
av->m_SceneManager->m_bMinimapGenerate = true;
}
void CMainFrame::OnMenuZ3cload()
{
// TODO: Add your command handler code here
char str[] = "Z3C 파일(*.Z3C) |*.z3c| 모든파일(*.*)|*.*||";
char strFileName[256] = {0};
CString strFilter = str;
CString t_name;
CFileDialog filedia(TRUE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,strFilter,this);
filedia.DoModal();
strcpy(strFileName,filedia.GetFileName().GetBuffer(256));
FILE *fp=fopen(strFileName,"rb");
if(fp==NULL)
{
return;
}
m_MeshContainerBar.m_MeshContainerSheet->m_PageHouseContainer.Load(fp,1);
m_MeshContainerBar.m_MeshContainerSheet->SetActivePage(0);
m_MeshContainerBar.m_MeshContainerSheet->m_PageHouseContainer.UpdateHouseTree();
m_MeshContainerBar.m_MeshContainerSheet->SetActivePage(1);
m_MeshContainerBar.m_MeshContainerSheet->m_PageObjectContainer.Load(fp,1);
m_MeshContainerBar.m_MeshContainerSheet->m_PageObjectContainer.UpdateList();
m_MeshContainerBar.m_MeshContainerSheet->SetActivePage(2);
m_MeshContainerBar.m_MeshContainerSheet->m_PageLightContainer.Load(fp,1);
m_MeshContainerBar.m_MeshContainerSheet->m_PageLightContainer.UpdateList();
m_MeshContainerBar.m_MeshContainerSheet->SetActivePage(3);
m_MeshContainerBar.m_MeshContainerSheet->m_PageWideContainer.Load(fp,1);
m_MeshContainerBar.m_MeshContainerSheet->m_PageWideContainer.UpdateList();
m_MeshContainerBar.m_MeshContainerSheet->SetActivePage(4);
// m_MeshContainerBar.m_MeshContainerSheet->m_PageSoundContainer.Load(fp);
// m_MeshContainerBar.m_MeshContainerSheet->m_PageSoundContainer.UpdateList();
m_MeshContainerBar.m_MeshContainerSheet->SetActivePage(0);
fclose(fp);
}
void CMainFrame::OnCameraset()
{
// TODO: Add your command handler code here
CDlgCameraSet Dlg;
Dlg.DoModal();
}