|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons,ShellAPI;
type
TForm1 = class(TForm)
EdtName: TEdit;
LbName: TLabel;
EdtInitNum: TEdit;
LbInitNum: TLabel;
LbPos: TLabel;
EdtX: TEdit;
EdtY: TEdit;
EdtZ: TEdit;
EdtaddX: TEdit;
EdtaddY: TEdit;
EdtaddZ: TEdit;
LbAdd: TLabel;
EdtRealNum: TEdit;
LbRealNum: TLabel;
EdtModelName: TEdit;
LbModel: TLabel;
CreateObjBtn: TBitBtn;
BtnAbout: TButton;
ComboBox: TComboBox;
Label1: TLabel;
EdtR: TEdit;
EdtAngleOff: TEdit;
LBR: TLabel;
LBAngle: TLabel;
EdtROff: TEdit;
Label2: TLabel;
EdtSinA: TEdit;
Label3: TLabel;
Label4: TLabel;
EdtSinX: TEdit;
Btnwyzxw: TButton;
Button1: TButton;
Label5: TLabel;
EditSinT: TEdit;
procedure CreateObjBtnClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure EdtInitNumKeyPress(Sender: TObject; var Key: Char);
procedure EdtRealNumKeyPress(Sender: TObject; var Key: Char);
procedure DoDesLineFile();
procedure DoPstFile();
procedure DoDesCycleFile();
procedure DoDesSinFile();
procedure EdtNameKeyPress(Sender: TObject; var Key: Char);
procedure BtnAboutClick(Sender: TObject);
procedure ComboBoxChange(Sender: TObject);
procedure EdtRKeyPress(Sender: TObject; var Key: Char);
procedure EdtROffKeyPress(Sender: TObject; var Key: Char);
procedure EdtAngleOffKeyPress(Sender: TObject; var Key: Char);
procedure EdtSinAKeyPress(Sender: TObject; var Key: Char);
procedure EdtSinXKeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
//row
implementation
var
ObjectAllStr: String;
ObjectAllStr2: String;
ObjName:String;
initObjNum: Integer;
RealObjNum: Integer;
ModelName: String;
posX,posY,posZ:Extended; //Pos
addX,addY,AddZ:Extended; //posAdd
R,Angle:Extended; //半径,旋转角度
SinA,SinX,SinT:Extended; //幅值,步距,周期
S1,S2,S3,S4:Extended;
DesFile:TextFile;
PstFile:TextFile;
DirCur:String;
i,k:Integer;
Type
CandleInfo = Array[1..10] Of String;
DesInfo = Array[1..10] Of String;
PstInfo = Array[1..30] Of String;
{$R *.dfm}
var
CANDLE:CandleInfo;
procedure TForm1.CreateObjBtnClick(Sender: TObject);
begin
if((length(EdtName.Text)<1)) then
ShowMessage('名字不能为空!');
case ComboBox.ItemIndex of
0: DoDesLineFile();
1: DoDesCycleFile();
2: DoDesSinFile();
else
ShowMessage('未知错误,生成失败!');
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
SetWindowLong(EdtName.Handle, GWL_STYLE, GetWindowLong(EdtName.Handle, GWL_STYLE) or ES_Center);
EdtName.Invalidate;
SetWindowLong(EdtInitNum.Handle, GWL_STYLE, GetWindowLong(EdtInitNum.Handle, GWL_STYLE) or ES_Center);
EdtInitNum.Invalidate;
SetWindowLong(EdtRealNum.Handle, GWL_STYLE, GetWindowLong(EdtRealNum.Handle, GWL_STYLE) or ES_Center);
EdtRealNum.Invalidate;
SetWindowLong(EdtModelName.Handle, GWL_STYLE, GetWindowLong(EdtModelName.Handle, GWL_STYLE) or ES_Center);
EdtModelName.Invalidate;
SetWindowLong(EdtX.Handle, GWL_STYLE, GetWindowLong(EdtX.Handle, GWL_STYLE) or ES_Center);
EdtX.Invalidate;
SetWindowLong(EdtY.Handle, GWL_STYLE, GetWindowLong(EdtY.Handle, GWL_STYLE) or ES_Center);
EdtY.Invalidate;
SetWindowLong(EdtZ.Handle, GWL_STYLE, GetWindowLong(EdtZ.Handle, GWL_STYLE) or ES_Center);
EdtZ.Invalidate;
SetWindowLong(EdtaddX.Handle, GWL_STYLE, GetWindowLong(EdtaddX.Handle, GWL_STYLE) or ES_Center);
EdtaddX.Invalidate;
SetWindowLong(EdtaddY.Handle, GWL_STYLE, GetWindowLong(EdtaddY.Handle, GWL_STYLE) or ES_Center);
EdtaddY.Invalidate;
SetWindowLong(EdtaddZ.Handle, GWL_STYLE, GetWindowLong(EdtaddZ.Handle, GWL_STYLE) or ES_Center);
EdtaddZ.Invalidate;
SetWindowLong(EdtR.Handle, GWL_STYLE, GetWindowLong(EdtR.Handle, GWL_STYLE) or ES_Center);
EdtR.Invalidate;
SetWindowLong(EdtROff.Handle, GWL_STYLE, GetWindowLong(EdtROff.Handle, GWL_STYLE) or ES_Center);
EdtROff.Invalidate;
SetWindowLong(EdtAngleOff.Handle, GWL_STYLE, GetWindowLong(EdtAngleOff.Handle, GWL_STYLE) or ES_Center);
EdtAngleOff.Invalidate;
SetWindowLong(EdtSinA.Handle, GWL_STYLE, GetWindowLong(EdtSinA.Handle, GWL_STYLE) or ES_Center);
EdtSinA.Invalidate;
SetWindowLong(EdtSinX.Handle, GWL_STYLE, GetWindowLong(EdtSinX.Handle, GWL_STYLE) or ES_Center);
EdtSinX.Invalidate;
SetWindowLong(EditSinT.Handle, GWL_STYLE, GetWindowLong(EditSinT.Handle, GWL_STYLE) or ES_Center);
EditSinT.Invalidate;
ComboBox.Items.Insert(0,'直线生成');
ComboBox.Items.Insert(1,'环绕生成');
ComboBox.Items.Insert(2,'正弦生成');
ComboBox.ItemIndex:=1;
ComboBox.Style:=csDropDownList;
ComboBoxChange(Sender);
EdtName.Text:='Candle';
EdtInitNum.Text:='101';
EdtRealNum.Text:='80';
EdtModelName.Text:='BBox02';
EdtX.Text:='1.124';
EdtY.Text:='5';
EdtZ.Text:='6.414';
EdtaddX.Text:='10';
EdtaddY.Text:='5';
EdtaddZ.Text:='6';
EdtR.Text:='200';
EdtROff.Text:='5';
EdtAngleOff.Text:='1';
end;
procedure TForm1.EdtInitNumKeyPress(Sender: TObject; var Key: Char);
begin
if not(key in ['0'..'9']) then key:=#0;
end;
procedure TForm1.EdtRealNumKeyPress(Sender: TObject; var Key: Char);
begin
if not(key in ['0'..'9']) then key:=#0;
end;
procedure TForm1.DoDesLineFile();
var
DES:DesInfo;
begin
//从每个编辑框获取数据保存到变量里面
ObjName:=EdtName.Text;
initObjNum:=StrToInt(EdtInitNum.Text);
RealObjNum:=StrToInt(EdtRealNum.Text);
ModelName:=EdtModelName.Text;
posX:=StrToFloat(EdtX.Text);
posY:=StrToFloat(EdtY.Text);
posZ:=StrToFloat(EdtZ.Text);
addX:=StrToFloat(EdtaddX.Text);
addY:=StrToFloat(EdtaddY.Text);
addZ:=StrToFloat(EdtaddZ.Text);
//初始化作者信息
CANDLE[1]:='## Delphi 7 鱼C工作室 (2020年9月28日00:42:43)';
CANDLE[2]:='## 流星蝴蝶剑.net 907';
CANDLE[3]:='## 直线方式生成';
CANDLE[4]:='## 把生成的DES代码添加到SnXX.des文件末尾';
CANDLE[5]:='## 把文件开始声明的两个值都改为 9999 ';
CANDLE[6]:='## QQ:962665270';
CANDLE[7]:='## 逾越书';
CANDLE[8]:='## 一共生成了'+EdtRealNum.Text+'个道具'+'(编号:'+EdtInitNum.Text+'~'+IntToStr(initObjNum+RealObjNum-1)+')';
//得到当前目录
GetDir(0,DirCur);
//关联文件
AssignFile(DesFile,DirCur+'\snxx.des');
//打开方式
Rewrite(DesFile);
//写作者信息
i:=1;
While (i<=8) Do
begin
writeLn(DesFile,CANDLE[i]);
i:=i+1;
end;
//写Obj信息
i:=1;
k:=initObjNum;
While (k<=(initObjNum+RealObjNum-1)) Do
begin //为信息 字符串 挨个赋值
DES[1]:='Object '+ObjName+IntToStr(k);
DES[2]:='{';
DES[3]:=' Position: '+FormatFloat('###.###',posX)+' '+ FormatFloat('###.###',posY)+' '+FormatFloat('###.###',posZ)+' ';
DES[4]:=' Quaternion: -1.000 0.000 0.000 0.000';
DES[5]:=' TextureAnimation: 0 0.000 0.000 ';
DES[6]:=' Custom:';
DES[7]:=' {';
DES[8]:=' model="'+ModelName+'"';
DES[9]:=' }';
DES[10]:='}';
i:=1;
While (i<=10) Do
begin //挨个写入字符串
writeLn(DesFile,DES[i]);
i:=i+1;
end;
//更新下一个obj的数据(Line方式)
posX:= posX + addX;
posY:= posY + addY;
posZ:= posZ + addZ;
k:=k+1;
end;
//关闭文件
CloseFile(DesFile);
//接着写Pst文件
DoPstFile();
end;
procedure TForm1.DoDesCycleFile();
var
DES:DesInfo;
begin
//从每个编辑框获取数据保存到变量里面
ObjName:=EdtName.Text;
initObjNum:=StrToInt(EdtInitNum.Text);
RealObjNum:=StrToInt(EdtRealNum.Text);
ModelName:=EdtModelName.Text;
posX:=StrToFloat(EdtX.Text);
posY:=StrToFloat(EdtY.Text);
posZ:=StrToFloat(EdtZ.Text);
addX:=StrToFloat(EdtaddX.Text);
addY:=StrToFloat(EdtaddY.Text);
addZ:=StrToFloat(EdtaddZ.Text);
R:=StrToFloat(EdtR.Text);
Angle:=StrToFloat(EdtAngleOff.Text);
//初始化作者信息
CANDLE[1]:='## Delphi 7 鱼C工作室 (2020年9月28日00:42:43)';
CANDLE[2]:='## 流星蝴蝶剑.net 907';
CANDLE[3]:='## 环绕方式生成';
CANDLE[4]:='## 把生成的DES代码添加到SnXX.des文件末尾';
CANDLE[5]:='## 把文件开始声明的两个值都改为 9999 ';
CANDLE[6]:='## QQ:962665270';
CANDLE[7]:='## 逾越书';
CANDLE[8]:='## 一共生成了'+EdtRealNum.Text+'个道具'+'(编号:'+EdtInitNum.Text+'~'+IntToStr(initObjNum+RealObjNum-1)+')';
//得到当前目录
GetDir(0,DirCur);
//关联文件
AssignFile(DesFile,DirCur+'\snxx.des');
//打开方式
Rewrite(DesFile);
//写作者信息
i:=1;
While (i<=8) Do
begin
writeLn(DesFile,CANDLE[i]);
i:=i+1;
end;
//写Obj信息
i:=1;
k:=initObjNum;
While (k<=(initObjNum+RealObjNum-1)) Do
begin //为信息 字符串 挨个赋值
DES[1]:='Object '+ObjName+IntToStr(k);
DES[2]:='{';
DES[3]:=' Position: '+FormatFloat('###.###',posX)+' '+ FormatFloat('###.###',posY)+' '+FormatFloat('###.###',posZ)+' ';
DES[4]:=' Quaternion: -1.000 0.000 0.000 0.000';
DES[5]:=' TextureAnimation: 0 0.000 0.000 ';
DES[6]:=' Custom:';
DES[7]:=' {';
DES[8]:=' model="'+ModelName+'"';
DES[9]:=' }';
DES[10]:='}';
i:=1;
While (i<=10) Do
begin //挨个写入字符串
writeLn(DesFile,DES[i]);
i:=i+1;
end;
//更新下一个obj的数据(Line方式)
posX:= addX+ R*Cos((Angle/360)*3.14); //X值为半径*Cos(角度对应弧度)
posY:= addY+ R*Sin((Angle/360)*3.14); //y值为半径*Sin(角度对应弧度)
posZ:= posZ + addZ; //Z值更新
addX:=addX+StrToInt(EdtaddX.Text); //坐标便宜改变
addY:=addY+StrToInt(EdtaddY.Text); //
Angle:=Angle+StrToInt(EdtAngleOff.Text); //变化角度重新赋值
k:=k+1;
end;
//关闭文件
CloseFile(DesFile);
//写入Pst文件
DoPstFile();
end;
procedure TForm1.DoDesSinFile();
var
DES:DesInfo;
temp:Extended;
begin
//从每个编辑框获取数据保存到变量里面
ObjName:=EdtName.Text;
initObjNum:=StrToInt(EdtInitNum.Text);
RealObjNum:=StrToInt(EdtRealNum.Text);
ModelName:=EdtModelName.Text;
posX:=StrToFloat(EdtX.Text);
posY:=StrToFloat(EdtY.Text);
posZ:=StrToFloat(EdtZ.Text);
addX:=StrToFloat(EdtaddX.Text);
addY:=StrToFloat(EdtaddY.Text);
addZ:=StrToFloat(EdtaddZ.Text);
SinA:=StrToFloat(EdtSinA.Text);
SinX:=StrToFloat(EdtSinX.Text);
SinT:=StrToFloat(EditSinT.Text);
//初始化作者信息
CANDLE[1]:='## Delphi 7 鱼C工作室 (2020年9月28日00:42:43)';
CANDLE[2]:='## 流星蝴蝶剑.net 907';
CANDLE[3]:='## 正弦方式生成';
CANDLE[4]:='## 把生成的DES代码添加到SnXX.des文件末尾';
CANDLE[5]:='## 把文件开始声明的两个值都改为 9999 ';
CANDLE[6]:='## QQ:962665270';
CANDLE[7]:='## 逾越书';
CANDLE[8]:='## 一共生成了'+EdtRealNum.Text+'个道具'+'(编号:'+EdtInitNum.Text+'~'+IntToStr(initObjNum+RealObjNum-1)+')';
//得到当前目录
GetDir(0,DirCur);
//关联文件
AssignFile(DesFile,DirCur+'\snxx.des');
//打开方式
Rewrite(DesFile);
//写作者信息
i:=1;
While (i<=8) Do
begin
writeLn(DesFile,CANDLE[i]);
i:=i+1;
end;
//写Obj信息
i:=1;
k:=initObjNum;
temp:=posX;
While (k<=(initObjNum+RealObjNum-1)) Do
begin //为信息 字符串 挨个赋值
DES[1]:='Object '+ObjName+IntToStr(k);
DES[2]:='{';
DES[3]:=' Position: '+FormatFloat('###.###',posX)+' '+ FormatFloat('###.###',posY)+' '+FormatFloat('###.###',posZ)+' ';
DES[4]:=' Quaternion: -1.000 0.000 0.000 0.000';
DES[5]:=' TextureAnimation: 0 0.000 0.000 ';
DES[6]:=' Custom:';
DES[7]:=' {';
DES[8]:=' model="'+ModelName+'"';
DES[9]:=' }';
DES[10]:='}';
i:=1;
While (i<=10) Do
begin //挨个写入字符串
writeLn(DesFile,DES[i]);
i:=i+1;
end;
//更新下一个obj的数据(Line方式)
//SinTT
temp:=temp+SinX;
posX:= posX + SinX; //X值为半径*Cos(角度对应弧度)
posY:= posY + addY+ SinA*Sin(((temp/SinT)/180)*3.14); //y值为半径*Sin(角度对应弧度)
//posY:=S1*Sin(((temp*S2+S3))/180*3.14)+S4;
posZ:= posZ + addZ; //Z值更新
//addX:=addX+StrToInt(EdtaddX.Text); //坐标便宜改变
//addY:=addY+StrToInt(EdtaddY.Text); //
//Angle:=Angle+StrToInt(EdtAngleOff.Text); //变化角度重新赋值
k:=k+1;
end;
//关闭文件
CloseFile(DesFile);
//写入Pst文件
DoPstFile();
end;
//写Pst文件
procedure TForm1.DoPstFile();
var
PST:PstInfo;
begin
CANDLE[1]:='## Delphi 7 鱼C工作室 (2020年9月27日23:53:00)';
CANDLE[2]:='## ';
CANDLE[3]:='## 把代码复制到Scene_OnLoad()或 Scene_OnInit() 函数里面';
CANDLE[4]:='## 逾越书QQ:962665270';
CANDLE[5]:='## ';
//清空PST数组
for i:=1 To 30 Do
begin
PST[i]:='';
end;
//关联文件
AssignFile(PstFile,DirCur+'\snxx.pst');
//打开方式(写)
Rewrite(PstFile);
//给PST数组成员赋值
PST[1]:='Scene_OnInit()'; //IntToStr StrToInt
PST[2]:='{';
PST[3]:=' string name;';
PST[4]:=' int i;';
PST[5]:=' for (i = '+EdtInitNum.Text+'; i <= '+IntToStr(StrToInt(EdtInitNum.Text)+StrToInt(EdtRealNum.Text)-1)+'; i++) ';
PST[6]:=' {';
PST[7]:=' MakeString(name, "'+EdtName.Text+'", i);';
PST[8]:=' SetSceneItem(name, "name", "machine");';
PST[9]:=' SetSceneItem(name, "attribute", "collision", 1);';
PST[10]:=' SetSceneItem(name, "attribute", "active", 1);';
PST[11]:=' }';
PST[12]:='}';
//打印文件头
i:=1;
While (i<=5) Do
begin
writeLn(PstFile,CANDLE[i]);
i:=i+1;
end;
//打印PST数组每个成员
i:=1;
While (i<=30) Do
begin
writeLn(PstFile,PST[i]);
i:=i+1;
end;
//关闭文件
CloseFile(PstFile);
end;
procedure TForm1.EdtNameKeyPress(Sender: TObject; var Key: Char);
begin
//现在名字只能为字母 ,#8是退格键←
if not((key in ['A'..'Z'])or(key in ['a'..'z'])or(key in [#8])) then key:=#0;
end;
procedure TForm1.BtnAboutClick(Sender: TObject);
begin
ShellExecute(Handle,'open','https://fishc.com.cn/',nil,nil,SW_SHOWNORMAL);
end;
procedure TForm1.ComboBoxChange(Sender: TObject);
begin
case ComboBox.ItemIndex of
0: begin
EdtX.Enabled:=True;
EdtY.Enabled:=True;
EdtZ.Enabled:=True;
EdtaddX.Enabled:=True;
EdtaddY.Enabled:=True;
EdtaddZ.Enabled:=True;
EdtR.Enabled:=False;
EditSinT.Enabled:=False;
//EdtR.Visible:=False;
EdtROff.Enabled:=False;
EdtAngleOff.Enabled:=False;
EdtSinA.Enabled:=False;
EdtSinX.Enabled:=False;
end;
1: begin
EdtX.Enabled:=True;
EdtY.Enabled:=True;
EdtZ.Enabled:=True;
EdtaddX.Enabled:=True;
EdtaddY.Enabled:=True;
EdtaddZ.Enabled:=True;
EdtR.Enabled:=True;
EdtROff.Enabled:=True;
EdtAngleOff.Enabled:=True;
EdtSinA.Enabled:=False;
EdtSinX.Enabled:=False;
EditSinT.Enabled:=False;
end;
2: begin
EdtX.Enabled:=True;
EdtY.Enabled:=True;
EdtZ.Enabled:=True;
EdtaddX.Enabled:=True;
EdtaddY.Enabled:=True;
EdtaddZ.Enabled:=True;
EdtR.Enabled:=False;
EdtROff.Enabled:=False;
EdtAngleOff.Enabled:=False;
EdtSinA.Enabled:=True;
EdtSinX.Enabled:=True;
EditSinT.Enabled:=True;
end;
else
;
end;
end;
procedure TForm1.EdtRKeyPress(Sender: TObject; var Key: Char);
begin
if not(key in ['0'..'9']) then key:=#0;
end;
procedure TForm1.EdtROffKeyPress(Sender: TObject; var Key: Char);
begin
if not(key in ['0'..'9']) then key:=#0;
end;
procedure TForm1.EdtAngleOffKeyPress(Sender: TObject; var Key: Char);
begin
if not(key in ['0'..'9']) then key:=#0;
end;
procedure TForm1.EdtSinAKeyPress(Sender: TObject; var Key: Char);
begin
if not(key in ['0'..'9']) then key:=#0;
end;
procedure TForm1.EdtSinXKeyPress(Sender: TObject; var Key: Char);
begin
if not(key in ['0'..'9']) then key:=#0;
end;
end.
|
|