diff 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
line wrap: on
line diff
--- a/Renderer/Engine/Camera.cc	Sat Nov 21 11:20:29 2009 +0900
+++ b/Renderer/Engine/Camera.cc	Wed Nov 25 21:56:14 2009 +0900
@@ -6,9 +6,13 @@
 #include "show_time.h"
 #include "TaskManager.h"
 
+//static SceneGraphRoot *sgroot;
+
+#if 1
 static void
-camera_move(SceneGraphPtr _node, int screen_w, int screen_h)
+camera_move(SceneGraphPtr _node, void *sgroot_, int screen_w, int screen_h)
 {
+    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
     Pad *pad = sgroot->getController();
     CameraPtr node = (CameraPtr)_node;
 
@@ -62,9 +66,45 @@
     }
 
 }
+#endif
+
+#if 0
+static void
+Camera::camera_move(SceneGraphPtr _node, int screen_w, int screen_h)
+{
+    Pad *pad = sgroot->getController();
+    CameraPtr node = (CameraPtr)_node;
+
+    if (pad->r1.isPush() || pad->r1.isHold()) {
+	node->xyz[2] += 10.0f;
+    } else if (pad->l1.isPush() || pad->l1.isHold()) {
+	node->xyz[2] -= 10.0f;
+    }
+
+    if (pad->r2.isHold()) {
+	if (node->zd[0] <= 1.0f) {
+	    node->zd[0] += 0.02f;
+	}
+	if (node->zd[2] >= 0.0f) {
+	    node->zd[2] -= 0.02f;
+	}
+    } else if (pad->l2.isHold()) {
+	if (node->zd[0] > -1.0f) {
+	    node->zd[0] -= -0.02f;
+	}
+	if (node->zd[2] >= 0.0f) {
+	    node->zd[2] -= 0.02f;
+	}
+    } else {
+	node->zd[0] = 0.0f;
+	node->zd[2] = 1.0f;
+    }
+
+}
+#endif
 
 static void
-camera_collision(SceneGraphPtr node, int screen_w, int screen_h,
+camera_collision(SceneGraphPtr node, void *sgroot_,int screen_w, int screen_h,
 		 SceneGraphPtr tree)
 {
 }
@@ -73,10 +113,10 @@
  * @param w Width of screen
  * @param h Height of screen
  */
-Camera::Camera(float w, float h)
+Camera::Camera(float w, float h, SceneGraphRoot *sgroot_)
 {
     name = (char*)"Camera";
-
+    sgroot = sgroot_;
 
     fov  = 60.0f;
     near = 0.0f;
@@ -105,7 +145,7 @@
     m_pers = new float[16];
     m_screen = new float[16];
     
-    this->set_move_collision(camera_move, camera_collision);
+    this->set_move_collision(camera_move, camera_collision, (void *)sgroot);
 }
 
 Camera::~Camera(void)