;///////////////////////////////////////////////////////// ;// ;// トゥーン表示テストスクリプト ;// ;// トゥーン表示用の命令は、E3DSetShaderTypeと、E3DSetToon0Paramsです。 ;// このサンプルでは、シェーダーに、COL_TOON0を指定します。 ;// COL_TOON0は、ピクセルシェーダー1.1以上が付いているビデオカードでのみ、有効になります。 ;// ピクセルシェーダーの付いていない方は、COL_TOON1をご使用ください。 ;////////////////////////////////////////////////////////// ; e3dhsp.dll test script #include "e3dhsp3.as" #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, 2 screenw = 640 : screenh = 480 screen 0, screenw, screenh, 1 pointmax = 100 title "Easy3D for HSP3 sample" ;開発中は下の行のコメントアウトを外すことを推奨します。 ;E3DEnableDbgFile ;初期化 E3DInit 0, -1, 0, 16, 0, scid1 ;カメラの初期化 eye_y = 1500.0 camposx = 0.0 : camposy = eye_y : camposz = -5000.0 E3DSetCameraPos camposx, camposy, camposz camdegxz = 0.0 : camdegy = 0.0 E3DSetCameraDeg camdegxz, camdegy targetx = 0.0 targety = eye_y targetz = 0.0 cameradist = 3000.0 ;projectionの変更をしたいときは、以下の2行を有効にしてください。 proj_near = 100.0 : proj_far = 30000.0 : proj_fov = 60.0 E3DSetProjection proj_near, proj_far, proj_fov E3DCreateProgressBar E3DSetProgressBar 0 pathbuf.0 = mediadir + "\\saru_bone.sig" // pathbuf.0 = mediadir + "\\morob_6_26_r3.sig" E3DSigLoad pathbuf.0, hsid1 E3DSetPos hsid1, 0.0, 900.0, 0.0 E3DSetShaderType hsid1, COL_TOON0, OVERFLOW_ORG E3DSetToon0Params hsid1, 0.0, 0.9, 66.4, 25.8 lightdirx1 = -1.0 lightdiry1 = 0.0 lightdirz1 = 1.0 lightr1 = 255 lightg1 = 255 lightb1 = 255 E3DCreateLight lid1 E3DSetDirectionalLight lid1, lightdirx1, lightdiry1, lightdirz1, lightr1, lightg1, lightb1 /////////////////////// E3DCreateQ camq E3DCreateQ invcamq chkfps1 = 0 E3DDestroyProgressBar *main ; keybuf変数は、メインループの外で、dim keybuf, 256 として、確保しておいてください。 E3DGetKeyboardState keybuf if keybuf.VK_ESCAPE = 1 : goto *bye ; [ESC]で終了 gosub *RotateChara gosub *MoveCamera E3DBeginScene scid1 E3DChkInView scid1, hsid1 ;不透明部分の描画をする E3DRender scid1, hsid1, 0, frameno0, 0 ;半透明部分の描画をする E3DRender scid1, hsid1, 1, frameno0, 0 gosub *DrawText E3DEndScene E3DPresent scid1 waitbyfps 1000, chkfps1 goto *main *bye E3DBye end *RotateChara if( keybuf.VK_LEFT == 1 ){ E3DRotateY hsid1, 1.0 } if( keybuf.VK_RIGHT == 1 ){ E3DRotateY hsid1, -1.0 } return *MoveCamera //targetの場所と角度から、カメラの位置を計算する E3DSin camdegxz, sinxz E3DCos camdegxz, cosxz E3DSin camdegy, siny E3DCos camdegy, cosy camposx = sinxz * cosy * cameradist + targetx camposy = eye_y + siny * cameradist camposz = -cosxz * cosy * cameradist + targetz E3DSetCameraPos camposx, camposy, camposz E3DSetCameraTarget targetx, targety, targetz, 0.0, 1.0, 0.0 return *DrawText textr = 255 : textg = 255 : textb = 255 textscale = 1 textposx = 10 : textposy = 60 strchk7 = "chkfps1 " + chkfps1 E3DDrawText textposx, textposy, textscale, textr, textg, textb, strchk7 return