annotate TaskManager/Test/test_render/Application/dynamic_create.cc @ 520:8d86242337ba draft

SGList isn't used
author tkaito@henri.cr.ie.u-ryukyu.ac.jp
date Wed, 21 Oct 2009 19:56:00 +0900
parents d2772feb34e3
children 74a8b7c97964
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
515
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
1 #include <stdlib.h>
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
2 #include "SceneGraphRoot.h"
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
3
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
4 static void
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
5 earth_collision(SceneGraphPtr node, int screen_w, int screen_h,
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
6 SceneGraphPtr tree)
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
7 {
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
8 }
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
9
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
10 static void
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
11 moon_collision(SceneGraphPtr node, int screen_w, int screen_h,
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
12 SceneGraphPtr tree)
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
13 {
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
14 }
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
15
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
16 static void
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
17 moon_move(SceneGraphPtr node, int screen_w, int screen_h)
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
18 {
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
19 node->angle[0] += 3.0f;
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
20 node->xyz[1] += 1.0f;
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
21 }
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
22
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
23
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
24 static void
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
25 earth_move(SceneGraphPtr node, int screen_w, int screen_h)
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
26 {
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
27 node->angle[1] += 1.0f;
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
28 if (node->angle[1] > 360.0f) {
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
29 node->angle[1] = 0.0f;
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
30 }
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
31
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
32 node->xyz[0] += node->stack_xyz[0];
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
33 if ((int)node->xyz[0] > screen_w || (int)node->xyz[0] < 0) {
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
34 node->stack_xyz[0] = -node->stack_xyz[0];
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
35 }
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
36
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
37 node->xyz[1] += node->stack_xyz[1];
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
38 if ((int)node->xyz[1] > screen_h || (int)node->xyz[1] < 0) {
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
39 node->stack_xyz[1] = -node->stack_xyz[1];
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
40 }
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
41
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
42 Pad *pad = sgroot->getController();
520
8d86242337ba SGList isn't used
tkaito@henri.cr.ie.u-ryukyu.ac.jp
parents: 515
diff changeset
43 if (pad->circle.isPush()) {
515
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
44 SceneGraphPtr earth;
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
45 sgroot->createFromXMLmemory(sgroot->tmanager, "xml_file/universe.xml");
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
46 earth = sgroot->createSceneGraph("Earth");
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
47 earth->set_move_collision(moon_move, moon_collision);
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
48 node->addChild(earth);
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
49 }
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
50 }
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
51
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
52 void
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
53 dynamic_init(TaskManager *manager)
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
54 {
520
8d86242337ba SGList isn't used
tkaito@henri.cr.ie.u-ryukyu.ac.jp
parents: 515
diff changeset
55 //SceneGraphPtr earth;
515
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
56 sgroot->tmanager = manager;
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
57
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
58 #if 0
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
59 // テスト用に mmap したデータを第2引数に渡す
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
60 sgroot->createFromXMLmemory(manager, "xml_file/universe.xml");
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
61
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
62 // sglist に登録されている name から sgid を引き、sg_src[sgid] からコピーして返す
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
63 earth = sgroot->createSceneGraph("Earth");
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
64 #else
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
65 SceneGraphPtr parent;
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
66 parent = sgroot->createSceneGraph();
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
67 parent->set_move_collision(earth_move, earth_collision);
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
68 #endif
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
69
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
70 // SceneGraphRoot に、使用する SceneGraph を設定する
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
71 // このとき、ユーザーが記述した SceneGraph の root を渡す。
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
72 sgroot->setSceneData(parent);
d2772feb34e3 add Application/dynamic_create.cc
aaa
parents:
diff changeset
73 }