Mercurial > hg > Members > kono > Cerium
annotate Renderer/Test/create_task.cc @ 759:bb47827c04c1
fix create_task
author | hiroki@henri.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Mon, 01 Feb 2010 17:08:36 +0900 |
parents | e615e552efa5 |
children | 24a37fe8419a |
rev | line source |
---|---|
756
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
1 #include <math.h> |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
2 #include <stdlib.h> |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
3 #include "SceneGraphRoot.h" |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
4 #include "MainLoop.h" |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
5 #include "create_task.h" |
757
5238f3e854fc
Test/create_task , create SPE task from application.
hiroki
parents:
756
diff
changeset
|
6 #include "types.h" |
756
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
7 #include "Func.h" |
759 | 8 #include "SgChange.h" |
757
5238f3e854fc
Test/create_task , create SPE task from application.
hiroki
parents:
756
diff
changeset
|
9 |
5238f3e854fc
Test/create_task , create SPE task from application.
hiroki
parents:
756
diff
changeset
|
10 Property *property, *update_property; |
5238f3e854fc
Test/create_task , create SPE task from application.
hiroki
parents:
756
diff
changeset
|
11 |
756
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
12 // prototype |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
13 static void move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h); |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
14 static void collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree); |
758 | 15 static void createSceneGraphFromProperty(SchedTask *s, void *sgroot, void *arg1); |
756
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
16 |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
17 static void |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
18 move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
19 { |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
20 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
21 TaskManager *manager = sgroot->tmanager; |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
22 HTaskPtr property_task = manager->create_task(PropertyTask); |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
23 |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
24 property_task->add_inData(property, sizeof(Property)); |
757
5238f3e854fc
Test/create_task , create SPE task from application.
hiroki
parents:
756
diff
changeset
|
25 property_task->add_outData(update_property, sizeof(Property)); |
756
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
26 property_task->set_cpu(SPE_ANY); |
758 | 27 |
759 | 28 property_task->set_post(createSceneGraphFromProperty, (void *)sgroot, 0); |
757
5238f3e854fc
Test/create_task , create SPE task from application.
hiroki
parents:
756
diff
changeset
|
29 property_task->spawn(); |
756
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
30 } |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
31 |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
32 static void |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
33 collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
34 SceneGraphPtr tree) |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
35 { |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
36 } |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
37 |
758 | 38 static void |
39 createSceneGraphFromProperty(SchedTask *s, void *sgroot_, void *arg1) | |
40 { | |
41 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; | |
42 SceneGraphPtr node; | |
43 | |
44 node = sgroot->createSceneGraph(update_property->name); | |
759 | 45 //node = sgroot->createSceneGraph("Ball"); |
758 | 46 node->set_move_collision(move, collision); |
47 node->xyz[0] = update_property->xyz[0]; | |
48 node->xyz[1] = update_property->xyz[1]; | |
49 node->xyz[2] = update_property->xyz[2]; | |
50 sgroot->setSceneData(node); | |
51 | |
52 Property *tmp = property; | |
53 property = update_property; | |
54 update_property = tmp; | |
55 | |
56 } | |
57 | |
58 static void | |
59 set_property(Property *p, SceneGraphPtr sg) | |
60 { | |
61 p->xyz[0] = sg->xyz[0]; | |
62 p->xyz[1] = sg->xyz[1]; | |
63 p->xyz[2] = sg->xyz[2]; | |
64 p->name = sg->name; | |
65 } | |
66 | |
756
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
67 MainLoopPtr |
759 | 68 create_task::init(Viewer *viewer, int screen_w, int screen_h) |
756
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
69 { |
759 | 70 // SgChange を使うための2行 |
71 SgChange *sgroot = new SgChange(viewer); | |
72 sgroot->run_init(); | |
73 | |
758 | 74 property = (Property *)sgroot->manager->allocate(sizeof(Property)); |
75 update_property = (Property *)sgroot->manager->allocate(sizeof(Property)); | |
76 | |
756
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
77 SceneGraphPtr ball; |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
78 |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
79 sgroot->createFromXMLfile("xml_file/Ball.xml"); |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
80 |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
81 ball = sgroot->createSceneGraph("Ball"); |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
82 ball->set_move_collision(move, collision); |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
83 |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
84 ball->xyz[0] = screen_w/2; |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
85 ball->xyz[1] = screen_h/2; |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
86 ball->xyz[2] = 30.0f; |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
87 |
758 | 88 set_property(property, ball); |
89 | |
756
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
90 sgroot->setSceneData(ball); |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
91 |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
92 return sgroot; |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
93 } |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
94 |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
95 extern Application * |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
96 application() { |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
97 return new create_task(); |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
98 } |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
99 |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
100 const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n"; |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
101 |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
102 extern int init(TaskManager *manager, int argc, char *argv[]); |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
103 extern void task_initialize(); |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
104 static void TMend(TaskManager *manager); |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
105 |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
106 int |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
107 TMmain(TaskManager *manager, int argc, char *argv[]) |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
108 { |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
109 task_initialize(); |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
110 manager->set_TMend(TMend); |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
111 return init(manager, argc, argv); |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
112 |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
113 } |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
114 |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
115 void |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
116 TMend(TaskManager *manager) |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
117 { |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
118 printf("test_nogl end\n"); |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
119 } |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
120 |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
121 /* end */ |