var private const	Tosha_pos = 1;
var private const	Kakusu_pos = 2;
var private const	Deg_pos = 3;
var private const	Jouge_pos = 4;
var private	Menu_temp1;
var private	Menu_temp2;
var private	Menu_temp3;

function ToshaChange()
{
	tosha_flag = !tosha_flag;
	if( tosha_flag == ON )
		Status_title[Tosha_pos] = "平面投射:自動";
	else
		Status_title[Tosha_pos] = "平面投射:手動";
	DrawStatus();
}

function private InputSetup()
{
	var	men[2], key, temp;

	men = {" 生成 ", "非生成" };
	DlogOpen( "回転体作成 設定変更", 5, "ｷｬﾝｾﾙ ", " 決定 " );
	DlogString( 0, "分割数         ", tostring( Menu_temp1 ), 14 );
	DlogString( 2, "生成角度(1-360)", tostring( Menu_temp2 ), 14 );
	DlogSelect( 4, "上面・下面     ", men, (1-Menu_temp3) );
	key = DlogWait();
	if( key == 0 )
		return FALSE;
	else
	{
		Menu_temp1 = atoi( DlogAnswer( 0 ));
		if( Menu_temp1 >= (MAXVERTEX-2))
			Menu_temp1 = MAXVERTEX-2;
		if( Menu_temp1 < 3 )
			Menu_temp1 = 3;
		Menu_temp2 = atoi( DlogAnswer( 2 ));
		if( Menu_temp2 > 360 )
			Menu_temp2 = 360;
		if( Menu_temp2 < 1 )
			Menu_temp2 = 1;
		temp = DlogAnswer( 4 );
		if( temp == 0 )
			Menu_temp3 = ON;
		else
			Menu_temp3 = OFF;
		Status_title[Kakusu_pos] = "分割数:"+tostring( Menu_temp1, 3 );
		Status_title[Deg_pos] = "角度:"+tostring( Menu_temp2 , 3);
		if( Menu_temp3 == OFF )
			Status_title[Jouge_pos] = "上下面:非生成";
		else
			Status_title[Jouge_pos] = "上下面:  生成";
		DrawStatus();
	}
	return TRUE;
}

function private Inputkakusu()
{
	DlogOpen( "角数入力", 1 );
	DlogString( 0, "角数 ", tostring( Menu_temp1 ), 6 );
	if( DlogWait() )
		Menu_temp1 = atoi( DlogAnswer( 0 ));
	if( Menu_temp1 > MAXVERTEX )
		Menu_temp1 = MAXVERTEX;
	if( Menu_temp1 < 3 )
		Menu_temp1 = 3;
	Status_title[Kakusu_pos] = "角数: "+tostring( Menu_temp1, 4 )+" ";
	DrawStatus();
}

//
//	正多角形描画
//
function DrawEquilateral( kakusuu, point0, point1, point2, save_mode )
{
	var	axis_vec,p0_vec,p1_vec,p2_vec,p01_vec, p12_vec;
	var	trans_matrix, move_matrix,temp1_matrix, temp2_matrix;
	var	i,j, draw_edge;
	var	v0, v1, v2;

	if( kakusuu < 3 )
		return Edge();

	p0_vec = Position( point0 );
	p1_vec = Position( point1 );
	p2_vec = Position( point2 );
	p01_vec = p1_vec - p0_vec;
	p12_vec = p2_vec - p1_vec;
	axis_vec = p01_vec*p12_vec;

	if( abs(axis_vec) < 0.00001 )
		return Edge();

	move_matrix = move( UNIT_MATRIX, p0_vec*(-1) );
	trans_matrix = vec( UNIT_MATRIX, axis_vec, p01_vec );
	temp1_matrix = move_matrix/trans_matrix;
	temp2_matrix = trans_matrix/move_matrix;

	v0 = point1;
	v1 = v0;
	draw_edge = Edge();
	if( save_mode == ON )
		PolySetVertex( v0, 0 );
	for( i = 1;i<kakusuu;i++ )
	{
		j = 0.0;
		j = (360.0*i)/kakusuu;
		v2 = point1*(temp1_matrix*rot(UNIT_MATRIX, AXISX, j )*temp2_matrix);
		if( save_mode == ON )
			PolySetVertex( v2, i );
		draw_edge = draw_edge + Edge( v1, v2 );
		v1 = v2;
	}
	draw_edge = draw_edge + Edge( v2, v0 );
	if( save_mode == ON )
	{
		PolyVertexs( kakusuu );
		PolyType( POLY_SIMPLE );
		PolyAttr( AttrCurrent());
		PolyObj( ObjCurrent());
		SelectAll( FALSE );
		PolyAppend( TRUE );
		ViewCursor( OFF );
		DrawCurrent( TRUE );
		ViewCursor( ON );
	}
	return draw_edge;
}

//
//	正多角形生成
//
function CreateEquilateralPolygon()
{

	var	point[3], p_vec[3];
	var	vers, key, mode, temp;
	var	pick, draw_flag = ON;
	var	pick_kakusu, vers_temp;
	var	draw_edge, prev_sel;

	Menu_temp1 = Equilateral_kakusu;
	PushMenu();
	Status_org = Status_title;
	MenuPosition( Menu( " 動作設定(&S)",
			"角数入力",		Inputkakusu,
			"--------",		SEPARATE_MENU,
			"作成中止	ESC",	MenuQuit
		), Menu_Title );

	ClearStatus();
	Status_title[0] = "【正多角形作成中】";
	Status_title[Kakusu_pos] = "角数: "+tostring( Menu_temp1, 4 )+" ";
	DrawStatus();

	quit_flag = FALSE;

	prev_sel = Select();
	point[0] = Cursor();
	cur = Cursor();
	pick = cur;
	vers = 1;
	pick_kakusu = Menu_temp1;
	vers_temp = 0;
	input_flag = OFF;
	while( TRUE )
	{
		if( draw_flag == ON )
		{
			if( vers == 1 )
			{
				draw_edge = Edge( point[0], cur );
				DrawEdge( draw_edge );
			}
			else
			{
				draw_edge = Edge( point[0], point[1] );
				if( point[1] != cur )
				{
					mode = OFF;
					draw_edge = DrawEquilateral( Menu_temp1, point[0], point[1], cur, mode ) + draw_edge;
				}
				DrawEdge( draw_edge );
			}
		}
		key = WaitEvent();
		if( key )
			input_flag = ON;
		if( (( ShiftStat() & 1 ) == 1) & ( vers == 1 ))
		{
			cur = Cursor();
			TrimCursor(point[0], MouseWindow());
			Cursor( cur );
		}
		else
			cur = Cursor();
		key = KeyCode();
		if( input_flag | key == INPUT_KEY )
		{
			if( vers == 1 )
			{
				if( cur == point[0] )
				{
					Warning();
					if( MESSAGE == ON )
						Message( "外接円の半径を指定してください" );
				}
				else
				{
					point[1] = cur;
					vers_temp = 1;
				}
			}
			else if( vers == 2 )
			{
				if( cur == point[0]  |  cur == point[1] )
				{
					Warning();
					if( MESSAGE == ON )
						Message( "面を生成する方向を指定してください" );
				}
				else
				{
					DrawEdge( draw_edge );
					point[2] = cur;
					break;
				}
			}
		}
		else if( key == ESC | quit_flag == TRUE )
		{
			DrawEdge( draw_edge );
			PopandClear();
			Equilateral_kakusu = Menu_temp1;
			return;
		}
		else if( key == BS )
		{
			if( vers == 1 )
			{
				DrawEdge( draw_edge );
				Warning();
				PopandClear();
				Equilateral_kakusu = Menu_temp1;
				return;
			}
			else
			{
				vers_temp = -1;
				Cursor( point[1] );
				cur = Cursor();
			}
		}
		else if( key == KEY_ROLLUP )
		{
			if( Menu_temp1 >= MAXVERTEX )
			{
				Warning();
				if( MESSAGE == ON )
					Message( "これ以上の角数の面は生成できません" );
			}
			else
				Menu_temp1++;
			Status_title[Kakusu_pos] = "角数: "+tostring( Menu_temp1, 4 )+" ";
			DrawStatus();
		}
		else if( key == KEY_ROLLDOWN )
		{
			if( Menu_temp1 <= 3 )
			{
				Warning();
				if( MESSAGE == ON )
					Message( "これ以下の角数の面は生成できません" );
			}
			else
				Menu_temp1--;
			Status_title[Kakusu_pos] = "角数: "+tostring( Menu_temp1, 4 )+" ";
			DrawStatus();
		}
		else
			temp = KeyProcess( key );
		if(((key!=0 )&(key!=INPUT_KEY))|(pick!=Cursor())|(pick_kakusu!= Menu_temp1))
		{
			draw_flag = ON;
			DrawEdge( draw_edge );
		}
		else
			draw_flag = OFF;
		pick_kakusu = Menu_temp1;
		vers = vers+vers_temp;
		vers_temp = 0;
		pick = Cursor();
		input_flag = OFF;
	}
	if( SelectPolygons( prev_sel ) != 0 )
	{
		SelectAllFalse();
		SelectAll( FALSE );
	}
	mode = ON;
	DrawEquilateral( Menu_temp1, point[0], point[1], cur, mode );
	Equilateral_kakusu = Menu_temp1;
	UpdateObject();
	pers_rotation_flag = FALSE;
	PopMenu();
	Status_title = Status_org;
	DrawStatus();
}

//
//	回転体の作成
//
function CreateRotationBody()
{
	var	maxbodyline = 100;
	var	axis[2], prev, bodyline[100];
	var	bodyline2[100],bodyline3[100];
	var	key,vers, axis_type, i, mode;
	var	j, end_deg, temp, tosha_pos,tosha_mode = OFF;
	var	temp_vec, axis_vec;
	var	trans_matrix, move_matrix, temp_matrix, rot_matrix[MAXVERTEX];
	var	position_vec;
	var	msg[2], vertex_flag[2];
	var	pick, draw_flag = ON;
	var	draw_edge, prev_sel;

	if( maxbodyline*2 > MAXVERTEX )
		maxbodyline = MAXVERTEX/2;

	Menu_temp1 = Rotation_kakusu;
	Menu_temp2 = 360;	/* 生成角度 */
	Menu_temp3 = OFF;	/* 上面・下面生成の有無 */

	prev_sel = Select();
	PushMenu();
	Status_org = Status_title;
	MenuPosition( Menu( " 動作設定(&S)",
			"設定変更    ",		InputSetup,
			"------------",		SEPARATE_MENU,
			"自動平面投射	C",	ToshaChange, Check_Toshaflag,
			"------------",		SEPARATE_MENU,
			"作成中止    	ESC",	MenuQuit
		), Menu_Title );

	quit_flag = FALSE;

	ClearStatus();
	Status_title[0] = "【回転体作成中】";
	Status_title[Kakusu_pos] = "分割数:"+tostring( Menu_temp1, 3 );
	Status_title[Deg_pos] = "角度:"+tostring( Menu_temp2 , 3);
	if( Menu_temp3 == OFF )
		Status_title[Jouge_pos] = "上下面:非生成";
	else
		Status_title[Jouge_pos] = "上下面:  生成";
	if( tosha_flag == ON )
		Status_title[Tosha_pos] = "平面投射:自動";
	else
		Status_title[Tosha_pos] = "平面投射:手動";
	DrawStatus();

	axis[0] = Cursor();
	cur = Cursor();
	pick = cur;
	vers = 1;
	input_flag = OFF;
	draw_edge = Edge();
	while( TRUE )
	{
		if( draw_flag == ON )
		{
			draw_edge = Edge( axis[0], cur );
			DrawLine( axis[0], cur );
		}
		key = WaitEvent();
		if( key )
			input_flag = ON;
		if( (( ShiftStat() & 1 ) == 1))
		{
			cur = Cursor();
			TrimCursor(axis[0], MouseWindow());
			Cursor( cur );
		}
		else
		{
			cur = Cursor();
		}
		key = KeyCode();
		if( input_flag | key == INPUT_KEY )
		{
			axis[vers] = cur;
			if( pick != cur )
			{
				DrawEdge( draw_edge );
				DrawLine( axis[0], axis[1] );
			}
			if( cur == axis[0] )
			{
				Warning();
				if( MESSAGE == ON )
					Message( "回転体の軸を指定してください" );
			}
			else
				break;
		}
		else if( key == ESC | key == BS | quit_flag == TRUE )
		{
			PopandClear( OVERWRITE );
			Rotation_kakusu = Menu_temp1;
			return;
		}
		else if( key == KEY_ROLLUP )
		{
			if( Menu_temp1 >= (MAXVERTEX-2))
			{
				Warning();
				if( MESSAGE == ON )
					Message( "これ以上の分割数の面は生成できません" );
			}
			else
				Menu_temp1++;
			Status_title[Kakusu_pos] = "分割数:"+tostring( Menu_temp1, 3 );
			DrawStatus();
		}
		else if( key == KEY_ROLLDOWN )
		{
			if( Menu_temp1 <= 3 )
			{
				Warning();
				if( MESSAGE == ON )
					Message( "これ以下の分割数の面は生成できません" );
			}
			else
				Menu_temp1--;
			Status_title[Kakusu_pos] = "分割数:"+tostring( Menu_temp1, 3 );
			DrawStatus();
		}
		else if( key == 'c' )
			ToshaChange();
		else
			temp = KeyProcess( key );
		if( ((key!=0 ) & (key != INPUT_KEY)) | ( pick != Cursor()) )
		{
			draw_flag = ON;
			DrawEdge( draw_edge );
		}
		else
			draw_flag = OFF;
		pick = Cursor();
		input_flag = OFF;
	}
	axis_vec = unit(Position( axis[1]) - Position( axis[0] ));
	if( vector( 0, 0, 1 ).axis_vec < 0 )
	{
		cur = axis[0];
		axis[0] = axis[1];
		axis[1] = cur;
		axis_vec *= -1;
	}
	vers = 0;
	draw_flag = ON;
	input_flag = OFF;
	draw_edge = Edge();
	while( TRUE )
	{
		if( vers != 0 & (draw_flag == ON ))
		{
			draw_edge = Edge( cur, prev );
			DrawLine( cur, prev );
		}
		key = WaitEvent();
		if( key )
			input_flag = ON;
		if( (( ShiftStat() & 1 ) == 1 )& ( vers != 0 ))
		{
			cur = Cursor();
			TrimCursor(prev, MouseWindow());
			Cursor( cur );
		}
		else
			cur = Cursor();
		if(( tosha_mode == ON ) & ( tosha_flag == ON ) & ( cur != pick))
		{
			cur = PolyPlane( cur, MouseWindow(),
					axis[0], axis[1], tosha_pos );
			Cursor( cur );
		}
		key = KeyCode();
		if ( input_flag | key == INPUT_KEY )
		{
			if( pick != cur )
			{
				DrawEdge( draw_edge );
				DrawLine( cur, prev );
			}
			if( vers == 0 )
			{
				bodyline[vers] = cur;
				vers++;
				draw_edge = Edge();
				if(abs( axis_vec*(Position(cur) - Position(axis[0]))) > 0.00001 )
				{
					tosha_mode = ON;
					tosha_pos = cur;
				}
			}
			else if( vers == 1 )
			{
				if ( prev == cur )
				{
					Warning();
					if( MESSAGE == ON )
						Message( "前に確定した点と同じ点です" );
				}
				else
				{
					bodyline[vers] = cur;
					draw_edge = Edge();
					vers++;
					if( tosha_mode == OFF )
					{
						if(abs( axis_vec*(Position(cur)-Position(axis[0]))) > 0.00001 )
						{
							tosha_mode = ON;
							tosha_pos = cur;
						}
					}
				}
			}
			else
			{
				if( prev == cur )
					break;
				else
				{
					bodyline[vers] = cur;
					draw_edge = Edge();
					vers++;
					if( tosha_mode == OFF )
					{
						if(abs( axis_vec*(Position(cur)-Position(axis[0]))) > 0.00001 )
						{
							tosha_mode = ON;
							tosha_pos = cur;
						}
					}
				}
			}
			if( vers == maxbodyline )
			{
				Warning();
				Message( "これ以上の回転体は作ることができません\n"
					+"現在までに確定された点で回転体を生成します" );
				break;
			}
			prev = cur ;
		}
		else if( key == ESC | quit_flag == TRUE )
		{
			PopandClear( OVERWRITE );
			Rotation_kakusu = Menu_temp1;
			return;
		}
		else if ( key == BS )
		{
			if ( vers > 1 )
			{
				if( cur != prev )
				{
					cur = bodyline[vers-1];
					prev = bodyline[vers - 2];
					cur = Cursor( cur );
					vers --;
					DrawLine( prev, cur );
				}
				else
				{
					prev = bodyline[vers - 2];
					vers --;
					DrawLine( prev, cur );
				}
			}
			else if ( vers == 1 )
			{
				cur = bodyline[vers-1];
				Cursor( cur );
				vers--;
				DrawEdge( draw_edge );
				draw_edge = Edge();
			}
			else
			{
				PopandClear( OVERWRITE );
				Rotation_kakusu = Menu_temp1;
				return ;
			}
		}
		else if( ( key == 'p' ) & ( tosha_mode == ON ))
		{
			cur = PolyPlane( cur, MouseWindow(),
					axis[0], axis[1], tosha_pos );
			Cursor( cur );
		}
		else if( key == KEY_ROLLUP )
		{
			if( Menu_temp1 >= (MAXVERTEX-2))
			{
				Warning();
				if( MESSAGE == ON )
					Message( "これ以上の分割数の面は生成できません" );
			}
			else
				Menu_temp1++;
			Status_title[Kakusu_pos] = "分割数:"+tostring( Menu_temp1, 3 );
			DrawStatus();
		}
		else if( key == KEY_ROLLDOWN )
		{
			if( Menu_temp1 <= 3 )
			{
				Warning();
				if( MESSAGE == ON )
					Message( "これ以下の分割数の面は生成できません" );
			}
			else
				Menu_temp1--;
			Status_title[Kakusu_pos] = "分割数:"+tostring( Menu_temp1, 3 );
			DrawStatus();
		}
		else if( key == 'c' )
			ToshaChange();
		else
			temp = KeyProcess( key );
		if( ((key!=0 ) & (key != INPUT_KEY)) | ( pick != Cursor()) )
		{
			draw_flag = ON;
			DrawEdge( draw_edge );
		}
		else
			draw_flag = OFF;
		pick = Cursor();
		input_flag = OFF;
	}

	Clear( OVERWRITE );
	if( SelectPolygons( prev_sel ) != 0 )
	{
		SelectAllFalse();
		SelectAll( FALSE );
	}

//	回転行列作成
	move_matrix = move( UNIT_MATRIX, Position( axis[0] )*(-1));
	trans_matrix = CalRotMatrix( axis_vec, vector( 0,0,1 ));

	for( i = 0;i<(Menu_temp1+1);i++ )
	{
		j = (0.0+Menu_temp2)*i/Menu_temp1;
		temp_matrix = rot( UNIT_MATRIX, AXISZ, j );
		rot_matrix[i] = (move_matrix*trans_matrix*temp_matrix/trans_matrix)/move_matrix;
	}
	rot_matrix[0] = UNIT_MATRIX;
	if( Menu_temp2 == 360 )
		rot_matrix[Menu_temp1] = UNIT_MATRIX;

//	面生成
	temp =	( Position( bodyline[0] ) - Position( axis[0] ))*
		( Position( bodyline[0] ) - Position( axis[1] ));
	if( abs( temp ) < 0.00001 )
		vertex_flag[0] = FALSE;
	else
		vertex_flag[0] = TRUE;
	temp =	( Position( bodyline[vers-1] ) - Position( axis[0] ))*
		( Position( bodyline[vers-1] ) - Position( axis[1] ));
	if( abs( temp ) < 0.00001 )
		vertex_flag[1] = FALSE;
	else
		vertex_flag[1] = TRUE;

	ViewCursor( OFF );
	for( j = 0;j<vers;j++ )
	{
		temp =	( Position( bodyline[j] ) - Position( axis[0] ))*
			( Position( bodyline[j] ) - Position( axis[1] ));
		if( abs( temp ) < 0.00001 )
			bodyline2[j] = bodyline[j];
		else
			bodyline2[j] = bodyline[j]*rot_matrix[0];
	}
	for( i = 1;i<(Menu_temp1+1);i++ )
	{
		for( j = 0;j<vers;j++ )
		{
			temp =	( Position( bodyline[j] ) - Position( axis[0] ))*
				( Position( bodyline[j] ) - Position( axis[1] ));
			if( abs( temp ) < 0.00001 )
				bodyline3[j] = bodyline[j];
			else
				bodyline3[j] = bodyline[j]*rot_matrix[i];
		}
		for( j = 0;j<(vers-1);j++ )
		{
			if(	( bodyline2[j] != bodyline3[j] ) |
				( bodyline2[j+1] != bodyline3[j+1] ))
			{
				if( bodyline2[j] == bodyline3[j] )
				{
					PolySetVertex( bodyline2[j], 0 );
					PolySetVertex( bodyline2[j+1], 1 );
					PolySetVertex( bodyline3[j+1], 2 );
					PolyVertexs( 3 );
				}
				else if( bodyline2[j+1] == bodyline3[j+1] )
				{
					PolySetVertex( bodyline2[j], 0 );
					PolySetVertex( bodyline2[j+1], 1 );
					PolySetVertex( bodyline3[j], 2 );
					PolyVertexs( 3 );
				}
				else
				{
					PolySetVertex( bodyline2[j], 0 );
					PolySetVertex( bodyline2[j+1], 1 );
					PolySetVertex( bodyline3[j+1], 2 );
					PolySetVertex( bodyline3[j], 3 );
					PolyVertexs( 4 );
				}
				PolyType( POLY_SIMPLE );
				PolyAttr( AttrCurrent() );
				PolyObj( ObjCurrent() );
				PolyAppend( TRUE );
				DrawCurrent( TRUE );
			}
		}
		for( j = 0;j<vers;j++ )
			bodyline2[j] = bodyline3[j];
	}
	if( Menu_temp3 == ON )
	{
		if(Menu_temp2 == 360 )
		{
			if( vertex_flag[0] )
			{
				for( i = 0;i<Menu_temp1;i++ )
				{
					cur = bodyline[0]*rot_matrix[i];
					PolySetVertex( cur, i );
				}
				PolyVertexs( Menu_temp1 );
				PolyAttr( AttrCurrent());
				PolyObj( ObjCurrent());
				PolyAppend( TRUE );
				DrawCurrent( TRUE );
			}
			if( vertex_flag[1] )
			{
				for( i = 0;i<Menu_temp1;i++ )
				{
					cur = bodyline[vers-1]*rot_matrix[i];
					PolySetVertex( cur, i );
				}
				PolyVertexs( Menu_temp1 );
				PolyAttr( AttrCurrent());
				PolyObj( ObjCurrent());
				PolyAppend( TRUE );
				DrawCurrent( TRUE );
			}
		}
		else if(Menu_temp2 == 180 )
		{
			if( vertex_flag[0] )
			{
				for( i = 0;i<(Menu_temp1+1);i++ )
				{
					cur = bodyline[0]*rot_matrix[i];
					PolySetVertex( cur, i );
				}
				PolyVertexs( Menu_temp1+1 );
				PolyAttr( AttrCurrent());
				PolyObj( ObjCurrent());
				PolyAppend( TRUE );
				DrawCurrent( TRUE );
			}
			if( vertex_flag[1] )
			{
				for( i = 0;i<(Menu_temp1+1);i++ )
				{
					cur = bodyline[vers-1]*rot_matrix[i];
					PolySetVertex( cur, i );
				}
				PolyVertexs( Menu_temp1+1 );
				PolyAttr( AttrCurrent());
				PolyObj( ObjCurrent());
				PolyAppend( TRUE );
				DrawCurrent( TRUE );
			}
			for( i = 0;i<vers;i++ )
			{
				cur = bodyline[i]*rot_matrix[0];
				PolySetVertex( cur, i );
			}
			if( vertex_flag[0] & vertex_flag[1] )
			{
				for( i = 0; i<vers;i++ )
				{
					cur = bodyline[vers-i-1]*rot_matrix[Menu_temp1];
					PolySetVertex( cur, i+vers );
				}
				PolyVertexs( vers*2 );
			}
			else if( vertex_flag[1] )
			{
				for( i = 0; i<(vers-1); i++ )
				{
					cur = bodyline[vers-i-1]*rot_matrix[Menu_temp1];
					PolySetVertex( cur, i+vers );
				}
				PolyVertexs( vers*2-1);
			}
			else if( vertex_flag[0] )
			{
				for( i = 0; i<(vers-1);i++ )
				{
					cur = bodyline[vers-i-2]*rot_matrix[Menu_temp1];
					PolySetVertex( cur, i+vers );
				}
				PolyVertexs( vers*2-1);
			}
			else
			{
				for( i = 0; i< (vers-2); i++ )
				{
					cur = bodyline[vers-i-2]*rot_matrix[Menu_temp1];
					PolySetVertex( cur, i+vers );
				}
				PolyVertexs( vers*2-2);
			}
			PolyAttr( AttrCurrent());
			PolyObj( ObjCurrent());
			PolyAppend( TRUE );
			DrawCurrent( TRUE );
		}
		else
		{
			temp_matrix = Matrix(	0, 0, 0,
						0, 0, 0,
						0, 0, 1,
						0, 0, 0 );
			temp_matrix = ((move_matrix*trans_matrix*temp_matrix)/trans_matrix)/move_matrix;

			if( vertex_flag[0] )
			{
				for( i = 0;i<(Menu_temp1+1);i++ )
				{
					cur = bodyline[0]*rot_matrix[i];
					PolySetVertex( cur, i );
				}
				cur = bodyline[0]*temp_matrix;
				PolySetVertex( cur, Menu_temp1+1 );
				PolyVertexs( Menu_temp1+2 );
				PolyAttr( AttrCurrent());
				PolyObj( ObjCurrent());
				PolyAppend( TRUE );
				DrawCurrent( TRUE );
			}
			if( vertex_flag[1] )
			{
				for( i = 0;i<(Menu_temp1+1);i++ )
				{
					cur = bodyline[vers-1]*rot_matrix[i];
					PolySetVertex( cur, i );
				}
				cur = bodyline[vers-1]*temp_matrix;
				PolySetVertex( cur, Menu_temp1+1 );
				PolyVertexs( Menu_temp1+2 );
				PolyAttr( AttrCurrent());
				PolyObj( ObjCurrent());
				PolyAppend( TRUE );
				DrawCurrent( TRUE );
			}

			for( i = 0;i<vers;i++ )
			{
				cur = bodyline[i]*rot_matrix[0];
				PolySetVertex( cur, i );
			}
			if( vertex_flag[1] & vertex_flag[0] )
			{
				cur = bodyline[vers-1]*temp_matrix;
				PolySetVertex( cur, vers );
				cur = bodyline[0]*temp_matrix;
				PolySetVertex( cur, vers+1 );
				PolyVertexs( vers+2 );
			}
			else if( vertex_flag[1] )
			{
				cur = bodyline[vers-1]*temp_matrix;
				PolySetVertex( cur, vers );
				PolyVertexs( vers+1 );
			}
			else if( vertex_flag[0] )
			{
				cur = bodyline[0]*temp_matrix;
				PolySetVertex( cur, vers );
				PolyVertexs( vers+1 );
			}
			else
			{
				PolyVertexs( vers );
			}
			PolyAttr( AttrCurrent());
			PolyObj( ObjCurrent());
			PolyAppend( TRUE );
			DrawCurrent( TRUE );

			for( i = 0;i<vers;i++ )
			{
				cur = bodyline[i]*rot_matrix[Menu_temp1];
				PolySetVertex( cur, i );
			}
			if( vertex_flag[1] & vertex_flag[0] )
			{
				cur = bodyline[vers-1]*temp_matrix;
				PolySetVertex( cur, vers );
				cur = bodyline[0]*temp_matrix;
				PolySetVertex( cur, vers+1 );
				PolyVertexs( vers+2 );
			}
			else if( vertex_flag[1] )
			{
				cur = bodyline[vers-1]*temp_matrix;
				PolySetVertex( cur, vers );
				PolyVertexs( vers+1 );
			}
			else if( vertex_flag[0] )
			{
				cur = bodyline[0]*temp_matrix;
				PolySetVertex( cur, vers );
				PolyVertexs( vers+1 );
			}
			else
			{
				PolyVertexs( vers );
			}
			PolyAttr( AttrCurrent());
			PolyObj( ObjCurrent());
			PolyAppend( TRUE );
			DrawCurrent( TRUE );
		}
	}
	ViewCursor( ON );
	Rotation_kakusu = Menu_temp1;
	UpdateObject();
	pers_rotation_flag = FALSE;
	PopMenu();
	Status_title = Status_org;
	DrawStatus();
}
