我尝试将网格物体放入虚拟现实中。
我尝试使用的命令是:CreateObjectFromMeshMemblock
我插入的数据是以下数据:
Byte No Value
0 3 vertice count (aka first)
1 0 vertice count
2 0 vertice count
3 0 vertice count
4 3 indices count (aka second)
5 0 indices count
6 0 indices count
7 0 indices count
8 2 attr count (aka third)
9 0 attr count
10 0 attr count
11 0 attr count
12 20 vertex size (aka fourth)
13 0 vertex size (20 because x+y+z + uvx+uvy = 5 * 4bytes = 20)
14 0 vertex size
15 0 vertex size
16 48 vertex-data offset (aka fifth)
17 0 vertex-data offset
18 0 vertex-data offset
19 0 vertex-data offset
20 108 indices-data offset (aka sixth)
21 0 indices-data offset
22 0 indices-data offset
23 0 indices-data offset
-- header success, starting vertex attribute data --
24 0 data type
25 3 cmp count
26 0 normalize flag
27 12 string length
28 112 p
29 111 o
30 115 s
31 105 i
32 116 t
33 105 i
34 111 o
35 110 n
36 0 \0
37 0 \0
38 0 \0
39 0 \0
40 1 data type
41 2 cmp count
42 0 normalize flag
43 4 string length
44 117 u
45 118 v
46 0 \0
47 0 \0
-- offset vertex data --
48 0
49 0
50 183
51 66
52 0
53 0
54 183
55 66
56 0
57 0
58 183
59 66
60 0
61 0
62 0
63 0
64 0
65 0
66 0
67 0
-- next vertex --
68 0
69 0
70 183
71 189
72 0
73 0
74 183
75 66
76 0
77 0
78 183
79 66
80 0
81 0
82 0
83 0
84 0
85 0
86 0
87 0
-- next vertex --
88 0
89 0
90 183
91 189
92 0
93 0
94 183
95 189
96 0
97 0
98 183
99 66
100 0
101 0
102 0
103 0
104 0
105 0
106 0
107 0
-- now starting indices --
108 0 first index
109 0 first index
110 0 first index
111 0 first index
112 1 second index
113 0 second index
114 0 second index
115 0 second index
116 2 third index
117 0 third index
118 0 third index
119 0 third index
不幸的是,该程序杀死了执行命令的错误代码1。
知道为什么吗?
答案 0 :(得分:2)
通过分析数据,看来您正在做
SetMemblockInt(memblock,0,3) //3 vertices
SetMemblockInt(memblock,4,3) //3 indices
SetMemblockint(memblock,8,2) //2 attributes, pos+uv
SetMemblockInt(memblock,12,20) // number bytes per vertex
SetMemblockInt(memblock,16,48) // vertex-data offset
SetMemblockInt(memblock,20,108) // indices-data offset
设置标题,然后:
SetMemBlockInt(memblock,24,0x0C000300) // float, 3 components, no normalizing, position
SetMemblockString(memblock,28,"position")
SetMemBlockInt(memblock,40,0x04000201) // unsigned byte, 2 components, no normalizing, uv
SetMemblockString(memblock,44,"uv")
设置属性信息,并最终转储两个顶点/索引数据,其中使用偏移量48
,108
。似乎整个转储文件的偏移量都是正确的(如果我的评论没有遗漏任何内容),所以我要在这里做出一些猜测:
unsigned byte
作为uv坐标的数据类型,而不是float
,也许是个错误吗?这只是猜测,仅查看内存转储并不容易发现错误,也许如果您发布了实际代码,我可以做出更好的假设
编辑:看来您被迫对顶点属性使用正确的数据类型,一个很好的提示是考虑Mesh吸气剂的返回类型,即:
float GetMeshMemblockVertexNormalX( memID, vertexIndex )
float GetMeshMemblockVertexNormalY( memID, vertexIndex )
float GetMeshMemblockVertexNormalZ( memID, vertexIndex )
float GetMeshMemblockVertexU( memID, vertexIndex )
float GetMeshMemblockVertexV( memID, vertexIndex )
float GetMeshMemblockVertexX( memID, vertexIndex )
float GetMeshMemblockVertexY( memID, vertexIndex )
float GetMeshMemblockVertexZ( memID, vertexIndex )
integer GetMeshMemblockVertexAlpha( memID, vertexIndex )
integer GetMeshMemblockVertexBlue( memID, vertexIndex )
integer GetMeshMemblockVertexGreen( memID, vertexIndex )
integer GetMeshMemblockVertexRed( memID, vertexIndex )
此外,请确保您使用Error函数来了解有关所得到的错误类型的更多信息