updated verse to version r6p1
[blender.git] / extern / verse / dist / v_gen_pack_o_node.c
1 /*
2 ** This is automatically generated source code -- do not edit.
3 ** Changes are affected either by editing the corresponding protocol
4 ** definition file (v_cmd_def_X.c where X=node type), or by editing
5 ** the code generator itself, in v_cmd_gen.c.
6 */
7
8 #include <stdlib.h>
9 #include <stdio.h>
10
11 #include "v_cmd_gen.h"
12 #if !defined(V_GENERATE_FUNC_MODE)
13 #include "verse.h"
14 #include "v_cmd_buf.h"
15 #include "v_network_out_que.h"
16 #include "v_network.h"
17 #include "v_connection.h"
18 #include "v_util.h"
19
20 void verse_send_o_transform_pos_real32(VNodeID node_id, uint32 time_s, uint32 time_f, const real32 *pos, const real32 *speed, const real32 *accelerate, const real32 *drag_normal, real32 drag)
21 {
22         uint8 *buf;
23         unsigned int buffer_pos = 0;
24         VCMDBufHead *head;
25         head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
26         buf = ((VCMDBuffer10 *)head)->buf;
27
28         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 32); /* Pack the command. */
29 #if defined V_PRINT_SEND_COMMANDS
30         printf("send: verse_send_o_transform_pos_real32(node_id = %u time_s = %u time_f = %u pos = %p speed = %p accelerate = %p drag_normal = %p drag = %f );\n", node_id, time_s, time_f, pos, speed, accelerate, drag_normal, drag);
31 #endif
32         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
33         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], time_s);
34         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], time_f);
35         {
36                 unsigned char mask = 0;
37                 unsigned int cmd;
38                 cmd = buffer_pos++;
39                 buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], pos[0]);
40                 buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], pos[1]);
41                 buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], pos[2]);
42                 if(speed != NULL && (speed[0] > 0.0000001 || speed[0] < -0.0000001 || speed[1] > 0.0000001 || speed[1] < -0.0000001 || speed[2] > 0.0000001 || speed[2] < -0.0000001))
43                 {
44                         mask |= 1;
45                         buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], speed[0]);
46                         buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], speed[1]);
47                         buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], speed[2]);
48                 }
49                 if(accelerate != NULL && (accelerate[0] > 0.0000001 || accelerate[0] < -0.0000001 || accelerate[1] > 0.0000001 || accelerate[1] < -0.0000001 || accelerate[2] > 0.0000001 || accelerate[2] < -0.0000001))
50                 {
51                         mask |= 2;
52                         buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], accelerate[0]);
53                         buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], accelerate[1]);
54                         buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], accelerate[2]);
55                 }
56                 if(drag_normal != NULL && (drag > 0.0000001 || drag < -0.0000001) && (drag_normal[0] > 0.0000001 || drag_normal[0] < -0.0000001 || drag_normal[1] > 0.0000001 || drag_normal[1] < -0.0000001 || drag_normal[2] > 0.0000001 || drag_normal[2] < -0.0000001))
57                 {
58                         mask |= 4;
59                         buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], drag_normal[0]);
60                         buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], drag_normal[1]);
61                         buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], drag_normal[2]);
62                 }
63                 if(drag > 0.0000001 || drag < -0.0000001)
64                 {
65                         mask |= 8;
66                         buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], drag);
67                 }
68                 vnp_raw_pack_uint8(&buf[cmd], mask);
69         }if(FALSE)
70         buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], drag);
71         if(node_id == (uint32) ~0u)
72                 v_cmd_buf_set_unique_address_size(head, 5);
73         else
74                 v_cmd_buf_set_address_size(head, 5);
75         v_cmd_buf_set_size(head, buffer_pos);
76         v_noq_send_buf(v_con_get_network_queue(), head);
77 }
78
79 unsigned int v_unpack_o_transform_pos_real32(const char *buf, size_t buffer_length)
80 {
81         unsigned int buffer_pos = 0;
82         void (* func_o_transform_pos_real32)(void *user_data, VNodeID node_id, uint32 time_s, uint32 time_f, const real32 *pos, const real32 *speed, const real32 *accelerate, const real32 *drag_normal, real32 drag);
83         VNodeID node_id;
84         uint32 time_s;
85         uint32 time_f;
86         const real32 *pos;
87         const real32 *speed;
88         const real32 *accelerate;
89         const real32 *drag_normal;
90         real32 drag;
91         
92         func_o_transform_pos_real32 = v_fs_get_user_func(32);
93         if(buffer_length < 4)
94                 return -1;
95         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
96         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &time_s);
97         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &time_f);
98 #if defined V_PRINT_RECEIVE_COMMANDS
99         printf("receive: verse_send_o_transform_pos_real32(node_id = %u time_s = %u time_f = %u drag = %f ); callback = %p\n", node_id, time_s, time_f, drag, v_fs_get_user_func(32));
100 #endif
101         {
102                 float output[4][3];
103                 unsigned int i, j;
104                 char mask, pow = 1;
105                 buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &mask);
106                 for(j = 0; j < 3; j++)
107                         buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &output[0][j]);
108                 for(i = 1; i < 4; i++)
109                 {
110                         if((mask & pow) != 0)
111                                 for(j = 0; j < 3; j++)
112                                         buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &output[i][j]);
113                         else
114                                 for(j = 0; j < 3; j++)
115                                         output[i][j] = 0;
116                         pow *= 2;
117                 }
118                 if((mask & pow) != 0)
119                         buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &drag);
120                 else
121                         drag = 0.0f;
122                 if(func_o_transform_pos_real32 != NULL)
123                         func_o_transform_pos_real32(v_fs_get_user_data(32), node_id, time_s, time_f, &output[0][0], &output[1][0], &output[2][0], &output[3][0], drag);
124                 return buffer_pos;
125         }
126
127         if(func_o_transform_pos_real32 != NULL)
128                 func_o_transform_pos_real32(v_fs_get_user_data(32), node_id, time_s, time_f, pos, speed, accelerate, drag_normal, drag);
129
130         return buffer_pos;
131 }
132
133 void verse_send_o_transform_rot_real32(VNodeID node_id, uint32 time_s, uint32 time_f, const VNQuat32 *rot, const VNQuat32 *speed, const VNQuat32 *accelerate, const VNQuat32 *drag_normal, real32 drag)
134 {
135         uint8 *buf;
136         unsigned int buffer_pos = 0;
137         VCMDBufHead *head;
138         head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
139         buf = ((VCMDBuffer10 *)head)->buf;
140
141         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 33); /* Pack the command. */
142 #if defined V_PRINT_SEND_COMMANDS
143         printf("send: verse_send_o_transform_rot_real32(node_id = %u time_s = %u time_f = %u rot = %p speed = %p accelerate = %p drag_normal = %p drag = %f );\n", node_id, time_s, time_f, rot, speed, accelerate, drag_normal, drag);
144 #endif
145         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
146         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], time_s);
147         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], time_f);
148         {
149                 uint8 mask = 0;
150                 unsigned int maskpos;
151                 maskpos = buffer_pos++;         /* Remember location, and reserve a byte for the mask. */
152                 buffer_pos += vnp_pack_quat32(&buf[buffer_pos], rot);
153                 if(v_quat32_valid(speed))
154                 {
155                         mask |= 1;
156                         buffer_pos += vnp_pack_quat32(&buf[buffer_pos], speed);
157                 }
158                 if(v_quat32_valid(accelerate))
159                 {
160                         mask |= 2;
161                         buffer_pos += vnp_pack_quat32(&buf[buffer_pos], accelerate);
162                 }
163                 if(v_quat32_valid(drag_normal))
164                 {
165                         mask |= 4;
166                         buffer_pos += vnp_pack_quat32(&buf[buffer_pos], drag_normal);
167                 }
168                 if(drag > 0.0000001 || drag < -0.0000001)
169                 {
170                         mask |= 8;
171                         buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], drag);
172                 }
173                 vnp_raw_pack_uint8(&buf[maskpos], mask);        /* Write the mask into start of command. */
174         }
175         if(FALSE)
176         buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], drag);
177         if(node_id == (uint32) ~0u)
178                 v_cmd_buf_set_unique_address_size(head, 5);
179         else
180                 v_cmd_buf_set_address_size(head, 5);
181         v_cmd_buf_set_size(head, buffer_pos);
182         v_noq_send_buf(v_con_get_network_queue(), head);
183 }
184
185 unsigned int v_unpack_o_transform_rot_real32(const char *buf, size_t buffer_length)
186 {
187         unsigned int buffer_pos = 0;
188         void (* func_o_transform_rot_real32)(void *user_data, VNodeID node_id, uint32 time_s, uint32 time_f, const VNQuat32 *rot, const VNQuat32 *speed, const VNQuat32 *accelerate, const VNQuat32 *drag_normal, real32 drag);
189         VNodeID node_id;
190         uint32 time_s;
191         uint32 time_f;
192         const VNQuat32 *rot;
193         const VNQuat32 *speed;
194         const VNQuat32 *accelerate;
195         const VNQuat32 *drag_normal;
196         real32 drag;
197         
198         func_o_transform_rot_real32 = v_fs_get_user_func(33);
199         if(buffer_length < 4)
200                 return -1;
201         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
202         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &time_s);
203         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &time_f);
204 #if defined V_PRINT_RECEIVE_COMMANDS
205         printf("receive: verse_send_o_transform_rot_real32(node_id = %u time_s = %u time_f = %u drag = %f ); callback = %p\n", node_id, time_s, time_f, drag, v_fs_get_user_func(33));
206 #endif
207         {
208                 VNQuat32 trot, temp[3], *q[3];
209                 unsigned int i;
210                 uint8 mask, test;
211                 buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &mask);
212                 buffer_pos += vnp_unpack_quat32(&buf[buffer_pos], &trot);
213                 for(i = 0, test = 1; i < sizeof temp / sizeof *temp; i++, test <<= 1)
214                 {
215                         if(mask & test)         /* Field present? */
216                         {
217                                 buffer_pos += vnp_unpack_quat32(&buf[buffer_pos], &temp[i]);
218                                 q[i] = &temp[i];
219                         }
220                         else
221                                 q[i] = NULL;
222                 }
223                 if(mask & test)
224                         buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &drag);
225                 else
226                         drag = 0.0;
227                 if(func_o_transform_rot_real32 != NULL)
228                         func_o_transform_rot_real32(v_fs_get_user_data(33), node_id, time_s, time_f, &trot, q[0], q[1], q[2], drag);
229                 return buffer_pos;
230         }
231
232         if(func_o_transform_rot_real32 != NULL)
233                 func_o_transform_rot_real32(v_fs_get_user_data(33), node_id, time_s, time_f, rot, speed, accelerate, drag_normal, drag);
234
235         return buffer_pos;
236 }
237
238 void verse_send_o_transform_scale_real32(VNodeID node_id, real32 scale_x, real32 scale_y, real32 scale_z)
239 {
240         uint8 *buf;
241         unsigned int buffer_pos = 0;
242         VCMDBufHead *head;
243         head = v_cmd_buf_allocate(VCMDBS_20);/* Allocating the buffer */
244         buf = ((VCMDBuffer10 *)head)->buf;
245
246         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 34); /* Pack the command. */
247 #if defined V_PRINT_SEND_COMMANDS
248         printf("send: verse_send_o_transform_scale_real32(node_id = %u scale_x = %f scale_y = %f scale_z = %f );\n", node_id, scale_x, scale_y, scale_z);
249 #endif
250         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
251         buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], scale_x);
252         buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], scale_y);
253         buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], scale_z);
254         if(node_id == (uint32) ~0u)
255                 v_cmd_buf_set_unique_address_size(head, 5);
256         else
257                 v_cmd_buf_set_address_size(head, 5);
258         v_cmd_buf_set_size(head, buffer_pos);
259         v_noq_send_buf(v_con_get_network_queue(), head);
260 }
261
262 unsigned int v_unpack_o_transform_scale_real32(const char *buf, size_t buffer_length)
263 {
264         unsigned int buffer_pos = 0;
265         void (* func_o_transform_scale_real32)(void *user_data, VNodeID node_id, real32 scale_x, real32 scale_y, real32 scale_z);
266         VNodeID node_id;
267         real32 scale_x;
268         real32 scale_y;
269         real32 scale_z;
270         
271         func_o_transform_scale_real32 = v_fs_get_user_func(34);
272         if(buffer_length < 4)
273                 return -1;
274         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
275         buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &scale_x);
276         buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &scale_y);
277         buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &scale_z);
278 #if defined V_PRINT_RECEIVE_COMMANDS
279         printf("receive: verse_send_o_transform_scale_real32(node_id = %u scale_x = %f scale_y = %f scale_z = %f ); callback = %p\n", node_id, scale_x, scale_y, scale_z, v_fs_get_user_func(34));
280 #endif
281         if(func_o_transform_scale_real32 != NULL)
282                 func_o_transform_scale_real32(v_fs_get_user_data(34), node_id, scale_x, scale_y, scale_z);
283
284         return buffer_pos;
285 }
286
287 void verse_send_o_transform_pos_real64(VNodeID node_id, uint32 time_s, uint32 time_f, const real64 *pos, const real64 *speed, const real64 *accelerate, const real64 *drag_normal, real64 drag)
288 {
289         uint8 *buf;
290         unsigned int buffer_pos = 0;
291         VCMDBufHead *head;
292         head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
293         buf = ((VCMDBuffer10 *)head)->buf;
294
295         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 35); /* Pack the command. */
296 #if defined V_PRINT_SEND_COMMANDS
297         printf("send: verse_send_o_transform_pos_real64(node_id = %u time_s = %u time_f = %u pos = %p speed = %p accelerate = %p drag_normal = %p drag = %f );\n", node_id, time_s, time_f, pos, speed, accelerate, drag_normal, drag);
298 #endif
299         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
300         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], time_s);
301         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], time_f);
302         {
303                 unsigned char mask = 0;
304                 unsigned int cmd;
305                 cmd = buffer_pos++;
306                 buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], pos[0]);
307                 buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], pos[1]);
308                 buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], pos[2]);
309                 if(speed != NULL && (speed[0] > 0.0000001 || speed[0] < -0.0000001 || speed[1] > 0.0000001 || speed[1] < -0.0000001 || speed[2] > 0.0000001 || speed[2] < -0.0000001))
310                 {
311                         mask |= 1;
312                         buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], speed[0]);
313                         buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], speed[1]);
314                         buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], speed[2]);
315                 }
316                 if(accelerate != NULL && (accelerate[0] > 0.0000001 || accelerate[0] < -0.0000001 || accelerate[1] > 0.0000001 || accelerate[1] < -0.0000001 || accelerate[2] > 0.0000001 || accelerate[2] < -0.0000001))
317                 {
318                         mask |= 2;
319                         buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], accelerate[0]);
320                         buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], accelerate[1]);
321                         buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], accelerate[2]);
322                 }
323                 if(drag_normal != NULL && (drag > 0.0000001 || drag < -0.0000001) && (drag_normal[0] > 0.0000001 || drag_normal[0] < -0.0000001 || drag_normal[1] > 0.0000001 || drag_normal[1] < -0.0000001 || drag_normal[2] > 0.0000001 || drag_normal[2] < -0.0000001))
324                 {
325                         mask |= 4;
326                         buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], drag_normal[0]);
327                         buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], drag_normal[1]);
328                         buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], drag_normal[2]);
329                 }
330                 if(drag > 0.0000001 || drag < -0.0000001)
331                 {
332                         mask |= 8;
333                         buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], drag);
334                 }
335                 vnp_raw_pack_uint8(&buf[cmd], mask);
336         }if(FALSE)
337         buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], drag);
338         if(node_id == (uint32) ~0u)
339                 v_cmd_buf_set_unique_address_size(head, 5);
340         else
341                 v_cmd_buf_set_address_size(head, 5);
342         v_cmd_buf_set_size(head, buffer_pos);
343         v_noq_send_buf(v_con_get_network_queue(), head);
344 }
345
346 unsigned int v_unpack_o_transform_pos_real64(const char *buf, size_t buffer_length)
347 {
348         unsigned int buffer_pos = 0;
349         void (* func_o_transform_pos_real64)(void *user_data, VNodeID node_id, uint32 time_s, uint32 time_f, const real64 *pos, const real64 *speed, const real64 *accelerate, const real64 *drag_normal, real64 drag);
350         VNodeID node_id;
351         uint32 time_s;
352         uint32 time_f;
353         const real64 *pos;
354         const real64 *speed;
355         const real64 *accelerate;
356         const real64 *drag_normal;
357         real64 drag;
358         
359         func_o_transform_pos_real64 = v_fs_get_user_func(35);
360         if(buffer_length < 4)
361                 return -1;
362         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
363         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &time_s);
364         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &time_f);
365 #if defined V_PRINT_RECEIVE_COMMANDS
366         printf("receive: verse_send_o_transform_pos_real64(node_id = %u time_s = %u time_f = %u drag = %f ); callback = %p\n", node_id, time_s, time_f, drag, v_fs_get_user_func(35));
367 #endif
368         {
369                 double output[4][3];
370                 unsigned int i, j;
371                 char mask, pow = 1;
372                 buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &mask);
373                 for(j = 0; j < 3; j++)
374                         buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &output[0][j]);
375                 for(i = 1; i < 4; i++)
376                 {
377                         if((mask & pow) != 0)
378                                 for(j = 0; j < 3; j++)
379                                         buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &output[i][j]);
380                         else
381                                 for(j = 0; j < 3; j++)
382                                         output[i][j] = 0;
383                         pow *= 2;
384                 }
385                 if((mask & pow) != 0)
386                         buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &drag);
387                 else
388                         drag = 0.0;
389                 if(func_o_transform_pos_real64 != NULL)
390                         func_o_transform_pos_real64(v_fs_get_user_data(35), node_id, time_s, time_f, &output[0][0], &output[1][0], &output[2][0], &output[3][0], drag);
391                 return buffer_pos;
392         }
393
394         if(func_o_transform_pos_real64 != NULL)
395                 func_o_transform_pos_real64(v_fs_get_user_data(35), node_id, time_s, time_f, pos, speed, accelerate, drag_normal, drag);
396
397         return buffer_pos;
398 }
399
400 void verse_send_o_transform_rot_real64(VNodeID node_id, uint32 time_s, uint32 time_f, const VNQuat64 *rot, const VNQuat64 *speed, const VNQuat64 *accelerate, const VNQuat64 *drag_normal, real64 drag)
401 {
402         uint8 *buf;
403         unsigned int buffer_pos = 0;
404         VCMDBufHead *head;
405         head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
406         buf = ((VCMDBuffer10 *)head)->buf;
407
408         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 36); /* Pack the command. */
409 #if defined V_PRINT_SEND_COMMANDS
410         printf("send: verse_send_o_transform_rot_real64(node_id = %u time_s = %u time_f = %u rot = %p speed = %p accelerate = %p drag_normal = %p drag = %f );\n", node_id, time_s, time_f, rot, speed, accelerate, drag_normal, drag);
411 #endif
412         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
413         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], time_s);
414         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], time_f);
415         {
416                 uint8 mask = 0;
417                 unsigned int maskpos;
418                 maskpos = buffer_pos++;         /* Remember location, and reserve a byte for the mask. */
419                 buffer_pos += vnp_pack_quat64(&buf[buffer_pos], rot);
420                 if(v_quat64_valid(speed))
421                 {
422                         mask |= 1;
423                         buffer_pos += vnp_pack_quat64(&buf[buffer_pos], speed);
424                 }
425                 if(v_quat64_valid(accelerate))
426                 {
427                         mask |= 2;
428                         buffer_pos += vnp_pack_quat64(&buf[buffer_pos], accelerate);
429                 }
430                 if(v_quat64_valid(drag_normal))
431                 {
432                         mask |= 4;
433                         buffer_pos += vnp_pack_quat64(&buf[buffer_pos], drag_normal);
434                 }
435                 if(drag > 0.0000001 || drag < -0.0000001)
436                 {
437                         mask |= 8;
438                         buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], drag);
439                 }
440                 vnp_raw_pack_uint8(&buf[maskpos], mask);        /* Write the mask into start of command. */
441         }
442         if(FALSE)
443         buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], drag);
444         if(node_id == (uint32) ~0u)
445                 v_cmd_buf_set_unique_address_size(head, 5);
446         else
447                 v_cmd_buf_set_address_size(head, 5);
448         v_cmd_buf_set_size(head, buffer_pos);
449         v_noq_send_buf(v_con_get_network_queue(), head);
450 }
451
452 unsigned int v_unpack_o_transform_rot_real64(const char *buf, size_t buffer_length)
453 {
454         unsigned int buffer_pos = 0;
455         void (* func_o_transform_rot_real64)(void *user_data, VNodeID node_id, uint32 time_s, uint32 time_f, const VNQuat64 *rot, const VNQuat64 *speed, const VNQuat64 *accelerate, const VNQuat64 *drag_normal, real64 drag);
456         VNodeID node_id;
457         uint32 time_s;
458         uint32 time_f;
459         const VNQuat64 *rot;
460         const VNQuat64 *speed;
461         const VNQuat64 *accelerate;
462         const VNQuat64 *drag_normal;
463         real64 drag;
464         
465         func_o_transform_rot_real64 = v_fs_get_user_func(36);
466         if(buffer_length < 4)
467                 return -1;
468         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
469         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &time_s);
470         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &time_f);
471 #if defined V_PRINT_RECEIVE_COMMANDS
472         printf("receive: verse_send_o_transform_rot_real64(node_id = %u time_s = %u time_f = %u drag = %f ); callback = %p\n", node_id, time_s, time_f, drag, v_fs_get_user_func(36));
473 #endif
474         {
475                 VNQuat64 trot, temp[3], *q[3];
476                 unsigned int i;
477                 uint8 mask, test;
478                 buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &mask);
479                 buffer_pos += vnp_unpack_quat64(&buf[buffer_pos], &trot);
480                 for(i = 0, test = 1; i < sizeof temp / sizeof *temp; i++, test <<= 1)
481                 {
482                         if(mask & test)         /* Field present? */
483                         {
484                                 buffer_pos += vnp_unpack_quat64(&buf[buffer_pos], &temp[i]);
485                                 q[i] = &temp[i];
486                         }
487                         else
488                                 q[i] = NULL;
489                 }
490                 if(mask & test)
491                         buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &drag);
492                 else
493                         drag = 0.0;
494                 if(func_o_transform_rot_real64 != NULL)
495                         func_o_transform_rot_real64(v_fs_get_user_data(36), node_id, time_s, time_f, &trot, q[0], q[1], q[2], drag);
496                 return buffer_pos;
497         }
498
499         if(func_o_transform_rot_real64 != NULL)
500                 func_o_transform_rot_real64(v_fs_get_user_data(36), node_id, time_s, time_f, rot, speed, accelerate, drag_normal, drag);
501
502         return buffer_pos;
503 }
504
505 void verse_send_o_transform_scale_real64(VNodeID node_id, real64 scale_x, real64 scale_y, real64 scale_z)
506 {
507         uint8 *buf;
508         unsigned int buffer_pos = 0;
509         VCMDBufHead *head;
510         head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */
511         buf = ((VCMDBuffer10 *)head)->buf;
512
513         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 37); /* Pack the command. */
514 #if defined V_PRINT_SEND_COMMANDS
515         printf("send: verse_send_o_transform_scale_real64(node_id = %u scale_x = %f scale_y = %f scale_z = %f );\n", node_id, scale_x, scale_y, scale_z);
516 #endif
517         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
518         buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], scale_x);
519         buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], scale_y);
520         buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], scale_z);
521         if(node_id == (uint32) ~0u)
522                 v_cmd_buf_set_unique_address_size(head, 5);
523         else
524                 v_cmd_buf_set_address_size(head, 5);
525         v_cmd_buf_set_size(head, buffer_pos);
526         v_noq_send_buf(v_con_get_network_queue(), head);
527 }
528
529 unsigned int v_unpack_o_transform_scale_real64(const char *buf, size_t buffer_length)
530 {
531         unsigned int buffer_pos = 0;
532         void (* func_o_transform_scale_real64)(void *user_data, VNodeID node_id, real64 scale_x, real64 scale_y, real64 scale_z);
533         VNodeID node_id;
534         real64 scale_x;
535         real64 scale_y;
536         real64 scale_z;
537         
538         func_o_transform_scale_real64 = v_fs_get_user_func(37);
539         if(buffer_length < 4)
540                 return -1;
541         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
542         buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &scale_x);
543         buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &scale_y);
544         buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &scale_z);
545 #if defined V_PRINT_RECEIVE_COMMANDS
546         printf("receive: verse_send_o_transform_scale_real64(node_id = %u scale_x = %f scale_y = %f scale_z = %f ); callback = %p\n", node_id, scale_x, scale_y, scale_z, v_fs_get_user_func(37));
547 #endif
548         if(func_o_transform_scale_real64 != NULL)
549                 func_o_transform_scale_real64(v_fs_get_user_data(37), node_id, scale_x, scale_y, scale_z);
550
551         return buffer_pos;
552 }
553
554 void verse_send_o_transform_subscribe(VNodeID node_id, VNRealFormat type)
555 {
556         uint8 *buf;
557         unsigned int buffer_pos = 0;
558         VCMDBufHead *head;
559         head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
560         buf = ((VCMDBuffer10 *)head)->buf;
561
562         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 38); /* Pack the command. */
563 #if defined V_PRINT_SEND_COMMANDS
564         printf("send: verse_send_o_transform_subscribe(node_id = %u type = %u );\n", node_id, type);
565 #endif
566         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
567         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)type);
568         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], TRUE);
569         if(node_id == (uint32) ~0u)
570                 v_cmd_buf_set_unique_address_size(head, 5);
571         else
572                 v_cmd_buf_set_address_size(head, 5);
573         v_cmd_buf_set_size(head, buffer_pos);
574         v_noq_send_buf(v_con_get_network_queue(), head);
575 }
576
577 void verse_send_o_transform_unsubscribe(VNodeID node_id, VNRealFormat type)
578 {
579         uint8 *buf;
580         unsigned int buffer_pos = 0;
581         VCMDBufHead *head;
582         head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
583         buf = ((VCMDBuffer10 *)head)->buf;
584
585         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 38); /* Pack the command. */
586 #if defined V_PRINT_SEND_COMMANDS
587         printf("send: verse_send_o_transform_unsubscribe(node_id = %u type = %u );\n", node_id, type);
588 #endif
589         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
590         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)type);
591         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], FALSE);
592         if(node_id == (uint32) ~0u)
593                 v_cmd_buf_set_unique_address_size(head, 5);
594         else
595                 v_cmd_buf_set_address_size(head, 5);
596         v_cmd_buf_set_size(head, buffer_pos);
597         v_noq_send_buf(v_con_get_network_queue(), head);
598 }
599
600 unsigned int v_unpack_o_transform_subscribe(const char *buf, size_t buffer_length)
601 {
602         uint8 enum_temp;
603         unsigned int buffer_pos = 0;
604         void (* func_o_transform_subscribe)(void *user_data, VNodeID node_id, VNRealFormat type);
605         VNodeID node_id;
606         VNRealFormat type;
607         uint8   alias_bool;
608
609         func_o_transform_subscribe = v_fs_get_user_func(38);
610         if(buffer_length < 4)
611                 return -1;
612         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
613         buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &enum_temp);
614         type = (VNRealFormat)enum_temp;
615         if(buffer_length < buffer_pos + 1)
616                 return -1;
617         buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &alias_bool);
618 #if defined V_PRINT_RECEIVE_COMMANDS
619         if(!alias_bool)
620                 printf("receive: verse_send_o_transform_unsubscribe(node_id = %u type = %u ); callback = %p\n", node_id, type, v_fs_get_alias_user_func(38));
621         else
622                 printf("receive: verse_send_o_transform_subscribe(node_id = %u type = %u ); callback = %p\n", node_id, type, v_fs_get_user_func(38));
623 #endif
624         if(!alias_bool)
625         {
626                 void (* alias_o_transform_unsubscribe)(void *user_data, VNodeID node_id, VNRealFormat type);
627                 alias_o_transform_unsubscribe = v_fs_get_alias_user_func(38);
628                 if(alias_o_transform_unsubscribe != NULL)
629                         alias_o_transform_unsubscribe(v_fs_get_alias_user_data(38), node_id, (VNRealFormat)type);
630                 return buffer_pos;
631         }
632         if(func_o_transform_subscribe != NULL)
633                 func_o_transform_subscribe(v_fs_get_user_data(38), node_id, (VNRealFormat) type);
634
635         return buffer_pos;
636 }
637
638 void verse_send_o_light_set(VNodeID node_id, real64 light_r, real64 light_g, real64 light_b)
639 {
640         uint8 *buf;
641         unsigned int buffer_pos = 0;
642         VCMDBufHead *head;
643         head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */
644         buf = ((VCMDBuffer10 *)head)->buf;
645
646         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 39); /* Pack the command. */
647 #if defined V_PRINT_SEND_COMMANDS
648         printf("send: verse_send_o_light_set(node_id = %u light_r = %f light_g = %f light_b = %f );\n", node_id, light_r, light_g, light_b);
649 #endif
650         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
651         buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], light_r);
652         buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], light_g);
653         buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], light_b);
654         if(node_id == (uint32) ~0u)
655                 v_cmd_buf_set_unique_address_size(head, 5);
656         else
657                 v_cmd_buf_set_address_size(head, 5);
658         v_cmd_buf_set_size(head, buffer_pos);
659         v_noq_send_buf(v_con_get_network_queue(), head);
660 }
661
662 unsigned int v_unpack_o_light_set(const char *buf, size_t buffer_length)
663 {
664         unsigned int buffer_pos = 0;
665         void (* func_o_light_set)(void *user_data, VNodeID node_id, real64 light_r, real64 light_g, real64 light_b);
666         VNodeID node_id;
667         real64 light_r;
668         real64 light_g;
669         real64 light_b;
670         
671         func_o_light_set = v_fs_get_user_func(39);
672         if(buffer_length < 4)
673                 return -1;
674         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
675         buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &light_r);
676         buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &light_g);
677         buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &light_b);
678 #if defined V_PRINT_RECEIVE_COMMANDS
679         printf("receive: verse_send_o_light_set(node_id = %u light_r = %f light_g = %f light_b = %f ); callback = %p\n", node_id, light_r, light_g, light_b, v_fs_get_user_func(39));
680 #endif
681         if(func_o_light_set != NULL)
682                 func_o_light_set(v_fs_get_user_data(39), node_id, light_r, light_g, light_b);
683
684         return buffer_pos;
685 }
686
687 void verse_send_o_link_set(VNodeID node_id, uint16 link_id, VNodeID link, const char *label, uint32 target_id)
688 {
689         uint8 *buf;
690         unsigned int buffer_pos = 0;
691         VCMDBufHead *head;
692         head = v_cmd_buf_allocate(VCMDBS_80);/* Allocating the buffer */
693         buf = ((VCMDBuffer10 *)head)->buf;
694
695         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 40); /* Pack the command. */
696 #if defined V_PRINT_SEND_COMMANDS
697         printf("send: verse_send_o_link_set(node_id = %u link_id = %u link = %u label = %s target_id = %u );\n", node_id, link_id, link, label, target_id);
698 #endif
699         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
700         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], link_id);
701         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], link);
702         buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], label, 16);
703         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], target_id);
704         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], TRUE);
705         if(node_id == (uint32) ~0u || link_id == (uint16) ~0u)
706                 v_cmd_buf_set_unique_address_size(head, 7);
707         else
708                 v_cmd_buf_set_address_size(head, 7);
709         v_cmd_buf_set_size(head, buffer_pos);
710         v_noq_send_buf(v_con_get_network_queue(), head);
711 }
712
713 void verse_send_o_link_destroy(VNodeID node_id, uint16 link_id)
714 {
715         uint8 *buf;
716         unsigned int buffer_pos = 0;
717         VCMDBufHead *head;
718         head = v_cmd_buf_allocate(VCMDBS_80);/* Allocating the buffer */
719         buf = ((VCMDBuffer10 *)head)->buf;
720
721         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 40); /* Pack the command. */
722 #if defined V_PRINT_SEND_COMMANDS
723         printf("send: verse_send_o_link_destroy(node_id = %u link_id = %u );\n", node_id, link_id);
724 #endif
725         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
726         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], link_id);
727         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], -1);
728         buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], NULL, 16);
729         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], -1);
730         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], FALSE);
731         if(node_id == (uint32) ~0u || link_id == (uint16) ~0u)
732                 v_cmd_buf_set_unique_address_size(head, 7);
733         else
734                 v_cmd_buf_set_address_size(head, 7);
735         v_cmd_buf_set_size(head, buffer_pos);
736         v_noq_send_buf(v_con_get_network_queue(), head);
737 }
738
739 unsigned int v_unpack_o_link_set(const char *buf, size_t buffer_length)
740 {
741         unsigned int buffer_pos = 0;
742         void (* func_o_link_set)(void *user_data, VNodeID node_id, uint16 link_id, VNodeID link, const char *label, uint32 target_id);
743         VNodeID node_id;
744         uint16 link_id;
745         VNodeID link;
746         char label[16];
747         uint32 target_id;
748         uint8   alias_bool;
749
750         func_o_link_set = v_fs_get_user_func(40);
751         if(buffer_length < 6)
752                 return -1;
753         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
754         buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &link_id);
755         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &link);
756         buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], label, 16, buffer_length - buffer_pos);
757         if(buffer_length < 4 + buffer_pos)
758                 return -1;
759         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &target_id);
760         if(buffer_length < buffer_pos + 1)
761                 return -1;
762         buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &alias_bool);
763 #if defined V_PRINT_RECEIVE_COMMANDS
764         if(!alias_bool)
765                 printf("receive: verse_send_o_link_destroy(node_id = %u link_id = %u ); callback = %p\n", node_id, link_id, v_fs_get_alias_user_func(40));
766         else
767                 printf("receive: verse_send_o_link_set(node_id = %u link_id = %u link = %u label = %s target_id = %u ); callback = %p\n", node_id, link_id, link, label, target_id, v_fs_get_user_func(40));
768 #endif
769         if(!alias_bool)
770         {
771                 void (* alias_o_link_destroy)(void *user_data, VNodeID node_id, uint16 link_id);
772                 alias_o_link_destroy = v_fs_get_alias_user_func(40);
773                 if(alias_o_link_destroy != NULL)
774                         alias_o_link_destroy(v_fs_get_alias_user_data(40), node_id, link_id);
775                 return buffer_pos;
776         }
777         if(func_o_link_set != NULL)
778                 func_o_link_set(v_fs_get_user_data(40), node_id, link_id, link, label, target_id);
779
780         return buffer_pos;
781 }
782
783 void verse_send_o_method_group_create(VNodeID node_id, uint16 group_id, const char *name)
784 {
785         uint8 *buf;
786         unsigned int buffer_pos = 0;
787         VCMDBufHead *head;
788         head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */
789         buf = ((VCMDBuffer10 *)head)->buf;
790
791         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 41); /* Pack the command. */
792 #if defined V_PRINT_SEND_COMMANDS
793         printf("send: verse_send_o_method_group_create(node_id = %u group_id = %u name = %s );\n", node_id, group_id, name);
794 #endif
795         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
796         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], group_id);
797         buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], name, 16);
798         if(node_id == (uint32) ~0u || group_id == (uint16) ~0u)
799                 v_cmd_buf_set_unique_address_size(head, 7);
800         else
801                 v_cmd_buf_set_address_size(head, 7);
802         v_cmd_buf_set_size(head, buffer_pos);
803         v_noq_send_buf(v_con_get_network_queue(), head);
804 }
805
806 void verse_send_o_method_group_destroy(VNodeID node_id, uint16 group_id)
807 {
808         uint8 *buf;
809         unsigned int buffer_pos = 0;
810         VCMDBufHead *head;
811         head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */
812         buf = ((VCMDBuffer10 *)head)->buf;
813
814         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 41); /* Pack the command. */
815 #if defined V_PRINT_SEND_COMMANDS
816         printf("send: verse_send_o_method_group_destroy(node_id = %u group_id = %u );\n", node_id, group_id);
817 #endif
818         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
819         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], group_id);
820         buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], NULL, 16);
821         if(node_id == (uint32) ~0u || group_id == (uint16) ~0u)
822                 v_cmd_buf_set_unique_address_size(head, 7);
823         else
824                 v_cmd_buf_set_address_size(head, 7);
825         v_cmd_buf_set_size(head, buffer_pos);
826         v_noq_send_buf(v_con_get_network_queue(), head);
827 }
828
829 unsigned int v_unpack_o_method_group_create(const char *buf, size_t buffer_length)
830 {
831         unsigned int buffer_pos = 0;
832         void (* func_o_method_group_create)(void *user_data, VNodeID node_id, uint16 group_id, const char *name);
833         VNodeID node_id;
834         uint16 group_id;
835         char name[16];
836         
837         func_o_method_group_create = v_fs_get_user_func(41);
838         if(buffer_length < 6)
839                 return -1;
840         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
841         buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &group_id);
842         buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], name, 16, buffer_length - buffer_pos);
843 #if defined V_PRINT_RECEIVE_COMMANDS
844         if(name[0] == 0)
845                 printf("receive: verse_send_o_method_group_destroy(node_id = %u group_id = %u ); callback = %p\n", node_id, group_id, v_fs_get_alias_user_func(41));
846         else
847                 printf("receive: verse_send_o_method_group_create(node_id = %u group_id = %u name = %s ); callback = %p\n", node_id, group_id, name, v_fs_get_user_func(41));
848 #endif
849         if(name[0] == 0)
850         {
851                 void (* alias_o_method_group_destroy)(void *user_data, VNodeID node_id, uint16 group_id);
852                 alias_o_method_group_destroy = v_fs_get_alias_user_func(41);
853                 if(alias_o_method_group_destroy != NULL)
854                         alias_o_method_group_destroy(v_fs_get_alias_user_data(41), node_id, group_id);
855                 return buffer_pos;
856         }
857         if(func_o_method_group_create != NULL)
858                 func_o_method_group_create(v_fs_get_user_data(41), node_id, group_id, name);
859
860         return buffer_pos;
861 }
862
863 void verse_send_o_method_group_subscribe(VNodeID node_id, uint16 group_id)
864 {
865         uint8 *buf;
866         unsigned int buffer_pos = 0;
867         VCMDBufHead *head;
868         head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
869         buf = ((VCMDBuffer10 *)head)->buf;
870
871         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 42); /* Pack the command. */
872 #if defined V_PRINT_SEND_COMMANDS
873         printf("send: verse_send_o_method_group_subscribe(node_id = %u group_id = %u );\n", node_id, group_id);
874 #endif
875         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
876         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], group_id);
877         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], TRUE);
878         if(node_id == (uint32) ~0u || group_id == (uint16) ~0u)
879                 v_cmd_buf_set_unique_address_size(head, 7);
880         else
881                 v_cmd_buf_set_address_size(head, 7);
882         v_cmd_buf_set_size(head, buffer_pos);
883         v_noq_send_buf(v_con_get_network_queue(), head);
884 }
885
886 void verse_send_o_method_group_unsubscribe(VNodeID node_id, uint16 group_id)
887 {
888         uint8 *buf;
889         unsigned int buffer_pos = 0;
890         VCMDBufHead *head;
891         head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
892         buf = ((VCMDBuffer10 *)head)->buf;
893
894         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 42); /* Pack the command. */
895 #if defined V_PRINT_SEND_COMMANDS
896         printf("send: verse_send_o_method_group_unsubscribe(node_id = %u group_id = %u );\n", node_id, group_id);
897 #endif
898         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
899         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], group_id);
900         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], FALSE);
901         if(node_id == (uint32) ~0u || group_id == (uint16) ~0u)
902                 v_cmd_buf_set_unique_address_size(head, 7);
903         else
904                 v_cmd_buf_set_address_size(head, 7);
905         v_cmd_buf_set_size(head, buffer_pos);
906         v_noq_send_buf(v_con_get_network_queue(), head);
907 }
908
909 unsigned int v_unpack_o_method_group_subscribe(const char *buf, size_t buffer_length)
910 {
911         unsigned int buffer_pos = 0;
912         void (* func_o_method_group_subscribe)(void *user_data, VNodeID node_id, uint16 group_id);
913         VNodeID node_id;
914         uint16 group_id;
915         uint8   alias_bool;
916
917         func_o_method_group_subscribe = v_fs_get_user_func(42);
918         if(buffer_length < 6)
919                 return -1;
920         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
921         buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &group_id);
922         if(buffer_length < buffer_pos + 1)
923                 return -1;
924         buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &alias_bool);
925 #if defined V_PRINT_RECEIVE_COMMANDS
926         if(!alias_bool)
927                 printf("receive: verse_send_o_method_group_unsubscribe(node_id = %u group_id = %u ); callback = %p\n", node_id, group_id, v_fs_get_alias_user_func(42));
928         else
929                 printf("receive: verse_send_o_method_group_subscribe(node_id = %u group_id = %u ); callback = %p\n", node_id, group_id, v_fs_get_user_func(42));
930 #endif
931         if(!alias_bool)
932         {
933                 void (* alias_o_method_group_unsubscribe)(void *user_data, VNodeID node_id, uint16 group_id);
934                 alias_o_method_group_unsubscribe = v_fs_get_alias_user_func(42);
935                 if(alias_o_method_group_unsubscribe != NULL)
936                         alias_o_method_group_unsubscribe(v_fs_get_alias_user_data(42), node_id, group_id);
937                 return buffer_pos;
938         }
939         if(func_o_method_group_subscribe != NULL)
940                 func_o_method_group_subscribe(v_fs_get_user_data(42), node_id, group_id);
941
942         return buffer_pos;
943 }
944
945 void verse_send_o_method_create(VNodeID node_id, uint16 group_id, uint16 method_id, const char *name, uint8 param_count, const VNOParamType *param_types, const char * *param_names)
946 {
947         uint8 *buf;
948         unsigned int buffer_pos = 0;
949         VCMDBufHead *head;
950         head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
951         buf = ((VCMDBuffer10 *)head)->buf;
952
953         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 43); /* Pack the command. */
954 #if defined V_PRINT_SEND_COMMANDS
955         printf("send: verse_send_o_method_create(node_id = %u group_id = %u method_id = %u name = %s param_count = %u param_types = %p param_names = %p );\n", node_id, group_id, method_id, name, param_count, param_types, param_names);
956 #endif
957         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
958         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], group_id);
959         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], method_id);
960         buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], name, 512);
961         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], param_count);
962         {
963                 unsigned int i, j, sum = 1;
964                 for(i = 0; i < param_count; i++)
965                 {
966                         sum += 3;
967                         for(j = 0; param_names[i][j] != 0; j++);
968                 }
969                 if(sum + buffer_pos > 1500)
970                         return;
971                 for(i = 0; i < param_count; i++)
972                 {
973                         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], param_types[i]);
974                         buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], param_names[i], 1500 - buffer_pos);
975                 }
976         }
977         if(node_id == (uint32) ~0u || group_id == (uint16) ~0u || method_id == (uint16) ~0u)
978                 v_cmd_buf_set_unique_address_size(head, 9);
979         else
980                 v_cmd_buf_set_address_size(head, 9);
981         v_cmd_buf_set_size(head, buffer_pos);
982         v_noq_send_buf(v_con_get_network_queue(), head);
983 }
984
985 void verse_send_o_method_destroy(VNodeID node_id, uint16 group_id, uint16 method_id)
986 {
987         uint8 *buf;
988         unsigned int buffer_pos = 0;
989         VCMDBufHead *head;
990         head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
991         buf = ((VCMDBuffer10 *)head)->buf;
992
993         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 43); /* Pack the command. */
994 #if defined V_PRINT_SEND_COMMANDS
995         printf("send: verse_send_o_method_destroy(node_id = %u group_id = %u method_id = %u );\n", node_id, group_id, method_id);
996 #endif
997         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
998         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], group_id);
999         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], method_id);
1000         buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], NULL, 512);
1001         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], -1);
1002         if(node_id == (uint32) ~0u || group_id == (uint16) ~0u || method_id == (uint16) ~0u)
1003                 v_cmd_buf_set_unique_address_size(head, 9);
1004         else
1005                 v_cmd_buf_set_address_size(head, 9);
1006         v_cmd_buf_set_size(head, buffer_pos);
1007         v_noq_send_buf(v_con_get_network_queue(), head);
1008 }
1009
1010 unsigned int v_unpack_o_method_create(const char *buf, size_t buffer_length)
1011 {
1012         unsigned int buffer_pos = 0;
1013         void (* func_o_method_create)(void *user_data, VNodeID node_id, uint16 group_id, uint16 method_id, const char *name, uint8 param_count, const VNOParamType *param_types, const char * *param_names);
1014         VNodeID node_id;
1015         uint16 group_id;
1016         uint16 method_id;
1017         char name[512];
1018         uint8 param_count;
1019         const VNOParamType *param_types;
1020         const char * *param_names;
1021         
1022         func_o_method_create = v_fs_get_user_func(43);
1023         if(buffer_length < 8)
1024                 return -1;
1025         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
1026         buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &group_id);
1027         buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &method_id);
1028         buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], name, 512, buffer_length - buffer_pos);
1029         if(buffer_length < 1 + buffer_pos)
1030                 return -1;
1031         buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &param_count);
1032 #if defined V_PRINT_RECEIVE_COMMANDS
1033         if(name[0] == 0)
1034                 printf("receive: verse_send_o_method_destroy(node_id = %u group_id = %u method_id = %u ); callback = %p\n", node_id, group_id, method_id, v_fs_get_alias_user_func(43));
1035         else
1036                 printf("receive: verse_send_o_method_create(node_id = %u group_id = %u method_id = %u name = %s param_count = %u ); callback = %p\n", node_id, group_id, method_id, name, param_count, v_fs_get_user_func(43));
1037 #endif
1038         if(param_count != 255)
1039         {
1040                 unsigned int i, size, text = 0;
1041                 VNOParamType types[256];
1042                 uint8 t;
1043                 char name_buf[1500], *names[256];
1044                 for(i = 0; i < param_count; i++)
1045                 {
1046                         buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &t);
1047                         types[i] = t;
1048                         names[i] = &name_buf[text];
1049                         size = vnp_raw_unpack_string(&buf[buffer_pos], names[i], 1500 - buffer_pos, buffer_length - buffer_pos);
1050                         buffer_pos += size;
1051                         text += size;
1052                 }
1053                 if(func_o_method_create != NULL)
1054                         func_o_method_create(v_fs_get_user_data(43), node_id, group_id, method_id, name, param_count, types, (const char **) names);
1055                 return buffer_pos;
1056         }
1057
1058         if(name[0] == 0)
1059         {
1060                 void (* alias_o_method_destroy)(void *user_data, VNodeID node_id, uint16 group_id, uint16 method_id);
1061                 alias_o_method_destroy = v_fs_get_alias_user_func(43);
1062                 if(alias_o_method_destroy != NULL)
1063                         alias_o_method_destroy(v_fs_get_alias_user_data(43), node_id, group_id, method_id);
1064                 return buffer_pos;
1065         }
1066         if(func_o_method_create != NULL)
1067                 func_o_method_create(v_fs_get_user_data(43), node_id, group_id, method_id, name, param_count, param_types, param_names);
1068
1069         return buffer_pos;
1070 }
1071
1072 void verse_send_o_method_call(VNodeID node_id, uint16 group_id, uint16 method_id, VNodeID sender, const VNOPackedParams *params)
1073 {
1074         uint8 *buf;
1075         unsigned int buffer_pos = 0;
1076         VCMDBufHead *head;
1077         head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
1078         buf = ((VCMDBuffer10 *)head)->buf;
1079
1080         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 44); /* Pack the command. */
1081 #if defined V_PRINT_SEND_COMMANDS
1082         printf("send: verse_send_o_method_call(node_id = %u group_id = %u method_id = %u sender = %u params = %p );\n", node_id, group_id, method_id, sender, params);
1083 #endif
1084         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
1085         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], group_id);
1086         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], method_id);
1087         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], sender);
1088         {
1089                 unsigned int i;
1090                 uint16 size;
1091                 vnp_raw_unpack_uint16(params, &size);
1092                 for(i = 0; i < size; i++)
1093                         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], ((uint8 *)params)[i]);
1094                 free((void *) params);  /* Drop the const. */
1095         }
1096         v_cmd_buf_set_size(head, buffer_pos);
1097         v_noq_send_buf(v_con_get_network_queue(), head);
1098 }
1099
1100 unsigned int v_unpack_o_method_call(const char *buf, size_t buffer_length)
1101 {
1102         unsigned int buffer_pos = 0;
1103         void (* func_o_method_call)(void *user_data, VNodeID node_id, uint16 group_id, uint16 method_id, VNodeID sender, const VNOPackedParams *params);
1104         VNodeID node_id;
1105         uint16 group_id;
1106         uint16 method_id;
1107         VNodeID sender;
1108         const VNOPackedParams *params;
1109         
1110         func_o_method_call = v_fs_get_user_func(44);
1111         if(buffer_length < 12)
1112                 return -1;
1113         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
1114         buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &group_id);
1115         buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &method_id);
1116         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &sender);
1117 #if defined V_PRINT_RECEIVE_COMMANDS
1118         printf("receive: verse_send_o_method_call(node_id = %u group_id = %u method_id = %u sender = %u ); callback = %p\n", node_id, group_id, method_id, sender, v_fs_get_user_func(44));
1119 #endif
1120         {
1121                 unsigned int i;
1122                 uint8 par[1500];
1123                 uint16 size;
1124                 vnp_raw_unpack_uint16(&buf[buffer_pos], &size);
1125                 for(i = 0; i < size; i++)
1126                         buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &par[i]);
1127                 if(func_o_method_call != NULL)
1128                         func_o_method_call(v_fs_get_user_data(44), node_id, group_id, method_id, sender, par);
1129                 return buffer_pos;
1130         }
1131
1132         if(func_o_method_call != NULL)
1133                 func_o_method_call(v_fs_get_user_data(44), node_id, group_id, method_id, sender, params);
1134
1135         return buffer_pos;
1136 }
1137
1138 void verse_send_o_anim_run(VNodeID node_id, uint16 link_id, uint32 time_s, uint32 time_f, uint8 dimensions, const real64 *pos, const real64 *speed, const real64 *accel, const real64 *scale, const real64 *scale_speed)
1139 {
1140         uint8 *buf;
1141         unsigned int buffer_pos = 0;
1142         VCMDBufHead *head;
1143         head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
1144         buf = ((VCMDBuffer10 *)head)->buf;
1145
1146         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 45); /* Pack the command. */
1147 #if defined V_PRINT_SEND_COMMANDS
1148         printf("send: verse_send_o_anim_run(node_id = %u link_id = %u time_s = %u time_f = %u dimensions = %u pos = %p speed = %p accel = %p scale = %p scale_speed = %p );\n", node_id, link_id, time_s, time_f, dimensions, pos, speed, accel, scale, scale_speed);
1149 #endif
1150         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
1151         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], link_id);
1152         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], time_s);
1153         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], time_f);
1154         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], dimensions);
1155         {
1156                 unsigned char mask = 0;
1157                 unsigned int cmd, i;
1158                 cmd = buffer_pos++;
1159                 if(dimensions > 4)
1160                         dimensions = 4;
1161                 for(i = 0; i < dimensions; i++)
1162                         buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], pos[i]);
1163                 if(speed != NULL)
1164                 {
1165                         mask |= 1;
1166                         for(i = 0; i < dimensions; i++)
1167                                 buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], speed[i]);
1168                 }
1169                 if(accel != NULL)
1170                 {
1171                         mask |= 2;
1172                         for(i = 0; i < dimensions; i++)
1173                                 buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], accel[i]);
1174                 }
1175                 if(scale != NULL)
1176                 {
1177                         mask |= 3;
1178                         for(i = 0; i < dimensions; i++)
1179                                 buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], scale[i]);
1180                 }
1181                 if(scale_speed != NULL)
1182                 {
1183                         mask |= 4;
1184                         for(i = 0; i < dimensions; i++)
1185                                 buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], scale_speed[i]);
1186                 }
1187                 vnp_raw_pack_uint8(&buf[cmd], mask);
1188         }
1189         if(node_id == (uint32) ~0u || link_id == (uint16) ~0u)
1190                 v_cmd_buf_set_unique_address_size(head, 7);
1191         else
1192                 v_cmd_buf_set_address_size(head, 7);
1193         v_cmd_buf_set_size(head, buffer_pos);
1194         v_noq_send_buf(v_con_get_network_queue(), head);
1195 }
1196
1197 unsigned int v_unpack_o_anim_run(const char *buf, size_t buffer_length)
1198 {
1199         unsigned int buffer_pos = 0;
1200         void (* func_o_anim_run)(void *user_data, VNodeID node_id, uint16 link_id, uint32 time_s, uint32 time_f, uint8 dimensions, const real64 *pos, const real64 *speed, const real64 *accel, const real64 *scale, const real64 *scale_speed);
1201         VNodeID node_id;
1202         uint16 link_id;
1203         uint32 time_s;
1204         uint32 time_f;
1205         uint8 dimensions;
1206         const real64 *pos;
1207         const real64 *speed;
1208         const real64 *accel;
1209         const real64 *scale;
1210         const real64 *scale_speed;
1211         
1212         func_o_anim_run = v_fs_get_user_func(45);
1213         if(buffer_length < 6)
1214                 return -1;
1215         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
1216         buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &link_id);
1217         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &time_s);
1218         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &time_f);
1219         buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &dimensions);
1220 #if defined V_PRINT_RECEIVE_COMMANDS
1221         printf("receive: verse_send_o_anim_run(node_id = %u link_id = %u time_s = %u time_f = %u dimensions = %u ); callback = %p\n", node_id, link_id, time_s, time_f, dimensions, v_fs_get_user_func(45));
1222 #endif
1223         {
1224                 double output[5][4];
1225                 unsigned int i, j;
1226                 char mask, pow = 1;
1227                 buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &mask);
1228                 if(dimensions > 4)
1229                         dimensions = 4;
1230                 for(j = 0; j < dimensions; j++)
1231                         buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &output[0][j]);
1232                 for(i = 1; i < 5; i++)
1233                 {
1234                         if((mask & pow) != 0)
1235                                 for(j = 0; j < dimensions; j++)
1236                                         buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &output[i][j]);
1237                         else
1238                                 for(j = 0; j < dimensions; j++)
1239                                         output[i][j] = 0;
1240                         pow *= 2;
1241                 }
1242                 if(func_o_anim_run != NULL)
1243                         func_o_anim_run(v_fs_get_user_data(45), node_id, link_id, time_s, time_f, dimensions, &output[0][0], &output[1][0], &output[2][0], &output[3][0], &output[4][0]);
1244                 return buffer_pos;
1245         }
1246
1247         if(func_o_anim_run != NULL)
1248                 func_o_anim_run(v_fs_get_user_data(45), node_id, link_id, time_s, time_f, dimensions, pos, speed, accel, scale, scale_speed);
1249
1250         return buffer_pos;
1251 }
1252
1253 void verse_send_o_hide(VNodeID node_id, uint8 hidden)
1254 {
1255         uint8 *buf;
1256         unsigned int buffer_pos = 0;
1257         VCMDBufHead *head;
1258         head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
1259         buf = ((VCMDBuffer10 *)head)->buf;
1260
1261         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 46); /* Pack the command. */
1262 #if defined V_PRINT_SEND_COMMANDS
1263         printf("send: verse_send_o_hide(node_id = %u hidden = %u );\n", node_id, hidden);
1264 #endif
1265         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
1266         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], hidden);
1267         if(node_id == (uint32) ~0u)
1268                 v_cmd_buf_set_unique_address_size(head, 5);
1269         else
1270                 v_cmd_buf_set_address_size(head, 5);
1271         v_cmd_buf_set_size(head, buffer_pos);
1272         v_noq_send_buf(v_con_get_network_queue(), head);
1273 }
1274
1275 unsigned int v_unpack_o_hide(const char *buf, size_t buffer_length)
1276 {
1277         unsigned int buffer_pos = 0;
1278         void (* func_o_hide)(void *user_data, VNodeID node_id, uint8 hidden);
1279         VNodeID node_id;
1280         uint8 hidden;
1281         
1282         func_o_hide = v_fs_get_user_func(46);
1283         if(buffer_length < 4)
1284                 return -1;
1285         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
1286         buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &hidden);
1287 #if defined V_PRINT_RECEIVE_COMMANDS
1288         printf("receive: verse_send_o_hide(node_id = %u hidden = %u ); callback = %p\n", node_id, hidden, v_fs_get_user_func(46));
1289 #endif
1290         if(func_o_hide != NULL)
1291                 func_o_hide(v_fs_get_user_data(46), node_id, hidden);
1292
1293         return buffer_pos;
1294 }
1295
1296 #endif
1297