Mercurial > hg > Game > Cerium
annotate Renderer/Engine/Camera.cc @ 2001:3e3cc12096f7 draft
dim_count and self management in multiple TaskList in a TaskArray
author | kkb |
---|---|
date | Fri, 02 May 2014 19:56:25 +0900 |
parents | ab9b7d21b32b |
children |
rev | line source |
---|---|
539 | 1 #include <math.h> |
2 #include "SceneGraphRoot.h" | |
3 #include "Camera.h" | |
1050 | 4 #include "matrix_calc.h" |
539 | 5 #include "Scheduler.h" |
6 #include "TaskManager.h" | |
7 | |
653
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
8 //static SceneGraphRoot *sgroot; |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
9 |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
10 #if 1 |
539 | 11 static void |
653
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
12 camera_move(SceneGraphPtr _node, void *sgroot_, int screen_w, int screen_h) |
539 | 13 { |
653
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
14 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; |
539 | 15 Pad *pad = sgroot->getController(); |
16 CameraPtr node = (CameraPtr)_node; | |
17 | |
18 #if 0 | |
19 if (pad->right.isHold()) { | |
20 node->xyz[0] += 10.0f; | |
21 } else if (pad->left.isHold()) { | |
22 node->xyz[0] -= 10.0f; | |
23 } | |
24 | |
25 if (pad->up.isPush() || pad->up.isHold()) { | |
26 node->xyz[1] -= 2.0f; | |
27 } else if (pad->down.isPush() || pad->down.isHold()) { | |
28 node->xyz[1] += 2.0f; | |
29 } | |
30 #endif | |
31 | |
32 /* | |
33 * ここに show_dma_wait 表示をいれようか | |
34 */ | |
35 | |
36 /* | |
37 if (pad->r1.isPush()) { | |
38 show_time(manager); | |
39 } | |
40 */ | |
41 | |
42 if (pad->r1.isPush() || pad->r1.isHold()) { | |
43 node->xyz[2] += 10.0f; | |
44 } else if (pad->l1.isPush() || pad->l1.isHold()) { | |
45 node->xyz[2] -= 10.0f; | |
46 } | |
47 | |
48 if (pad->r2.isHold()) { | |
49 if (node->zd[0] <= 1.0f) { | |
50 node->zd[0] += 0.02f; | |
51 } | |
52 if (node->zd[2] >= 0.0f) { | |
53 node->zd[2] -= 0.02f; | |
54 } | |
55 } else if (pad->l2.isHold()) { | |
56 if (node->zd[0] > -1.0f) { | |
57 node->zd[0] -= -0.02f; | |
58 } | |
59 if (node->zd[2] >= 0.0f) { | |
60 node->zd[2] -= 0.02f; | |
61 } | |
62 } else { | |
63 node->zd[0] = 0.0f; | |
64 node->zd[2] = 1.0f; | |
65 } | |
66 | |
67 } | |
653
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
68 #endif |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
69 |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
70 #if 0 |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
71 static void |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
72 Camera::camera_move(SceneGraphPtr _node, int screen_w, int screen_h) |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
73 { |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
74 Pad *pad = sgroot->getController(); |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
75 CameraPtr node = (CameraPtr)_node; |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
76 |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
77 if (pad->r1.isPush() || pad->r1.isHold()) { |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
78 node->xyz[2] += 10.0f; |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
79 } else if (pad->l1.isPush() || pad->l1.isHold()) { |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
80 node->xyz[2] -= 10.0f; |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
81 } |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
82 |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
83 if (pad->r2.isHold()) { |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
84 if (node->zd[0] <= 1.0f) { |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
85 node->zd[0] += 0.02f; |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
86 } |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
87 if (node->zd[2] >= 0.0f) { |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
88 node->zd[2] -= 0.02f; |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
89 } |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
90 } else if (pad->l2.isHold()) { |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
91 if (node->zd[0] > -1.0f) { |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
92 node->zd[0] -= -0.02f; |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
93 } |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
94 if (node->zd[2] >= 0.0f) { |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
95 node->zd[2] -= 0.02f; |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
96 } |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
97 } else { |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
98 node->zd[0] = 0.0f; |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
99 node->zd[2] = 1.0f; |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
100 } |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
101 |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
102 } |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
103 #endif |
539 | 104 |
105 static void | |
653
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
106 camera_collision(SceneGraphPtr node, void *sgroot_,int screen_w, int screen_h, |
539 | 107 SceneGraphPtr tree) |
108 { | |
109 } | |
110 | |
111 /** | |
112 * @param w Width of screen | |
113 * @param h Height of screen | |
114 */ | |
1143 | 115 Camera::Camera(float w, float h, SceneGraphRoot *sgroot_, TaskManager *manager) : SceneGraph(manager) |
539 | 116 { |
1129 | 117 |
539 | 118 name = (char*)"Camera"; |
653
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
539
diff
changeset
|
119 sgroot = sgroot_; |
539 | 120 |
121 fov = 60.0f; | |
1292
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
122 near = 100.0f; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
123 far = 1000.0f; |
539 | 124 |
125 zd[0] = 0.0f; | |
126 zd[1] = 0.0f; | |
127 zd[2] = 1.0f; | |
128 zd[3] = 1.0f; | |
129 | |
130 yd[0] = 0.0f; | |
131 yd[1] = 1.0f; | |
132 yd[2] = 0.0f; | |
133 yd[3] = 1.0f; | |
134 | |
135 // Screen の真ん中を初期値とする | |
136 xyz[0] = w/2.0f; | |
137 xyz[1] = h/2.0f; | |
138 | |
139 // min(w, h) がちょうど一杯見えるような z の位置の計算 | |
140 xyz[2] = -(((xyz[1] < xyz[0]) ? xyz[1] : xyz[0])/tanf((fov/2.0f)*M_PI/180.0f)); | |
141 //xyz[2] = -200.0f; | |
142 xyz[3] = 1.0f; | |
143 | |
1302
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1293
diff
changeset
|
144 /* |
539 | 145 m_view = new float[16]; |
146 m_pers = new float[16]; | |
147 m_screen = new float[16]; | |
1302
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1293
diff
changeset
|
148 */ |
747 | 149 |
1302
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1293
diff
changeset
|
150 m_view = (float*)manager->allocate(sizeof(float)*16); |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1293
diff
changeset
|
151 m_pers = (float*)manager->allocate(sizeof(float)*16); |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1293
diff
changeset
|
152 m_screen = (float*)manager->allocate(sizeof(float)*16); |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1293
diff
changeset
|
153 |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1293
diff
changeset
|
154 this->set_move_collision(camera_move, camera_collision, (void *)sgroot); |
747 | 155 |
1047
f87218eed9fc
broken texure ( h/w != 2^n ) protection
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
909
diff
changeset
|
156 update(w,h); // to make matrix[] |
539 | 157 } |
158 | |
159 Camera::~Camera(void) | |
160 { | |
1302
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1293
diff
changeset
|
161 |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1293
diff
changeset
|
162 /* |
539 | 163 delete [] m_view; |
164 delete [] m_pers; | |
165 delete [] m_screen; | |
1302
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1293
diff
changeset
|
166 */ |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1293
diff
changeset
|
167 |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1293
diff
changeset
|
168 free(m_view); |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1293
diff
changeset
|
169 free(m_pers); |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1293
diff
changeset
|
170 free(m_screen); |
539 | 171 } |
172 | |
173 void | |
174 Camera::updateView(void) | |
175 { | |
176 float radx,rady,radz; | |
177 float cx[4], cy[4], cz[4], p[4]; | |
178 float tm[16]; | |
179 | |
1254 | 180 radx = angle[0]*M_PI/180; |
181 rady = angle[1]*M_PI/180; | |
182 radz = angle[2]*M_PI/180; | |
539 | 183 |
184 float sinx = sin(radx); | |
185 float cosx = cos(radx); | |
186 float siny = sin(rady); | |
187 float cosy = cos(rady); | |
188 float sinz = sin(radz); | |
189 float cosz = cos(radz); | |
190 | |
191 /* View Transform */ | |
192 tm[0] = cosz*cosy+sinz*sinx*siny; | |
193 tm[1] = sinz*cosx; | |
194 tm[2] = -cosz*siny+sinz*sinx*cosy; | |
195 tm[3] = 0.0f; | |
196 tm[4] = -sinz*cosy+cosz*sinx*siny; | |
197 tm[5] = cosz*cosx; | |
198 tm[6] = sinz*siny+cosz*sinx*cosy; | |
199 tm[7] = 0.0f; | |
200 tm[8] = cosx*siny; | |
201 tm[9] = -sinx; | |
202 tm[10] = cosx*cosy; | |
203 tm[11] = 0.0f; | |
204 tm[12] = 0.0f; | |
205 tm[13] = 0.0f; | |
206 tm[14] = 0.0f; | |
207 tm[15] = 1.0f; | |
208 | |
1276
e92f00ed2fc0
apply view matrix to normal vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
209 /* transform */ |
e92f00ed2fc0
apply view matrix to normal vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
210 |
539 | 211 applyMatrix(cz, tm, zd); |
212 applyMatrix(cy, tm, yd); | |
213 applyMatrix(p, tm, xyz); | |
214 | |
1276
e92f00ed2fc0
apply view matrix to normal vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
215 /* define view axis of coordinates */ |
e92f00ed2fc0
apply view matrix to normal vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
216 |
539 | 217 outerProduct(cx, cy, cz); |
218 normalize(cx, cx); | |
219 normalize(cz, cz); | |
220 outerProduct(cy, cz, cx); | |
221 | |
222 m_view[ 0] = cx[0]; | |
223 m_view[ 1] = cy[0]; | |
224 m_view[ 2] = cz[0]; | |
225 m_view[ 3] = 0.0f; | |
226 | |
227 m_view[ 4] = cx[1]; | |
228 m_view[ 5] = cy[1]; | |
229 m_view[ 6] = cz[1]; | |
230 m_view[ 7] = 0.0f; | |
231 m_view[ 8] = cx[2]; | |
232 m_view[ 9] = cy[2]; | |
233 m_view[10] = cz[2]; | |
234 m_view[11] = 0.0f; | |
235 | |
236 m_view[12] = innerProduct(xyz, cx)*(-1); | |
237 m_view[13] = innerProduct(xyz, cy)*(-1); | |
238 m_view[14] = innerProduct(xyz, cz)*(-1); | |
239 m_view[15] = 1.0f; | |
240 } | |
241 | |
242 void | |
243 Camera::updatePerspective(float w, float h) | |
244 { | |
245 float sx, sy, sz; | |
246 float aspect = w/h; | |
247 | |
248 sy = (1.0f/tanf((fov/2.0f)*M_PI/180.0f)); | |
249 sx = sy/aspect; | |
250 //sz = far/(far+near); | |
251 sz = far/(far-near); | |
252 | |
253 m_pers[ 0] = sx; | |
254 m_pers[ 1] = 0.0f; | |
255 m_pers[ 2] = 0.0f; | |
256 m_pers[ 3] = 0.0f; | |
257 | |
258 m_pers[ 4] = 0.0f; | |
259 m_pers[ 5] = sy; | |
260 m_pers[ 6] = 0.0f; | |
261 m_pers[ 7] = 0.0f; | |
262 | |
263 m_pers[ 8] = 0.0f; | |
264 m_pers[ 9] = 0.0f; | |
265 m_pers[10] = sz; | |
266 m_pers[11] = 1.0f; | |
267 | |
268 m_pers[12] = 0.0f; | |
269 m_pers[13] = 0.0f; | |
270 m_pers[14] = -near*sz; | |
271 m_pers[15] = 0.0f; | |
1302
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1293
diff
changeset
|
272 |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1293
diff
changeset
|
273 |
539 | 274 } |
275 | |
276 void | |
277 Camera::updateScreen(float _w, float _h) | |
278 { | |
279 float w = _w/2.0f; | |
280 float h = _h/2.0f; | |
281 | |
282 m_screen[ 0] = w; | |
283 m_screen[ 1] = 0.0f; | |
284 m_screen[ 2] = 0.0f; | |
285 m_screen[ 3] = 0.0f; | |
286 | |
287 m_screen[ 4] = 0.0f; | |
288 m_screen[ 5] = h; | |
289 m_screen[ 6] = 0.0f; | |
290 m_screen[ 7] = 0.0f; | |
291 | |
292 m_screen[ 8] = 0.0f; | |
293 m_screen[ 9] = 0.0f; | |
294 m_screen[10] = 1.0f; | |
295 m_screen[11] = 0.0f; | |
296 | |
297 m_screen[12] = w; | |
298 m_screen[13] = h; | |
299 m_screen[14] = 0.0f; | |
300 m_screen[15] = 1.0f; | |
301 } | |
302 | |
303 void | |
304 Camera::setCamera(float *pose) | |
305 { | |
306 //memcpy(xyz, &pose[12], sizeof(float)*4); | |
307 } | |
308 | |
309 void | |
310 Camera::update(float w, float h) | |
311 { | |
312 #if 1 | |
1302
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1293
diff
changeset
|
313 //float tmp[16]; |
539 | 314 |
315 updateView(); | |
316 updatePerspective(w, h); | |
317 updateScreen(w, h); | |
1292
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
318 |
1302
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1293
diff
changeset
|
319 //matrix4x4(tmp, this->m_pers, this->m_screen); |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1293
diff
changeset
|
320 //matrix4x4(this->matrix, this->m_view, tmp); |
1276
e92f00ed2fc0
apply view matrix to normal vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
321 |
539 | 322 #else |
323 get_matrix(matrix, angle, xyz, NULL); | |
324 #endif | |
325 } |