#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
#define KEYDOWN(name) ((GetAsyncKeyState(name) & 0x8000)?1:0)
using namespace std;
HWND now_window=GetForegroundWindow();//当前窗口
struct xy
{
	int x,y;
};
string file,deep;
int n,m;
int mr[500][500];
int mg[500][500];
int mb[500][500];
int mu[500][500];
int r=255,g=255,b=255;
xy mouse_point()//获取鼠标字符位置 
{
	HANDLE hOutput=GetStdHandle(STD_OUTPUT_HANDLE);
	if(hOutput==INVALID_HANDLE_VALUE)
		return {0,0};
	CONSOLE_FONT_INFO ft_size;
	if(!GetCurrentConsoleFont(hOutput,FALSE,&ft_size))
		return {0,0};
	POINT p;
	GetCursorPos(&p);
	ScreenToClient(GetForegroundWindow(),&p);
	return {p.y/ft_size.dwFontSize.Y,p.x/ft_size.dwFontSize.X};
}
void gotoxy(int x,int y)//移动输出位置 
{
	COORD pos={y,x};
	HANDLE hOut=GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleCursorPosition(hOut,pos);
}
void gotoxy(xy po)//移动输出位置 
{
	COORD pos={po.y,po.x};
	HANDLE hOut=GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleCursorPosition(hOut,pos);
}
void init()
{
	system("color 0");
	CONSOLE_CURSOR_INFO cciCursor;
	HANDLE hStdOut=GetStdHandle(STD_OUTPUT_HANDLE);
	if(GetConsoleCursorInfo(hStdOut,&cciCursor))
	{
		cciCursor.bVisible=FALSE;
		SetConsoleCursorInfo(hStdOut,&cciCursor);
	}
	HANDLE hStdin=GetStdHandle(STD_INPUT_HANDLE);
	DWORD mode;
	GetConsoleMode(hStdin,&mode);
	mode&=~ENABLE_QUICK_EDIT_MODE;
	SetConsoleMode(hStdin,mode);
}
void draw()
{
	for(int i=0;i<=m;i++)
	{
		for(int j=0;j<=n;j++)
		{
			if(!mu[i][j])
			{
				cout<<"■";
			}
			else
			{
				cout<<"  ";
			}
		}
		cout<<"\n";
	}
	cout<<"目前颜色值:"<<r<<" "<<g<<" "<<b<<"\n";
}
xy checkBlock()//检测点击 
{
	xy p=mouse_point();
	for(int i=0;i<=m;i++)
	{
		for(int j=0;j<=n;j++)
		{
			if(p.x==i && (j*2==p.y || j*2+1==p.y) && KEYDOWN(VK_LBUTTON))
			{
				return {i,j};
			}
		}
	}
	return {-1,-1};
}
xy downBlock(bool f=0)//重复检测点击 
{
	xy p=checkBlock();
	while(p.x==-1 && p.y==-1)
	{
		if(f && p.x==-1 && p.y==-1)
			return {-1,-1};
		p=checkBlock();
	}
	return p;
}
struct jhc//几何点 
{
	int x,y,a,b;
	int R,G,B;
};
struct xyc//点 
{
	int x,y;
	int R,G,B;
};
vector<jhc>jhp;
vector<xyc>mdp;
int main()
{
	init();
	cout<<"模型文件名:";cin>>file;
	cout<<"模型深度层次:";cin>>deep;
	cout<<"你预设的模型宽度n<60:";cin>>n;
	cout<<"你预设的模型长度m<30:";cin>>m;
	while(1)
	{
		system("cls");
		draw();
		cout<<"1,完成模型\n2,点阵\n3,几何\n4,修改颜色\n";
		char a;
		a=getch();
		if(a=='1')
		{
			break;
		}
		if(a=='2')
		{
			xy p=downBlock(0);
			while(KEYDOWN(VK_LBUTTON));
			mr[p.x][p.y]=r;
			mg[p.x][p.y]=g;
			mb[p.x][p.y]=b;
			mu[p.x][p.y]=1;
			mdp.push_back({p.x,p.y,r,g,b});
		}
		if(a=='3')
		{
			xy p=downBlock(0);
			//plane 2 10 20
			mu[p.x][p.y]=1;
			system("cls");
			draw();
			while(KEYDOWN(VK_LBUTTON));
			xy q=downBlock(0);
			while(KEYDOWN(VK_LBUTTON));
			for(int i=p.x;i<=q.x;i++)
			{
				for(int j=p.y;j<=q.y;j++)
				{
					mr[i][j]=r;
					mg[i][j]=g;
					mb[i][j]=b;
					mu[i][j]=1;
				}
			}
			jhp.push_back({p.x,p.y,q.x,q.y,r,g,b});
		}
		if(a=='4')
		{
			cout<<"输入R,G,B值:";
			cin>>r>>g>>b;
		}
		Sleep(100);
	}
	ofstream of(file+".model");
	of<<deep<<"\n";
	of<<jhp.size()<<"\n";
	for(int i=0;i<jhp.size();i++)
	{
		of<<jhp[i].y<<" "<<jhp[i].x<<" "<<jhp[i].b<<" "<<jhp[i].a<<" "<<jhp[i].R<<" "<<jhp[i].G<<" "<<jhp[i].B<<"\n";
	}
	of<<mdp.size()<<"\n";
	for(int i=0;i<mdp.size();i++)
	{
		of<<mdp[i].y<<" "<<mdp[i].x<<" "<<mdp[i].R<<" "<<mdp[i].G<<" "<<mdp[i].B<<"\n";
	}
	of.close();
	return 0;
}

附赠小飞机模型

1
14
5 1 9 13 255 255 255
4 7 1 8 255 255 255
1 7 4 8 255 255 255
10 7 13 8 255 255 255
0 8 0 8 255 255 255
14 8 14 8 255 255 255
3 5 4 6 255 255 255
10 5 11 6 255 255 255
7 0 7 0 255 255 255
4 14 5 14 255 255 255
10 14 8 10 255 255 255
10 10 10 10 255 255 255
11 11 11 11 255 255 255
12 12 12 12 255 255 255
10
3 5 255 255 255
4 6 255 255 255
9 14 255 255 255
4 10 255 255 255
4 10 255 255 255
3 11 255 255 255
3 11 255 255 255
2 12 255 255 255
7 6 255 255 255
7 6 255 255 255