dbase/3d/demo_3d.prg · 1898 字节 · 下载原文
* demo_3d.prg —— dBase (xBase) 3D 层:**加载 glTF 立方体并画 20 帧**
* demo_3d.prg -- dBase (xBase) 3D layer: **load a glTF cube and draw 20 frames**
*
* 跑法(桌面 vmlcli):
* How to run (desktop vmlcli):
* dotnet scripts/vmlcli/bin/Release/net10.0/vmlcli.dll Examples/dbase/3d/demo_3d.prg
* 同目录的 box.glb 是 CC0 立方体(复制自 Examples/c/3d/models/BoxVertexColors.glb)。
* box.glb next to this file is a CC0 cube (copied from Examples/c/3d/models/BoxVertexColors.glb).
*
* 本前端的写法要求:
* Coding rules of this frontend:
* ① 3D 接口没有独立声明文件,直接按名字写;`Lib/dbase/builtin.vml` 之外的模块靠 vml3d 自动挂上。
* ① there is no separate 3D declaration file; call by name (vml3d is auto-linked).
* ② **浮点形参按 float32 的位模式传**:本前端的库调用实参一律按 32 位整数传(浮点会被截断)
* ② **float parameters are passed as float32 bit patterns**: library-call arguments here are always 32-bit ints
* (浮点实参会被截断)⇒ 1.5 写成 1069547520(0x3FC00000)。每个数后面都标了它对应的浮点值。
* (float arguments are truncated) => 1.5 is written as 1069547520 (0x3FC00000). Each carries its float value.
k = ui_win_open_ex("demo_3d", 0, 0, 0, 0)
w = ui_scr_get_w()
h = ui_scr_get_h()
vp = ui_3d_viewport_create(0, 0, w, h, 0)
k = ui_3d_viewport_set_camera(vp, 0, 1069547520, 1082130432, 0, 0, 0)
k = ui_3d_viewport_set_fov(vp, 1112014848, 1036831949, 1120403456)
k = ui_3d_viewport_set_bg(vp, -15458257) && 0xFF14202F
k = ui_3d_viewport_set_light(vp, 1053609165, 1063675494, 1058642330, -1, 1050253722)
k = ui_2d_clear(0)
sc = ui_3d_gltf_load(vp, "box.glb")
frame = 0
DO WHILE frame < 20
k = ui_2d_present()
k = ui_msg_fetch_wait(40)
frame = frame + 1
ENDDO
k = ui_win_close()
? "dBase 3D demo: done"