I try to put a mesh into virtual reality.
What I try to use is this command: CreateObjectFromMeshMemblock
The Data I insert is this data:
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
Unfortuantely the program killing with errorcode 1 executing the command.
Any idea why?
By analyzing your data it seems you're doing:
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
to setup your header, then:
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")
to setup your attribute information and finally dumping both the vertex/index data, where you use offsets 48
, 108
. It seems the offsets of the whole dump are correct (if I'm my reviewing didn't miss anything) so I'm going to guess here:
unsigned byte
as datatype for the uv coordinates instead float
, maybe that's a mistake?This is just guessing and by looking just at the memory dump isn't easy to find the bug, maybe if you posted the actual code I could make better assumptions
EDIT: It seems you're enforced to use the correct datatypes for the vertex attributes, a good hint is by considering the return types of the Mesh getters, ie:
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 )
Also, make sure you use the Error functions to know more about the type of errors you're getting