comparison Renderer/Test/direction.cc @ 0:04e28d8d3c6f

first commit
author Daiki KINJYO <e085722@ie.u-ryukyu.ac.jp>
date Mon, 08 Nov 2010 01:23:25 +0900
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:04e28d8d3c6f
1 #include "SceneGraphRoot.h"
2 #include "direction.h"
3
4 static void
5 x_move(SceneGraphPtr node, void *sgroot_, int w, int h)
6 {
7 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
8 Pad *pad = sgroot->getController();
9
10 node->xyz[0] = w/2;
11 node->xyz[1] = h/2;
12
13 if (pad->circle.isPush() || pad->circle.isHold()) {
14 node->angle[1] += 10.0f;
15 if (node->angle[1] > 360.0f) node->angle[1] = 0.0f;
16 }
17
18 if (pad->triangle.isPush() || pad->triangle.isHold()) {
19 node->angle[0] += 10.0f;
20 if (node->angle[0] > 360.0f) node->angle[0] = 0.0f;
21 }
22
23 if (pad->start.isPush()) {
24 node->angle[0] = 0.0f;
25 node->angle[1] = 90.0f;
26 }
27
28 }
29
30 static void
31 y_move(SceneGraphPtr node, void *sgroot_, int w, int h)
32 {
33 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
34 Pad *pad = sgroot->getController();
35
36 node->xyz[0] = w/2;
37 node->xyz[1] = h/2;
38
39 if (pad->cross.isPush() || pad->cross.isHold()) {
40 node->angle[2] += 10.0f;
41 }
42
43 if (pad->square.isPush() || pad->square.isHold()) {
44 node->angle[0] += 10.0f;
45 }
46
47 if (pad->start.isPush()) {
48 node->angle[0] = 90.0f;
49 node->angle[1] = 0.0f;
50 }
51
52 }
53
54 static void
55 z_move(SceneGraphPtr node, void *sgroot_, int w, int h)
56 {
57 node->xyz[0] = w/2;
58 node->xyz[1] = h/2;
59 }
60
61 static void
62 dir_collision(SceneGraphPtr node, void *sgroot_, int w, int h, SceneGraphPtr tree)
63 {
64 }
65
66 MainLoopPtr
67 direction::init(Viewer *sgroot, int screen_w, int screen_h)
68 {
69 SceneGraphPtr dx;
70 SceneGraphPtr dy;
71 SceneGraphPtr dz;
72 SceneGraphPtr back;
73
74 sgroot->createFromXMLfile("xml_file/direction.xml");
75
76 dx = sgroot->createSceneGraph("Dirx");
77 dy = sgroot->createSceneGraph("Diry");
78 dz = sgroot->createSceneGraph("Dirz");
79 back = sgroot->createSceneGraph();
80
81 back->addChild(dx);
82 back->addChild(dy);
83 back->addChild(dz);
84
85 dx->set_move_collision(x_move, dir_collision);
86 dx->angle[1] = 90.0f;
87 dy->set_move_collision(y_move, dir_collision);
88 dy->angle[0] = 90.0f;
89 dz->set_move_collision(z_move, dir_collision);
90
91 back->angle[0] = 30.0f;
92 back->angle[1] = -30.0f;
93
94 sgroot->setSceneData(back);
95 return sgroot;
96 }
97
98 extern Application *
99 application() {
100 return new direction();
101 }
102
103 const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n";
104
105 extern int init(TaskManager *manager, int argc, char *argv[]);
106 extern void task_initialize();
107 static void TMend(TaskManager *manager);
108
109 int
110 TMmain(TaskManager *manager, int argc, char *argv[])
111 {
112 task_initialize();
113 manager->set_TMend(TMend);
114 return init(manager, argc, argv);
115
116 }
117
118 void
119 TMend(TaskManager *manager)
120 {
121 printf("test_nogl end\n");
122 }
123