1019 lines
33 KiB
C++
1019 lines
33 KiB
C++
/*=========================================================================
|
|
*
|
|
* CPASpec.cpp : CPA_SpecificEditor : Implementation file.
|
|
*
|
|
*
|
|
* Version 1.0
|
|
* Creation date
|
|
* Revision date
|
|
*
|
|
* Shaitan
|
|
*=======================================================================*/
|
|
|
|
#include "stdafx.h"
|
|
#include <afxtempl.h>
|
|
|
|
#ifdef ACTIVE_EDITOR
|
|
#include "acp_base.h"
|
|
#include "geo.h"
|
|
#include "gli.h"
|
|
#include "col.h"
|
|
#define HieFriend
|
|
#include "spo.h"
|
|
#include "lst.hpp"
|
|
#undef HieFriend
|
|
|
|
#include "IncMEC.h"
|
|
// Shaitan Clean Env {
|
|
//#include "ENV.h"
|
|
//End Shaitan Clean Env }
|
|
#include "snd.h"
|
|
#include "incSCT.h"
|
|
|
|
#include "incGAM.h"
|
|
|
|
//ANNECY Shaitan EmptySectors 25/02/98
|
|
#include "itf/CPABaseO.hpp"
|
|
//ENDANNECY Shaitan EmptySectors
|
|
#include "itf/CPASpec.hpp"
|
|
#include "itf/CPAInter.hpp"
|
|
#include "itf/DEVMulti.hpp"
|
|
#include "itf/cpaproj.hpp"
|
|
|
|
#include "itf/StdDLLId.h"
|
|
|
|
#include "itf/CPAHieEd.hpp"
|
|
|
|
#define M_GetMenuFrame() GetInterface()->GetFrameBase()
|
|
|
|
static BOOL g_bTooManyLights = FALSE;
|
|
ACP_tdxBool g_bShowCollisionMap = FALSE;
|
|
|
|
|
|
//#################################################################################
|
|
// CONSTRUCT
|
|
//#################################################################################
|
|
CPA_SpecificInterface::CPA_SpecificInterface (void)
|
|
{
|
|
m_eDisplayMode = E_dm_DrawWorld;
|
|
m_bDisplayFog = TRUE;
|
|
m_pCurrentSector = NULL;
|
|
m_pComboSector = NULL;
|
|
m_eUserStatus = E_us_NoStatus;
|
|
}
|
|
|
|
CPA_SpecificInterface::~CPA_SpecificInterface (void)
|
|
{
|
|
|
|
}
|
|
|
|
//#################################################################################
|
|
// INITS
|
|
//#################################################################################
|
|
/*===========================================================================
|
|
* Description: init specific parameters
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void CPA_SpecificInterface::fn_vSpecificInit (void)
|
|
{
|
|
// init display mode
|
|
m_eDisplayMode = E_dm_DrawWorld;
|
|
// init user status
|
|
m_eUserStatus = E_us_NoStatus;
|
|
// init combo current sector
|
|
m_pCurrentSector = NULL;
|
|
if (!m_pComboSector)
|
|
m_pComboSector = (CComboBox *) M_GetMenuFrame()->m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_CURRENTSECTOR);
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: update specific editor
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void CPA_SpecificInterface::fn_vSpecificUpdate (BOOL bReinitDisplayMode)
|
|
{
|
|
if ((bReinitDisplayMode)||(!fn_bHasValidWorld()))
|
|
SetDisplayMode(E_dm_DrawWorld);
|
|
else
|
|
SetCurrentSector(GetDefaultCurrentSector());
|
|
}
|
|
|
|
//#################################################################################
|
|
// HIERARCHY
|
|
//#################################################################################
|
|
/*===========================================================================
|
|
* Description: find dynamic root
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
CPA_SuperObject * CPA_SpecificInterface::GetDynamicRoot (void)
|
|
{
|
|
return GetInterface()->GetCurrentWorld()->GetRoot()->GetSuperObjectFirstChild();
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: find static root
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
CPA_SuperObject * CPA_SpecificInterface::GetStaticRoot (void)
|
|
{
|
|
return GetInterface()->GetCurrentWorld()->GetRoot()->GetSuperObjectLastChild();
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: check if hierarchy is coherent with specification
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
BOOL CPA_SpecificInterface::fn_bHasValidWorld (BOOL bCheckRoot)
|
|
{
|
|
// is there a world ?
|
|
if ((!GetInterface()->GetMultiDevice())||(!GetInterface()->GetCurrentWorld()))
|
|
return FALSE;
|
|
|
|
// is this hierarchy valid ?
|
|
if (GetInterface()->GetCurrentWorld()->fn_bIsTemporaryWorld())
|
|
return FALSE;
|
|
|
|
// is there a root in this world ?
|
|
if ((bCheckRoot)&&(!GetInterface()->GetCurrentWorld()->GetRoot()))
|
|
return FALSE;
|
|
|
|
// all seems OK
|
|
return TRUE;
|
|
}
|
|
|
|
//#################################################################################
|
|
// DISPLAY MODE
|
|
//#################################################################################
|
|
/*===========================================================================
|
|
* Description: Set super-objects display flag when draw mode changes
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void CPA_SpecificInterface::SetDisplayMode (tdeDisplayMode eMode)
|
|
{
|
|
CPA_SuperObject *pCharacter, *pSector;
|
|
CPA_SuperObject *pDRoot, *pSRoot;
|
|
CPA_PopUpToolBar *pDisplayToolbar;
|
|
CMenu *pDisplayMenu;
|
|
|
|
// invalid world => only world display
|
|
if (!fn_bHasValidWorld())
|
|
{
|
|
m_eDisplayMode = E_dm_DrawWorld;
|
|
if (m_pComboSector)
|
|
fn_vInitCurrentSector();
|
|
GetInterface()->fn_vUpdateAll(E_mc_JustDraw);
|
|
return;
|
|
}
|
|
|
|
// mode already set
|
|
if (eMode == m_eDisplayMode)
|
|
return;
|
|
|
|
// init parameters
|
|
pDRoot = GetDynamicRoot();
|
|
pSRoot = GetStaticRoot();
|
|
|
|
switch (eMode)
|
|
{
|
|
// display all
|
|
case E_dm_DrawWorld:
|
|
g_bShowCollisionMap = FALSE;
|
|
// display dynamic hierarchy
|
|
for (pCharacter = pDRoot->GetSuperObjectFirstChild(); pCharacter;
|
|
pCharacter = pDRoot->GetSuperObjectNextChild(pCharacter))
|
|
pCharacter->SetDisplayFlag(TRUE);
|
|
// display static hierarchy
|
|
for (pSector = pSRoot->GetSuperObjectFirstChild(); pSector;
|
|
pSector = pSRoot->GetSuperObjectNextChild(pSector))
|
|
pSector->SetDisplayFlag(TRUE);
|
|
break;
|
|
|
|
//ANNECY TQ 07/05/98{
|
|
case E_dm_DrawCollisionMap:
|
|
g_bShowCollisionMap = 1 - g_bShowCollisionMap;
|
|
break;
|
|
//ENDANNECY TQ}
|
|
|
|
// current sector + visible
|
|
case E_dm_DrawVisibleSectors:
|
|
g_bShowCollisionMap = FALSE;
|
|
// display character only if they are in visible sector
|
|
for (pCharacter = pDRoot->GetSuperObjectFirstChild(); pCharacter;
|
|
pCharacter = pDRoot->GetSuperObjectNextChild(pCharacter))
|
|
{
|
|
pSector = GetSuperObjectCurrentSector(pCharacter);
|
|
pCharacter->SetDisplayFlag(fn_bIsSectorVisible(pSector));
|
|
}
|
|
// display only visible sector
|
|
for (pSector = pSRoot->GetSuperObjectFirstChild(); pSector;
|
|
pSector = pSRoot->GetSuperObjectNextChild(pSector))
|
|
pSector->SetDisplayFlag(fn_bIsSectorVisible(pSector));
|
|
break;
|
|
|
|
// only current sector
|
|
case E_dm_DrawOnlyCurrentSector:
|
|
g_bShowCollisionMap = FALSE;
|
|
// display character only if they are in current sector
|
|
for (pCharacter = pDRoot->GetSuperObjectFirstChild(); pCharacter;
|
|
pCharacter = pDRoot->GetSuperObjectNextChild(pCharacter))
|
|
{
|
|
pSector = GetSuperObjectCurrentSector(pCharacter);
|
|
pCharacter->SetDisplayFlag(pSector == m_pCurrentSector);
|
|
}
|
|
// display only current sector
|
|
for (pSector = pSRoot->GetSuperObjectFirstChild(); pSector;
|
|
pSector = pSRoot->GetSuperObjectNextChild(pSector))
|
|
pSector->SetDisplayFlag(pSector == m_pCurrentSector);
|
|
break;
|
|
|
|
default:
|
|
return;
|
|
}
|
|
// update mode
|
|
m_eDisplayMode = eMode;
|
|
// update toolbar
|
|
pDisplayToolbar = &M_GetMenuFrame()->m_oGeneralDialogBar.m_oDisplayToolbar;
|
|
switch (m_eDisplayMode)
|
|
{
|
|
case E_dm_DrawWorld:
|
|
pDisplayToolbar->SetButton(CPA_IDB_DISPLAYWORLD);
|
|
break;
|
|
case E_dm_DrawVisibleSectors:
|
|
pDisplayToolbar->SetButton(CPA_IDB_DISPLAYVISIBLE);
|
|
break;
|
|
case E_dm_DrawOnlyCurrentSector:
|
|
pDisplayToolbar->SetButton(CPA_IDB_DISPLAYSECTOR);
|
|
break;
|
|
}
|
|
// update menu
|
|
pDisplayMenu = &M_GetMenuFrame()->m_oGeneralMenu;
|
|
pDisplayMenu->CheckMenuItem(CPA_IDCB_DISPLAYWORLD, (m_eDisplayMode == E_dm_DrawWorld) ? MF_CHECKED : MF_UNCHECKED);
|
|
pDisplayMenu->CheckMenuItem(CPA_IDCB_DISPLAYCOLLISIONMAP, (m_eDisplayMode == E_dm_DrawCollisionMap) ? MF_CHECKED : MF_UNCHECKED);
|
|
pDisplayMenu->CheckMenuItem(CPA_IDCB_DISPLAYVISIBLE, (m_eDisplayMode == E_dm_DrawVisibleSectors) ? MF_CHECKED : MF_UNCHECKED);
|
|
pDisplayMenu->CheckMenuItem(CPA_IDCB_DISPLAYSECTOR, (m_eDisplayMode == E_dm_DrawOnlyCurrentSector) ? MF_CHECKED : MF_UNCHECKED);
|
|
// update curent sector
|
|
fn_vInitCurrentSector();
|
|
GetInterface()->fn_vUpdateAll(E_mc_JustDraw);
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: update display mode when selection changes in toolbar
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void CPA_SpecificInterface::fn_vOnChangeDisplayMode (tdeDisplayMode eMode)
|
|
{
|
|
SetDisplayMode(eMode);
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: update display mode when selection changes in toolbar
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void CPA_SpecificInterface::fn_vChangeDisplayFog (BOOL bDisplay)
|
|
{
|
|
// update flag
|
|
m_bDisplayFog = bDisplay;
|
|
|
|
// update drawing
|
|
GetInterface()->fn_vUpdateAll(E_mc_JustDraw);
|
|
}
|
|
|
|
//#################################################################################
|
|
// CURRENT SECTOR
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
* Description: set current sector and update display
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void CPA_SpecificInterface::SetCurrentSector (CPA_SuperObject *pNewSector)
|
|
{
|
|
CPA_SuperObject *pOldSector, *pSector;
|
|
CPA_SuperObject *pCharacter;
|
|
|
|
// set current sector
|
|
pOldSector = m_pCurrentSector;
|
|
m_pCurrentSector = pNewSector;
|
|
|
|
// if necessary, update display
|
|
if (m_eDisplayMode == E_dm_DrawOnlyCurrentSector)
|
|
{
|
|
// display character only if they are in current sector
|
|
for (pCharacter = GetDynamicRoot()->GetSuperObjectFirstChild(); pCharacter;
|
|
pCharacter = GetDynamicRoot()->GetSuperObjectNextChild(pCharacter))
|
|
{
|
|
pSector = GetSuperObjectCurrentSector(pCharacter);
|
|
pCharacter->SetDisplayFlag(pSector == m_pCurrentSector);
|
|
}
|
|
// display only current sector
|
|
if (pOldSector)
|
|
pOldSector->SetDisplayFlag(FALSE);
|
|
if (m_pCurrentSector)
|
|
m_pCurrentSector->SetDisplayFlag(TRUE);
|
|
}
|
|
else if (m_eDisplayMode == E_dm_DrawVisibleSectors)
|
|
{
|
|
// display character only if they are in visible sector
|
|
for (pCharacter = GetDynamicRoot()->GetSuperObjectFirstChild(); pCharacter;
|
|
pCharacter = GetDynamicRoot()->GetSuperObjectNextChild(pCharacter))
|
|
{
|
|
pSector = GetSuperObjectCurrentSector(pCharacter);
|
|
pCharacter->SetDisplayFlag(fn_bIsSectorVisible(pSector));
|
|
}
|
|
// display only visible sector
|
|
for (pSector = GetStaticRoot()->GetSuperObjectFirstChild(); pSector;
|
|
pSector = GetStaticRoot()->GetSuperObjectNextChild(pSector))
|
|
pSector->SetDisplayFlag(fn_bIsSectorVisible(pSector));
|
|
}
|
|
if (!GetInterface()->fn_bIsLoadingWorld())
|
|
GetInterface()->fn_vUpdateAll(E_mc_JustDraw);
|
|
|
|
// set current selection
|
|
if (m_pComboSector->GetCurSel() != -1)
|
|
pSector = (CPA_SuperObject *) m_pComboSector->GetItemData(m_pComboSector->GetCurSel());
|
|
else
|
|
pSector = NULL;
|
|
|
|
if (pSector != m_pCurrentSector)
|
|
{
|
|
int iInd = m_pComboSector->FindStringExact(-1, m_pCurrentSector->GetNameToDraw());
|
|
m_pComboSector->SetCurSel(iInd);
|
|
}
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: init parameteers for load
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void CPA_SpecificInterface::fn_vInitCurrentSector (void)
|
|
{
|
|
CPA_SuperObject *pSector;
|
|
BOOL bEnabled;
|
|
int iInd, iPos;
|
|
|
|
// init the list
|
|
m_pComboSector->ResetContent();
|
|
iPos = m_pComboSector->AddString("Default Sector");
|
|
m_pComboSector->SetItemData(iPos, (DWORD) NULL);
|
|
|
|
// invalid world
|
|
if (!fn_bHasValidWorld())
|
|
{
|
|
m_pComboSector->EnableWindow(FALSE);
|
|
return;
|
|
}
|
|
|
|
// check lists by type to find the available DLLs
|
|
for (pSector = GetStaticRoot()->GetSuperObjectFirstChild(); pSector;
|
|
pSector = GetStaticRoot()->GetSuperObjectNextChild(pSector))
|
|
{
|
|
iPos = m_pComboSector->AddString(pSector->GetNameToDraw());
|
|
m_pComboSector->SetItemData(iPos, (DWORD) pSector);
|
|
}
|
|
|
|
// set current selection
|
|
if (GetCurrentSector())
|
|
iInd = m_pComboSector->FindStringExact(-1, GetCurrentSector()->GetNameToDraw());
|
|
else
|
|
iInd = m_pComboSector->FindStringExact(-1, "Default Sector");
|
|
m_pComboSector->SetCurSel(iInd);
|
|
|
|
// set display text & state
|
|
switch (GetDisplayMode())
|
|
{
|
|
// display all
|
|
case E_dm_DrawWorld:
|
|
bEnabled = FALSE;
|
|
break;
|
|
// current sector + visible
|
|
case E_dm_DrawVisibleSectors:
|
|
case E_dm_DrawOnlyCurrentSector:
|
|
bEnabled = TRUE;
|
|
break;
|
|
}
|
|
// update combo
|
|
m_pComboSector->EnableWindow(bEnabled);
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: update current sector when selection changes in combo
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void CPA_SpecificInterface::fn_vOnChangeCurrentSector (void)
|
|
{
|
|
CPA_SuperObject *pSector = NULL;
|
|
|
|
if (m_pComboSector->GetCurSel() != -1)
|
|
pSector = (CPA_SuperObject *) m_pComboSector->GetItemData(m_pComboSector->GetCurSel());
|
|
|
|
SetCurrentSector(pSector ? pSector : GetDefaultCurrentSector());
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: get sector from super object position
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
CPA_SuperObject * CPA_SpecificInterface::GetSuperObjectCurrentSector (CPA_SuperObject *pEdObj)
|
|
{
|
|
CPA_SuperObject *pOwner;
|
|
GEO_tdxHandleToMatrix hMatrix;
|
|
MTH3D_tdstVector stVect;
|
|
|
|
// if this is a sector (or it's protected child) => not from pos)
|
|
if (pEdObj->GetRealTypeName() == C_szSectorTypeName)
|
|
return pEdObj;
|
|
pOwner = pEdObj->GetSuperObjectOwner();
|
|
if ((pOwner)&&(pOwner->GetRealTypeName() == C_szSectorTypeName))
|
|
return pOwner;
|
|
// other case => get from pos
|
|
hMatrix = HIE_fn_hGetSuperObjectGlobalMatrix(pEdObj->GetStruct());
|
|
POS_fn_vGetTranslationVector(hMatrix,&stVect);
|
|
return GetCurrentSectorFromPos(&stVect);
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: find current sector from absolute position
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
CPA_SuperObject * CPA_SpecificInterface::GetCurrentSectorFromPos (MTH3D_tdstVector * p_stAbsolutePosition)
|
|
{
|
|
HIE_tdxHandleToSuperObject hStaticRoot;
|
|
HIE_tdxHandleToSuperObject hEngineSector;
|
|
|
|
// get engine sector from pos
|
|
hStaticRoot = (HIE_tdxHandleToSuperObject) GetStaticRoot()->GetStruct();
|
|
hEngineSector = SECT_fn_hResearchInWhatSectorIAm (hStaticRoot, p_stAbsolutePosition);
|
|
// No sector => sector inf
|
|
if (!hEngineSector)
|
|
return NULL;
|
|
// get corresponding editor sector
|
|
else
|
|
return GetInterface()->GetEditorObject(hEngineSector);
|
|
}
|
|
|
|
|
|
//#################################################################################
|
|
// DISPLAY WORLD
|
|
//#################################################################################
|
|
/*===========================================================================
|
|
* Description: display editor world
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
//ANNECY CB
|
|
extern "C" void SECT_fn_vSendFogToViewport(struct GLD_tdstViewportAttributes_ *_p_stVpt, HIE_tdxHandleToSuperObject _hSprObjSector);
|
|
extern "C" void fn_vSendBackGroundColor(HIE_tdxHandleToSuperObject _hSprObjSector);
|
|
//END ANNECY
|
|
void CPA_SpecificInterface::fn_vDisplayWorld (DEV_ViewPort3D *pViewport, GLD_tdxHandleToViewportAttributes hVpt,
|
|
GLI_tdxHandleToLight hLight, CPA_SuperObject *pRoot)
|
|
{
|
|
HIE_tdxHandleToSuperObject hRoot, hDRoot, hSRoot;
|
|
HIE_tdxHandleToSuperObject hSector;
|
|
CPA_SuperObject *pDRoot, *pSRoot;
|
|
CPA_SuperObject *pSector, *pCharacter;
|
|
CString csText;
|
|
BOOL bDisplayAll, bUseStaticLights;
|
|
long lDrawMask;
|
|
|
|
// invalid world => display with all lights
|
|
if ((pRoot != GetInterface()->GetCurrentWorld()->GetRoot())||(!fn_bHasValidWorld()))
|
|
{
|
|
pViewport->fn_vInitLightsInViewport(hVpt, hLight, pRoot->GetMainWorld());
|
|
pRoot->DisplayWorld (hVpt, pViewport->m_a_tdxhArrayOfLights, pViewport->m_lCurrentLights);
|
|
return;
|
|
}
|
|
|
|
// reinit matrix
|
|
HIE_fn_vInitMatrixStack();
|
|
if( HIE_fn_bInitCameraMatrixStack(hVpt) == NOK ) // no camera into ViewPort
|
|
return;
|
|
|
|
|
|
// init engine struct
|
|
hRoot = (HIE_tdxHandleToSuperObject) pRoot->GetSuperObjectStruct();
|
|
HIE_fn_vPushMatrix (hRoot);
|
|
HIE_fn_vPushOnCameraMatrixStack (hRoot);
|
|
// draw dynamic hierarchy
|
|
pDRoot = GetDynamicRoot();
|
|
hDRoot = (HIE_tdxHandleToSuperObject) pDRoot->GetSuperObjectStruct();
|
|
// init parameters
|
|
lDrawMask = HIE_fn_lGetSuperObjectDrawMask(hDRoot)&HIE_fn_lGetSuperObjectDrawMask(hRoot);
|
|
bDisplayAll = !GetInterface()->fn_bIgnoreFlags();
|
|
// init matrix
|
|
HIE_fn_vPushMatrix (hDRoot);
|
|
HIE_fn_vPushOnCameraMatrixStack (hDRoot);
|
|
for (pCharacter = pDRoot->GetSuperObjectFirstChild(); pCharacter;
|
|
pCharacter = pDRoot->GetSuperObjectNextChild(pCharacter))
|
|
{
|
|
if (pCharacter->fn_bMustDraw())
|
|
{
|
|
// get current sector
|
|
pSector = GetSuperObjectCurrentSector(pCharacter);
|
|
hSector = (pSector != NULL) ? pSector->GetStruct() : NULL;
|
|
|
|
//ANNECY CB
|
|
if (m_bDisplayFog)
|
|
SECT_fn_vSendFogToViewport(hVpt, hSector);
|
|
else
|
|
GLI_vFogOff();
|
|
//END ANNECY
|
|
|
|
// init lights
|
|
fn_vInitLightsInViewport(pViewport, hVpt, hLight, hSector);
|
|
if (g_bTooManyLights)
|
|
{
|
|
csText.Format("Too many lights in sector %s", pSector->GetName());
|
|
M_GetMainWnd()->UpdateStatus((char*)(LPCTSTR)csText, C_STATUSPANE_INFOS, C_STATUS_WARNING);
|
|
g_bTooManyLights = FALSE;
|
|
}
|
|
// display
|
|
pCharacter->Display (hVpt, lDrawMask,
|
|
pViewport->m_a_tdxhArrayOfLights,
|
|
pViewport->m_lCurrentLights,
|
|
hRoot, bDisplayAll);
|
|
}
|
|
}
|
|
HIE_fn_vPopMatrix ();
|
|
HIE_fn_vPopOnCameraMatrixStack ();
|
|
|
|
// draw static hierarchy
|
|
pSRoot = GetStaticRoot();
|
|
hSRoot = (HIE_tdxHandleToSuperObject) pSRoot->GetSuperObjectStruct();
|
|
// init parameters
|
|
lDrawMask = HIE_fn_lGetSuperObjectDrawMask(hSRoot)&HIE_fn_lGetSuperObjectDrawMask(hRoot);
|
|
bDisplayAll = !GetInterface()->fn_bIgnoreFlags();
|
|
// init matrix
|
|
HIE_fn_vPushMatrix (hSRoot);
|
|
HIE_fn_vPushOnCameraMatrixStack (hSRoot);
|
|
for (pSector = pSRoot->GetSuperObjectFirstChild(); pSector;
|
|
pSector = pSRoot->GetSuperObjectNextChild(pSector))
|
|
{
|
|
if (pSector->fn_bMustDraw())
|
|
{
|
|
// get engine sector
|
|
hSector = pSector->GetStruct();
|
|
|
|
//ANNECY CB
|
|
if(pSector == GetCurrentSector())
|
|
fn_vSendBackGroundColor(hSector);
|
|
if (m_bDisplayFog)
|
|
SECT_fn_vSendFogToViewport(hVpt, hSector);
|
|
else
|
|
GLI_vFogOff();
|
|
//END ANNECY
|
|
|
|
bUseStaticLights = !(HIE_fn_lGetSuperObjectDrawMask(hSector) & GLI_C_lIsUseRLI);
|
|
// init lights
|
|
fn_vInitLightsInViewport(pViewport, hVpt, hLight, hSector, bUseStaticLights);
|
|
if (g_bTooManyLights)
|
|
{
|
|
csText.Format("Too many lights in sector %s", pSector->GetName());
|
|
M_GetMainWnd()->UpdateStatus((char*)(LPCTSTR)csText, C_STATUSPANE_INFOS, C_STATUS_WARNING);
|
|
g_bTooManyLights = FALSE;
|
|
}
|
|
// display
|
|
pSector->Display (hVpt, lDrawMask,
|
|
pViewport->m_a_tdxhArrayOfLights,
|
|
pViewport->m_lCurrentLights,
|
|
hRoot, bDisplayAll);
|
|
}
|
|
}
|
|
HIE_fn_vPopMatrix ();
|
|
HIE_fn_vPopOnCameraMatrixStack ();
|
|
|
|
// update matrix
|
|
HIE_fn_vPopMatrix ();
|
|
HIE_fn_vPopOnCameraMatrixStack ();
|
|
}
|
|
|
|
/*===========================================================================
|
|
* Description: init lights according to sector
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void CPA_SpecificInterface::fn_vInitLightsInViewport (DEV_ViewPort3D *pViewport, GLD_tdxHandleToViewportAttributes hVpt,
|
|
GLI_tdxHandleToLight hLight, HIE_tdxHandleToSuperObject hSector,
|
|
BOOL bUseStaticLights)
|
|
{
|
|
SECT_tdxHandleOfElementLstStaticLights hElem;
|
|
SECT_tdxHandleOfElementLstDNMLights hDNM;
|
|
GLI_tdxHandleToLight hLocalLight;
|
|
CPA_MainWorld *pMainWorld;
|
|
|
|
pMainWorld = GetInterface()->GetMainWorld();
|
|
|
|
// clear lights
|
|
GLI_vClearListOfLightInViewport(hVpt);
|
|
pViewport->m_lCurrentLights = 0;
|
|
|
|
// dynamic lights
|
|
hDNM = (hSector) ? SECT_fn_hGetFirstDNMLightsListInSector(hSector) : NULL;
|
|
while (hDNM)
|
|
{
|
|
if (pViewport->m_lCurrentLights < C_lMaxLightInViewport - 1)
|
|
{
|
|
hLocalLight = SECT_GetDNMLightsInList(hDNM);
|
|
if (hLocalLight)
|
|
{
|
|
GLI_vAddLightToViewport(hVpt, hLocalLight);
|
|
pViewport->m_a_tdxhArrayOfLights[pViewport->m_lCurrentLights].hLight = hLocalLight;
|
|
GLI_xGetLightState(hLocalLight, &pViewport->m_a_tdxhArrayOfLights[pViewport->m_lCurrentLights].lInitialState);
|
|
pViewport->m_lCurrentLights++;
|
|
}
|
|
}
|
|
else
|
|
g_bTooManyLights = TRUE;
|
|
hDNM = SECT_fn_hGetNextDNMLightsListInSector(hDNM);
|
|
}
|
|
|
|
if (!bUseStaticLights)
|
|
return;
|
|
|
|
// local lights
|
|
hElem = (hSector) ? SECT_fn_hGetFirstStaticLightsListInSector(hSector) : NULL;
|
|
while (hElem)
|
|
{
|
|
if (pViewport->m_lCurrentLights < C_lMaxLightInViewport - 1)
|
|
{
|
|
hLocalLight = SECT_GetStaticLightsInList(hElem);
|
|
//ANNECY CT 19/02/98{
|
|
if (GLI_ucGetObjectLighted(hLocalLight) & GLI_C_LightPerso) {
|
|
GLI_vAddLightToViewport(hVpt, hLocalLight);
|
|
pViewport->m_a_tdxhArrayOfLights[pViewport->m_lCurrentLights].hLight = hLocalLight;
|
|
GLI_xGetLightState(hLocalLight, &pViewport->m_a_tdxhArrayOfLights[pViewport->m_lCurrentLights].lInitialState);
|
|
pViewport->m_lCurrentLights++;
|
|
}
|
|
//ENDANNECY CT}
|
|
}
|
|
else
|
|
g_bTooManyLights = TRUE;
|
|
hElem = SECT_fn_hGetNextStaticLightsListInSector(hElem);
|
|
}
|
|
|
|
// ambiant light (if no other lights)
|
|
if (pViewport->m_lCurrentLights == 0)
|
|
{
|
|
GLI_vAddLightToViewport(hVpt,hLight);
|
|
pViewport->m_a_tdxhArrayOfLights[pViewport->m_lCurrentLights].hLight = hLight;
|
|
GLI_xGetLightState(hLight, &pViewport->m_a_tdxhArrayOfLights[pViewport->m_lCurrentLights].lInitialState);
|
|
pViewport->m_lCurrentLights++;
|
|
}
|
|
}
|
|
|
|
|
|
//#################################################################################
|
|
// INSERTION
|
|
//#################################################################################
|
|
/*===========================================================================
|
|
* Description: get parent from pos
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
//ANNECY Shaitan EmptySectors 25/02/98
|
|
//CPA_SuperObject * CPA_SpecificInterface::GetDefaultParentFromPos (tdstPosition *p_stPosition, tdeTypeSO eTypeInsert)
|
|
CPA_SuperObject * CPA_SpecificInterface::GetDefaultParentFromPos (tdstPosition *p_stPosition, tdeTypeSO eTypeInsert, tdeSaveStatus eStatus)
|
|
//ENDANNECY Shaitan EmptySectors
|
|
{
|
|
//ANNECY Shaitan EmptySectors 25/02/98
|
|
CPA_SuperObject *pParent;
|
|
ACP_tdxIndex xIndex = 0;
|
|
BOOL bFound = FALSE;
|
|
//ENDANNECY Shaitan EmptySectors
|
|
|
|
if (!fn_bHasValidWorld())
|
|
return NULL;
|
|
|
|
// protected ojects have no default parent
|
|
if (eTypeInsert == C_Protected)
|
|
return NULL;
|
|
|
|
// static objects => current sector
|
|
if (eTypeInsert == C_Static)
|
|
{
|
|
//ANNECY Shaitan EmptySectors 25/02/98
|
|
while ((xIndex <p_stPosition->xIndex) && !bFound)
|
|
{
|
|
pParent = GetInterface()->GetEditorObject(p_stPosition->a_stPickInfo[xIndex].hSprObject);
|
|
if (M_GetEvtEditor()->fn_bCanBeParent(pParent, p_stPosition, C_Static, eStatus))
|
|
bFound = TRUE;
|
|
xIndex++;
|
|
}
|
|
if (bFound)
|
|
return pParent;
|
|
else
|
|
return GetCurrentSectorFromPos(&p_stPosition->stPos.stPos3D);
|
|
//ENDANNECY Shaitan EmptySectors
|
|
}
|
|
|
|
// dynamic object => dynamic root
|
|
if (eTypeInsert == C_Dynamic)
|
|
return GetDynamicRoot();
|
|
|
|
// unavailable type
|
|
return NULL;
|
|
}
|
|
|
|
|
|
//#################################################################################
|
|
// PROTECTED FUNCTIONS
|
|
//#################################################################################
|
|
/*===========================================================================
|
|
* Description: check if sector is visible from current one
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
BOOL CPA_SpecificInterface::fn_bIsSectorVisible (CPA_SuperObject *pSector)
|
|
{
|
|
SECT_tdxHandleOfElementLstGraphicInteraction hElem;
|
|
HIE_tdxHandleToSuperObject hCurrent, hSector;
|
|
|
|
// no sector => no visibility
|
|
if (!pSector)
|
|
return FALSE;
|
|
|
|
// current sector is visible
|
|
if (pSector == m_pCurrentSector)
|
|
return TRUE;
|
|
|
|
// init engine struct
|
|
hCurrent = m_pCurrentSector->GetStruct();
|
|
hSector = pSector->GetStruct();
|
|
// look in graphic list
|
|
hElem = SECT_fn_hGetFirstGraphicNodeInGraphicList(hCurrent);
|
|
while (hElem)
|
|
{
|
|
if (SECT_GetSectorInGraphicList(hElem) == hSector)
|
|
return TRUE;
|
|
hElem = SECT_fn_hGetNextGraphicNodeInGraphicList(hElem);
|
|
}
|
|
|
|
// sector is not visible
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: find current sector from main character pos
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
CPA_SuperObject * CPA_SpecificInterface::GetDefaultCurrentSector (void)
|
|
{
|
|
CPA_SuperObject *pMainCharacter, *pChild;
|
|
CPA_SuperObject *pSector;
|
|
BOOL bFound = FALSE;
|
|
|
|
// get main character
|
|
pChild = GetDynamicRoot()->GetSuperObjectFirstChild();
|
|
while ((pChild)&&(!bFound))
|
|
{
|
|
bFound = (MC_fn_ucIsCharacterInMainCharacterList(pChild->GetStruct()) == 1);
|
|
pMainCharacter = (bFound) ? pChild : NULL;
|
|
pChild = GetDynamicRoot()->GetSuperObjectNextChild(pChild);
|
|
}
|
|
|
|
if (!pMainCharacter)
|
|
return GetStaticRoot()->GetSuperObjectLastChild();
|
|
|
|
// get corresponding sector
|
|
pSector = GetSuperObjectCurrentSector(pMainCharacter);
|
|
if (!pSector)
|
|
pSector = GetStaticRoot()->GetSuperObjectLastChild();
|
|
|
|
return pSector;
|
|
}
|
|
|
|
//#################################################################################
|
|
// USER STATUS
|
|
//#################################################################################
|
|
|
|
/*===========================================================================
|
|
* Description: init user status
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void CPA_SpecificInterface::fn_vInitUserStatus (void)
|
|
{
|
|
CString csFileName;
|
|
char szUserStatus[256];
|
|
|
|
// try to read preference
|
|
if ((m_eUserStatus == E_us_NoStatus)&&(m_pInterface->fn_bUseUserPreferences()))
|
|
{
|
|
csFileName = M_GetMainApp()->m_csEditorDataPath + C_szInterfaceIniFile;
|
|
GetPrivateProfileString ("User", "User Status", "", szUserStatus, 256, (char*)(LPCSTR)csFileName);
|
|
|
|
if (!strcmp(szUserStatus, "Designer"))
|
|
SetUserStatus(E_us_StatusDesign);
|
|
else if (!strcmp(szUserStatus, "Graphist"))
|
|
SetUserStatus(E_us_StatusGraphic);
|
|
else if (!strcmp(szUserStatus, "Manager"))
|
|
SetUserStatus(E_us_StatusAll);
|
|
}
|
|
|
|
// if ther is still no mode, do dialog
|
|
if (m_eUserStatus == E_us_NoStatus)
|
|
m_oDialogStatus.fn_vDoDialog(this, TRUE);
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: set frame title
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void CPA_SpecificInterface::fn_vSaveUserStatus (tdeUserStatus eModeUser)
|
|
{
|
|
CString csFileName;
|
|
CString csUserStatus;
|
|
BOOL bRes;
|
|
|
|
csFileName = M_GetMainApp()->m_csEditorDataPath + C_szInterfaceIniFile;
|
|
switch (eModeUser)
|
|
{
|
|
case E_us_StatusDesign:
|
|
csUserStatus = "Designer";
|
|
break;
|
|
case E_us_StatusGraphic:
|
|
csUserStatus = "Graphist";
|
|
break;
|
|
case E_us_StatusAll:
|
|
csUserStatus = "Manager";
|
|
break;
|
|
default:
|
|
return;
|
|
}
|
|
bRes = WritePrivateProfileString ("User", "User Status", (char*)(LPCSTR)csUserStatus, (char*)(LPCSTR)csFileName);
|
|
if (!bRes)
|
|
M_GetMainWnd()->UpdateStatus("Hierarchy Editor cannot save your preferences. CPAPref.ini may have a ReadOnly status ?", C_STATUSPANE_INFOS, C_STATUS_WARNING);
|
|
else
|
|
M_GetMainWnd()->UpdateStatus("Preferences saved", C_STATUSPANE_INFOS, C_STATUS_NORMAL);
|
|
}
|
|
|
|
|
|
/*===========================================================================
|
|
* Description: set frame title
|
|
* Creation date:
|
|
* Author: Shaitan
|
|
*---------------------------------------------------------------------------
|
|
* Revision date: Author:
|
|
*=========================================================================*/
|
|
void CPA_SpecificInterface::fn_vSetFrameTitle (void)
|
|
{
|
|
CString csWindowText, csUserPrefix;
|
|
|
|
// get project name
|
|
csWindowText = "";//M_GetMainWnd()->m_szProjectName;
|
|
csUserPrefix = m_pInterface->GetUserPrefix().Left(3);
|
|
// add user status
|
|
switch (m_eUserStatus)
|
|
{
|
|
case E_us_StatusDesign:
|
|
csWindowText += "DESIGNER - " + csUserPrefix;
|
|
break;
|
|
case E_us_StatusGraphic:
|
|
csWindowText += "GRAPHIST - " + csUserPrefix;
|
|
break;
|
|
case E_us_StatusAll:
|
|
csWindowText += "MANAGER - " + csUserPrefix;
|
|
break;
|
|
}
|
|
// M_GetMainWnd()->SetWindowText(csWindowText);
|
|
#ifdef ACTIVE_EDITOR
|
|
CString act;
|
|
char actc[255], *p;
|
|
g_oBaseFrame.GetWindowText(act);
|
|
strcpy(actc, (char *) (LPCSTR) act);
|
|
p = strchr(actc, ']') + 1;
|
|
*p = '\0';
|
|
act = actc;
|
|
act += " ["+CString(csWindowText)+"]";
|
|
g_oBaseFrame.SetWindowText(act);
|
|
#endif
|
|
}
|
|
|
|
|
|
//#################################################################################
|
|
// SURFACES
|
|
//#################################################################################
|
|
|
|
//===========================================================================
|
|
//===========================================================================
|
|
BOOL CPA_SpecificInterface::fn_bIsSurfaceInList (CPA_SuperObject *pSurface)
|
|
{
|
|
CPA_SuperObject *pElem;
|
|
POSITION pos;
|
|
|
|
// check if list is empty
|
|
if (!pSurface)
|
|
return (m_stListOfSurfaces.GetCount() > 0);
|
|
|
|
// check each element in the list
|
|
for (pElem = m_stListOfSurfaces.GetHeadElement(pos); pElem;
|
|
pElem = m_stListOfSurfaces.GetNextElement(pos))
|
|
{
|
|
if (pElem == pSurface)
|
|
return TRUE;
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
//===========================================================================
|
|
//===========================================================================
|
|
void CPA_SpecificInterface::fn_vAddSurfaceInList (CPA_SuperObject *pSurface)
|
|
{
|
|
if (fn_bIsSurfaceInList(pSurface))
|
|
return;
|
|
|
|
m_stListOfSurfaces.AddTail(pSurface);
|
|
}
|
|
|
|
//===========================================================================
|
|
//===========================================================================
|
|
void CPA_SpecificInterface::fn_vReinitSurfaceList (void)
|
|
{
|
|
m_stListOfSurfaces.RemoveAll();
|
|
}
|
|
|
|
//===========================================================================
|
|
//===========================================================================
|
|
void CPA_SpecificInterface::fn_vUpdateSurfaces (BOOL bDrawSurfaces)
|
|
{
|
|
CPA_SuperObject *pSurface;
|
|
POSITION pos;
|
|
|
|
for (pSurface = m_stListOfSurfaces.GetHeadElement(pos); pSurface;
|
|
pSurface = m_stListOfSurfaces.GetNextElement(pos))
|
|
{
|
|
if (bDrawSurfaces)
|
|
{
|
|
if (pSurface->GetSuperObjectFather() == NULL)
|
|
M_GetWorld()->fn_vInsertSuperObjectInNewWorld(pSurface, GetDynamicRoot(), FALSE);
|
|
}
|
|
else
|
|
{
|
|
if (pSurface->GetSuperObjectFather() != NULL)
|
|
M_GetWorld()->fn_vDeleteSuperObjectInNewWorld(pSurface, FALSE);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif // ACTIVE_EDITOR
|