comparison Renderer/Test_/node.cc @ 4:b5b462ac9b3b

Cerium Blender ball_bound
author Daiki KINJYO <e085722@ie.u-ryukyu.ac.jp>
date Mon, 29 Nov 2010 16:42:42 +0900
parents
children
comparison
equal deleted inserted replaced
3:3f6fe22ac669 4:b5b462ac9b3b
1 #include <stdlib.h>
2 #include "SceneGraphRoot.h"
3 #include "SceneGraph.h"
4 #include "node.h"
5
6 static void
7 cube_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
8 SceneGraphPtr tree)
9 {
10 }
11
12 static void
13 cube_move2(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
14 {
15 node->angle[1] += 1.0f;
16 if (node->angle[1] > 360.0f) {
17 node->angle[1] = 0.0f;
18 }
19
20 node->xyz[0] += node->stack_xyz[0];
21 if ((int)node->xyz[0] > screen_w || (int)node->xyz[0] < 0) {
22 node->stack_xyz[0] = -node->stack_xyz[0];
23 }
24
25 node->xyz[1] += node->stack_xyz[1];
26 if ((int)node->xyz[1] > screen_h || (int)node->xyz[1] < 0) {
27 node->stack_xyz[1] = -node->stack_xyz[1];
28 }
29 }
30
31 static void
32 cube_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
33 {
34 node->angle[1] += 1.0f;
35 if (node->angle[1] > 360.0f) {
36 node->angle[1] = 0.0f;
37 }
38
39 node->xyz[0] += node->stack_xyz[0];
40 if ((int)node->xyz[0] > screen_w || (int)node->xyz[0] < 0) {
41 node->stack_xyz[0] = -node->stack_xyz[0];
42 }
43
44 node->xyz[1] += node->stack_xyz[1];
45 if ((int)node->xyz[1] > screen_h || (int)node->xyz[1] < 0) {
46
47 // 実は微妙に意味が無い
48 // そうじゃなくて、やっちゃいけないことです。
49 // srandom(random());
50
51 SceneGraphPtr p = node->clone();
52 p->position_init();
53 node->addBrother(p);
54 p->set_move_collision(cube_move2, cube_collision);
55 p->stack_xyz[0] = (float)(random() % 5);
56 p->stack_xyz[1] = (float)(random() % 5);
57 //p->xyz[0] = screen_w/2;
58 //p->xyz[1] = screen_h/2;
59 p->xyz[2] = node->xyz[2]+1000.0f;
60
61 node->stack_xyz[1] = -node->stack_xyz[1];
62 }
63 }
64
65 MainLoopPtr
66 node::init(Viewer *sgroot, int screen_w, int screen_h)
67 {
68 sgroot->createFromXMLfile( "xml_file/cube.xml");
69 SceneGraphPtr Cube = sgroot->createSceneGraph("Cube");
70 Cube->set_move_collision(cube_move, cube_collision);
71 Cube->stack_xyz[0] = 2.0f;
72 Cube->stack_xyz[1] = 2.0f;
73 return sgroot;
74 }
75
76 extern Application *
77 application() {
78 return new node();
79 }
80
81 const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n";
82
83 extern int init(TaskManager *manager, int argc, char *argv[]);
84 extern void task_initialize();
85 static void TMend(TaskManager *manager);
86
87 int
88 TMmain(TaskManager *manager, int argc, char *argv[])
89 {
90 task_initialize();
91 manager->set_TMend(TMend);
92 return init(manager, argc, argv);
93
94 }
95
96 void
97 TMend(TaskManager *manager)
98 {
99 printf("test_nogl end\n");
100 }
101
102 /* end */
103