📄 geneditdoc.cpp
字号:
Brush_SetName(b, TexName);
if(Brush_IsMulti(b))
{
const BrushList *BList; // post 0.55
BList = Brush_GetBrushList(b);
if (BList == NULL)
{
MessageBox(NULL, "BrushList == NULL", "GenEditDoc SetDefaultBrushTexInfo", MB_OK);
return;
}
else
BrushList_EnumLeafBrushes (BList, &CallbackData, ::BrushTexSetCB) ;
}
else
{
::BrushTexSetCB (b, &CallbackData);
}
}
// Test BOTH group and brush visiblity--group overrides
// User flags for All, Visible, and Current group must be considered
geBoolean CGenEditDoc::BrushIsVisible( const Brush * pBrush ) const
{
int GroupId ;
if (!Brush_IsVisible (pBrush))
{
return GE_FALSE;
}
GroupId = Brush_GetGroupId (pBrush);
switch (Level_GetGroupVisibility (pLevel))
{
case Group_ShowAll :
return GE_TRUE;
case Group_ShowCurrent :
return (GroupId == mCurrentGroup);
case Group_ShowVisible :
return Group_IsVisible (Level_GetGroups (pLevel), GroupId);
default :
assert (0);
return GE_FALSE;
}
}/* CGenEditDoc::BrushIsVisible */
// Test BOTH group and entity visiblity--group overrides
// User flags for All, Visible, and Current group must be considered
geBoolean CGenEditDoc::EntityIsVisible( const CEntity *pEntity ) const
{
int GroupId ;
if (pEntity->IsCamera ())
{
return pEntity->IsVisible ();
}
if ((mShowEntities == GE_FALSE) || !pEntity->IsVisible ())
{
return GE_FALSE ;
}
GroupId = pEntity->GetGroupId( );
switch (Level_GetGroupVisibility (pLevel))
{
case Group_ShowAll :
return GE_TRUE;
case Group_ShowCurrent :
return (GroupId == mCurrentGroup);
case Group_ShowVisible :
return Group_IsVisible (Level_GetGroups (pLevel), GroupId);
default :
assert (0);
return GE_FALSE;
}
}/* CGenEditDoc::EntityIsVisible */
void CGenEditDoc::CreateNewTemplateBrush( Brush *pBrush)
{
geVec3d *pTemplatePos;
geVec3d MoveVec;
geVec3d BrushPos;
assert (pBrush != NULL);
if (BTemplate != NULL)
{
Brush_Destroy (&BTemplate);
}
BTemplate = pBrush;
CurBrush = pBrush;
TempEnt = FALSE;
SetDefaultBrushTexInfo (CurBrush);
Brush_Bound (CurBrush);
Brush_Center (CurBrush, &BrushPos);
pTemplatePos = Level_GetTemplatePos (pLevel);
geVec3d_Subtract (pTemplatePos, &BrushPos, &MoveVec);
Brush_Move (CurBrush, &MoveVec);
// 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 ();
}
void CGenEditDoc::OnUpdateBrushPrimitives (CCmdUI *pCmdUI)
{
// This function is used by all the primitive UI OnUpdateXXX's
pCmdUI->Enable( (mModeTool == ID_TOOLS_TEMPLATE ) ? TRUE : FALSE ) ;
}
void CGenEditDoc::OnBrushPrimitivesCube()
{
CreateCube() ;
}
void CGenEditDoc::CreateCube()
{
if (mpMainFrame->m_createBoxDialog.m_hWnd != NULL) // new g3dc
return; // already showing
if (pLevel == NULL) // post 0.55
return;
BrushTemplate_Box *pBoxTemplate = Level_GetBoxTemplate (pLevel);
if (pBoxTemplate == NULL) // post 0.55
return;
// CCreateBoxDialog mBoxCreation; // old gedit
// old gedit
// if( mBoxCreation.DoModal((Level_GetGridType (pLevel) == GridMetric), pBoxTemplate) == IDOK )
// create it on the fly and put it as a child on the Propeties panel -- new for g3dc
if (!mpMainFrame->m_createBoxDialog.Create(IDD_CREATEBOX, &mpMainFrame->m_PropertiesPanel))
{
TRACE0("Failed to create m_createBoxDialog\n");
return;
}
mpMainFrame->m_createBoxDialog.ShowDialog((Level_GetGridType (pLevel) == GridMetric), pBoxTemplate, this); // new g3dc
/* {
Brush *pCube;
pCube = ::BrushTemplate_CreateBox (pBoxTemplate);
if (pCube != NULL)
{
CreateNewTemplateBrush (pCube);
}
}
*/ // commented out for new g3dc
}/* CGenEditDoc::CreateCube */
void CGenEditDoc::OnBrushPrimitivesSpheroid()
{
CreateSpheroid() ;
}
void CGenEditDoc::CreateSpheroid()
{
if (mpMainFrame->m_createSpheroidDialog.m_hWnd != NULL) // new g3dc
return; // already showing
if (pLevel == NULL) // post 0.55
return;
BrushTemplate_Spheroid *pTemplate = Level_GetSpheroidTemplate (pLevel);
if (pTemplate == NULL) // post 0.55
return;
/* CCreateSpheroidDialog mSpheroidCreation; // old gedit
if( mSpheroidCreation.DoModal(Level_GetGridType (pLevel) == GridMetric, pTemplate) == IDOK )
{
Brush *pBrush;
pBrush = BrushTemplate_CreateSpheroid (pTemplate);
if (pBrush != NULL)
{
CreateNewTemplateBrush (pBrush);
}
}
*/
// new g3dc
if (!mpMainFrame->m_createSpheroidDialog.Create(IDD_CREATE_SPHEROID, &mpMainFrame->m_PropertiesPanel))
{
TRACE0("Failed to create m_createSpheroidDialog\n");
return;
}
mpMainFrame->m_createSpheroidDialog.ShowDialog(Level_GetGridType (pLevel) == GridMetric, pTemplate, this);
}/* CGenEditDoc::CreateSpheroid */
void CGenEditDoc::OnBrushPrimitivesCylinder()
{
CreateCylinder() ;
}
void CGenEditDoc::CreateCylinder()
{
if (mpMainFrame->m_createCylDialog.m_hWnd != NULL) // new g3dc
return; // already showing
if (pLevel == NULL) // post 0.55
return;
BrushTemplate_Cylinder *pCylTemplate = Level_GetCylinderTemplate (pLevel);
// CCreateCylDialog mCylCreation; // old gedit
if (pCylTemplate == NULL) // post 0.55
return;
// new g3dc
if (!mpMainFrame->m_createCylDialog.Create(IDD_CREATE_CYL, &mpMainFrame->m_PropertiesPanel))
{
TRACE0("Failed to create m_createCylinderDialog\n");
return;
}
mpMainFrame->m_createCylDialog.ShowDialog(Level_GetGridType (pLevel) == GridMetric, pCylTemplate, this);
/* old gedit
if( mCylCreation.DoModal ((Level_GetGridType (pLevel) == GridMetric), pCylTemplate) == IDOK )
{
Brush *pCyl;
pCyl = BrushTemplate_CreateCylinder (pCylTemplate);
if (pCyl != NULL)
{
CreateNewTemplateBrush (pCyl);
}
}
*/
}/* CGenEditDoc::CreateCylinder */
void CGenEditDoc::OnBrushPrimitivesStaircase()
{
CreateStaircase() ;
}
void CGenEditDoc::CreateStaircase()
{
if (mpMainFrame->m_createStaircaseDialog.m_hWnd != NULL) // new g3dc
return; // already showing
if (pLevel == NULL) // post 0.55
return;
// CCreateStaircaseDialog mStairCreation;
BrushTemplate_Staircase *pStairTemplate = Level_GetStaircaseTemplate (pLevel);
if (pStairTemplate == NULL) // post 0.55
return;
// new g3dc
if (!mpMainFrame->m_createStaircaseDialog.Create(IDD_STAIRCASEDIALOG, &mpMainFrame->m_PropertiesPanel))
{
TRACE0("Failed to create m_createStaircaseDialog\n");
return;
}
mpMainFrame->m_createStaircaseDialog.ShowDialog(Level_GetGridType (pLevel) == GridMetric, pStairTemplate, this);
/* old gedit
if( mStairCreation.DoModal(Level_GetGridType (pLevel) == GridMetric, pStairTemplate) == IDOK )
{
Brush *pStair;
pStair = BrushTemplate_CreateStaircase (pStairTemplate);
if (pStair != NULL)
{
CreateNewTemplateBrush (pStair);
}
}
*/
}/* CGenEditDoc::CreateStaircase */
void CGenEditDoc::OnBrushPrimitivesArch()
{
CreateArch ();
}
void CGenEditDoc::CreateArch()
{
if (mpMainFrame->m_createArchDialog.m_hWnd != NULL) // new g3dc
return; // already showing
if (pLevel == NULL) // post 0.55
return;
// CCreateArchDialog mArchCreation;
BrushTemplate_Arch *pArchTemplate = Level_GetArchTemplate (pLevel);
if (pArchTemplate == NULL) // post 0.55
return;
// new g3dc
if (!mpMainFrame->m_createArchDialog.Create(IDD_CREATE_ARCH, &mpMainFrame->m_PropertiesPanel))
{
TRACE0("Failed to create m_createArchDialog\n");
return;
}
mpMainFrame->m_createArchDialog.ShowDialog(Level_GetGridType (pLevel) == GridMetric, pArchTemplate, this);
/* old gedit
if( mArchCreation.DoModal((Level_GetGridType (pLevel) == GridMetric), pArchTemplate) == IDOK )
{
Brush *pArch;
pArch = BrushTemplate_CreateArch (pArchTemplate);
if (pArch != NULL)
{
CreateNewTemplateBrush (pArch);
}
}
*/
}/* CGenEditDoc::CreateArch */
void CGenEditDoc::OnBrushPrimitivesCone()
{
CreateCone ();
}
void CGenEditDoc::CreateCone()
{
if (mpMainFrame->m_createConeDialog.m_hWnd != NULL) // new g3dc
return; // already showing
if (pLevel == NULL) // post 0.55
return;
// CCreateConeDialog mConeCreation;
BrushTemplate_Cone *pConeTemplate = Level_GetConeTemplate (pLevel);
if (pConeTemplate == NULL) // post 0.55
return;
// new g3dc
if (!mpMainFrame->m_createConeDialog.Create(IDD_CREATE_CONE, &mpMainFrame->m_PropertiesPanel))
{
TRACE0("Failed to create m_createConeDialog\n");
return;
}
mpMainFrame->m_createConeDialog.ShowDialog(Level_GetGridType (pLevel) == GridMetric, pConeTemplate, this);
// old gedit
/* if( mConeCreation.DoModal ((Level_GetGridType (pLevel) == GridMetric), pConeTemplate) == IDOK )
{
Brush *pCone;
pCone = BrushTemplate_CreateCone (pConeTemplate);
if (pCone != NULL)
{
CreateNewTemplateBrush (pCone);
}
}
*/
}
void CGenEditDoc::BrushSelect(Brush *pBrush)
{
// if the brush is already selected, then unselect it.
// if not currently selected, then select it.
if (!SelBrushList_Remove (pSelBrushes, pBrush))
{
SelBrushList_Add (pSelBrushes, pBrush);
// update all selcetions. Prevent unintended selections
// across groups. // new g3dc
mpMainFrame->UpdateMainControls(); // new g3dc
}
}
geBoolean CGenEditDoc::BrushIsSelected(Brush const *pBrush)
{
assert (pBrush != NULL);
return SelBrushList_Find (pSelBrushes, pBrush);
}
void CGenEditDoc::OnToolsUsegrid()
{
GridInfo *pGridInfo = Level_GetGridInfo (pLevel);
pGridInfo->UseGrid = !(pGridInfo->UseGrid);
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);
}
void CGenEditDoc::OnUpdateToolsUsegrid(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck( Level_UseGrid (pLevel));
}
void CGenEditDoc::OnToolsGridsettings()
{
/* int gdex[3]={GridSize_Centimeter, GridSize_Decimeter, GridSize_Meter};
CGridSizeDialog dlg;
GridInfo *pGridInfo;
static int TexelSnapValues[] = {1, 2, 4, 8, 16, 32};
static int nSnapValues = sizeof (TexelSnapValues)/sizeof (int);
pGridInfo = Level_GetGridInfo (pLevel);
dlg.m_UseSnap =pGridInfo->UseGrid;
dlg.m_SnapDegrees =pGridInfo->RotationSnap;
dlg.MetricOrTexelSnap =pGridInfo->SnapType;
dlg.MetricOrTexelGrid =pGridInfo->GridType;
if( dlg.MetricOrTexelSnap == 0 )
{
switch(pGridInfo->MetricSnapSize)
{
case GridSize_Centimeter:
dlg.m_GridUnits =0;
break;
case GridSize_Decimeter:
dlg.m_GridUnits =1;
break;
case GridSize_Meter:
dlg.m_GridUnits =2;
break ;
}
}
else
{
int i;
dlg.m_GridUnits = 0;
for (i = 0; i < nSnapValues; ++i)
{
if (pGridInfo->TexelSnapSize == TexelSnapValues[i])
{
dlg.m_GridUnits = i;
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -