Draw { SelectScreen(0) ; Box(0,0,SCR_X,SCR_Y,0,7) ; Print(108,8,0,6,12,0,"データ数 :") ; PrintData(180,8,0,6,12,0,0,buf(0,0)) ; Set3DLocalRotateX(0,rx) ; Set3DLocalRotateY(0,ry) ; Set3DLocalRotateZ(0,rz) ; Draw3DPack(0) ; CopyBMP(0,0,0,draw_w,draw_h, 1,draw_x,draw_y,draw_w,draw_h,0) ; } DrawN { SelectScreen(0) ; Box(0,0,SCR_X,SCR_Y,0,7) ; Draw3DPack(0) ; CopyBMP(0,0,0,draw_w,draw_h, 1,draw_x,draw_y,draw_w,draw_h,0) ; } TIMER { if(text_flag == 1){ return ; } if(pause_flag == 1){ return ; } call("Draw") ; } // バッファデータから3Dデータを作成 GetBufData { Clear3DPack(0) ; n = 1 ; loop(buf(0,0)){ Add3DPack(0, buf(n,0),buf(n,1),buf(n,2), buf(n,3),buf(n,4),buf(n,5), buf(n,6),buf(n,7),buf(n,8), buf(0,1),buf(0,2),buf(0,3)) ; n = n + 1 ; } } // 柱データのセット Hasira { if(kaku < 3){ kaku = 3 ; } n = 1 ; p = 360 / kaku ; x = p / 2 ; buf(0,0) = kaku * 4 ; buf(0,1) = icr ; buf(0,2) = icg ; buf(0,3) = icb ; loop(kaku){ sx1 = -cos(x) * s_size + x_center ; sz1 = sin(x) * s_size + z_center ; sx2 = -cos(x+p) * s_size + x_center ; sz2 = sin(x+p) * s_size + z_center ; sx3 = x_center ; sz3 = z_center ; sy = l_size + y_center ; fx1 = -cos(x) * f_size + x_center ; fz1 = sin(x) * f_size + z_center ; fx2 = -cos(x+p) * f_size + x_center ; fz2 = sin(x+p) * f_size + z_center ; fx3 = x_center ; fz3 = z_center ; fy = -l_size + y_center ; sx1 = sx1 * x_wide ; sx2 = sx2 * x_wide ; fx1 = fx1 * x_wide ; fx2 = fx2 * x_wide ; buf(n,0) = fx3 ; buf(n,1) = fy ; buf(n,2) = fz3 ; buf(n,3) = fx1 ; buf(n,4) = fy ; buf(n,5) = fz1 ; buf(n,6) = fx2 ; buf(n,7) = fy ; buf(n,8) = fz2 ; buf(n+1,0) = fx2 ; buf(n+1,1) = fy ; buf(n+1,2) = fz2 ; buf(n+1,3) = fx1 ; buf(n+1,4) = fy ; buf(n+1,5) = fz1 ; buf(n+1,6) = sx2 ; buf(n+1,7) = sy ; buf(n+1,8) = sz2 ; buf(n+2,0) = fx1 ; buf(n+2,1) = fy ; buf(n+2,2) = fz1 ; buf(n+2,3) = sx1 ; buf(n+2,4) = sy ; buf(n+2,5) = sz1 ; buf(n+2,6) = sx2 ; buf(n+2,7) = sy ; buf(n+2,8) = sz2 ; buf(n+3,0) = sx3 ; buf(n+3,1) = sy ; buf(n+3,2) = sz3 ; buf(n+3,3) = sx2 ; buf(n+3,4) = sy ; buf(n+3,5) = sz2 ; buf(n+3,6) = sx1 ; buf(n+3,7) = sy ; buf(n+3,8) = sz1 ; x = x + p ; n = n + 4 ; } call("GetBufData") ; } // とんがりデータセット Tongari { n = 1 ; if(kaku < 3){ kaku = 3 ; } p = 360 / kaku ; x = p / 2 ; buf(0,0) = kaku * 2 ; buf(0,1) = icr ; buf(0,2) = icg ; buf(0,3) = icb ; loop(kaku){ sx1 = -cos(x) * s_size + x_center ; sz1 = sin(x) * s_size + z_center ; sx2 = -cos(x+p) * s_size + x_center ; sz2 = sin(x+p) * s_size + z_center ; sx3 = x_center ; sz3 = z_center ; sy = l_size + y_center ; fy = -l_size + y_center ; sx1 = sx1 * x_wide ; sx2 = sx2 * x_wide ; fx1 = fx1 * x_wide ; fx2 = fx2 * x_wide ; buf(n,0) = sx3 ; buf(n,1) = fy ; buf(n,2) = sz3 ; buf(n,3) = sx1 ; buf(n,4) = sy ; buf(n,5) = sz1 ; buf(n,6) = sx2 ; buf(n,7) = sy ; buf(n,8) = sz2 ; buf(n+1,0) = sx3 ; buf(n+1,1) = sy ; buf(n+1,2) = sz3 ; buf(n+1,3) = sx2 ; buf(n+1,4) = sy ; buf(n+1,5) = sz2 ; buf(n+1,6) = sx1 ; buf(n+1,7) = sy ; buf(n+1,8) = sz1 ; x = x + p ; n = n + 2 ; } call("GetBufData") ; } // たまデータセット Tama { kaku2 = 4 ; // 地軸部の三角形の数 hp = 360 / (kaku2 * 2) ; // 水平方向の分割角度 vp = 30 ; // 垂直方向の分割角度 n = 1 ; // ふたの部分 vr = -90 ; hr = 0 ; buf(0,0) = 104 ; buf(0,1) = icr ; buf(0,2) = icg ; buf(0,3) = icb ; loop(kaku2){ // 上頂点座標 r = cos(vr) * f_size ; // 水平半径 px1 = -cos(hr) * r + x_center ; py1 = sin(vr) * l_size + y_center ; pz1 = sin(hr) * r + z_center ; // 下座標左 r = cos(vr+vp) * f_size ; // 水平半径 px2 = -cos(hr-hp) * r + x_center ; py2 = sin(vr+vp) * l_size + y_center ; pz2 = sin(hr-hp) * r + z_center ; // 下座標右 px3 = -cos(hr+hp) * r + x_center ; py3 = sin(vr+vp) * l_size + y_center ; pz3 = sin(hr+hp) * r + z_center ; px2 = px2 * x_wide ; px3 = px3 * x_wide ; buf(n,0) = px1 ; buf(n,1) = py1 ; buf(n,2) = pz1 ; buf(n,3) = px2 ; buf(n,4) = py2 ; buf(n,5) = pz2 ; buf(n,6) = px3 ; buf(n,7) = py3 ; buf(n,8) = pz3 ; buf(n+1,0) = px1 ; buf(n+1,1) = -py1 ; buf(n+1,2) = pz1 ; buf(n+1,3) = px3 ; buf(n+1,4) = -py3 ; buf(n+1,5) = pz3 ; buf(n+1,6) = px2 ; buf(n+1,7) = -py2 ; buf(n+1,8) = pz2 ; n = n + 2 ; hr = hr + hp * 2 ; } // 胴の部分 hr = 0 ; vr = vr + vp ; loop(3){ loop(kaku2){ // 上座標左 r = cos(vr) * f_size ; // 水平半径 px1 = -cos(hr-hp) * r + x_center ; py1 = sin(vr) * l_size + y_center ; pz1 = sin(hr-hp) * r + z_center ; // 上座標右 px2 = -cos(hr+hp) * r + x_center ; py2 = sin(vr) * l_size + y_center ; pz2 = sin(hr+hp) * r + z_center ; // 下頂点座標 r = cos(vr+vp) * f_size ; // 水平半径 px3 = -cos(hr) * r + x_center ; py3 = sin(vr+vp) * l_size + y_center ; pz3 = sin(hr) * r + z_center ; px4 = -cos(hr+hp) * r + x_center ; py4 = sin(vr+vp) * l_size + y_center ; pz4 = sin(hr+hp) * r + z_center ; px5 = -cos(hr-hp) * r + x_center ; py5 = sin(vr+vp) * l_size + y_center ; pz5 = sin(hr-hp) * r + z_center ; px1 = px1 * x_wide ; px2 = px2 * x_wide ; px3 = px3 * x_wide ; px4 = px4 * x_wide ; px5 = px5 * x_wide ; buf(n,0) = px1 ; buf(n,1) = py1 ; buf(n,2) = pz1 ; buf(n,3) = px3 ; buf(n,4) = py3 ; buf(n,5) = pz3 ; buf(n,6) = px2 ; buf(n,7) = py2 ; buf(n,8) = pz2 ; buf(n+1,0) = px2 ; buf(n+1,1) = py2 ; buf(n+1,2) = pz2 ; buf(n+1,3) = px3 ; buf(n+1,4) = py3 ; buf(n+1,5) = pz3 ; buf(n+1,6) = px4 ; buf(n+1,7) = py4 ; buf(n+1,8) = pz4 ; buf(n+2,0) = px1 ; buf(n+2,1) = py1 ; buf(n+2,2) = pz1 ; buf(n+2,3) = px5 ; buf(n+2,4) = py5 ; buf(n+2,5) = pz5 ; buf(n+2,6) = px3 ; buf(n+2,7) = py3 ; buf(n+2,8) = pz3 ; buf(n+3,0) = px1 ; buf(n+3,1) = -py1 ; buf(n+3,2) = pz1 ; buf(n+3,3) = px2 ; buf(n+3,4) = -py2 ; buf(n+3,5) = pz2 ; buf(n+3,6) = px3 ; buf(n+3,7) = -py3 ; buf(n+3,8) = pz3 ; buf(n+4,0) = px2 ; buf(n+4,1) = -py2 ; buf(n+4,2) = pz2 ; buf(n+4,3) = px4 ; buf(n+4,4) = -py4 ; buf(n+4,5) = pz4 ; buf(n+4,6) = px3 ; buf(n+4,7) = -py3 ; buf(n+4,8) = pz3 ; buf(n+5,0) = px1 ; buf(n+5,1) = -py1 ; buf(n+5,2) = pz1 ; buf(n+5,3) = px3 ; buf(n+5,4) = -py3 ; buf(n+5,5) = pz3 ; buf(n+5,6) = px5 ; buf(n+5,7) = -py5 ; buf(n+5,8) = pz5 ; n = n + 6 ; hr = hr + hp * 2 ; } vr = vr + vp ; hp = hp / 2 ; hr = hr + hp ; kaku2 = kaku2 * 3 ; } call("GetBufData") ; } /////////////////////// 形状の設定 //////////////// // 種類 CharType0 { SetButtonCheck("CharType0",1) ; SetButtonCheck("CharType1",0) ; SetButtonCheck("CharType2",0) ; type = 0 ; } CharType1 { SetButtonCheck("CharType0",0) ; SetButtonCheck("CharType1",1) ; SetButtonCheck("CharType2",0) ; type = 1 ; } CharType2 { SetButtonCheck("CharType0",0) ; SetButtonCheck("CharType1",0) ; SetButtonCheck("CharType2",1) ; type = 2 ; } // 確定ボタン SetOK { SelectScreen(1) ; Print(draw_x+8,draw_y+8,0,8,16,1,"処理中です") ; x_wide = GetEditData("WideX") ; if(x_wide > 255){ x_wide = 255 ; } if(x_wide < 0){ x_wide = 1 ; } x_center = GetEditData("Center_X") ; y_center = GetEditData("Center_Y") ; z_center = GetEditData("Center_Z") ; if(type == 0){ kaku = GetEditData("h_Kado") ; s_size = GetEditData("h_SokoSize") / 2 ; f_size = GetEditData("h_FutaSize") / 2 ; l_size = GetEditData("h_HasiraSize") / 2 ; call("Hasira") ; } if(type == 1){ kaku = GetEditData("s_Kado") ; s_size = GetEditData("s_SokoSize") / 2 ; l_size = GetEditData("s_HasiraSize") / 2 ; call("Tongari") ; } if(type == 2){ f_size = GetEditData("t_FutaSize") / 2 ; l_size = GetEditData("t_HasiraSize") / 2 ; call("Tama") ; } call("DrawN") ; } DrawCol { SelectScreen(1) ; SetPal(10,icr,icg,icb) ; Box(18,336,122,356,0,10) ; } RCol { icr = GetScrollPos("RCol") ; call("DrawCol") ; } GCol { icg = GetScrollPos("GCol") ; call("DrawCol") ; } BCol { icb = GetScrollPos("BCol") ; call("DrawCol") ; } //////////////////// 表示状態の設定 ///////////////////// // 一時停止 Pause { pause_flag = (pause_flag + 1) % 2 ; SetButtonCheck("Pause",pause_flag) ; if(pause_flag == 0){ SetButtonCheck("BasePause",0) ; } } // 基本姿勢を表示 BasePause { // 一次停止OFFの場合 if(pause_flag == 0){ pause_flag = 1 ; SetButtonCheck("Pause",1) ; SetButtonCheck("BasePause",1) ; Reset3DRotate(0) ; call("DrawN") ; return ; } // 一次停止ONの場合 if(pause_flag == 1){ // 基本停止ONの場合 if(GetButtonCheck("BasePause") == 1){ pause_flag = 0 ; SetButtonCheck("Pause",0) ; SetButtonCheck("BasePause",0) ; rx = GetButtonCheck("X_Kaitenn") * 5 ; ry = GetButtonCheck("Y_Kaitenn") * 5 ; rz = GetButtonCheck("Z_Kaitenn") * 5 ; Reset3DRotate(0) ; call("DrawN") ; return ; } // 基本停止OFFの場合 if(GetButtonCheck("BasePause") == 0){ pause_flag = 1 ; SetButtonCheck("Pause",1) ; SetButtonCheck("BasePause",1) ; Reset3DRotate(0) ; call("DrawN") ; return ; } } } // 軸回転 X_Kaitenn { if(rx == 5){ rx = 0 ; SetButtonCheck("X_Kaitenn",0) ; return ; } if(rx == 0){ rx = 5 ; SetButtonCheck("X_Kaitenn",1) ; return ; } } Y_Kaitenn { if(ry == 5){ ry = 0 ; SetButtonCheck("Y_Kaitenn",0) ; return ; } if(ry == 0){ ry = 5 ; SetButtonCheck("Y_Kaitenn",1) ; return ; } } Z_Kaitenn { if(rz == 5){ rz = 0 ; SetButtonCheck("Z_Kaitenn",0) ; return ; } if(rz == 0){ rz = 5 ; SetButtonCheck("Z_Kaitenn",1) ; return ; } } SIZE { draw_x = 140 ; draw_y = 60 ; draw_w = WIN_X-draw_x-10 ; draw_h = WIN_Y-draw_y-10 ; Set3DCenter(draw_w/2,draw_h/2,1000) ; } PAINT { SelectScreen(1) ; Line(0,0,SCR_X,0,14) ; Line(0,1,SCR_X,1,7) ; call("DrawCol") ; call("DrawN") ; } INIT { call("SetOK") ; SetButtonCheck("CharType0",1) ; SetButtonCheck("X_Kaitenn",1) ; SetButtonCheck("Y_Kaitenn",1) ; SetButtonCheck("Z_Kaitenn",0) ; SetScrollRange("RCol",255) ; SetScrollRange("GCol",255) ; SetScrollRange("BCol",255) ; SetScrollPos("RCol",icr) ; SetScrollPos("GCol",icg) ; SetScrollPos("BCol",icb) ; } CREATE { SetWinSize(696,454) ; SetCaption("3次元キャラクタ−エディッタ") ; SetWinColor(15) ; SubScreen(SCR_X,SCR_Y) ; SetTimer(100) ; Data("buf",513,9) ; Create3DPack(0,512) ; // 表示位置、回転方向 rx = 5 ; ry = 5 ; rz = 0 ; pause_flag = 0 ; text_flag = 0 ; // キャラクタ形状 type = 0 ; ocr = 0 ; ocg = 0 ; ocb = 0 ; icr = 255 ; icg = 192 ; icb = 255 ; kaku = 8 ; f_size = 40 ; s_size = 40 ; l_size = 40 ; x_wide = 1 ; x_center = 0 ; y_center = 0 ; z_center = 0 ; Menu("データ保存") ; PopupMenuEX("テキスト形式をコピー","MakeText") ; PopupMenuEX("座標データをファイルに保存","SaveData") ; x = 16 ; y = 8 ; CreateControl(51,""," ",x-8,y,120,106) ; y = y + 14 ; CreateControl(10,"多角柱","CharType0",x,y,12*5,12) ; y = y + 18 ; CreateControl(60,"角の数"," ",x, y,12*5,12) ; CreateControl(101,"8","h_Kado",x+78, y-2,26,16) ; y = y + 18 ; CreateControl(60,"底の直径"," ",x, y,12*5,12) ; CreateControl(101,"160","h_SokoSize",x+78, y-2,26,16) ; y = y + 18 ; CreateControl(60,"ふたの直径"," ",x, y,12*6,12) ; CreateControl(101,"160","h_FutaSize",x+78, y-2,26,16) ; y = y + 18 ; CreateControl(60,"高さ"," ",x, y,12*6,12) ; CreateControl(101,"160","h_HasiraSize",x+78, y-2,26,16) ; x = 16 ; y = 110 ; CreateControl(51,""," ",x-8, y,120,88) ; y = y + 14 ; CreateControl(10,"多角すい","CharType1",x,y,72,12) ; y = y + 18 ; CreateControl(60,"角の数"," ",x, y,12*5,12) ; CreateControl(101,"8","s_Kado",x+78, y-2,26,16) ; y = y + 18 ; CreateControl(60,"底の直径"," ",x, y,12*5,12) ; CreateControl(101,"160","s_SokoSize",x+78, y-2,26,16) ; y = y + 18 ; CreateControl(60,"高さ"," ",x, y,12*6,12) ; CreateControl(101,"160","s_HasiraSize",x+78, y-2,26,16) ; x = 16 ; y = 194 ; CreateControl(51,""," ",x-8, y,120,70) ; y = y + 14 ; CreateControl(10,"たま","CharType2",x,y,72,12) ; y = y + 18 ; CreateControl(60,"直径"," ",x, y,12*5,12) ; CreateControl(101,"160","t_FutaSize",x+78, y-2,26,16) ; y = y + 18 ; CreateControl(60,"高さ"," ",x, y,12*6,12) ; CreateControl(101,"160","t_HasiraSize",x+78, y-2,26,16) ; y = 276 ; CreateControl(60,"横幅の倍率"," ",16, y,12*5,12) ; CreateControl(101,"1.0","WideX",86, y-4,34,16) ; y = y + 18 ; CreateControl(60,"赤"," ",16, y,12,12) ; CreateControl(70,"","RCol",32, y,90,12) ; y = y + 14 ; CreateControl(60,"緑"," ",16, y,12,12) ; CreateControl(70,"","GCol",32, y,90,12) ; y = y + 14 ; CreateControl(60,"青"," ",16, y,12,12) ; CreateControl(70,"","BCol",32, y,90,12) ; y = y + 42 ; CreateControl(60,"中心X座標"," ",16, y,12*5,12) ; CreateControl(101,"0","Center_X",86, y-4,32,16) ; y = y + 18 ; CreateControl(60,"中心Y座標"," ",16, y,12*5,12) ; CreateControl(101,"0","Center_Y",86, y-4,32,16) ; y = y + 18 ; CreateControl(60,"中心Z座標"," ",16, y,12*5,12) ; CreateControl(101,"0","Center_Z",86, y-4,32,16) ; y = y + 22 ; CreateControl(0,"確定","SetOK",8, y,12*8,18) ; y = y + 22 ; x = 140 ; y = 8 ; CreateControl(51,"表示状態の設定"," ",x, y,480,40) ; x = x + 16 ; y = y + 16 ; CreateControl(10,"一時停止","Pause",x, y,68,12) ; x = x + 80 ; CreateControl(10,"基本姿勢で停止","BasePause",x, y,102,12) ; x = x + 130 ; CreateControl(20,"X軸回転","X_Kaitenn",x,y,80,12) ; x = x + 80 ; CreateControl(20,"Y軸回転","Y_Kaitenn",x,y,80,12) ; x = x + 80 ; CreateControl(20,"Z軸回転","Z_Kaitenn",x,y,80,12) ; x = x + 80 ; CreateControl(100,"0","ID_text",0,0,0,0) ; } // テキスト形式をコピー MakeText { text_flag = 1 ; SelectScreen(1) ; Print(draw_x+8,draw_y+8,0,8,16,1,"処理中です") ; AllSelectEdit("ID_text") ; ClearEdit("ID_text") ; SetEditCodeRet("ID_text") ; // 改行 SetEditCode("ID_text",9) ; // タブ SetEditText("ID_text","r = ") ; SetEditData("ID_text",buf(0,1),0) ; SetEditText("ID_text"," ; ") ; SetEditText("ID_text","g = ") ; SetEditData("ID_text",buf(0,2),0) ; SetEditText("ID_text"," ; ") ; SetEditText("ID_text","b = ") ; SetEditData("ID_text",buf(0,3),0) ; SetEditText("ID_text"," ; ") ; SetEditText("ID_text","p = 0 ;") ; SetEditCodeRet("ID_text") ; // 改行 n = 1 ; loop(buf(0,0)){ SetEditCode("ID_text",9) ; // タブ SetEditText("ID_text","Add3DPack(p,") ; SetEditData("ID_text",buf(n,0),0) ; SetEditText("ID_text",",") ; SetEditData("ID_text",buf(n,1),0) ; SetEditText("ID_text",",") ; SetEditData("ID_text",buf(n,2),0) ; SetEditText("ID_text",",") ; SetEditData("ID_text",buf(n,3),0) ; SetEditText("ID_text",",") ; SetEditData("ID_text",buf(n,4),0) ; SetEditText("ID_text",",") ; SetEditData("ID_text",buf(n,5),0) ; SetEditText("ID_text",",") ; SetEditData("ID_text",buf(n,6),0) ; SetEditText("ID_text",",") ; SetEditData("ID_text",buf(n,7),0) ; SetEditText("ID_text",",") ; SetEditData("ID_text",buf(n,8),0) ; SetEditText("ID_text",",") ; SetEditText("ID_text","r,g,b) ;") ; SetEditCodeRet("ID_text") ; // 改行 n = n + 1 ; } AllSelectEdit("ID_text") ; ClipEdit("ID_text") ; MessBox("データをクリップボードへコピーしました","IMWテキスト作成",0,0) ; text_flag = 0 ; } // 座標データをファイルに保存 SaveData { text_flag = 1 ; n = OpenFileWriteDlg("座標データの保存") ; if(n == 0){ text_flag = 0 ; return ; } // キャンセル Save3DPack(0) ; CloseFile ; text_flag = 0 ; }