comparison Renderer/Engine/Camera.cc @ 653:7a311860a76e draft

remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
author hiroki@henri.cr.ie.u-ryukyu.ac.jp
date Wed, 25 Nov 2009 21:56:14 +0900
parents 3bc98f6d31ff
children 6e9e4726113e 18d31d18a6b2
comparison
equal deleted inserted replaced
646:9f9390b45f78 653:7a311860a76e
4 #include "sys.h" 4 #include "sys.h"
5 #include "Scheduler.h" 5 #include "Scheduler.h"
6 #include "show_time.h" 6 #include "show_time.h"
7 #include "TaskManager.h" 7 #include "TaskManager.h"
8 8
9 //static SceneGraphRoot *sgroot;
10
11 #if 1
9 static void 12 static void
10 camera_move(SceneGraphPtr _node, int screen_w, int screen_h) 13 camera_move(SceneGraphPtr _node, void *sgroot_, int screen_w, int screen_h)
11 { 14 {
15 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
12 Pad *pad = sgroot->getController(); 16 Pad *pad = sgroot->getController();
13 CameraPtr node = (CameraPtr)_node; 17 CameraPtr node = (CameraPtr)_node;
14 18
15 #if 0 19 #if 0
16 if (pad->right.isHold()) { 20 if (pad->right.isHold()) {
60 node->zd[0] = 0.0f; 64 node->zd[0] = 0.0f;
61 node->zd[2] = 1.0f; 65 node->zd[2] = 1.0f;
62 } 66 }
63 67
64 } 68 }
65 69 #endif
70
71 #if 0
66 static void 72 static void
67 camera_collision(SceneGraphPtr node, int screen_w, int screen_h, 73 Camera::camera_move(SceneGraphPtr _node, int screen_w, int screen_h)
74 {
75 Pad *pad = sgroot->getController();
76 CameraPtr node = (CameraPtr)_node;
77
78 if (pad->r1.isPush() || pad->r1.isHold()) {
79 node->xyz[2] += 10.0f;
80 } else if (pad->l1.isPush() || pad->l1.isHold()) {
81 node->xyz[2] -= 10.0f;
82 }
83
84 if (pad->r2.isHold()) {
85 if (node->zd[0] <= 1.0f) {
86 node->zd[0] += 0.02f;
87 }
88 if (node->zd[2] >= 0.0f) {
89 node->zd[2] -= 0.02f;
90 }
91 } else if (pad->l2.isHold()) {
92 if (node->zd[0] > -1.0f) {
93 node->zd[0] -= -0.02f;
94 }
95 if (node->zd[2] >= 0.0f) {
96 node->zd[2] -= 0.02f;
97 }
98 } else {
99 node->zd[0] = 0.0f;
100 node->zd[2] = 1.0f;
101 }
102
103 }
104 #endif
105
106 static void
107 camera_collision(SceneGraphPtr node, void *sgroot_,int screen_w, int screen_h,
68 SceneGraphPtr tree) 108 SceneGraphPtr tree)
69 { 109 {
70 } 110 }
71 111
72 /** 112 /**
73 * @param w Width of screen 113 * @param w Width of screen
74 * @param h Height of screen 114 * @param h Height of screen
75 */ 115 */
76 Camera::Camera(float w, float h) 116 Camera::Camera(float w, float h, SceneGraphRoot *sgroot_)
77 { 117 {
78 name = (char*)"Camera"; 118 name = (char*)"Camera";
79 119 sgroot = sgroot_;
80 120
81 fov = 60.0f; 121 fov = 60.0f;
82 near = 0.0f; 122 near = 0.0f;
83 far = 1000.0f; 123 far = 1000.0f;
84 124
103 143
104 m_view = new float[16]; 144 m_view = new float[16];
105 m_pers = new float[16]; 145 m_pers = new float[16];
106 m_screen = new float[16]; 146 m_screen = new float[16];
107 147
108 this->set_move_collision(camera_move, camera_collision); 148 this->set_move_collision(camera_move, camera_collision, (void *)sgroot);
109 } 149 }
110 150
111 Camera::~Camera(void) 151 Camera::~Camera(void)
112 { 152 {
113 delete [] m_view; 153 delete [] m_view;