nx_gltf_pose_source_gate_t230.nx source
↩ module page · 31 lines · 11642 B
1import "nx_gltf_render_descriptor_candidate_t181.nx"
2import "nx_gate_verdict.nx"
3func rpt_contains(s:*u8,n:i64,t:*u8)->i64{let z:i64=gll_slen(t);var i:i64=0;while i<=n-z{var j:i64=0;while j<z&&s[i+j]==t[j]{j=j+1};if j==z{return 1};i=i+1};return 0}
4func rpt_case(json:*u8,reject:i64)->i64{
5 let jn:i64=gll_slen(json);let padded:i64=(jn+3)/4*4;let n:i64=28+padded+128;let src:*u8=sys_mmap(n)
6 glp_u32(src,0,0x46546c67);glp_u32(src,4,2);glp_u32(src,8,n);glp_u32(src,12,padded);glp_u32(src,16,0x4e4f534a)
7 var i:i64=0;while i<jn{src[20+i]=json[i];i=i+1};while i<padded{src[20+i]=32 as u8;i=i+1};glp_u32(src,20+padded,128);glp_u32(src,24+padded,0x004e4942)
8 let bin:*u8=(src as i64+28+padded) as *u8;i=0;while i<128{bin[i]=0 as u8;i=i+1}
9 glp_u32(bin,16,0x3f800000);glp_u32(bin,32,0x3f800000);glp_u32(bin,52,0x3f800000);glp_u32(bin,72,0x3f800000);glp_u32(bin,92,0x3f800000);glp_u32(bin,100,0x3f800000);glp_u32(bin,116,0x40000000)
10 let cx:*i64=sys_mmap(GLD_CONTEXT_WORDS*8) as *i64;let w:*i64=sys_mmap(32) as *i64;i=0;while i<4{w[i]=0;i=i+1};var time:i64=VM_Q30/2
11 var rc:i64=gltf_view_open(src,n,cx);if rc==0{rc=gltf_render_poses(cx,0,0,0,1,2,&time,1,w)}
12 var ok:i64=0
13 if reject==1{if rc!=0{ok=1}}else{
14 if rc==0&&w[2]>0{let need:i64=w[2];let out:*u8=sys_mmap(need);w[0]=out as i64;w[1]=need;w[2]=0;w[3]=0
15 if gltf_render_poses(cx,0,0,0,1,2,&time,1,w)==0&&w[2]==need&&rpt_contains(out,need,"\"jointWorld\":[[11534336,0,0]]")==1&&rpt_contains(out,need,"\"bounds\":[11534336,0,0,11534336,0,0]")==1{ok=1}
16 sys_munmap(out,need)
17 }
18 }
19 gltf_view_close(cx);sys_munmap(cx as *u8,GLD_CONTEXT_WORDS*8);sys_munmap(w as *u8,32);sys_munmap(src,n);return ok
20}
21func main()->i64{let ctr:*i64=gv_ctr();gv_head("POSE SOURCE WORLD CONTRACT")
22 gv_check("static matrix ancestor and animated child",rpt_case("{\"asset\":{\"version\":\"2.0\"},\"buffers\":[{\"byteLength\":128}],\"bufferViews\":[{\"buffer\":0,\"byteOffset\":0,\"byteLength\":12},{\"buffer\":0,\"byteOffset\":12,\"byteLength\":4},{\"buffer\":0,\"byteOffset\":16,\"byteLength\":16},{\"buffer\":0,\"byteOffset\":32,\"byteLength\":64},{\"buffer\":0,\"byteOffset\":96,\"byteLength\":8},{\"buffer\":0,\"byteOffset\":104,\"byteLength\":24}],\"accessors\":[{\"bufferView\":0,\"componentType\":5126,\"count\":1,\"type\":\"VEC3\"},{\"bufferView\":1,\"componentType\":5121,\"count\":1,\"type\":\"VEC4\"},{\"bufferView\":2,\"componentType\":5126,\"count\":1,\"type\":\"VEC4\"},{\"bufferView\":3,\"componentType\":5126,\"count\":1,\"type\":\"MAT4\"},{\"bufferView\":4,\"componentType\":5126,\"count\":2,\"type\":\"SCALAR\"},{\"bufferView\":5,\"componentType\":5126,\"count\":2,\"type\":\"VEC3\"}],\"nodes\":[{\"matrix\":[1,0,0,0,0,1,0,0,0,0,1,0,10,0,0,1],\"children\":[1]},{}],\"skins\":[{\"joints\":[1],\"inverseBindMatrices\":3}],\"animations\":[{\"samplers\":[{\"input\":4,\"output\":5,\"interpolation\":\"LINEAR\"}],\"channels\":[{\"sampler\":0,\"target\":{\"node\":1,\"path\":\"translation\"}}]}]}",0)==1,ctr)
23 gv_check("matrix node cannot receive TRS animation",rpt_case("{\"asset\":{\"version\":\"2.0\"},\"buffers\":[{\"byteLength\":128}],\"bufferViews\":[{\"buffer\":0,\"byteOffset\":0,\"byteLength\":12},{\"buffer\":0,\"byteOffset\":12,\"byteLength\":4},{\"buffer\":0,\"byteOffset\":16,\"byteLength\":16},{\"buffer\":0,\"byteOffset\":32,\"byteLength\":64},{\"buffer\":0,\"byteOffset\":96,\"byteLength\":8},{\"buffer\":0,\"byteOffset\":104,\"byteLength\":24}],\"accessors\":[{\"bufferView\":0,\"componentType\":5126,\"count\":1,\"type\":\"VEC3\"},{\"bufferView\":1,\"componentType\":5121,\"count\":1,\"type\":\"VEC4\"},{\"bufferView\":2,\"componentType\":5126,\"count\":1,\"type\":\"VEC4\"},{\"bufferView\":3,\"componentType\":5126,\"count\":1,\"type\":\"MAT4\"},{\"bufferView\":4,\"componentType\":5126,\"count\":2,\"type\":\"SCALAR\"},{\"bufferView\":5,\"componentType\":5126,\"count\":2,\"type\":\"VEC3\"}],\"nodes\":[{\"matrix\":[1,0,0,0,0,1,0,0,0,0,1,0,10,0,0,1],\"children\":[1]},{}],\"skins\":[{\"joints\":[1],\"inverseBindMatrices\":3}],\"animations\":[{\"samplers\":[{\"input\":4,\"output\":5,\"interpolation\":\"LINEAR\"}],\"channels\":[{\"sampler\":0,\"target\":{\"node\":0,\"path\":\"translation\"}}]}]}",1)==1,ctr)
24 gv_check("out of range target rejected",rpt_case("{\"asset\":{\"version\":\"2.0\"},\"buffers\":[{\"byteLength\":128}],\"bufferViews\":[{\"buffer\":0,\"byteOffset\":0,\"byteLength\":12},{\"buffer\":0,\"byteOffset\":12,\"byteLength\":4},{\"buffer\":0,\"byteOffset\":16,\"byteLength\":16},{\"buffer\":0,\"byteOffset\":32,\"byteLength\":64},{\"buffer\":0,\"byteOffset\":96,\"byteLength\":8},{\"buffer\":0,\"byteOffset\":104,\"byteLength\":24}],\"accessors\":[{\"bufferView\":0,\"componentType\":5126,\"count\":1,\"type\":\"VEC3\"},{\"bufferView\":1,\"componentType\":5121,\"count\":1,\"type\":\"VEC4\"},{\"bufferView\":2,\"componentType\":5126,\"count\":1,\"type\":\"VEC4\"},{\"bufferView\":3,\"componentType\":5126,\"count\":1,\"type\":\"MAT4\"},{\"bufferView\":4,\"componentType\":5126,\"count\":2,\"type\":\"SCALAR\"},{\"bufferView\":5,\"componentType\":5126,\"count\":2,\"type\":\"VEC3\"}],\"nodes\":[{\"matrix\":[1,0,0,0,0,1,0,0,0,0,1,0,10,0,0,1],\"children\":[1]},{}],\"skins\":[{\"joints\":[1],\"inverseBindMatrices\":3}],\"animations\":[{\"samplers\":[{\"input\":4,\"output\":5,\"interpolation\":\"LINEAR\"}],\"channels\":[{\"sampler\":0,\"target\":{\"node\":2,\"path\":\"translation\"}}]}]}",1)==1,ctr)
25 gv_check("duplicate target channel rejected",rpt_case("{\"asset\":{\"version\":\"2.0\"},\"buffers\":[{\"byteLength\":128}],\"bufferViews\":[{\"buffer\":0,\"byteOffset\":0,\"byteLength\":12},{\"buffer\":0,\"byteOffset\":12,\"byteLength\":4},{\"buffer\":0,\"byteOffset\":16,\"byteLength\":16},{\"buffer\":0,\"byteOffset\":32,\"byteLength\":64},{\"buffer\":0,\"byteOffset\":96,\"byteLength\":8},{\"buffer\":0,\"byteOffset\":104,\"byteLength\":24}],\"accessors\":[{\"bufferView\":0,\"componentType\":5126,\"count\":1,\"type\":\"VEC3\"},{\"bufferView\":1,\"componentType\":5121,\"count\":1,\"type\":\"VEC4\"},{\"bufferView\":2,\"componentType\":5126,\"count\":1,\"type\":\"VEC4\"},{\"bufferView\":3,\"componentType\":5126,\"count\":1,\"type\":\"MAT4\"},{\"bufferView\":4,\"componentType\":5126,\"count\":2,\"type\":\"SCALAR\"},{\"bufferView\":5,\"componentType\":5126,\"count\":2,\"type\":\"VEC3\"}],\"nodes\":[{\"matrix\":[1,0,0,0,0,1,0,0,0,0,1,0,10,0,0,1],\"children\":[1]},{}],\"skins\":[{\"joints\":[1],\"inverseBindMatrices\":3}],\"animations\":[{\"samplers\":[{\"input\":4,\"output\":5,\"interpolation\":\"LINEAR\"}],\"channels\":[{\"sampler\":0,\"target\":{\"node\":1,\"path\":\"translation\"}},{\"sampler\":0,\"target\":{\"node\":1,\"path\":\"translation\"}}]}]}",1)==1,ctr)
26 gv_check("matrix plus TRS rejected",rpt_case("{\"asset\":{\"version\":\"2.0\"},\"buffers\":[{\"byteLength\":128}],\"bufferViews\":[{\"buffer\":0,\"byteOffset\":0,\"byteLength\":12},{\"buffer\":0,\"byteOffset\":12,\"byteLength\":4},{\"buffer\":0,\"byteOffset\":16,\"byteLength\":16},{\"buffer\":0,\"byteOffset\":32,\"byteLength\":64},{\"buffer\":0,\"byteOffset\":96,\"byteLength\":8},{\"buffer\":0,\"byteOffset\":104,\"byteLength\":24}],\"accessors\":[{\"bufferView\":0,\"componentType\":5126,\"count\":1,\"type\":\"VEC3\"},{\"bufferView\":1,\"componentType\":5121,\"count\":1,\"type\":\"VEC4\"},{\"bufferView\":2,\"componentType\":5126,\"count\":1,\"type\":\"VEC4\"},{\"bufferView\":3,\"componentType\":5126,\"count\":1,\"type\":\"MAT4\"},{\"bufferView\":4,\"componentType\":5126,\"count\":2,\"type\":\"SCALAR\"},{\"bufferView\":5,\"componentType\":5126,\"count\":2,\"type\":\"VEC3\"}],\"nodes\":[{\"matrix\":[1,0,0,0,0,1,0,0,0,0,1,0,10,0,0,1],\"children\":[1],\"translation\":[0,0,0]},{}],\"skins\":[{\"joints\":[1],\"inverseBindMatrices\":3}],\"animations\":[{\"samplers\":[{\"input\":4,\"output\":5,\"interpolation\":\"LINEAR\"}],\"channels\":[{\"sampler\":0,\"target\":{\"node\":1,\"path\":\"translation\"}}]}]}",1)==1,ctr)
27 gv_check("short inverse-bind view rejected",rpt_case("{\"asset\":{\"version\":\"2.0\"},\"buffers\":[{\"byteLength\":128}],\"bufferViews\":[{\"buffer\":0,\"byteOffset\":0,\"byteLength\":12},{\"buffer\":0,\"byteOffset\":12,\"byteLength\":4},{\"buffer\":0,\"byteOffset\":16,\"byteLength\":16},{\"buffer\":0,\"byteOffset\":32,\"byteLength\":8},{\"buffer\":0,\"byteOffset\":96,\"byteLength\":8},{\"buffer\":0,\"byteOffset\":104,\"byteLength\":24}],\"accessors\":[{\"bufferView\":0,\"componentType\":5126,\"count\":1,\"type\":\"VEC3\"},{\"bufferView\":1,\"componentType\":5121,\"count\":1,\"type\":\"VEC4\"},{\"bufferView\":2,\"componentType\":5126,\"count\":1,\"type\":\"VEC4\"},{\"bufferView\":3,\"componentType\":5126,\"count\":1,\"type\":\"MAT4\"},{\"bufferView\":4,\"componentType\":5126,\"count\":2,\"type\":\"SCALAR\"},{\"bufferView\":5,\"componentType\":5126,\"count\":2,\"type\":\"VEC3\"}],\"nodes\":[{\"matrix\":[1,0,0,0,0,1,0,0,0,0,1,0,10,0,0,1],\"children\":[1]},{}],\"skins\":[{\"joints\":[1],\"inverseBindMatrices\":3}],\"animations\":[{\"samplers\":[{\"input\":4,\"output\":5,\"interpolation\":\"LINEAR\"}],\"channels\":[{\"sampler\":0,\"target\":{\"node\":1,\"path\":\"translation\"}}]}]}",1)==1,ctr)
28 gv_check("cyclic hierarchy rejected",rpt_case("{\"asset\":{\"version\":\"2.0\"},\"buffers\":[{\"byteLength\":128}],\"bufferViews\":[{\"buffer\":0,\"byteOffset\":0,\"byteLength\":12},{\"buffer\":0,\"byteOffset\":12,\"byteLength\":4},{\"buffer\":0,\"byteOffset\":16,\"byteLength\":16},{\"buffer\":0,\"byteOffset\":32,\"byteLength\":64},{\"buffer\":0,\"byteOffset\":96,\"byteLength\":8},{\"buffer\":0,\"byteOffset\":104,\"byteLength\":24}],\"accessors\":[{\"bufferView\":0,\"componentType\":5126,\"count\":1,\"type\":\"VEC3\"},{\"bufferView\":1,\"componentType\":5121,\"count\":1,\"type\":\"VEC4\"},{\"bufferView\":2,\"componentType\":5126,\"count\":1,\"type\":\"VEC4\"},{\"bufferView\":3,\"componentType\":5126,\"count\":1,\"type\":\"MAT4\"},{\"bufferView\":4,\"componentType\":5126,\"count\":2,\"type\":\"SCALAR\"},{\"bufferView\":5,\"componentType\":5126,\"count\":2,\"type\":\"VEC3\"}],\"nodes\":[{\"matrix\":[1,0,0,0,0,1,0,0,0,0,1,0,10,0,0,1],\"children\":[1]},{\"children\":[0]}],\"skins\":[{\"joints\":[1],\"inverseBindMatrices\":3}],\"animations\":[{\"samplers\":[{\"input\":4,\"output\":5,\"interpolation\":\"LINEAR\"}],\"channels\":[{\"sampler\":0,\"target\":{\"node\":1,\"path\":\"translation\"}}]}]}",1)==1,ctr)
29 gv_check("unsupported interpolation rejected",rpt_case("{\"asset\":{\"version\":\"2.0\"},\"buffers\":[{\"byteLength\":128}],\"bufferViews\":[{\"buffer\":0,\"byteOffset\":0,\"byteLength\":12},{\"buffer\":0,\"byteOffset\":12,\"byteLength\":4},{\"buffer\":0,\"byteOffset\":16,\"byteLength\":16},{\"buffer\":0,\"byteOffset\":32,\"byteLength\":64},{\"buffer\":0,\"byteOffset\":96,\"byteLength\":8},{\"buffer\":0,\"byteOffset\":104,\"byteLength\":24}],\"accessors\":[{\"bufferView\":0,\"componentType\":5126,\"count\":1,\"type\":\"VEC3\"},{\"bufferView\":1,\"componentType\":5121,\"count\":1,\"type\":\"VEC4\"},{\"bufferView\":2,\"componentType\":5126,\"count\":1,\"type\":\"VEC4\"},{\"bufferView\":3,\"componentType\":5126,\"count\":1,\"type\":\"MAT4\"},{\"bufferView\":4,\"componentType\":5126,\"count\":2,\"type\":\"SCALAR\"},{\"bufferView\":5,\"componentType\":5126,\"count\":2,\"type\":\"VEC3\"}],\"nodes\":[{\"matrix\":[1,0,0,0,0,1,0,0,0,0,1,0,10,0,0,1],\"children\":[1]},{}],\"skins\":[{\"joints\":[1],\"inverseBindMatrices\":3}],\"animations\":[{\"samplers\":[{\"input\":4,\"output\":5,\"interpolation\":\"CUBICSPLINE\"}],\"channels\":[{\"sampler\":0,\"target\":{\"node\":1,\"path\":\"translation\"}}]}]}",1)==1,ctr)
30 return gv_verdict("POSE-SOURCE-WORLD",ctr,"fixture semantics, not general physical qualification")
31}