📄 geneditdoc.cpp
字号:
}
}
// commented here because metric is disabled...
// dlg.m_GridUnits += 3; // metric takes up the first 3
}
if(dlg.DoModal()==IDOK)
{
pGridInfo->GridType = dlg.MetricOrTexelGrid; // Main Visible Grid mode
// must add here 'cause metric grid is disabled
dlg.m_GridUnits += 3;
switch( dlg.m_GridUnits ) // SnapGrid RB's 0-2 METRIC 3-5 TEXEL
{
case 0:// Centimeter
case 1:// Decimeter
case 2:// Meter
pGridInfo->MetricSnapSize =gdex[dlg.m_GridUnits];
pGridInfo->SnapType = GridMetric;
break ;
case 3:// 1
case 4:// 2
case 5:// 4
case 6:
case 7:
case 8:
pGridInfo->TexelSnapSize = TexelSnapValues[dlg.m_GridUnits - 3];
pGridInfo->SnapType = GridTexel;
break ;
default :
assert (0); // unexpected grid units value!
break;
}
pGridInfo->UseGrid = dlg.m_UseSnap;
pGridInfo->RotationSnap = (int)(dlg.m_SnapDegrees);
UpdateGridInformation();
// Be very careful when speccing flags for UpdateAllViews()
// The wrong flags at the wrong time will totally screw things up
UpdateAllViews(UAV_GRID_ONLY, NULL);
}// DoModal OK
*/
}
/* CGenEditDoc::OnToolsGridsettings */
void CGenEditDoc::OnEditUndo()
{
#if 0
// Well, here's the basic idea of undo.
// It doesn't work 'cause the stack isn't being built.
UndoStackEntry *pEntry;
UndoEntryType EntryType;
pEntry = UndoStack_Pop (pUndoStack);
EntryType = UndoStackEntry_GetType (pEntry);
switch (EntryType)
{
case UNDO_MOVE :
{
int i;
UndoMoveEntry *pMove;
geVec3d UndoVec;
ResetAllSelections ();
pMove = UndoStackEntry_GetMoveInfo (pEntry);
geVec3d_Scale (&(pMove->MoveDelta), -1.0f, &UndoVec);
for (i = 0; i < Array_GetSize (pMove->BrushArray); ++i)
{
Brush *pBrush;
pBrush = (Brush *)Array_ItemPtr (pMove->BrushArray, i);
Brush_Move (pBrush, &UndoVec);
SelListAddBrush (pBrush);
}
for (i = 0; i < Array_GetSize (pMove->EntityArray); ++i)
{
CEntity *pEnt;
pEnt = (CEntity *)Array_ItemPtr (pMove->EntityArray, i);
SelectEntity (pEnt);
}
UpdateSelected ();
if (GetSelState() & ANYENTITY)
{
DoneMoveEntity();
}
// Be very careful when speccing flags for UpdateAllViews()
// The wrong flags at the wrong time will totally screw things up
UpdateAllViews( UAV_ALL3DVIEWS, NULL );
break;
}
default :
assert (0);
break;
}
UndoStackEntry_Destroy (&pEntry);
#endif
}
void CGenEditDoc::OnUpdateEditUndo(CCmdUI* pCmdUI)
{
pCmdUI->Enable (CanUndo ());
}
//unimplemented currently
void CGenEditDoc::OnEditRedo()
{
// CurBrush->RedoLast();
// Be very careful when speccing flags for UpdateAllViews()
// The wrong flags at the wrong time will totally screw things up
// UpdateAllViews(UAV_ALLVIEWS, NULL);
}
void CGenEditDoc::OnUpdateEditRedo(CCmdUI* pCmdUI)
{
pCmdUI->Enable (CanRedo ());
}
/* ALL OBSOLETE
void CGenEditDoc::OnEntitiesEditor()
{
// CEntitiesDialog Dialog (AfxGetMainWnd ()); // old gedit
////////////////////////////////////////////////////////////////////////////////////////
//////////// PREPARING FOR PROPERTIES BUILD DIALOG ////////////////////////////////
// CPropertiesDlg *Dialog; // new g3dc
// CMainFrame* pMainFrame = CGlobals::GetActiveDocument()->mpMainFrame; // new g3dc
// pMainFrame->SetupPropBuildDialogControls(); // new g3dc
////////////////////////////////////////////////////////////////////////////////////////
CEntityArray *Entities = Level_GetEntities (pLevel);
////////////////////////////////////////////////////////////////////////////////////////
///////////// PUTTING ENTITY EDITOR ONTO THE PROPERTIES PANEL /////////////////////////
mpMainFrame->m_dPropEntitiesDialog.EditEntity(*Entities, mCurrentEntity, this);
// Dialog.EditEntity( *Entities, mCurrentEntity, this); // old gedit
UpdateEntityOrigins();
// Be very careful when speccing flags for UpdateAllViews()
// The wrong flags at the wrong time will totally screw things up
UpdateAllViews(UAV_ALL3DVIEWS, NULL);
SetModifiedFlag();
}
/////////////////// new g3dc ////////////////////////////////////////
void CGenEditDoc::ShowEntitiesEditor()
{
// CEntitiesDialog Dialog (AfxGetMainWnd ()); // old gedit
////////////////////////////////////////////////////////////////////////////////////////
//////////// PREPARING FOR PROPERTIES BUILD DIALOG ////////////////////////////////
// CPropertiesDlg *Dialog; // new g3dc
// CMainFrame* pMainFrame = CGlobals::GetActiveDocument()->mpMainFrame; // new g3dc
// pMainFrame->SetupPropBuildDialogControls(); // new g3dc
////////////////////////////////////////////////////////////////////////////////////////
CEntityArray *Entities = Level_GetEntities (pLevel);
////////////////////////////////////////////////////////////////////////////////////////
///////////// PUTTING ENTITY EDITOR ONTO THE PROPERTIES PANEL /////////////////////////
// mpMainFrame->m_dPropBrushAttributesDialog.ShowWindow(SW_HIDE);
mpMainFrame->m_dPropEntitiesDialog.ShowWindow(SW_SHOW);
mpMainFrame->m_dPropEntitiesDialog.EditEntity(*Entities, mCurrentEntity, this);
UpdateEntityOrigins();
// Be very careful when speccing flags for UpdateAllViews()
// The wrong flags at the wrong time will totally screw things up
UpdateAllViews(UAV_ALL3DVIEWS, NULL);
SetModifiedFlag();
}
////////////////////////////////////////////////////////////////////////////////////////
END ALL OBSOLETE
*/
geBoolean CGenEditDoc::CreateEntityFromName
(
char const *pEntityType,
CEntity &NewEnt
)
{
assert (pEntityType != NULL);
// get all properties for this entity type...
EntityPropertiesList *pProps;
pProps = EntityTable_GetEntityPropertiesFromName (Level_GetEntityDefs (pLevel), pEntityType, ET_ALL);
if (pProps == NULL)
{
return FALSE;
}
// Add key/value pairs for all of the properties...
for (int PropNo = 0; PropNo < pProps->NumProps; ++PropNo)
{
EntityProperty *p = &(pProps->Props[PropNo]);
NewEnt.SetKeyValue (p->pKey, p->pValue);
}
EntityTable_ReleaseEntityProperties (pProps);
NewEnt.SetGroupId ( 0 );
NewEnt.UpdateOrigin (Level_GetEntityDefs (pLevel));
return TRUE;
}
void CGenEditDoc::CreateEntity(char const *pEntityType)
{
CEntity NewEnt;
if (CreateEntityFromName (pEntityType, NewEnt))
{
TempEnt = TRUE;
mRegularEntity = NewEnt;
mCurrentEntity = -1;
// set this flag so that doc knows when enter is pressed that user is NOT adding
// objects to level
PlaceObjectFlag = FALSE;
mCurrentTool=ID_TOOLS_BRUSH_MOVEROTATEBRUSH;
// g3dc tuning comment
ConfigureCurrentTool(); // already calls UpdateAllViews()
// Be very careful when speccing flags for UpdateAllViews()
// The wrong flags at the wrong time will totally screw things up
// g3dc tuning comment
// UpdateAllViews(UAV_ALL3DVIEWS, NULL); // already called by Configure CurrentTool
SetModifiedFlag();
}
}
// creates a template entity with which the user specifies a location for any
// objects they place
void CGenEditDoc::CreateObjectTemplate()
{
CEntity NewEnt;
// make an origin
if (CreateEntityFromName ("ModelOrigin", NewEnt))
{
TempEnt=TRUE;
NewEnt.SetOrigin (0.0f, 0.0f, 0.0f, Level_GetEntityDefs (pLevel));
mRegularEntity=NewEnt;
mCurrentEntity=-1;
// set this flag so that doc knows when enter is pressed that user is adding objects
// to level
PlaceObjectFlag = TRUE; // old gedit
mCurrentTool=ID_TOOLS_BRUSH_MOVEROTATEBRUSH;
// g3dc tuning comment
// already calls UpdateAllViews()
ConfigureCurrentTool();
// Be very careful when speccing flags for UpdateAllViews()
// The wrong flags at the wrong time will totally screw things up
// g3dc tuning comment
// ConfigureCurrentTool() already calls UpdateAllViews()
// UpdateAllViews(UAV_ALL3DVIEWS, NULL);
SetModifiedFlag();
}
}
void CGenEditDoc::ResetAllSelections (void)
{
ResetAllSelectedFaces();
ResetAllSelectedBrushes();
ResetAllSelectedEntities();
}
void CGenEditDoc::OnEntitiesShow(void)
{
mShowEntities = !mShowEntities;
// Be very careful when speccing flags for UpdateAllViews()
// The wrong flags at the wrong time will totally screw things up
UpdateAllViews(UAV_ALL3DVIEWS, NULL);
}
void CGenEditDoc::OnUpdateEntitiesShow(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck( mShowEntities );
}
void CGenEditDoc::OnViewShowAllGroups()
{
CurBrush =BTemplate;
Level_SetGroupVisibility (pLevel, Group_ShowAll);
// Be very careful when speccing flags for UpdateAllViews()
// The wrong flags at the wrong time will totally screw things up
UpdateAllViews(UAV_ALL3DVIEWS, NULL);
}
void CGenEditDoc::OnViewShowCurrentGroup()
{
CurBrush = BTemplate;
Level_SetGroupVisibility (pLevel, Group_ShowCurrent);
// Be very careful when speccing flags for UpdateAllViews()
// The wrong flags at the wrong time will totally screw things up
UpdateAllViews(UAV_ALL3DVIEWS, NULL);
}
void CGenEditDoc::OnViewShowVisibleGroups()
{
CurBrush =BTemplate;
Level_SetGroupVisibility (pLevel, Group_ShowVisible);
// Be very careful when speccing flags for UpdateAllViews()
// The wrong flags at the wrong time will totally screw things up
UpdateAllViews(UAV_ALL3DVIEWS, NULL);
}
void CGenEditDoc::OnUpdateViewShowVisibleGroups(CCmdUI* pCmdUI)
{
BOOL bEnable ;
int Setting;
Setting = Level_GetGroupVisibility (pLevel);
bEnable = ( Group_GetCount( Level_GetGroups (pLevel)) ) ? TRUE : FALSE ;
if (((pCmdUI->m_nID == ID_VIEW_SHOW_ALLGROUPS) && (Setting == Group_ShowAll)) ||
((pCmdUI->m_nID == ID_VIEW_SHOW_CURRENTGROUP) && (Setting == Group_ShowCurrent)) ||
((pCmdUI->m_nID == ID_VIEW_SHOW_VISIBLEGROUPS) && (Setting == Group_ShowVisible)))
{
pCmdUI->SetCheck();
}
else
{
pCmdUI->SetCheck(0);
}
pCmdUI->Enable( bEnable ) ;
}
void CGenEditDoc::OnUpdateViewShowAllGroups(CCmdUI* pCmdUI)
{
OnUpdateViewShowVisibleGroups( pCmdUI ) ;
}
void CGenEditDoc::OnUpdateViewShowCurrentGroup(CCmdUI* pCmdUI)
{
OnUpdateViewShowVisibleGroups( pCmdUI ) ;
}
int CGenEditDoc::CanUndo()
{
return !(UndoStack_IsEmpty (pUndoStack));
}
void CGenEditDoc::SaveBrushUndo()
{
}
int CGenEditDoc::CanRedo()
{
return 0;
}
void CGenEditDoc::UpdateEntityOrigins()
{
int i;
CEntityArray *Entities;
Entities = Level_GetEntities (pLevel);
for(i=0;i < Entities->GetSize();i++)
{
(*Entities)[i].UpdateOrigin(Level_GetEntityDefs (pLevel));
}
}
void CGenEditDoc::MoveEntity(geVec3d *v)
{
assert (v != NULL);
if(mCurrentEntity < 0) //template
{
mRegularEntity.Move (v);
}
else
{
CEntityArray *Entities = Level_GetEntities (pLevel);
(*Entities)[mCurrentEntity].Move(v);
SetModifiedFlag();
}
}
static geBoolean fdocBrushNotDetail (const Brush *b)
{
return !Brush_IsDetail (b);
}
static geBoolean fdocBrushIsSubtract (const Brush *b)
{
return (Brush_IsSubtract (b) && !Brush_IsHollowCut (b));
}
CEntity *CGenEditDoc::FindCameraEntity (void)
{
CEntityArray *Entities = Level_GetEntities (pLevel);
int i;
for (i = 0; i < Entities->GetSize (); ++i)
{
CEntity *pEnt;
pEnt = &(*Entities)[i];
if (pEnt->IsCamera ())
{
return pEnt;
}
}
return NULL;
}
//need to put this somewhere
#define VectorToSUB(a, b) (*((((geFloat *)(&a))) + (b)))
void CGenEditDoc::RenderOrthoView(ViewVars *v, CDC *pDC)
{
int
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -