// RokDeBone2で作成した、モーションアクセラレータファイル(moa)を読み込み、モーションを再生します。 // 1から7キーを押すことによって、モーションが変化します。 // モーションとモーションの間に、自動的に、補間モーションを挟んで、変化します。 // ( E3DGetKeyboardStateではなく、E3DGetKeyboardCntを使っている点にも注意してください。) ; e3dhsp.dll test script #include "e3dhsp3.as" #module #deffunc waitbyfps int p1, var fps E3DWaitbyFPS@ p1, fps await 0 return #global dim keybuf, 256 dim savekeybuf, 256 ;file のpath 用のバッファーの作成 pathlen = 2048 sdim mediadir, pathlen mediadir = dir_cur + "\\Media\\my" sdim pathbuf, pathlen, 2 screenw = 640 : screenh = 480 screen 0, screenw, screenh, 1 title "Easy3D for HSP3 sample" ;開発中は下の行のコメントアウトを外すことを推奨します。 ;E3DEnableDbgFile ;初期化 E3DInit 0, -1, 0, 16, 0, scid1 ;カメラの初期化 camposx = 0.0 : camposy = 800.0 : camposz = -2000.0 E3DSetCameraPos camposx, camposy, camposz camdegxz = 180.0 : camdegy = 0.0 E3DSetCameraDeg camdegxz, camdegy ;projectionの変更をしたいときは、以下の2行を有効にしてください。 proj_near = 100.0 : proj_far = 30000.0 : proj_fov = 60.0 E3DSetProjection proj_near, proj_far, proj_fov //モデルデータ読み込み pathbuf.0 = mediadir + "\\my.sig" E3DSigLoad pathbuf.0, hsid1 E3DSetPos hsid1, 0.0, 0.0, 0.0 //MOAの読み込み pathbuf.0 = mediadir + "\\my.moa" E3DLoadMOAFile hsid1, pathbuf.0, 5 motmaxnum = 30 sdim motionname, 256, motmaxnum dim motionid, motmaxnum E3DGetMoaInfo hsid1, motmaxnum, motionname, motionid, moagetnum E3DCreateFont 20, 0, 400, 0, 0, 0, "MS ゴシック", fontid1 ; E3DSetMotionKind hsid1, 0 //ライトの作成 lightdirx1 = 0.0 lightdiry1 = 0.0 lightdirz1 = 1.0 lightr1 = 255 lightg1 = 255 lightb1 = 255 E3DCreateLight lid1 E3DSetDirectionalLight lid1, lightdirx1, lightdiry1, lightdirz1, lightr1, lightg1, lightb1 chkfps1 = 0 *main ; keybuf変数は、メインループの外で、dim keybuf, 256 として、確保しておいてください。 E3DGetKeyboardCnt keybuf if keybuf.VK_ESCAPE != 0 : goto *bye ; [ESC]で終了 eventno = 0 if( keybuf.'1' == 1 ){ eventno += 1 } if( keybuf.'2' == 1 ){ eventno += 2 } if( keybuf.'3' == 1 ){ eventno += 4 } if( keybuf.'4' == 1 ){ eventno += 8 } if( keybuf.'5' == 1 ){ eventno += 16 } if( keybuf.'6' == 1 ){ eventno += 32 } if( keybuf.'7' == 1 ){ eventno += 64 } E3DSetNewPoseByMOA hsid1, eventno E3DGetMotionFrameNo hsid1, curmk, curframe E3DGetNextMotionFrameNo hsid1, curmk, nextmk, nextframe E3DBeginScene scid1 E3DChkInView scid1, hsid1 ;不透明部分の描画をする E3DRender scid1, hsid1, 0, frameno1, 0 ;半透明部分の描画をする E3DRender scid1, hsid1, 1, frameno1, 0, 0, 0, 1 gosub *DrawText E3DEndScene E3DPresent scid1 waitbyfps 60, chkfps1 goto *main *bye E3DBye end *DrawText sdim strchk0, 1024 textr = 255 : textg = 255 : textb = 255 textscale = 1 textposx = 10 : textposy = 0 strchk0 = "motionID " + curmk + " frameNo " + curframe E3DDrawText textposx, textposy, textscale, textr, textg, textb, strchk0 textposy += 20 strchk0 = "moagetnum " + moagetnum E3DDrawText textposx, textposy, textscale, textr, textg, textb, strchk0 repeat moagetnum textposy += 20 strchk0 = "motionname " + motionname.cnt + " motionid " + motionid.cnt E3DDrawTextByFontID scid1, fontid1, textposx, textposy, strchk0, 255, 255, 255, 255 loop textposy += 40 strchk0 = "nextmk " + nextmk + " nextframe " + nextframe E3DDrawText textposx, textposy, textscale, textr, textg, textb, strchk0 return