comparison Dandy.cc @ 19:bdc882acda58

get_matrix
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 09 Dec 2010 22:31:06 +0900
parents b0f057171e18
children cd5768022d2b
comparison
equal deleted inserted replaced
16:7e7e6f73b11f 19:bdc882acda58
24 #include "debug.h" 24 #include "debug.h"
25 #include "trace.h" 25 #include "trace.h"
26 #include "LoadSprite.h" 26 #include "LoadSprite.h"
27 #include <SDL_mixer.h> 27 #include <SDL_mixer.h>
28 #include "error.h" 28 #include "error.h"
29 #include "sys.h" 29 #include "matrix_calc.h"
30 30
31 #include "Character.h" 31 #include "Character.h"
32 #include "Character_state.h" 32 #include "Character_state.h"
33 33
34 int use_keybord = 0; 34 int use_keybord = 0;
149 149
150 static void 150 static void
151 LightSysSwitch(Viewer *sgroot) { 151 LightSysSwitch(Viewer *sgroot) {
152 if (light_sysswitch == 1) { 152 if (light_sysswitch == 1) {
153 sgroot->OnLightSysSwitch(); 153 sgroot->OnLightSysSwitch();
154 } else if (light_sysswitch == 0) {
155 sgroot->OffLightSysSwitch();
156 }
157 }
158
159
160 static int
161 dandy_main_init(int gamef)
162 {
163 //Timeprof timeprof_move;
164 //timeprof_move = timeprof_new();
165 dbg_init("/dev/stdout");
166
167 /**
168 * timeprof があるんだけどね
169 */
170
171 sgroot->createFromXMLfile("xml/character.xml");
172 sgroot->createFromXMLfile("xml/font.xml");
173 sgroot->createFromXMLfile("xml/effect.xml");
174 sgroot->createFromXMLfile("xml/boss.xml");
175
176 LightSysSwitch(sgroot);
177 for (int i = 0; i < light_num; i++) { 154 for (int i = 0; i < light_num; i++) {
178 SceneGraphPtr light = sgroot->getLight(i); 155 SceneGraphPtr light = sgroot->getLight(i);
179 sgroot->OnLightSwitch(i); 156 sgroot->OnLightSwitch(i);
180 light->xyz[0] = screen_w / 2; 157 light->xyz[0] = screen_w / 2;
181 light->xyz[1] = screen_h / 2; 158 light->xyz[1] = screen_h / 2;
182 light->xyz[2] = -100; 159 light->xyz[2] = -100;
183 } 160 }
161 } else if (light_sysswitch == 0) {
162 sgroot->OffLightSysSwitch();
163 }
164 }
165
166
167 static int
168 dandy_main_init(int gamef)
169 {
170 //Timeprof timeprof_move;
171 //timeprof_move = timeprof_new();
172 dbg_init("/dev/stdout");
173
174 /**
175 * timeprof があるんだけどね
176 */
177
178 sgroot->createFromXMLfile("xml/character.xml");
179 sgroot->createFromXMLfile("xml/font.xml");
180 sgroot->createFromXMLfile("xml/effect.xml");
181 sgroot->createFromXMLfile("xml/boss.xml");
182
183 LightSysSwitch(sgroot);
184 184
185 185
186 init_sprite(0,0,0,0); 186 init_sprite(0,0,0,0);
187 187
188 __debug("syokikaが呼びだされました\n"); 188 __debug("syokikaが呼びだされました\n");
229 return 1; 229 return 1;
230 } 230 }
231 231
232 SceneGraphPtr root; 232 SceneGraphPtr root;
233 233
234 extern void get_matrix(float *matrix, float *rxyz, float *txyz, float *stack); 234 // extern void get_matrix(float *matrix, float *rxyz, float *txyz, float *scale, float *stack);
235 extern void ScaleMatrix(float *matrix, float rxyz);
236 extern void ScaleMatrixXY(float *matrix, float x, float y);
237 235
238 static void 236 static void
239 flip() 237 flip()
240 { 238 {
241 CameraPtr camera = sgroot->sgroot->getCamera(); 239 CameraPtr camera = sgroot->sgroot->getCamera();
247 root->xyz[0] = screen_w/2; 245 root->xyz[0] = screen_w/2;
248 root->xyz[1] = screen_h/2;; 246 root->xyz[1] = screen_h/2;;
249 root->xyz[2] = 30.0f; 247 root->xyz[2] = 30.0f;
250 248
251 /*親の回転、座標から、子の回転、座標を算出*/ 249 /*親の回転、座標から、子の回転、座標を算出*/
252 get_matrix(root->matrix, root->angle, root->xyz, camera->matrix); 250 get_matrix(root->matrix, root->angle, root->xyz, root->scale, camera->matrix);
253 /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/ 251 /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/
254 get_matrix(root->real_matrix, root->angle, root->xyz, camera->real_matrix); 252 get_matrix(root->real_matrix, root->angle, root->xyz, root->scale, camera->real_matrix);
255 253
256 sgroot->setSceneData(root); 254 sgroot->setSceneData(root);
257 } 255 }
258 256
259 257
558 object->xyz[0] = x; 556 object->xyz[0] = x;
559 object->xyz[1] = y; 557 object->xyz[1] = y;
560 object->xyz[2] = 0; 558 object->xyz[2] = 0;
561 root->addChild(object); 559 root->addChild(object);
562 560
561 float scale[] = {5,5,1};
563 /*親の回転、座標から、子の回転、座標を算出*/ 562 /*親の回転、座標から、子の回転、座標を算出*/
564 get_matrix(object->matrix, object->angle, object->xyz, root->matrix); 563 get_matrix(object->matrix, object->angle, object->xyz, scale, root->matrix);
565 ScaleMatrixXY(object->matrix,5,5);
566 /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/ 564 /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/
567 get_matrix(object->real_matrix, object->angle, object->xyz, root->real_matrix); 565 get_matrix(object->real_matrix, object->angle, object->xyz, scale, root->real_matrix);
568 566
569 } 567 }
570 568
571 void 569 void
572 PutSpriteEx(int number, int x, int y, float scalex, float scaley, float angle) 570 PutSpriteEx(int number, int x, int y, float scalex, float scaley, float angle)
584 object->c_xyz[0] = m->mx; 582 object->c_xyz[0] = m->mx;
585 object->c_xyz[1] = m->my; 583 object->c_xyz[1] = m->my;
586 object->angle[3] = angle; 584 object->angle[3] = angle;
587 root->addChild(object); 585 root->addChild(object);
588 586
587 float scale[] = {5*scalex,5*scaley,1};
589 /*親の回転、座標から、子の回転、座標を算出*/ 588 /*親の回転、座標から、子の回転、座標を算出*/
590 get_matrix(object->matrix, object->angle, object->xyz, root->matrix); 589 get_matrix(object->matrix, object->angle, object->xyz, scale, root->matrix);
591 ScaleMatrixXY(object->matrix,scalex*5,scaley*5);
592 /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/ 590 /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/
593 get_matrix(object->real_matrix, object->angle, object->xyz, root->real_matrix); 591 get_matrix(object->real_matrix, object->angle, object->xyz, scale, root->real_matrix);
594 } 592 }
595 593
596 594
597 struct SGO_PAD pad[2]; 595 struct SGO_PAD pad[2];
598 596