home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 March / VPR9703A.ISO / VPR_DATA / DOGA / SOURCES / POLYEDIT.LZH / MACRO / CREATEA.M < prev    next >
Text File  |  1996-06-24  |  22KB  |  960 lines

  1. var private const    Tosha_pos = 1;
  2. var private const    Kakusu_pos = 2;
  3. var private const    Deg_pos = 3;
  4. var private const    Jouge_pos = 4;
  5. var private    Menu_temp1;
  6. var private    Menu_temp2;
  7. var private    Menu_temp3;
  8.  
  9. function ToshaChange()
  10. {
  11.     tosha_flag = !tosha_flag;
  12.     if( tosha_flag == ON )
  13.         Status_title[Tosha_pos] = "平面投射:自動";
  14.     else
  15.         Status_title[Tosha_pos] = "平面投射:手動";
  16.     DrawStatus();
  17. }
  18.  
  19. function private InputSetup()
  20. {
  21.     var    men[2], key, temp;
  22.  
  23.     men = {" 生成 ", "非生成" };
  24.     DlogOpen( "回転体作成 設定変更", 5, "キャンセル ", " 決定 " );
  25.     DlogString( 0, "分割数         ", tostring( Menu_temp1 ), 14 );
  26.     DlogString( 2, "生成角度(1-360)", tostring( Menu_temp2 ), 14 );
  27.     DlogSelect( 4, "上面・下面     ", men, (1-Menu_temp3) );
  28.     key = DlogWait();
  29.     if( key == 0 )
  30.         return FALSE;
  31.     else
  32.     {
  33.         Menu_temp1 = atoi( DlogAnswer( 0 ));
  34.         if( Menu_temp1 >= (MAXVERTEX-2))
  35.             Menu_temp1 = MAXVERTEX-2;
  36.         if( Menu_temp1 < 3 )
  37.             Menu_temp1 = 3;
  38.         Menu_temp2 = atoi( DlogAnswer( 2 ));
  39.         if( Menu_temp2 > 360 )
  40.             Menu_temp2 = 360;
  41.         if( Menu_temp2 < 1 )
  42.             Menu_temp2 = 1;
  43.         temp = DlogAnswer( 4 );
  44.         if( temp == 0 )
  45.             Menu_temp3 = ON;
  46.         else
  47.             Menu_temp3 = OFF;
  48.         Status_title[Kakusu_pos] = "分割数:"+tostring( Menu_temp1, 3 );
  49.         Status_title[Deg_pos] = "角度:"+tostring( Menu_temp2 , 3);
  50.         if( Menu_temp3 == OFF )
  51.             Status_title[Jouge_pos] = "上下面:非生成";
  52.         else
  53.             Status_title[Jouge_pos] = "上下面:  生成";
  54.         DrawStatus();
  55.     }
  56.     return TRUE;
  57. }
  58.  
  59. function private Inputkakusu()
  60. {
  61.     DlogOpen( "角数入力", 1 );
  62.     DlogString( 0, "角数 ", tostring( Menu_temp1 ), 6 );
  63.     if( DlogWait() )
  64.         Menu_temp1 = atoi( DlogAnswer( 0 ));
  65.     if( Menu_temp1 > MAXVERTEX )
  66.         Menu_temp1 = MAXVERTEX;
  67.     if( Menu_temp1 < 3 )
  68.         Menu_temp1 = 3;
  69.     Status_title[Kakusu_pos] = "角数: "+tostring( Menu_temp1, 4 )+" ";
  70.     DrawStatus();
  71. }
  72.  
  73. //
  74. //    正多角形描画
  75. //
  76. function DrawEquilateral( kakusuu, point0, point1, point2, save_mode )
  77. {
  78.     var    axis_vec,p0_vec,p1_vec,p2_vec,p01_vec, p12_vec;
  79.     var    trans_matrix, move_matrix,temp1_matrix, temp2_matrix;
  80.     var    i,j, draw_edge;
  81.     var    v0, v1, v2;
  82.  
  83.     if( kakusuu < 3 )
  84.         return Edge();
  85.  
  86.     p0_vec = Position( point0 );
  87.     p1_vec = Position( point1 );
  88.     p2_vec = Position( point2 );
  89.     p01_vec = p1_vec - p0_vec;
  90.     p12_vec = p2_vec - p1_vec;
  91.     axis_vec = p01_vec*p12_vec;
  92.  
  93.     if( abs(axis_vec) < 0.00001 )
  94.         return Edge();
  95.  
  96.     move_matrix = move( UNIT_MATRIX, p0_vec*(-1) );
  97.     trans_matrix = vec( UNIT_MATRIX, axis_vec, p01_vec );
  98.     temp1_matrix = move_matrix/trans_matrix;
  99.     temp2_matrix = trans_matrix/move_matrix;
  100.  
  101.     v0 = point1;
  102.     v1 = v0;
  103.     draw_edge = Edge();
  104.     if( save_mode == ON )
  105.         PolySetVertex( v0, 0 );
  106.     for( i = 1;i<kakusuu;i++ )
  107.     {
  108.         j = 0.0;
  109.         j = (360.0*i)/kakusuu;
  110.         v2 = point1*(temp1_matrix*rot(UNIT_MATRIX, AXISX, j )*temp2_matrix);
  111.         if( save_mode == ON )
  112.             PolySetVertex( v2, i );
  113.         draw_edge = draw_edge + Edge( v1, v2 );
  114.         v1 = v2;
  115.     }
  116.     draw_edge = draw_edge + Edge( v2, v0 );
  117.     if( save_mode == ON )
  118.     {
  119.         PolyVertexs( kakusuu );
  120.         PolyType( POLY_SIMPLE );
  121.         PolyAttr( AttrCurrent());
  122.         PolyObj( ObjCurrent());
  123.         SelectAll( FALSE );
  124.         PolyAppend( TRUE );
  125.         ViewCursor( OFF );
  126.         DrawCurrent( TRUE );
  127.         ViewCursor( ON );
  128.     }
  129.     return draw_edge;
  130. }
  131.  
  132. //
  133. //    正多角形生成
  134. //
  135. function CreateEquilateralPolygon()
  136. {
  137.  
  138.     var    point[3], p_vec[3];
  139.     var    vers, key, mode, temp;
  140.     var    pick, draw_flag = ON;
  141.     var    pick_kakusu, vers_temp;
  142.     var    draw_edge, prev_sel;
  143.  
  144.     Menu_temp1 = Equilateral_kakusu;
  145.     PushMenu();
  146.     Status_org = Status_title;
  147.     MenuPosition( Menu( " 動作設定(&S)",
  148.             "角数入力",        Inputkakusu,
  149.             "--------",        SEPARATE_MENU,
  150.             "作成中止    ESC",    MenuQuit
  151.         ), Menu_Title );
  152.  
  153.     ClearStatus();
  154.     Status_title[0] = "【正多角形作成中】";
  155.     Status_title[Kakusu_pos] = "角数: "+tostring( Menu_temp1, 4 )+" ";
  156.     DrawStatus();
  157.  
  158.     quit_flag = FALSE;
  159.  
  160.     prev_sel = Select();
  161.     point[0] = Cursor();
  162.     cur = Cursor();
  163.     pick = cur;
  164.     vers = 1;
  165.     pick_kakusu = Menu_temp1;
  166.     vers_temp = 0;
  167.     input_flag = OFF;
  168.     while( TRUE )
  169.     {
  170.         if( draw_flag == ON )
  171.         {
  172.             if( vers == 1 )
  173.             {
  174.                 draw_edge = Edge( point[0], cur );
  175.                 DrawEdge( draw_edge );
  176.             }
  177.             else
  178.             {
  179.                 draw_edge = Edge( point[0], point[1] );
  180.                 if( point[1] != cur )
  181.                 {
  182.                     mode = OFF;
  183.                     draw_edge = DrawEquilateral( Menu_temp1, point[0], point[1], cur, mode ) + draw_edge;
  184.                 }
  185.                 DrawEdge( draw_edge );
  186.             }
  187.         }
  188.         key = WaitEvent();
  189.         if( key )
  190.             input_flag = ON;
  191.         if( (( ShiftStat() & 1 ) == 1) & ( vers == 1 ))
  192.         {
  193.             cur = Cursor();
  194.             TrimCursor(point[0], MouseWindow());
  195.             Cursor( cur );
  196.         }
  197.         else
  198.             cur = Cursor();
  199.         key = KeyCode();
  200.         if( input_flag | key == INPUT_KEY )
  201.         {
  202.             if( vers == 1 )
  203.             {
  204.                 if( cur == point[0] )
  205.                 {
  206.                     Warning();
  207.                     if( MESSAGE == ON )
  208.                         Message( "外接円の半径を指定してください" );
  209.                 }
  210.                 else
  211.                 {
  212.                     point[1] = cur;
  213.                     vers_temp = 1;
  214.                 }
  215.             }
  216.             else if( vers == 2 )
  217.             {
  218.                 if( cur == point[0]  |  cur == point[1] )
  219.                 {
  220.                     Warning();
  221.                     if( MESSAGE == ON )
  222.                         Message( "面を生成する方向を指定してください" );
  223.                 }
  224.                 else
  225.                 {
  226.                     DrawEdge( draw_edge );
  227.                     point[2] = cur;
  228.                     break;
  229.                 }
  230.             }
  231.         }
  232.         else if( key == ESC | quit_flag == TRUE )
  233.         {
  234.             DrawEdge( draw_edge );
  235.             PopandClear();
  236.             Equilateral_kakusu = Menu_temp1;
  237.             return;
  238.         }
  239.         else if( key == BS )
  240.         {
  241.             if( vers == 1 )
  242.             {
  243.                 DrawEdge( draw_edge );
  244.                 Warning();
  245.                 PopandClear();
  246.                 Equilateral_kakusu = Menu_temp1;
  247.                 return;
  248.             }
  249.             else
  250.             {
  251.                 vers_temp = -1;
  252.                 Cursor( point[1] );
  253.                 cur = Cursor();
  254.             }
  255.         }
  256.         else if( key == KEY_ROLLUP )
  257.         {
  258.             if( Menu_temp1 >= MAXVERTEX )
  259.             {
  260.                 Warning();
  261.                 if( MESSAGE == ON )
  262.                     Message( "これ以上の角数の面は生成できません" );
  263.             }
  264.             else
  265.                 Menu_temp1++;
  266.             Status_title[Kakusu_pos] = "角数: "+tostring( Menu_temp1, 4 )+" ";
  267.             DrawStatus();
  268.         }
  269.         else if( key == KEY_ROLLDOWN )
  270.         {
  271.             if( Menu_temp1 <= 3 )
  272.             {
  273.                 Warning();
  274.                 if( MESSAGE == ON )
  275.                     Message( "これ以下の角数の面は生成できません" );
  276.             }
  277.             else
  278.                 Menu_temp1--;
  279.             Status_title[Kakusu_pos] = "角数: "+tostring( Menu_temp1, 4 )+" ";
  280.             DrawStatus();
  281.         }
  282.         else
  283.             temp = KeyProcess( key );
  284.         if(((key!=0 )&(key!=INPUT_KEY))|(pick!=Cursor())|(pick_kakusu!= Menu_temp1))
  285.         {
  286.             draw_flag = ON;
  287.             DrawEdge( draw_edge );
  288.         }
  289.         else
  290.             draw_flag = OFF;
  291.         pick_kakusu = Menu_temp1;
  292.         vers = vers+vers_temp;
  293.         vers_temp = 0;
  294.         pick = Cursor();
  295.         input_flag = OFF;
  296.     }
  297.     if( SelectPolygons( prev_sel ) != 0 )
  298.     {
  299.         SelectAllFalse();
  300.         SelectAll( FALSE );
  301.     }
  302.     mode = ON;
  303.     DrawEquilateral( Menu_temp1, point[0], point[1], cur, mode );
  304.     Equilateral_kakusu = Menu_temp1;
  305.     UpdateObject();
  306.     pers_rotation_flag = FALSE;
  307.     PopMenu();
  308.     Status_title = Status_org;
  309.     DrawStatus();
  310. }
  311.  
  312. //
  313. //    回転体の作成
  314. //
  315. function CreateRotationBody()
  316. {
  317.     var    maxbodyline = 100;
  318.     var    axis[2], prev, bodyline[100];
  319.     var    bodyline2[100],bodyline3[100];
  320.     var    key,vers, axis_type, i, mode;
  321.     var    j, end_deg, temp, tosha_pos,tosha_mode = OFF;
  322.     var    temp_vec, axis_vec;
  323.     var    trans_matrix, move_matrix, temp_matrix, rot_matrix[MAXVERTEX];
  324.     var    position_vec;
  325.     var    msg[2], vertex_flag[2];
  326.     var    pick, draw_flag = ON;
  327.     var    draw_edge, prev_sel;
  328.  
  329.     if( maxbodyline*2 > MAXVERTEX )
  330.         maxbodyline = MAXVERTEX/2;
  331.  
  332.     Menu_temp1 = Rotation_kakusu;
  333.     Menu_temp2 = 360;    /* 生成角度 */
  334.     Menu_temp3 = OFF;    /* 上面・下面生成の有無 */
  335.  
  336.     prev_sel = Select();
  337.     PushMenu();
  338.     Status_org = Status_title;
  339.     MenuPosition( Menu( " 動作設定(&S)",
  340.             "設定変更    ",        InputSetup,
  341.             "------------",        SEPARATE_MENU,
  342.             "自動平面投射    C",    ToshaChange, Check_Toshaflag,
  343.             "------------",        SEPARATE_MENU,
  344.             "作成中止        ESC",    MenuQuit
  345.         ), Menu_Title );
  346.  
  347.     quit_flag = FALSE;
  348.  
  349.     ClearStatus();
  350.     Status_title[0] = "【回転体作成中】";
  351.     Status_title[Kakusu_pos] = "分割数:"+tostring( Menu_temp1, 3 );
  352.     Status_title[Deg_pos] = "角度:"+tostring( Menu_temp2 , 3);
  353.     if( Menu_temp3 == OFF )
  354.         Status_title[Jouge_pos] = "上下面:非生成";
  355.     else
  356.         Status_title[Jouge_pos] = "上下面:  生成";
  357.     if( tosha_flag == ON )
  358.         Status_title[Tosha_pos] = "平面投射:自動";
  359.     else
  360.         Status_title[Tosha_pos] = "平面投射:手動";
  361.     DrawStatus();
  362.  
  363.     axis[0] = Cursor();
  364.     cur = Cursor();
  365.     pick = cur;
  366.     vers = 1;
  367.     input_flag = OFF;
  368.     draw_edge = Edge();
  369.     while( TRUE )
  370.     {
  371.         if( draw_flag == ON )
  372.         {
  373.             draw_edge = Edge( axis[0], cur );
  374.             DrawLine( axis[0], cur );
  375.         }
  376.         key = WaitEvent();
  377.         if( key )
  378.             input_flag = ON;
  379.         if( (( ShiftStat() & 1 ) == 1))
  380.         {
  381.             cur = Cursor();
  382.             TrimCursor(axis[0], MouseWindow());
  383.             Cursor( cur );
  384.         }
  385.         else
  386.         {
  387.             cur = Cursor();
  388.         }
  389.         key = KeyCode();
  390.         if( input_flag | key == INPUT_KEY )
  391.         {
  392.             axis[vers] = cur;
  393.             if( pick != cur )
  394.             {
  395.                 DrawEdge( draw_edge );
  396.                 DrawLine( axis[0], axis[1] );
  397.             }
  398.             if( cur == axis[0] )
  399.             {
  400.                 Warning();
  401.                 if( MESSAGE == ON )
  402.                     Message( "回転体の軸を指定してください" );
  403.             }
  404.             else
  405.                 break;
  406.         }
  407.         else if( key == ESC | key == BS | quit_flag == TRUE )
  408.         {
  409.             PopandClear( OVERWRITE );
  410.             Rotation_kakusu = Menu_temp1;
  411.             return;
  412.         }
  413.         else if( key == KEY_ROLLUP )
  414.         {
  415.             if( Menu_temp1 >= (MAXVERTEX-2))
  416.             {
  417.                 Warning();
  418.                 if( MESSAGE == ON )
  419.                     Message( "これ以上の分割数の面は生成できません" );
  420.             }
  421.             else
  422.                 Menu_temp1++;
  423.             Status_title[Kakusu_pos] = "分割数:"+tostring( Menu_temp1, 3 );
  424.             DrawStatus();
  425.         }
  426.         else if( key == KEY_ROLLDOWN )
  427.         {
  428.             if( Menu_temp1 <= 3 )
  429.             {
  430.                 Warning();
  431.                 if( MESSAGE == ON )
  432.                     Message( "これ以下の分割数の面は生成できません" );
  433.             }
  434.             else
  435.                 Menu_temp1--;
  436.             Status_title[Kakusu_pos] = "分割数:"+tostring( Menu_temp1, 3 );
  437.             DrawStatus();
  438.         }
  439.         else if( key == 'c' )
  440.             ToshaChange();
  441.         else
  442.             temp = KeyProcess( key );
  443.         if( ((key!=0 ) & (key != INPUT_KEY)) | ( pick != Cursor()) )
  444.         {
  445.             draw_flag = ON;
  446.             DrawEdge( draw_edge );
  447.         }
  448.         else
  449.             draw_flag = OFF;
  450.         pick = Cursor();
  451.         input_flag = OFF;
  452.     }
  453.     axis_vec = unit(Position( axis[1]) - Position( axis[0] ));
  454.     if( vector( 0, 0, 1 ).axis_vec < 0 )
  455.     {
  456.         cur = axis[0];
  457.         axis[0] = axis[1];
  458.         axis[1] = cur;
  459.         axis_vec *= -1;
  460.     }
  461.     vers = 0;
  462.     draw_flag = ON;
  463.     input_flag = OFF;
  464.     draw_edge = Edge();
  465.     while( TRUE )
  466.     {
  467.         if( vers != 0 & (draw_flag == ON ))
  468.         {
  469.             draw_edge = Edge( cur, prev );
  470.             DrawLine( cur, prev );
  471.         }
  472.         key = WaitEvent();
  473.         if( key )
  474.             input_flag = ON;
  475.         if( (( ShiftStat() & 1 ) == 1 )& ( vers != 0 ))
  476.         {
  477.             cur = Cursor();
  478.             TrimCursor(prev, MouseWindow());
  479.             Cursor( cur );
  480.         }
  481.         else
  482.             cur = Cursor();
  483.         if(( tosha_mode == ON ) & ( tosha_flag == ON ) & ( cur != pick))
  484.         {
  485.             cur = PolyPlane( cur, MouseWindow(),
  486.                     axis[0], axis[1], tosha_pos );
  487.             Cursor( cur );
  488.         }
  489.         key = KeyCode();
  490.         if ( input_flag | key == INPUT_KEY )
  491.         {
  492.             if( pick != cur )
  493.             {
  494.                 DrawEdge( draw_edge );
  495.                 DrawLine( cur, prev );
  496.             }
  497.             if( vers == 0 )
  498.             {
  499.                 bodyline[vers] = cur;
  500.                 vers++;
  501.                 draw_edge = Edge();
  502.                 if(abs( axis_vec*(Position(cur) - Position(axis[0]))) > 0.00001 )
  503.                 {
  504.                     tosha_mode = ON;
  505.                     tosha_pos = cur;
  506.                 }
  507.             }
  508.             else if( vers == 1 )
  509.             {
  510.                 if ( prev == cur )
  511.                 {
  512.                     Warning();
  513.                     if( MESSAGE == ON )
  514.                         Message( "前に確定した点と同じ点です" );
  515.                 }
  516.                 else
  517.                 {
  518.                     bodyline[vers] = cur;
  519.                     draw_edge = Edge();
  520.                     vers++;
  521.                     if( tosha_mode == OFF )
  522.                     {
  523.                         if(abs( axis_vec*(Position(cur)-Position(axis[0]))) > 0.00001 )
  524.                         {
  525.                             tosha_mode = ON;
  526.                             tosha_pos = cur;
  527.                         }
  528.                     }
  529.                 }
  530.             }
  531.             else
  532.             {
  533.                 if( prev == cur )
  534.                     break;
  535.                 else
  536.                 {
  537.                     bodyline[vers] = cur;
  538.                     draw_edge = Edge();
  539.                     vers++;
  540.                     if( tosha_mode == OFF )
  541.                     {
  542.                         if(abs( axis_vec*(Position(cur)-Position(axis[0]))) > 0.00001 )
  543.                         {
  544.                             tosha_mode = ON;
  545.                             tosha_pos = cur;
  546.                         }
  547.                     }
  548.                 }
  549.             }
  550.             if( vers == maxbodyline )
  551.             {
  552.                 Warning();
  553.                 Message( "これ以上の回転体は作ることができません\n"
  554.                     +"現在までに確定された点で回転体を生成します" );
  555.                 break;
  556.             }
  557.             prev = cur ;
  558.         }
  559.         else if( key == ESC | quit_flag == TRUE )
  560.         {
  561.             PopandClear( OVERWRITE );
  562.             Rotation_kakusu = Menu_temp1;
  563.             return;
  564.         }
  565.         else if ( key == BS )
  566.         {
  567.             if ( vers > 1 )
  568.             {
  569.                 if( cur != prev )
  570.                 {
  571.                     cur = bodyline[vers-1];
  572.                     prev = bodyline[vers - 2];
  573.                     cur = Cursor( cur );
  574.                     vers --;
  575.                     DrawLine( prev, cur );
  576.                 }
  577.                 else
  578.                 {
  579.                     prev = bodyline[vers - 2];
  580.                     vers --;
  581.                     DrawLine( prev, cur );
  582.                 }
  583.             }
  584.             else if ( vers == 1 )
  585.             {
  586.                 cur = bodyline[vers-1];
  587.                 Cursor( cur );
  588.                 vers--;
  589.                 DrawEdge( draw_edge );
  590.                 draw_edge = Edge();
  591.             }
  592.             else
  593.             {
  594.                 PopandClear( OVERWRITE );
  595.                 Rotation_kakusu = Menu_temp1;
  596.                 return ;
  597.             }
  598.         }
  599.         else if( ( key == 'p' ) & ( tosha_mode == ON ))
  600.         {
  601.             cur = PolyPlane( cur, MouseWindow(),
  602.                     axis[0], axis[1], tosha_pos );
  603.             Cursor( cur );
  604.         }
  605.         else if( key == KEY_ROLLUP )
  606.         {
  607.             if( Menu_temp1 >= (MAXVERTEX-2))
  608.             {
  609.                 Warning();
  610.                 if( MESSAGE == ON )
  611.                     Message( "これ以上の分割数の面は生成できません" );
  612.             }
  613.             else
  614.                 Menu_temp1++;
  615.             Status_title[Kakusu_pos] = "分割数:"+tostring( Menu_temp1, 3 );
  616.             DrawStatus();
  617.         }
  618.         else if( key == KEY_ROLLDOWN )
  619.         {
  620.             if( Menu_temp1 <= 3 )
  621.             {
  622.                 Warning();
  623.                 if( MESSAGE == ON )
  624.                     Message( "これ以下の分割数の面は生成できません" );
  625.             }
  626.             else
  627.                 Menu_temp1--;
  628.             Status_title[Kakusu_pos] = "分割数:"+tostring( Menu_temp1, 3 );
  629.             DrawStatus();
  630.         }
  631.         else if( key == 'c' )
  632.             ToshaChange();
  633.         else
  634.             temp = KeyProcess( key );
  635.         if( ((key!=0 ) & (key != INPUT_KEY)) | ( pick != Cursor()) )
  636.         {
  637.             draw_flag = ON;
  638.             DrawEdge( draw_edge );
  639.         }
  640.         else
  641.             draw_flag = OFF;
  642.         pick = Cursor();
  643.         input_flag = OFF;
  644.     }
  645.  
  646.     Clear( OVERWRITE );
  647.     if( SelectPolygons( prev_sel ) != 0 )
  648.     {
  649.         SelectAllFalse();
  650.         SelectAll( FALSE );
  651.     }
  652.  
  653. //    回転行列作成
  654.     move_matrix = move( UNIT_MATRIX, Position( axis[0] )*(-1));
  655.     trans_matrix = CalRotMatrix( axis_vec, vector( 0,0,1 ));
  656.  
  657.     for( i = 0;i<(Menu_temp1+1);i++ )
  658.     {
  659.         j = (0.0+Menu_temp2)*i/Menu_temp1;
  660.         temp_matrix = rot( UNIT_MATRIX, AXISZ, j );
  661.         rot_matrix[i] = (move_matrix*trans_matrix*temp_matrix/trans_matrix)/move_matrix;
  662.     }
  663.     rot_matrix[0] = UNIT_MATRIX;
  664.     if( Menu_temp2 == 360 )
  665.         rot_matrix[Menu_temp1] = UNIT_MATRIX;
  666.  
  667. //    面生成
  668.     temp =    ( Position( bodyline[0] ) - Position( axis[0] ))*
  669.         ( Position( bodyline[0] ) - Position( axis[1] ));
  670.     if( abs( temp ) < 0.00001 )
  671.         vertex_flag[0] = FALSE;
  672.     else
  673.         vertex_flag[0] = TRUE;
  674.     temp =    ( Position( bodyline[vers-1] ) - Position( axis[0] ))*
  675.         ( Position( bodyline[vers-1] ) - Position( axis[1] ));
  676.     if( abs( temp ) < 0.00001 )
  677.         vertex_flag[1] = FALSE;
  678.     else
  679.         vertex_flag[1] = TRUE;
  680.  
  681.     ViewCursor( OFF );
  682.     for( j = 0;j<vers;j++ )
  683.     {
  684.         temp =    ( Position( bodyline[j] ) - Position( axis[0] ))*
  685.             ( Position( bodyline[j] ) - Position( axis[1] ));
  686.         if( abs( temp ) < 0.00001 )
  687.             bodyline2[j] = bodyline[j];
  688.         else
  689.             bodyline2[j] = bodyline[j]*rot_matrix[0];
  690.     }
  691.     for( i = 1;i<(Menu_temp1+1);i++ )
  692.     {
  693.         for( j = 0;j<vers;j++ )
  694.         {
  695.             temp =    ( Position( bodyline[j] ) - Position( axis[0] ))*
  696.                 ( Position( bodyline[j] ) - Position( axis[1] ));
  697.             if( abs( temp ) < 0.00001 )
  698.                 bodyline3[j] = bodyline[j];
  699.             else
  700.                 bodyline3[j] = bodyline[j]*rot_matrix[i];
  701.         }
  702.         for( j = 0;j<(vers-1);j++ )
  703.         {
  704.             if(    ( bodyline2[j] != bodyline3[j] ) |
  705.                 ( bodyline2[j+1] != bodyline3[j+1] ))
  706.             {
  707.                 if( bodyline2[j] == bodyline3[j] )
  708.                 {
  709.                     PolySetVertex( bodyline2[j], 0 );
  710.                     PolySetVertex( bodyline2[j+1], 1 );
  711.                     PolySetVertex( bodyline3[j+1], 2 );
  712.                     PolyVertexs( 3 );
  713.                 }
  714.                 else if( bodyline2[j+1] == bodyline3[j+1] )
  715.                 {
  716.                     PolySetVertex( bodyline2[j], 0 );
  717.                     PolySetVertex( bodyline2[j+1], 1 );
  718.                     PolySetVertex( bodyline3[j], 2 );
  719.                     PolyVertexs( 3 );
  720.                 }
  721.                 else
  722.                 {
  723.                     PolySetVertex( bodyline2[j], 0 );
  724.                     PolySetVertex( bodyline2[j+1], 1 );
  725.                     PolySetVertex( bodyline3[j+1], 2 );
  726.                     PolySetVertex( bodyline3[j], 3 );
  727.                     PolyVertexs( 4 );
  728.                 }
  729.                 PolyType( POLY_SIMPLE );
  730.                 PolyAttr( AttrCurrent() );
  731.                 PolyObj( ObjCurrent() );
  732.                 PolyAppend( TRUE );
  733.                 DrawCurrent( TRUE );
  734.             }
  735.         }
  736.         for( j = 0;j<vers;j++ )
  737.             bodyline2[j] = bodyline3[j];
  738.     }
  739.     if( Menu_temp3 == ON )
  740.     {
  741.         if(Menu_temp2 == 360 )
  742.         {
  743.             if( vertex_flag[0] )
  744.             {
  745.                 for( i = 0;i<Menu_temp1;i++ )
  746.                 {
  747.                     cur = bodyline[0]*rot_matrix[i];
  748.                     PolySetVertex( cur, i );
  749.                 }
  750.                 PolyVertexs( Menu_temp1 );
  751.                 PolyAttr( AttrCurrent());
  752.                 PolyObj( ObjCurrent());
  753.                 PolyAppend( TRUE );
  754.                 DrawCurrent( TRUE );
  755.             }
  756.             if( vertex_flag[1] )
  757.             {
  758.                 for( i = 0;i<Menu_temp1;i++ )
  759.                 {
  760.                     cur = bodyline[vers-1]*rot_matrix[i];
  761.                     PolySetVertex( cur, i );
  762.                 }
  763.                 PolyVertexs( Menu_temp1 );
  764.                 PolyAttr( AttrCurrent());
  765.                 PolyObj( ObjCurrent());
  766.                 PolyAppend( TRUE );
  767.                 DrawCurrent( TRUE );
  768.             }
  769.         }
  770.         else if(Menu_temp2 == 180 )
  771.         {
  772.             if( vertex_flag[0] )
  773.             {
  774.                 for( i = 0;i<(Menu_temp1+1);i++ )
  775.                 {
  776.                     cur = bodyline[0]*rot_matrix[i];
  777.                     PolySetVertex( cur, i );
  778.                 }
  779.                 PolyVertexs( Menu_temp1+1 );
  780.                 PolyAttr( AttrCurrent());
  781.                 PolyObj( ObjCurrent());
  782.                 PolyAppend( TRUE );
  783.                 DrawCurrent( TRUE );
  784.             }
  785.             if( vertex_flag[1] )
  786.             {
  787.                 for( i = 0;i<(Menu_temp1+1);i++ )
  788.                 {
  789.                     cur = bodyline[vers-1]*rot_matrix[i];
  790.                     PolySetVertex( cur, i );
  791.                 }
  792.                 PolyVertexs( Menu_temp1+1 );
  793.                 PolyAttr( AttrCurrent());
  794.                 PolyObj( ObjCurrent());
  795.                 PolyAppend( TRUE );
  796.                 DrawCurrent( TRUE );
  797.             }
  798.             for( i = 0;i<vers;i++ )
  799.             {
  800.                 cur = bodyline[i]*rot_matrix[0];
  801.                 PolySetVertex( cur, i );
  802.             }
  803.             if( vertex_flag[0] & vertex_flag[1] )
  804.             {
  805.                 for( i = 0; i<vers;i++ )
  806.                 {
  807.                     cur = bodyline[vers-i-1]*rot_matrix[Menu_temp1];
  808.                     PolySetVertex( cur, i+vers );
  809.                 }
  810.                 PolyVertexs( vers*2 );
  811.             }
  812.             else if( vertex_flag[1] )
  813.             {
  814.                 for( i = 0; i<(vers-1); i++ )
  815.                 {
  816.                     cur = bodyline[vers-i-1]*rot_matrix[Menu_temp1];
  817.                     PolySetVertex( cur, i+vers );
  818.                 }
  819.                 PolyVertexs( vers*2-1);
  820.             }
  821.             else if( vertex_flag[0] )
  822.             {
  823.                 for( i = 0; i<(vers-1);i++ )
  824.                 {
  825.                     cur = bodyline[vers-i-2]*rot_matrix[Menu_temp1];
  826.                     PolySetVertex( cur, i+vers );
  827.                 }
  828.                 PolyVertexs( vers*2-1);
  829.             }
  830.             else
  831.             {
  832.                 for( i = 0; i< (vers-2); i++ )
  833.                 {
  834.                     cur = bodyline[vers-i-2]*rot_matrix[Menu_temp1];
  835.                     PolySetVertex( cur, i+vers );
  836.                 }
  837.                 PolyVertexs( vers*2-2);
  838.             }
  839.             PolyAttr( AttrCurrent());
  840.             PolyObj( ObjCurrent());
  841.             PolyAppend( TRUE );
  842.             DrawCurrent( TRUE );
  843.         }
  844.         else
  845.         {
  846.             temp_matrix = Matrix(    0, 0, 0,
  847.                         0, 0, 0,
  848.                         0, 0, 1,
  849.                         0, 0, 0 );
  850.             temp_matrix = ((move_matrix*trans_matrix*temp_matrix)/trans_matrix)/move_matrix;
  851.  
  852.             if( vertex_flag[0] )
  853.             {
  854.                 for( i = 0;i<(Menu_temp1+1);i++ )
  855.                 {
  856.                     cur = bodyline[0]*rot_matrix[i];
  857.                     PolySetVertex( cur, i );
  858.                 }
  859.                 cur = bodyline[0]*temp_matrix;
  860.                 PolySetVertex( cur, Menu_temp1+1 );
  861.                 PolyVertexs( Menu_temp1+2 );
  862.                 PolyAttr( AttrCurrent());
  863.                 PolyObj( ObjCurrent());
  864.                 PolyAppend( TRUE );
  865.                 DrawCurrent( TRUE );
  866.             }
  867.             if( vertex_flag[1] )
  868.             {
  869.                 for( i = 0;i<(Menu_temp1+1);i++ )
  870.                 {
  871.                     cur = bodyline[vers-1]*rot_matrix[i];
  872.                     PolySetVertex( cur, i );
  873.                 }
  874.                 cur = bodyline[vers-1]*temp_matrix;
  875.                 PolySetVertex( cur, Menu_temp1+1 );
  876.                 PolyVertexs( Menu_temp1+2 );
  877.                 PolyAttr( AttrCurrent());
  878.                 PolyObj( ObjCurrent());
  879.                 PolyAppend( TRUE );
  880.                 DrawCurrent( TRUE );
  881.             }
  882.  
  883.             for( i = 0;i<vers;i++ )
  884.             {
  885.                 cur = bodyline[i]*rot_matrix[0];
  886.                 PolySetVertex( cur, i );
  887.             }
  888.             if( vertex_flag[1] & vertex_flag[0] )
  889.             {
  890.                 cur = bodyline[vers-1]*temp_matrix;
  891.                 PolySetVertex( cur, vers );
  892.                 cur = bodyline[0]*temp_matrix;
  893.                 PolySetVertex( cur, vers+1 );
  894.                 PolyVertexs( vers+2 );
  895.             }
  896.             else if( vertex_flag[1] )
  897.             {
  898.                 cur = bodyline[vers-1]*temp_matrix;
  899.                 PolySetVertex( cur, vers );
  900.                 PolyVertexs( vers+1 );
  901.             }
  902.             else if( vertex_flag[0] )
  903.             {
  904.                 cur = bodyline[0]*temp_matrix;
  905.                 PolySetVertex( cur, vers );
  906.                 PolyVertexs( vers+1 );
  907.             }
  908.             else
  909.             {
  910.                 PolyVertexs( vers );
  911.             }
  912.             PolyAttr( AttrCurrent());
  913.             PolyObj( ObjCurrent());
  914.             PolyAppend( TRUE );
  915.             DrawCurrent( TRUE );
  916.  
  917.             for( i = 0;i<vers;i++ )
  918.             {
  919.                 cur = bodyline[i]*rot_matrix[Menu_temp1];
  920.                 PolySetVertex( cur, i );
  921.             }
  922.             if( vertex_flag[1] & vertex_flag[0] )
  923.             {
  924.                 cur = bodyline[vers-1]*temp_matrix;
  925.                 PolySetVertex( cur, vers );
  926.                 cur = bodyline[0]*temp_matrix;
  927.                 PolySetVertex( cur, vers+1 );
  928.                 PolyVertexs( vers+2 );
  929.             }
  930.             else if( vertex_flag[1] )
  931.             {
  932.                 cur = bodyline[vers-1]*temp_matrix;
  933.                 PolySetVertex( cur, vers );
  934.                 PolyVertexs( vers+1 );
  935.             }
  936.             else if( vertex_flag[0] )
  937.             {
  938.                 cur = bodyline[0]*temp_matrix;
  939.                 PolySetVertex( cur, vers );
  940.                 PolyVertexs( vers+1 );
  941.             }
  942.             else
  943.             {
  944.                 PolyVertexs( vers );
  945.             }
  946.             PolyAttr( AttrCurrent());
  947.             PolyObj( ObjCurrent());
  948.             PolyAppend( TRUE );
  949.             DrawCurrent( TRUE );
  950.         }
  951.     }
  952.     ViewCursor( ON );
  953.     Rotation_kakusu = Menu_temp1;
  954.     UpdateObject();
  955.     pers_rotation_flag = FALSE;
  956.     PopMenu();
  957.     Status_title = Status_org;
  958.     DrawStatus();
  959. }
  960.