diff Renderer/Application/direction.cc @ 539:3bc98f6d31ff draft

Reorganization..
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 12 Oct 2009 09:39:35 +0900
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Application/direction.cc	Mon Oct 12 09:39:35 2009 +0900
@@ -0,0 +1,93 @@
+#include "SceneGraphRoot.h"
+#include "SGList.h"
+
+static void
+x_move(SceneGraphPtr node, int w, int h)
+{
+    Pad *pad = sgroot->getController();
+
+    node->xyz[0] = w/2;
+    node->xyz[1] = h/2;
+
+    if (pad->circle.isPush() || pad->circle.isHold()) {
+	node->angle[1] += 10.0f;
+	if (node->angle[1] > 360.0f) node->angle[1] = 0.0f;
+    }
+
+    if (pad->triangle.isPush() || pad->triangle.isHold()) {
+	node->angle[0] += 10.0f;
+	if (node->angle[0] > 360.0f) node->angle[0] = 0.0f;
+    }    
+
+    if (pad->start.isPush()) {
+	node->angle[0] = 0.0f;
+	node->angle[1] = 90.0f;
+    }
+    
+}
+
+static void
+y_move(SceneGraphPtr node, int w, int h)
+{
+    Pad *pad = sgroot->getController();
+
+    node->xyz[0] = w/2;
+    node->xyz[1] = h/2;
+
+    if (pad->cross.isPush() || pad->cross.isHold()) {
+	node->angle[2] += 10.0f;
+    }
+
+    if (pad->square.isPush() || pad->square.isHold()) {
+	node->angle[0] += 10.0f;
+    }
+
+    if (pad->start.isPush()) {
+	node->angle[0] = 90.0f;
+	node->angle[1] = 0.0f;
+    }
+    
+}
+
+static void
+z_move(SceneGraphPtr node, int w, int h)
+{
+    node->xyz[0] = w/2;
+    node->xyz[1] = h/2;
+}
+
+static void
+dir_collision(SceneGraphPtr node, int w, int h, SceneGraphPtr tree)
+{
+}
+
+void
+direction_init(TaskManager *manager)
+{
+    SceneGraphPtr dx;
+    SceneGraphPtr dy;
+    SceneGraphPtr dz;
+    SceneGraphPtr back;
+
+    sgroot->createFromXMLfile(manager, "xml_file/direction.xml");
+
+    dx = sgroot->createSceneGraph(Dirx);
+    dy = sgroot->createSceneGraph(Diry);
+    dz = sgroot->createSceneGraph(Dirz);
+    back = sgroot->createSceneGraph();
+    
+    back->addChild(dx);
+    back->addChild(dy);
+    back->addChild(dz);
+
+    dx->set_move_collision(x_move, dir_collision);
+    dx->angle[1] = 90.0f;
+    dy->set_move_collision(y_move, dir_collision);
+    dy->angle[0] = 90.0f;
+    dz->set_move_collision(z_move, dir_collision);
+
+    back->angle[0] = 30.0f;
+    back->angle[1] = -30.0f;
+
+    sgroot->setSceneData(back);
+}