📄 leveledit.cpp
字号:
glPushMatrix(); // Store The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
glOrtho(0,640,0,480,-1,1); // Set UP An Ortho Screen
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glPushMatrix(); // Store The Modelview Matrix
glLoadIdentity(); // Reset The Modelview Matrix
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
glOrtho(0,640,0,480,-1,1); // Set UP An Ortho Screen
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glDisable(GL_COLOR_MATERIAL);
glDisable(GL_LIGHT0);
glDisable(GL_LIGHTING);
}
void DoneText()
{
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glPopMatrix(); // Restore The Old Projection Matrix
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glPopMatrix(); // Restore The Old Projection Matrix
glEnable(GL_DEPTH_TEST); // Enables DePth Testing
glDisable(GL_TEXTURE_2D);
}
void AddToUndoList()
{
long I;
if(!UnDoOn) return;
DestroySector(UndoList[UndoSteps-1]);
for(I=UndoSteps-1;I>0;I--)
{
UndoList[I]=UndoList[I-1];
}
UndoList[0]=CopySector(Level,NULL,true,true);
}
void GetAktSector()
{
AktSector=GetSubSectorNr(Level,ASNr);
}
void MyCalcCommand(tCommand *C,tSector *Sec)
{
CalcCommand(C,Sec);
GetAktSector();
CreateSectorDL(AktSector,false);
}
void SaveLevelWindows() // Saved n Model
{
OPENFILENAME ofn; /* common dialog box structure */
char szDirName[MAX_PATH]; /* directory string */
char szFile[4096]; /* filename string */
char szFileTitle[4096]; /* filename string */
/*
hinst = (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE);
*/
/*
Obtain the system directory name and store it in szDirName.
*/
GetSystemDirectory(szDirName, sizeof(szDirName));
/*
Place the terminating null character in the szFile.
*/
szFile[0] = '\0';
/*
Set the members of the OPENFILENAME structure.
*/
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = MainWindow;
ofn.lpstrTitle = "Save Level/Model File\0";
ofn.lpstrFilter = "B-Clopd3D Level Files (*.BCL)\0*.BCL\0All files (*.*)\0*.*\0\0";
ofn.lpstrCustomFilter = NULL;
ofn.nFilterIndex = 1;
ofn.lpstrFile = szFile;
ofn.nMaxFile = 2048;
ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = 2048;
ofn.lpstrInitialDir = ".\0";
ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST /*| OFN_ALLOWMULTISELECT*/;
/*
Display the Open dialog box.
*/
if (GetSaveFileName(&ofn))
{
char *path = ofn.lpstrFile;
char *fname = ofn.lpstrFile;
char *outp;
SaveLevel(fname,CommandList);
};
}
void LoadLevelWindows() // L鋎t ne .dat
{
OPENFILENAME ofn; /* common dialog box structure */
char szDirName[MAX_PATH]; /* directory string */
char szFile[4096]; /* filename string */
char szFileTitle[4096]; /* filename string */
long I,K,M;
/*
hinst = (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE);
*/
/*
Obtain the system directory name and store it in szDirName.
*/
GetSystemDirectory(szDirName, sizeof(szDirName));
/*
Place the terminating null character in the szFile.
*/
szFile[0] = '\0';
/*
Set the members of the OPENFILENAME structure.
*/
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = MainWindow;
ofn.lpstrTitle = "Load Level/Model File\0";
ofn.lpstrFilter = "B-Clopd3D Level Files (*.bcl)\0*.bcl\0All files (*.*)\0*.*\0\0";
ofn.lpstrCustomFilter = NULL;
ofn.nFilterIndex = 1;
ofn.lpstrFile = szFile;
ofn.nMaxFile = 2048;
ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = 2048;
ofn.lpstrInitialDir = ".\0";
ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
/*
Display the Open dialog box.
*/
if (GetOpenFileName(&ofn))
{
char *path = ofn.lpstrFile;
char *fname = ofn.lpstrFileTitle;
char *outp;
strcpy(LastFileName,fname);
// LoadDaAnimation(fname);
DestroyCommand(CommandList);
DestroySector(Level);
CommandList=LoadLevel(fname);
Level=ReCalcCommandList(CommandList);
for(I=0;I<UndoSteps;I++) UndoList[I]=NULL;
#ifdef ReduceFak
ReduceSector(Level,ReduceFak);
#endif
// ReduceSector(Level,0.13,0.15);
/* ReduceSector(Level,0.24);
ReduceSector(Level,0.24);
ReduceSector(Level,0.24);
*/
CreateSectorDL(Level,true);
AddToUndoList();
ASNr=2;
GetAktSector();
SetResSec(ASNr,Level);
ResNr=ASNr;
};
SetCursorPos(ScreenXSize/2,ScreenYSize/2);
MX=0;
MY=0;
mouse_klick=0;
mouselklick=0;
}
void DrawRectangle(long X1,long Y1,long X2,long Y2,float CR,float CG,float CB)
{
glLoadIdentity(); // Reset The Projection Matrix
glOrtho(0,ScreenXSize,0,ScreenYSize,1,1); // Set Up An Ortho Screen
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glDisable(GL_TEXTURE_2D);
glColor3f(CR,CG,CB);
glBegin(GL_LINES); // Start Drawing Our Player Using Lines
glVertex3f(X1,Y1,0);
glVertex3f(X2,Y1,0);
glVertex3f(X1,Y2,0);
glVertex3f(X2,Y2,0);
glVertex3f(X1,Y1,0);
glVertex3f(X1,Y2,0);
glVertex3f(X2,Y1,0);
glVertex3f(X2,Y2,0);
glEnd();
}
void DrawMenuItem(tMenuItem Item,float CR,float CG,float CB)
{
InitText();
// glColor3f(1,1,1);
glColor3f(Item.C1,Item.C2,Item.C3);
glPrint(Item.X,Item.Y,Item.Text);
DrawRectangle(Item.X1,Item.Y1,Item.X2,Item.Y2,CR,CG,CB);
DoneText();
}
bool MouseOverItem(tMenuItem Item)
{
return((MX>=Item.X1)&&(MX<=Item.X2)&&(MY>=Item.Y1)&&(MY<=Item.Y2));
}
void DrawItemWithCol(tMenuItem Item)
{
if(MouseOverItem(Item))
{DrawMenuItem(Item,1,0,0);}
else
{DrawMenuItem(Item,1,1,1);}
}
void DrawStats()
{
long M,N,S;
tP3D TempV;
InitText();
glColor3f(1,1,1);
/*
glPrint(10,200,TestString);
glPrint(10,400,"Err1 : %f.4,%f.4",Err1.X,Err1.Y);
glPrint(10,380,"Err2 : %f.4,%f.4",Err2.X,Err2.Y);
glPrint(10,360,"Err3 : %f.4,%f.4",Err3.X,Err3.Y);
glPrint(10,340,"Err4 : %f.4,%f.4",Err4.X,Err4.Y);
glPrint(10,320,"Err5 : %f.4,%f.4",Err5.X,Err5.Y);
glPrint(10,300,"Err6 : %f.4,%f.4",Err6.X,Err6.Y);
*/
glPrint(550,460,"FpS:%d",FramesPS);
// glPrint(550,460,ToString("FpS:%d",FramesPS));
glPrint(430,440,"Commands:%d (%db)",CountCommandList(CommandList),SizeOfCommandList(CommandList));
// glPrint(550,420,ToString("SelV:%d",SelV));
if(Level->SubSector!=NULL)
{
GetAktSector();
glPrint(500,400,ToString("Polys:%d",CountPolys(AktSector->Mesh->Poly)));
glPrint(500,380,ToString("Verts:%d",CountVertices(AktSector->Mesh->Vertice)));
glPrint(500,320,"OPolys:%d",GetSectorPolys(AktSector,true,false));
/*
TempV=AktSector->WSize;
glPrint(10,360,"%f.4,%f.4,%f.4",TempV.X,TempV.Y,TempV.Z);
TempV=AktSector->Matrix.Up;
glPrint(10,340,"%f.4,%f.4,%f.4",TempV.X,TempV.Y,TempV.Z);
TempV=AktSector->Matrix.Left;
glPrint(10,320,"%f.4,%f.4,%f.4",TempV.X,TempV.Y,TempV.Z);
TempV=AktSector->Matrix.Forward;
glPrint(10,300,"%f.4,%f.4,%f.4",TempV.X,TempV.Y,TempV.Z);
*/
}
glPrint(500,360,ToString("ASNr:%d",ASNr));
glPrint(500,340,ToString("SelO:%d",SelO));
glPrint(500,250,"TexX:%f",TexXS);
glPrint(500,230,"TexY:%f",TexYS);
glPrint(10,400,"Rotation:%1.2f Grad",MainRotAmount);
if(!InsertMove) glPrint(10,380,"No InsertMove");
if(((MenuMode==_Change_Flags)&&(AktSector!=NULL))||
((MenuMode==_Create_Item)&&(AktSector!=NULL))
)
{
glPrint(80,15,"%d",AktSector->Attr2);
glPrint(200,15,"%d",AktSector->Attr3);
glPrint(320,15,"%d",AktSector->Attr4);
if((AktSector->Flags&_SF_Effect)&&(AktSector->Attr==_SF_Effect_Flamer))
{ glPrint(25,165,"On"); } else { glPrint(25,165,"Off"); }
if((AktSector->Flags&_SF_Effect)&&(AktSector->Attr==_SF_Effect_Water))
{ glPrint(95,165,"On"); } else { glPrint(95,165,"Off"); }
if((AktSector->Flags&_SF_Effect)&&(AktSector->Attr==_SF_Effect_Swing))
{ glPrint(165,165,"On"); } else { glPrint(165,165,"Off"); }
if((AktSector->Flags&_SF_Effect)&&(AktSector->Attr==_SF_Effect_Move))
{ glPrint(235,165,"On"); } else { glPrint(235,165,"Off"); }
if((AktSector->Flags&_SF_Bumper))
{ glPrint(300,395,"On"); } else { glPrint(300,395,"Off"); }
if((AktSector->Flags&_SF_Dead))
{ glPrint(300,365,"On"); } else { glPrint(300,365,"Off"); }
if((AktSector->Flags&_SF_WalkThrough))
{ glPrint(85,395,"On"); } else { glPrint(85,395,"Off"); }
if((AktSector->Flags&_SF_SkeletonNode))
{ glPrint(105,365,"On"); } else { glPrint(105,365,"Off"); }
if((AktSector->Flags&_SF_Player)&&(AktSector->Attr==0))
{ glPrint(25,305,"On"); } else { glPrint(25,305,"Off"); }
if((AktSector->Flags&_SF_Player)&&(AktSector->Attr==1))
{ glPrint(100,305,"On"); } else { glPrint(100,305,"Off"); }
if((AktSector->Flags&_SF_Player)&&(AktSector->Attr==2))
{ glPrint(180,305,"On"); } else { glPrint(180,305,"Off"); }
if((AktSector->Flags&_SF_Player)&&(AktSector->Attr==3))
{ glPrint(220,305,"On"); } else { glPrint(220,305,"Off"); }
if((AktSector->Flags&_SF_Player)&&(AktSector->Attr==4))
{ glPrint(280,305,"On"); } else { glPrint(280,305,"Off"); }
if((AktSector->Flags&_SF_Player)&&(AktSector->Attr==5))
{ glPrint(350,305,"On"); } else { glPrint(350,305,"Off"); }
if((AktSector->Flags&_SF_ItemBox)&&(AktSector->Attr==0))
{ glPrint(25,245,"On"); } else { glPrint(25,245,"Off"); }
if((AktSector->Flags&_SF_ItemBox)&&(AktSector->Attr==1))
{ glPrint(105,245,"On"); } else { glPrint(105,245,"Off"); }
if((AktSector->Flags&_SF_ItemBox)&&(AktSector->Attr==_ItemBox_Continue))
{ glPrint(205,245,"On"); } else { glPrint(205,245,"Off"); }
if((AktSector->Flags&_SF_ItemBox)&&(AktSector->Attr==_ItemBox_LevEnd))
{ glPrint(295,245,"On"); } else { glPrint(295,245,"Off"); }
if((AktSector->Flags&_SF_ItemBox)&&(AktSector->Attr==_ItemBox_Gun2))
{ glPrint(365,245,"On"); } else { glPrint(365,245,"Off"); }
}
/*
if(AktObj!=NULL)
{
M=(AktObj->Poly->T1.X*1000);N=(AktObj->Poly->T1.Y*1000);S=(AktObj->Poly->T1.Z*1000);
glPrint(10,300,ToString("%d",M)); glPrint(80,300,ToString("%d",N)); glPrint(150,300,ToString("%d",S));
M=(AktObj->Poly->T2.X*1000);N=(AktObj->Poly->T2.Y*1000);S=(AktObj->Poly->T2.Z*1000);
glPrint(10,280,ToString("%d",M)); glPrint(80,280,ToString("%d",N));glPrint(150,280,ToString("%d",S));
M=(AktObj->Poly->T3.X*1000);N=(AktObj->Poly->T3.Y*1000);S=(AktObj->Poly->T3.Z*1000);
glPrint(10,260,ToString("%d",M)); glPrint(80,260,ToString("%d",N));glPrint(150,260,ToString("%d",S));
}
*/
/*
if(AktSector->Mesh!=NULL)
{
glPrint(0,40,"Vertices:%d Polys:%d",AktSector->Mesh->Vertices,AktSector->Mesh->Polys);
}
*/
DrawItemWithCol(MINewLevel);
DrawItemWithCol(MILoadLevel);
DrawItemWithCol(MISaveLevel);
DrawItemWithCol(MIInsert);
if(UnDoOn) DrawItemWithCol(MIUndo);
DrawItemWithCol(MIClone);
if(MenuMode!=_Main_Menu) DrawItemWithCol(MIBack);
if(MenuMode==_Main_Menu)
{
DrawItemWithCol(MICreatePrimitive);
DrawItemWithCol(MIModify);
DrawItemWithCol(MISelectObject);
DrawItemWithCol(MIMakeSub);
DrawItemWithCol(MIUnSub);
DrawItemWithCol(MIMerge);
}
if(MenuMode==_Create_Primitive)
{
DrawItemWithCol(MIPlattform);
DrawItemWithCol(MIPlane);
DrawItemWithCol(MIKegel);
DrawItemWithCol(MITorus);
DrawItemWithCol(MICylinder);
DrawItemWithCol(MIItem);
}
if(MenuMode==_Create_Cube)
{
DrawItemWithCol(MIParts1Plus);
DrawItemWithCol(MIParts1Minus);
DrawItemWithCol(MIParts2Plus);
DrawItemWithCol(MIParts2Minus);
}
if(MenuMode==_Create_Plane)
{
DrawItemWithCol(MIParts1Plus);
DrawItemWithCol(MIParts1Minus);
DrawItemWithCol(MIParts2Plus);
DrawItemWithCol(MIParts2Minus);
}
if(MenuMode==_Create_Kegel)
{
DrawItemWithCol(MIAttr1Plus);
DrawItemWithCol(MIAttr1Minus);
DrawItemWithCol(MIAttr2Plus);
DrawItemWithCol(MIAttr2Minus);
DrawItemWithCol(MIAttr3Plus);
DrawItemWithCol(MIAttr3Minus);
}
if(MenuMode==_Create_Torus)
{
DrawItemWithCol(MIParts2Plus);
DrawItemWithCol(MIParts2Minus);
DrawItemWithCol(MIAttr1Plus);
DrawItemWithCol(MIAttr1Minus);
DrawItemWithCol(MIAttr2Plus);
DrawItemWithCol(MIAttr2Minus);
}
if(MenuMode==_Create_Cylinder)
{
DrawItemWithCol(MIParts2Plus);
DrawItemWithCol(MIParts2Minus);
DrawItemWithCol(MIAttr1Plus);
DrawItemWithCol(MIAttr1Minus);
DrawItemWithCol(MIAttr2Plus);
DrawItemWithCol(MIAttr2Minus);
}
if(MenuMode==_Modify)
{
DrawItemWithCol(MIModifyVertex);
// DrawItemWithCol(MIModellieren);
DrawItemWithCol(MISetMaterial);
DrawItemWithCol(MIChangeFlags);
DrawItemWithCol(MISize);
DrawItemWithCol(MISizeX);
DrawItemWithCol(MISizeY);
DrawItemWithCol(MISizeZ);
DrawItemWithCol(MIPos);
DrawItemWithCol(MIPosXZ);
DrawItemWithCol(MIPosY);
DrawItemWithCol(MIMMPos);
DrawItemWithCol(MIMMPosXZ);
DrawItemWithCol(MIMMPosY);
DrawItemWithCol(MIRotX);
DrawItemWithCol(MIRotY);
DrawItemWithCol(MIRotZ);
}
if(MenuMode==_Change_Flags)
{
DrawItemWithCol(MIWalkThrough);
DrawItemWithCol(MIDead);
DrawItemWithCol(MISkeletonNode);
DrawItemWithCol(MIPlayer);
DrawItemWithCol(MIFlamer);
DrawItemWithCol(MIWater);
DrawItemWithCol(MISwing);
DrawItemWithCol(MIMove);
DrawItemWithCol(MIBumper);
DrawItemWithCol(MIEnemy1);
DrawItemWithCol(MISecAttr);
DrawItemWithCol(MISecAttr2);
DrawItemWithCol(MISecAttr3);
DrawItemWithCol(MIEnemy2);
DrawItemWithCol(MIEnemy3);
DrawItemWithCol(MIEnemy4);
DrawItemWithCol(MIEnemy5);
DrawItemWithCol(MIBoxGun1);
DrawItemWithCol(MIBoxMediKit);
DrawItemWithCol(MIBoxContinue);
DrawItemWithCol(MIBoxLevEnd);
DrawItemWithCol(MIBoxGun2);
}
if(MenuMode==_Create_Item)
{
DrawItemWithCol(MISkeletonNode);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -