rollout san "凉宫专用模型编辑插件" width:200 height:144
(
	button SaveBut "模型保存为" pos:[48,88] width:108 height:23
	label lab1 "凉宫专用模型编辑插件" pos:[32,9] width:145 height:20 enabled:true
	button OpBut "打开模型" pos:[48,56] width:108 height:23
	label lbl4 "By 凉宫@3DM" pos:[104,117] width:82 height:19
	label lbl3 "-- For 356" pos:[112,32] width:80 height:16 enabled:true
	on SaveBut pressed do
	(
			Save_FileName = getSaveFileName caption:"选择模型保存位置:" types:"模型文件(*.LGmesh)|*.LGmesh"
			if Save_FileName != undefined then
			(
				out_file = createfile (Save_FileName)
				i=0
				for tmesh in objects do
				(
					i = i + 1
					select tmesh
					tmesh2 = snapshotAsMesh selection[1]
					ts_name = tmesh.name
					
					if i == 1 then (format "%," objects.count to:out_file)
					format "\"%\",%,%\n" ts_name tmesh2.numverts tmesh2.numfaces to:out_file
					for v = 1 to tmesh2.numverts do
					format "%," (getVert tmesh2 v) to:out_file
					format "\n" to:out_file
					for f = 1 to tmesh2.numfaces do
					format "%," (getFace tmesh2 f) to:out_file
					format "\n" to:out_file
					for j = 1 to tmesh2.numtverts do
					format "%," (getTVert tmesh2 j) to:out_file
					format "\n" to:out_file
					for j = 1 to tmesh2.numverts do
					format "%," (getNormal tmesh2 j) to:out_file
					if i != objects.count then format "\n" to:out_file
				)
				close out_file
				
				messagebox "导出完成！"
			)
		)
	on OpBut pressed do
	(
				Open_FileName = getOpenFileName caption:"选择要打开的模型:" types:"模型文件(*.LGmesh)|*.LGmesh"
				vert_array = #()
				face_array = #()
				uv_array = #()
				normal_array = #()
				if Open_FileName != undefined then
				(
					in_name = (Open_FileName)
					in_file = openFile in_name
					if in_file != undefined then
					(
						mesh_n = readValue in_file
						for n = 1 to mesh_n do
						(
							mod_Name = readValue in_file
							num_verts = readValue in_file
							num_faces = readValue in_file
							
							vert_array.count = num_verts
							face_array.count = num_faces
							uv_array.count = num_verts
							normal_array.count = num_verts
							
							for v = 1 to num_verts do
							(
								vert = readValue in_file
								vert_array[v] = vert
							)
							for f = 1 to num_faces do
							(
								face = readValue in_file
								face_array[f] = face
							)
							for j = 1 to num_verts do
							(
								nvs = readValue in_file
								uv_array[j] = nvs
							)
							for j = 1 to num_verts do
							(
								nor = readValue in_file
								normal_array[j] = nor
							)
							new_mesh = mesh vertices:vert_array faces:face_array 
							
							SetNumTVerts new_mesh uv_array.count
							buildTVFaces new_mesh
							for v = 1 to uv_array.count do
								setTVert new_mesh v uv_array[v]
							for v = 1 to face_array.count do
								setTVFace  new_mesh v face_array[v]
							for v = 1 to num_verts do
							(
								setNormal new_mesh v normal_array[v]
							)
							new_mesh.name=mod_Name
						)
						close in_file
						
						messagebox "导入完成！"
					)
				)
		)
)createdialog san