annotate Renderer/Engine/viewer.h @ 848:a033d464c812 draft

addChild fix
author tkaito
date Sun, 06 Jun 2010 03:31:52 +0900
parents 66497087393d
children 63a08f3a468a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
283
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
1 #ifndef INCLUDED_VIEWER
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
2 #define INCLUDED_VIEWER
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
3
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
4 #include <SDL.h>
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
5
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 283
diff changeset
6 #include "viewer_types.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 283
diff changeset
7 #include "TaskManager.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 283
diff changeset
8 #include "KeyStat.h"
542
109a33b72b10 continue...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 541
diff changeset
9 #include "MainLoop.h"
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 283
diff changeset
10 #include "Application.h"
558
00428ba0ba03 boss1_action
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 544
diff changeset
11 #include "SceneGraphRoot.h"
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 671
diff changeset
12 #include "ViewerDevice.h"
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 283
diff changeset
13
562
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
14 class SceneGraphRoot;
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
15
543
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 542
diff changeset
16 class Application;
283
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
17
543
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 542
diff changeset
18 class Viewer : public MainLoop {
542
109a33b72b10 continue...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 541
diff changeset
19
283
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
20 public:
542
109a33b72b10 continue...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 541
diff changeset
21
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 671
diff changeset
22 Viewer(TaskManager *manager, ViewerDevice *dev, int bpp, int width, int height, int spenum);
283
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
23
542
109a33b72b10 continue...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 541
diff changeset
24 virtual ~Viewer() {}
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 671
diff changeset
25 BASE_NEW_DELETE(Viewer);
283
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
26
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 671
diff changeset
27 ViewerDevice *dev;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 283
diff changeset
28 Application *app;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 283
diff changeset
29
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 283
diff changeset
30 TaskManager *manager;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 283
diff changeset
31 key_stat *keyPtr;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 283
diff changeset
32 HTaskPtr draw_dummy;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 283
diff changeset
33
283
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
34 /* screen info */
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
35 int bpp;
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
36
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 671
diff changeset
37 int rgb_size[3];
283
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
38 int spe_num;
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 671
diff changeset
39 int width;
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 671
diff changeset
40 int height;
283
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
41
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 671
diff changeset
42 float *light_xyz;
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 671
diff changeset
43 float *light_xyz_stock;
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
44 int *light_switch;
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
45 int *light_switch_stock;
793
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
46 int *light_sysswitch;
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
47 int light_sysswitch_stock;
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 671
diff changeset
48
283
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
49 Uint32 video_flags;
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
50 Uint32 *pixels;
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
51
558
00428ba0ba03 boss1_action
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 544
diff changeset
52 SceneGraphRoot *sgroot;
00428ba0ba03 boss1_action
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 544
diff changeset
53
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 671
diff changeset
54 //Uint32 *video_init(TaskManager *manager, int bpp, int width, int height);
283
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
55 void init();
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
56
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
57 int get_ticks();
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
58 bool quit_check();
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
59 void quit();
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 671
diff changeset
60 HTaskPtr initLoop();
283
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
61
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 671
diff changeset
62 void clean_pixels() {}
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 671
diff changeset
63
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 671
diff changeset
64 void run_init(TaskManager *manager, Application *app);
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 671
diff changeset
65 void run_loop(HTaskPtr task_next);
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 671
diff changeset
66 void run_draw(HTaskPtr task_next);
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 671
diff changeset
67 void run_finish();
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 671
diff changeset
68 void run_move(HTaskPtr task_next);
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 671
diff changeset
69 void run_collision();
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 671
diff changeset
70 void rendering(HTaskPtr task_next);
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 671
diff changeset
71 void common_draw(HTaskPtr task_next);
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 671
diff changeset
72 void common_rendering(HTaskPtr task_next, SceneGraphRoot *sgroot);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 283
diff changeset
73
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 671
diff changeset
74 void spe_rendering(HTaskPtr task_next);
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 671
diff changeset
75 void spe_draw(HTaskPtr task_next);
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 671
diff changeset
76 // void exchange_sgroot(TaskManager *manager);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 283
diff changeset
77
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
78 HTaskPtr update_task_create(void *data, int size,
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
79 int load_id, int spe_id, HTaskPtr wait);
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
80
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 283
diff changeset
81 void getKey();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 283
diff changeset
82 void get_send_controll();
543
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 542
diff changeset
83
558
00428ba0ba03 boss1_action
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 544
diff changeset
84 // void createFromXMLfile(const char *file);
00428ba0ba03 boss1_action
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 544
diff changeset
85 // SceneGraph *createSceneGraph(int id);
00428ba0ba03 boss1_action
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 544
diff changeset
86 // SceneGraph *createSceneGraph();
00428ba0ba03 boss1_action
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 544
diff changeset
87 // void setSceneData(SceneGraph *g);
544
dc59679d9a36 ball_bound worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 543
diff changeset
88 void mainLoop();
543
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 542
diff changeset
89
671
7761ebf9c62a fix several Renderer/Test with (void*)sgroot.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 589
diff changeset
90 void createFromXMLmemory(SceneGraph * node, char *data, int len)
7761ebf9c62a fix several Renderer/Test with (void*)sgroot.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 589
diff changeset
91 {
7761ebf9c62a fix several Renderer/Test with (void*)sgroot.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 589
diff changeset
92 sgroot->createFromXMLmemory(manager, node, data, len);
7761ebf9c62a fix several Renderer/Test with (void*)sgroot.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 589
diff changeset
93 }
7761ebf9c62a fix several Renderer/Test with (void*)sgroot.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 589
diff changeset
94
558
00428ba0ba03 boss1_action
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 544
diff changeset
95 void createFromXMLfile(const char *file)
00428ba0ba03 boss1_action
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 544
diff changeset
96 {
00428ba0ba03 boss1_action
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 544
diff changeset
97 sgroot->createFromXMLfile(manager, file);
00428ba0ba03 boss1_action
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 544
diff changeset
98 }
00428ba0ba03 boss1_action
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 544
diff changeset
99
00428ba0ba03 boss1_action
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 544
diff changeset
100 SceneGraph * createSceneGraph(int id)
00428ba0ba03 boss1_action
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 544
diff changeset
101 {
00428ba0ba03 boss1_action
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 544
diff changeset
102 return sgroot->createSceneGraph(id);
00428ba0ba03 boss1_action
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 544
diff changeset
103 }
00428ba0ba03 boss1_action
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 544
diff changeset
104
562
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
105 SceneGraph * createSceneGraph(const char *id)
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
106 {
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
107 return sgroot->createSceneGraph(id);
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
108 }
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
109
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
110 int getSgid(const char *id)
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
111 {
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
112 return sgroot->getSgid(id);
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
113 }
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
114
558
00428ba0ba03 boss1_action
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 544
diff changeset
115 SceneGraph * createSceneGraph()
00428ba0ba03 boss1_action
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 544
diff changeset
116 {
00428ba0ba03 boss1_action
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 544
diff changeset
117 return sgroot->createSceneGraph();
00428ba0ba03 boss1_action
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 544
diff changeset
118 }
00428ba0ba03 boss1_action
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 544
diff changeset
119
00428ba0ba03 boss1_action
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 544
diff changeset
120 void setSceneData(SceneGraph *g)
00428ba0ba03 boss1_action
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 544
diff changeset
121 {
00428ba0ba03 boss1_action
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 544
diff changeset
122 sgroot->setSceneData(g);
00428ba0ba03 boss1_action
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 544
diff changeset
123 }
00428ba0ba03 boss1_action
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 544
diff changeset
124
589
e112f38275d5 add viwer.cc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 562
diff changeset
125 int getLast()
e112f38275d5 add viwer.cc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 562
diff changeset
126 {
e112f38275d5 add viwer.cc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 562
diff changeset
127 return sgroot->getLast();
e112f38275d5 add viwer.cc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 562
diff changeset
128 }
e112f38275d5 add viwer.cc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 562
diff changeset
129
793
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
130 SceneGraphPtr getLight(int id)
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
131 {
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
132 return sgroot->getLight(id);
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
133 }
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
134
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
135 void OnLightSwitch(int id)
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
136 {
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
137 sgroot->OnLightSwitch(id);
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
138 }
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
139
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
140 void OffLightSwitch(int id)
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
141 {
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
142 sgroot->OffLightSwitch(id);
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
143 }
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
144
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
145 void OnLightSysSwitch()
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
146 {
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
147 sgroot->OnLightSysSwitch();
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
148 }
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
149
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
150 void OffLightSysSwitch()
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
151 {
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
152 sgroot->OffLightSysSwitch();
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
153 }
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
154
283
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
155 };
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
156
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 283
diff changeset
157 #define default_sdl_flag SDL_INIT_TIMER | SDL_INIT_JOYSTICK
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 283
diff changeset
158
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 283
diff changeset
159
283
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
160 #endif
15bfacccde99 fix test_render
e065746@localhost.localdomain
parents:
diff changeset
161