annotate Renderer/Test/dynamic_create.cc @ 843:de64695a7f02 draft

cleanup unused variables and fix warning.
author kazz <kazz@cr.ie.u-ryukyu.ac.jp>
date Wed, 02 Jun 2010 02:03:40 +0900
parents 8d702fc5d77a
children ba9e10f636eb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
566
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #include <stdlib.h>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #include <stdio.h>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 #include <string.h>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 #include <fcntl.h>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 #include <sys/types.h>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 #include <sys/mman.h>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 #include <sys/stat.h>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 #include <unistd.h>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 #include <arpa/inet.h>
610
d38d9896dfa4 change htonl to xdr_float (checked working on mac)
kazz@kazzone.st.ie.u-ryukyu.ac.jp
parents: 601
diff changeset
10 #include <rpc/types.h>
d38d9896dfa4 change htonl to xdr_float (checked working on mac)
kazz@kazzone.st.ie.u-ryukyu.ac.jp
parents: 601
diff changeset
11 #include <rpc/xdr.h>
566
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 #include "SceneGraphRoot.h"
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 #include "lindaapi.h"
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 #include "dynamic_create.h"
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 #define PORT 10000
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 #define SERIAL_REGIST_TUPLE_NO 1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19
610
d38d9896dfa4 change htonl to xdr_float (checked working on mac)
kazz@kazzone.st.ie.u-ryukyu.ac.jp
parents: 601
diff changeset
20 #define RECV_DATA_SIZE sizeof(float) * 6
d38d9896dfa4 change htonl to xdr_float (checked working on mac)
kazz@kazzone.st.ie.u-ryukyu.ac.jp
parents: 601
diff changeset
21
566
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 typedef struct client_ {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 int id;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 SceneGraphPtr sgp;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 struct client_ *next;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 } client_t;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 typedef struct {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 int tid;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 int sid;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 int read_id;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 SceneGraphPtr node;
671
7761ebf9c62a fix several Renderer/Test with (void*)sgroot.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 653
diff changeset
33 SceneGraphRoot *sgroot;
566
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 TaskManager *manager;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 client_t *clist;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 } callback_arg;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 void
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 client_list_init(TaskManager* manager, client_t *clist)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 clist->id = -1;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 clist->next = clist;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 void
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 client_list_update(TaskManager *manager, client_t *clist, int id, SceneGraphPtr sgp)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 void
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 client_list_delete(TaskManager *manager, client_t *clist, int id)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 client_t *c, *prev;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 for (c = clist->next, prev = clist; c->next != clist; c = c->next) {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 if (c->id == id) {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 prev->next = c->next;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 return;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 prev = clist;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 if (c->id == id) {
591
65e52fd2c2e2 send linda not work...
kazz@kazzone.st.ie.u-ryukyu.ac.jp
parents: 587
diff changeset
63 prev->next = c->next;
65e52fd2c2e2 send linda not work...
kazz@kazzone.st.ie.u-ryukyu.ac.jp
parents: 587
diff changeset
64 return;
566
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
67
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
68
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 static void
653
7a311860a76e remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 642
diff changeset
70 earth_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
566
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 SceneGraphPtr tree)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
74
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 static void
653
7a311860a76e remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 642
diff changeset
76 moon_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
566
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 SceneGraphPtr tree)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
80
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 static void
841
8d702fc5d77a dynamic loading demo bug fix
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 729
diff changeset
82 set_position(SceneGraphPtr node, unsigned char *reply) {
8d702fc5d77a dynamic loading demo bug fix
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 729
diff changeset
83 char *data = (char *)(reply + LINDA_HEADER_SIZE);
8d702fc5d77a dynamic loading demo bug fix
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 729
diff changeset
84 // XDRの準備
8d702fc5d77a dynamic loading demo bug fix
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 729
diff changeset
85 XDR xdrs;
8d702fc5d77a dynamic loading demo bug fix
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 729
diff changeset
86 xdrmem_create(&xdrs, data, RECV_DATA_SIZE, XDR_DECODE);
8d702fc5d77a dynamic loading demo bug fix
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 729
diff changeset
87 for (int i = 0; i < 3; i++) {
8d702fc5d77a dynamic loading demo bug fix
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 729
diff changeset
88 xdr_float(&xdrs, &node->xyz[i]);
8d702fc5d77a dynamic loading demo bug fix
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 729
diff changeset
89 }
8d702fc5d77a dynamic loading demo bug fix
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 729
diff changeset
90 }
8d702fc5d77a dynamic loading demo bug fix
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 729
diff changeset
91
8d702fc5d77a dynamic loading demo bug fix
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 729
diff changeset
92 static void
653
7a311860a76e remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 642
diff changeset
93 moon_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
566
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 {
653
7a311860a76e remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 642
diff changeset
95 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
591
65e52fd2c2e2 send linda not work...
kazz@kazzone.st.ie.u-ryukyu.ac.jp
parents: 587
diff changeset
96 // LindaServerから座標データを取得してオブジェクトに反映させる。
843
de64695a7f02 cleanup unused variables and fix warning.
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 841
diff changeset
97 unsigned char *reply = psx_reply(node->seq);
de64695a7f02 cleanup unused variables and fix warning.
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 841
diff changeset
98 if (reply != NULL) {
de64695a7f02 cleanup unused variables and fix warning.
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 841
diff changeset
99 set_position(node, reply);
de64695a7f02 cleanup unused variables and fix warning.
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 841
diff changeset
100 free(reply);
de64695a7f02 cleanup unused variables and fix warning.
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 841
diff changeset
101 node->seq = psx_wait_rd(sgroot->tid, node->id * 10 + 1);
591
65e52fd2c2e2 send linda not work...
kazz@kazzone.st.ie.u-ryukyu.ac.jp
parents: 587
diff changeset
102 }
566
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
104
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 static void
671
7761ebf9c62a fix several Renderer/Test with (void*)sgroot.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 653
diff changeset
106 earth_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
566
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 {
575
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 574
diff changeset
108 // psx_sync_n(); in viewer::MainLoop
566
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
109 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
110
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 SceneGraphPtr
671
7761ebf9c62a fix several Renderer/Test with (void*)sgroot.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 653
diff changeset
112 create_sg(TaskManager *manager, SceneGraphRoot *sgroot, SceneGraphPtr parent, unsigned char *data,
653
7a311860a76e remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 642
diff changeset
113 int len, int serial_id)
566
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
114 {
580
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 579
diff changeset
115 SceneGraphPtr child = sgroot->createSceneGraph();
581
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 580
diff changeset
116 parent->addChild(child);
580
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 579
diff changeset
117 // 読み込んだオブジェクトは、すべて、child の child になる。
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 579
diff changeset
118 sgroot->createFromXMLmemory(sgroot->tmanager, child, (char *)data, len);
581
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 580
diff changeset
119 child->set_move_collision(moon_move, moon_collision);
671
7761ebf9c62a fix several Renderer/Test with (void*)sgroot.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 653
diff changeset
120 child->id = serial_id;
843
de64695a7f02 cleanup unused variables and fix warning.
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 841
diff changeset
121 child->seq = psx_wait_rd(sgroot->tid, serial_id * 10 + 1);
593
75c78f8fba24 sending and moving of multi xml work (linda)
kazz@kazzone.st.ie.u-ryukyu.ac.jp
parents: 592
diff changeset
122
581
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 580
diff changeset
123 return child;
566
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
125
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
126
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 static void
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
128 callback_get_xml(unsigned char *xml_tuple, void *arg) {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
129 int xml_len = psx_get_datalength(xml_tuple);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 callback_arg *carg = (callback_arg *)arg;
591
65e52fd2c2e2 send linda not work...
kazz@kazzone.st.ie.u-ryukyu.ac.jp
parents: 587
diff changeset
131 unsigned char *xml_data = xml_tuple + LINDA_HEADER_SIZE;
566
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 SceneGraphPtr sgp;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 // ここで create
671
7761ebf9c62a fix several Renderer/Test with (void*)sgroot.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 653
diff changeset
134 sgp = create_sg(carg->manager, carg->sgroot, carg->node, xml_data, xml_len, carg->sid);
581
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 580
diff changeset
135 printf("%s size %d loaded\n", sgp->children->name, xml_len);
566
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 client_list_update(carg->manager, carg->clist, carg->sid, sgp);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
137 free(arg);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
138 free(xml_tuple);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
139 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
140
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
141 static void
591
65e52fd2c2e2 send linda not work...
kazz@kazzone.st.ie.u-ryukyu.ac.jp
parents: 587
diff changeset
142 callbacker(unsigned char *taple, void *arg) {
566
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 int serial_id, xml_id;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
144
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 unsigned char *data;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 callback_arg *carg = (callback_arg *)arg;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
147
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 // 最初の4byteデータは使わない
601
50c877027e0f linda work on mac osx
kazz@e065701.local
parents: 600
diff changeset
149 data = taple + LINDA_HEADER_SIZE;
566
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
150 // clientのSerialIDを取得
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 serial_id = ntohl(*(int *)data);
610
d38d9896dfa4 change htonl to xdr_float (checked working on mac)
kazz@kazzone.st.ie.u-ryukyu.ac.jp
parents: 601
diff changeset
152 printf("serial id = %d\n", serial_id); // タプルを解放
566
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
153
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 // xml fileを取得する もうすでにxml fileが送信済みである事を期待
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 // つまり、送信者がserial_idを送る前にxml fileを送信していなくてはならない
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 xml_id = serial_id * 10;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 callback_arg *copy_arg = (callback_arg *)carg->manager->allocate(sizeof(callback_arg));
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 *copy_arg = *carg;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
159 copy_arg->sid = serial_id;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
160 psx_callback_in(carg->tid, xml_id, callback_get_xml, (void *)copy_arg);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
161
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
162 /* dataは'\0'で終わっている事を期待 (writerで保証する) */
591
65e52fd2c2e2 send linda not work...
kazz@kazzone.st.ie.u-ryukyu.ac.jp
parents: 587
diff changeset
163 free(taple);
671
7761ebf9c62a fix several Renderer/Test with (void*)sgroot.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 653
diff changeset
164
7761ebf9c62a fix several Renderer/Test with (void*)sgroot.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 653
diff changeset
165 // arg は使い回すらしい。
574
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 566
diff changeset
166 psx_callback_in(carg->tid, carg->read_id, callbacker, arg);
566
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
167 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
168
843
de64695a7f02 cleanup unused variables and fix warning.
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 841
diff changeset
169 static const char *linda = "localhost";
577
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
170
671
7761ebf9c62a fix several Renderer/Test with (void*)sgroot.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 653
diff changeset
171 static void
7761ebf9c62a fix several Renderer/Test with (void*)sgroot.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 653
diff changeset
172 linda_init(TaskManager *manager, SceneGraphRoot *sgroot, client_t *clist, SceneGraphPtr node)
566
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
173 {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
174 init_linda();
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
175 callback_arg *carg = (callback_arg *)manager->allocate(sizeof(callback_arg));
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
176
579
root@localhost.localdomain
parents: 577
diff changeset
177 carg->tid = open_linda_java(linda, PORT);
671
7761ebf9c62a fix several Renderer/Test with (void*)sgroot.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 653
diff changeset
178 carg->sgroot = sgroot;
7761ebf9c62a fix several Renderer/Test with (void*)sgroot.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 653
diff changeset
179 carg->sgroot->tid = carg->tid;
566
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
180 carg->read_id = SERIAL_REGIST_TUPLE_NO;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
181 carg->node = node;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
182 carg->manager = manager;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
183 carg->clist = clist;
574
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 566
diff changeset
184 psx_callback_in(carg->tid, carg->read_id, callbacker, carg);
566
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
185 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
186
593
75c78f8fba24 sending and moving of multi xml work (linda)
kazz@kazzone.st.ie.u-ryukyu.ac.jp
parents: 592
diff changeset
187 MainLoopPtr
566
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
188 dynamic_create::init(Viewer *sgroot, int screen_w, int screen_h)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
189 {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
190 client_t *clist;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
191 clist = (client_t *)sgroot->manager->allocate(sizeof(client_t));
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
192
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
193 client_list_init(sgroot->manager, clist);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
194
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
195 SceneGraphPtr parent;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
196 parent = sgroot->createSceneGraph();
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
197 parent->set_move_collision(earth_move, earth_collision);
671
7761ebf9c62a fix several Renderer/Test with (void*)sgroot.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 653
diff changeset
198 linda_init(sgroot->manager, sgroot->sgroot, clist, parent);
566
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
199
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
200 // SceneGraphRoot に、使用する SceneGraph を設定する
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
201 // このとき、ユーザーが記述した SceneGraph の root を渡す。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
202 sgroot->setSceneData(parent);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
203 return sgroot;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
204 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
205
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
206 extern Application *
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
207 application() {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
208 return new dynamic_create();
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
209 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
210
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
211 const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n";
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
212
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
213 extern int init(TaskManager *manager, int argc, char *argv[]);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
214 extern void task_initialize();
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
215 static void TMend(TaskManager *manager);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
216
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
217 int
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
218 TMmain(TaskManager *manager, int argc, char *argv[])
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
219 {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
220 task_initialize();
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
221 manager->set_TMend(TMend);
577
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
222
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
223 for(int i=0;i<argc;i++) {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
224 if (strcmp(argv[i],"-linda") == 0 && i+1<=argc) {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
225 linda = argv[i+1];
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
226 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
227 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
228
566
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
229 return init(manager, argc, argv);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
230 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
231
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
232 void
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
233 TMend(TaskManager *manager)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
234 {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
235 printf("test_nogl end\n");
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
236 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
237
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
238 /* end */