annotate TaskManager/Test/test_render/universe.cpp @ 383:b3fb0013e6b2 draft

fix header, MemHash in kernel
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 06 Aug 2009 12:04:55 +0900
parents 5bb12a76a335
children ce86b0186a4a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
157
gongo@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
1 #include <stdlib.h>
195
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 165
diff changeset
2 #include "SceneGraphRoot.h"
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 165
diff changeset
3 #include "SGList.h"
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 165
diff changeset
4
157
gongo@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
5 static void
199
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 198
diff changeset
6 earth_collision(SceneGraphPtr node, int screen_w, int screen_h,
157
gongo@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
7 SceneGraphPtr tree)
gongo@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
8 {
gongo@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
9 }
gongo@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
10
gongo@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
11 static void
195
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 165
diff changeset
12 moon_collision(SceneGraphPtr node, int screen_w, int screen_h,
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 165
diff changeset
13 SceneGraphPtr tree)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 165
diff changeset
14 {
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 165
diff changeset
15 }
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 165
diff changeset
16
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 165
diff changeset
17 static void
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 165
diff changeset
18 moon_move(SceneGraphPtr node, int screen_w, int screen_h)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 165
diff changeset
19 {
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 165
diff changeset
20 node->angle[0] += 3.0f;
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 165
diff changeset
21 }
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 165
diff changeset
22
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 165
diff changeset
23
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 165
diff changeset
24 static void
222
gongo@localhost.localdomain
parents: 213
diff changeset
25 earth_move(SceneGraphPtr node, int screen_w, int screen_h)
157
gongo@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
26 {
gongo@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
27 node->angle[1] += 1.0f;
gongo@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
28 if (node->angle[1] > 360.0f) {
gongo@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
29 node->angle[1] = 0.0f;
gongo@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
30 }
gongo@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
31
gongo@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
32 node->xyz[0] += node->stack_xyz[0];
gongo@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
33 if ((int)node->xyz[0] > screen_w || (int)node->xyz[0] < 0) {
gongo@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
34 node->stack_xyz[0] = -node->stack_xyz[0];
gongo@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
35 }
gongo@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
36
gongo@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
37 node->xyz[1] += node->stack_xyz[1];
gongo@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
38 if ((int)node->xyz[1] > screen_h || (int)node->xyz[1] < 0) {
gongo@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
39 node->stack_xyz[1] = -node->stack_xyz[1];
gongo@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
40 }
gongo@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
41 }
gongo@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
42
195
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 165
diff changeset
43 void
198
b832e6cff83e rename snake_bg to panel
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
44 universe_init(void)
157
gongo@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
45 {
195
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 165
diff changeset
46 SceneGraphPtr earth;
228
5bb12a76a335 remove SceneGraph::data, add SceneGraph::coord_xyz, coord_tex, normal
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 222
diff changeset
47 SceneGraphPtr moon;
157
gongo@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
48
195
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 165
diff changeset
49 sgroot->createFromXMLfile("xml_file/universe.xml");
157
gongo@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
50
195
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 165
diff changeset
51 // SGList.h にある SceneGraph ID から SceneGraph を生成する
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 165
diff changeset
52 earth = sgroot->createSceneGraph(Earth);
157
gongo@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
53
195
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 165
diff changeset
54 // SceneGraph の move と collision を設定
222
gongo@localhost.localdomain
parents: 213
diff changeset
55 earth->set_move_collision(earth_move, earth_collision);
195
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 165
diff changeset
56 earth->stack_xyz[0] = 3.0f;
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 165
diff changeset
57 earth->stack_xyz[1] = 3.0f;
228
5bb12a76a335 remove SceneGraph::data, add SceneGraph::coord_xyz, coord_tex, normal
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 222
diff changeset
58
5bb12a76a335 remove SceneGraph::data, add SceneGraph::coord_xyz, coord_tex, normal
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 222
diff changeset
59 moon = sgroot->createSceneGraph(Moon);
5bb12a76a335 remove SceneGraph::data, add SceneGraph::coord_xyz, coord_tex, normal
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 222
diff changeset
60 moon->set_move_collision(moon_move, moon_collision);
222
gongo@localhost.localdomain
parents: 213
diff changeset
61
gongo@localhost.localdomain
parents: 213
diff changeset
62 // SceneGraph 同士の親子関係を設定 (今回は 親 earth、子 moon)
228
5bb12a76a335 remove SceneGraph::data, add SceneGraph::coord_xyz, coord_tex, normal
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 222
diff changeset
63 earth->addChild(moon);
195
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 165
diff changeset
64
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 165
diff changeset
65 // SceneGraphRoot に、使用する SceneGraph を設定する
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 165
diff changeset
66 // このとき、ユーザーが記述した SceneGraph の root を渡す。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 165
diff changeset
67 sgroot->setSceneData(earth);
157
gongo@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
68 }