; 画面のセーブ サンプル #include "e3dhsp3.as" ;///////////////////////////////////////////////////////////////////////////////// ; このサンプルは、表示されている画面をBMPファイルと、AVIファイルに保存するためのサンプルです。 ; Bキーを押すと、BMPファイルが作成されます。 ; Aキーを押すと、AVIファイルが作成されます。 ; どちらも、重い処理なので、表示は遅くなります。 ; Aキー、Bキーを押すたびに、新しいファイルが作成されます。(ファイルのおしりに番号が付きます) ; ファイルを出力している間よりちょっと長い時間、キーを無視するようにしてあります。 ; (間違って、一杯、ファイルができないように) ; ; ファイルに保存する関数は、SaveDisplay 関数です。 ; ; ;///////////////////////////////////////////////////////////////////////////////// #module #deffunc waitbyfps int p1, var fps E3DWaitbyFPS@ p1, fps await 0 return #global dim keybuf, 256 ;file のpath 用のバッファーの作成 pathlen = 2048 sdim mediadir, pathlen mediadir = dir_cur + "\\Media" sdim pathbuf, pathlen, 4 mapsize = 150000.0 mapdiv = 50 mapheight = 10000.0 chgdegx = 0.0 : chkdegy = 0.0 : chkdegz = 0.0 screenw = 640 : screenh = 480 ;screenw = 420 : screenh = 340 screen 0, screenw, screenh, 1 pointmax = 100 title "Save Display" ;開発中は下の行のコメントアウトを外すことを推奨します。 ;E3DEnableDbgFile ;初期化 E3DInit 0, -1, 0, 16, 0, scid1 ;カメラの初期化 camposx = 0.0 : camposy = 2500.0 : camposz = 0.0 E3DSetCameraPos camposx, camposy, camposz camdegxz = 180.0 : camdegy = 0.0 E3DSetCameraDeg camdegxz, camdegy confflag = 0 endflag = 0 ;projectionの変更をしたいときは、以下の2行を有効にしてください。 proj_near = 100.0 : proj_far = 50000.0 : proj_fov = 60.0 E3DSetProjection proj_near, proj_far, proj_fov E3DCreateProgressBar E3DSetProgressBar 30 ; 地面データのロード pathbuf.0 = mediadir + "\\test_course_01.mqo" E3DLoadMQOFileAsGround pathbuf.0, 100.0, hsid0 E3DSetPos hsid0, 0.0, 0.0, 0.0 frameno0 = 0 E3DSetProgressBar 60 ; たこの読み込み pathbuf.0 = mediadir + "\\tako.sig" pathbuf.1 = mediadir + "\\tako_idling.qua" pathbuf.2 = mediadir + "\\tako_run.qua" E3DSigLoad pathbuf.0, hsid4 E3DAddMotion hsid4, pathbuf.1, mk4_idling, max4_idling E3DAddMotion hsid4, pathbuf.2, mk4_run, max4_run E3DSetMotionKind hsid4, mk4_run posx4 = 117424.0 : posy4 = 7000.0 : posz4 = 44745.0 degx4 = 0.0 : degy4 = 162.0 : degz4 = 0.0 E3DSetPos hsid4, posx4, posy4, posz4 E3DSetDir hsid4, degx4, degy4, degz4 frameno4 = 0 newmk4 = 0 curposx4 = posx4 : curposy4 = posy4 : curposz4 = posz4 E3DSetBeforePos hsid4 ; 走行ラインの読み込み gosub *LoadNaviLine ; 別ファイル、naviline0.as の関数です。 ;///////////////// testfps = 0 lightdirx1 = 0.0 lightdiry1 = -1.0 lightdirz1 = 2.0 lightr1 = 255 lightg1 = 255 lightb1 = 255 E3DCreateLight lid1 E3DSetDirectionalLight lid1, lightdirx1, lightdiry1, lightdirz1, lightr1, lightg1, lightb1 chkfps1 = 0 pathbuf.0 = mediadir + "\\lake.bmp" pathbuf.1 = mediadir + "\\cloud3.bmp" E3DCreateBG scid1, pathbuf.0, pathbuf.1, 0.001, 0.0, 0 E3DDestroyProgressBar pbflag = 0; result0 = 0 : result1 = 0 : result2 = 0 : result3 = 0 adjustx0 = 0.0 : adjusty0 = 0.0 : adjustz0 = 0.0 adjustx1 = 0.0 : adjusty1 = 0.0 : adjustz1 = 0.0 adjustx2 = 0.0 : adjusty2 = 0.0 : adjustz2 = 0.0 adjustx3 = 0.0 : adjusty3 = 0.0 : adjustz3 = 0.0 befposx = posx4 : befposy = posy4 : befposz = posz4 ccw = 0 newdeg = 0.0 nx1 = 0.0 : ny1 = 0.0 : nz1 = 0.0 dot1 = 0.0 : dot2 = 0.0 : dot = 0.0 dim arfps, 50 maxfps = 60 befshiftF = 0 curshiftF = 0 turboflag = 0 targetpid4 = 0 movestep = 200 writebmpflag = 0 writeaviflag = 0 bmpno = 0 avino = -1 dim bmpname, 2048 dim aviname, 2048 *main ; keybuf変数は、メインループの外で、dim keybuf, 256 として、確保しておいてください。 E3DGetKeyboardState keybuf if keybuf.VK_ESCAPE = 1 : goto *bye ; [ESC]で終了 gosub *CheckTurbo gosub *ChangeFPS gosub *MoveChara2 gosub *MoveCamera2 E3DSetNewPose hsid4, frameno4 E3DBeginScene scid1 E3DChkInView scid1, hsid0 E3DChkInView scid1, hsid4 gosub *ChkConf ; !!! E3DChkInViewより後で呼んでください。 ;不透明部分の描画をする E3DRender scid1, hsid0, 0, frameno0, 0 E3DRender scid1, hsid4, 0, frameno4, 0 ;半透明部分の描画をする E3DRender scid1, hsid0, 1, frameno0, 0 E3DRender scid1, hsid4, 1, frameno4, 0 gosub *SaveDisplay gosub *DrawText E3DEndScene E3DPresent scid1 waitbyfps maxfps, chkfps1 arno = 0 repeat 49 befno = 48 - arno aftno = 49 - arno arfps.aftno = arfps.befno arno++ loop arfps.0 = chkfps1 E3DGetPos hsid4, posx4, posy4, posz4 E3DSetBeforePos hsid4 befposx = posx4 : befposy = posy4 : befposz = posz4 goto *main #include "naviline0.as" *bye E3DBye end *SaveDisplay if ( (writebmpflag == 0) & (writeaviflag == 0) & (keybuf.'B' == 1) ) { bmpname = dir_cur + "\\testbmp" + bmpno ; bmpnameには、拡張子を付けないでください。 ; E3DWriteDisplay2BMP 関数で、自動的に".bmp"が付け足されます。 E3DWriteDisplay2BMP bmpname writebmpflag = 1 bmpno++ } aviframeleng = 30 if ( (writebmpflag == 0) & (writeaviflag == 0) & (keybuf.'A' == 1) ) { ; ファイルの名前に拡張子は付けないでください。 ; 自動的に、".avi"という拡張子が付け足されます。 nameindex = avino + 1 aviname = dir_cur + "\\testavi" + nameindex E3DCreateAVIFile aviname, 1, 1, 60, aviframeleng, avino writeaviflag = 1 } if ( (writeaviflag >= 1) & (writeaviflag <= aviframeleng) ){ E3DWriteData2AVIFile avino, 1 } if( writeaviflag == aviframeleng) { E3DCompleteAVIFile avino, 1 avino++ } if ( writebmpflag > 60 ) { writebmpflag = 0 } ; aviframeleng が100より大きい場合は、下の値を100より大きい値に直してください。 if ( writeaviflag > 100 ) { writeaviflag = 0 } if ( writebmpflag > 0 ) { writebmpflag++ } if ( writeaviflag > 0 ) { writeaviflag++ } return *MoveChara2 dummytpid = -1 E3DControlByNaviLine hsid4, nlid0, 5, 1, 0, 1000, movestep, 200, ctrlx4, ctrly4, ctrlz4, ctrlqx4, ctrlqy4, ctrlqz4, ctrlqw4, targetpid4 ;E3DControlByNaviLine hsid4, nlid0, 5, 1, 0, 1000, movestep, 200, ctrlx4, ctrly4, ctrlz4, ctrlqx4, ctrlqy4, ctrlqz4, ctrlqw4, dummytpid ;E3DControlByNaviLine hsid4, nlid0, 4, 1, 0, 4000, movestep, 100, ctrlx4, ctrly4, ctrlz4, ctrlqx4, ctrlqy4, ctrlqz4, ctrlqw4, targetpid4 ;E3DControlByNaviLine hsid4, nlid0, 4, 1, 0, 4000, movestep, 40, ctrlx4, ctrly4, ctrlz4, ctrlqx4, ctrlqy4, ctrlqz4, ctrlqw4, dummytpid posx4 = ctrlx4 : posy4 = ctrly4 : posz4 = ctrlz4 E3DSetPos hsid4, posx4, posy4, posz4 E3DSetDirQ hsid4, ctrlqx4, ctrlqy4, ctrlqz4, ctrlqw4 return *ChkConf result0 = 0 ; 地面その1と、キャラクタのあたり判定 E3DChkConfGround hsid4, hsid0, 1, 200.0, -100.0, result0, adjustx0, adjusty0, adjustz0, nx0, ny0, nz0 if ( result0 != 0 ) { posx4 = adjustx0 : posy4 = adjusty0 : posz4 = adjustz0 E3DSetPos hsid4, posx4, posy4, posz4 } return *MoveCamera2 E3DGetPos hsid4, saveposx4, saveposy4, saveposz4 E3DGetDirQ hsid4, saveqx4, saveqy4, saveqz4, saveqw4 E3DRotateInit hsid4 E3DRotateY hsid4, 180.0 E3DPosForward hsid4, -2500.0 E3DGetPos hsid4, backposx, backposy, backposz E3DSetPos hsid4, saveposx4, saveposy4, saveposz4 E3DSetDirQ hsid4, saveqx4, saveqy4, saveqz4, saveqw4 E3DChkConfGround2 backposx, mapheight, backposz, backposx, -100.0, backposz, hsid0, 0, 200, 0, resultc, adjustxc, adjustyc, adjustzc, nxc, nyc, nzc if ( resultc = 0 ) { backposy = 1500.0 } else { backposy = adjustyc + 1500.0 } E3DSetCameraPos backposx, backposy, backposz E3DSetCameraTarget saveposx4, saveposy4 + 800.0, saveposz4, 0.0, 1.0, 0.0 return *CheckTurbo if ( keybuf.'T' = 1 ) { if ( turboflag = 0 ) { E3DSetMotionStep hsid4, mk4_idling, 2 E3DSetMotionStep hsid4, mk4_run, 2 turboflag = 1 movestep = 400 } } else { if( turboflag = 1 ) { E3DSetMotionStep hsid4, mk4_idling, 1 E3DSetMotionStep hsid4, mk4_run, 1 turboflag = 0 movestep = 200 } } return *ChangeFPS curshiftF = 0 if ( (keybuf.VK_SHIFT = 1) & (keybuf.'F' = 1) ) { curshiftF = 1 } if ( ( curshiftF = 0 ) & ( befshiftF = 1 ) ) { if ( maxfps = 60 ) { maxfps = 500 } else { maxfps = 60 } } befshiftF = curshiftF return *DrawText textr = 0 : textg = 255 : textb = 0 textscale = 1 lcnt = 0 avfps = 0 repeat 50 avfps += arfps.lcnt lcnt++ loop avfps = avfps / 50 textposx = 10 : textposy = 20 strchk2 = "avfps " + avfps E3DDrawText textposx, textposy, textscale, textr, textg, textb, strchk2 E3DGetPos hsid4, chkposx, chkposy, chkposz textposx = 10 : textposy = 40 sdim strchk3, 1024, 1 strchk3.0 = "chara position X : " + chkposx + " Y : " + chkposy + " Z : " + chkposz E3DDrawText textposx, textposy, textscale, textr, textg, textb, strchk3.0 E3DGetNaviPointPos nlid0, targetpid4, tpx, tpy, tpz textposx = 10 : textposy = 60 strchk4 = "targetpid4 " + targetpid4 + " x " + tpx + " y " + tpy + " z " + tpz E3DDrawText textposx, textposy, textscale, textr, textg, textb, strchk4 textposx = 10 : textposy = 100 strchk5 = "ctrlqx4 " + ctrlqx4 + " ctrlqy4 " + ctrlqy4 + " ctrlqz4 " + ctrlqz4 + " ctrlqw4 " + ctrlqw4 E3DDrawText textposx, textposy, textscale, textr, textg, textb, strchk5 textposx = 10 : textposy = 120 strchk6 = "dummytpid " + dummytpid E3DDrawText textposx, textposy, textscale, textr, textg, textb, strchk6 if( dummytpid >= 0 ) { E3DGetNaviPointPos nlid0, dummytpid, dtpx, dtpy, dtpz textposx = 10 : textposy = 140 strchk7 = " dtpx " + dtpx + " dtpy " + dtpy + " dptz " + dtpz E3DDrawText textposx, textposy, textscale, textr, textg, textb, strchk7 } if ( writebmpflag > 0 ) { textposx = 10 : textposy = 160 dim strchk8, 2048 strchk8 = "bmpname " + bmpname E3DDrawText textposx, textposy, textscale, 255, 0, 0, strchk8 } if ( writeaviflag > 0 ) { textposx = 10 : textposy = 180 dim strchk9, 2048 strchk9 = "aviname " + aviname E3DDrawText textposx, textposy, textscale, 255, 0, 0, strchk9 } return