diff Renderer/Test/ladybug.cc @ 1207:9a5e21195600 draft

clipping
author Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
date Thu, 21 Jul 2011 21:14:18 +0900
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Test/ladybug.cc	Thu Jul 21 21:14:18 2011 +0900
@@ -0,0 +1,135 @@
+#include <stdlib.h>
+#include "SceneGraphRoot.h"
+#include "ladybug.h"
+
+static void
+obj_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
+	       SceneGraphPtr tree)
+{
+}
+
+static void
+moon_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
+	       SceneGraphPtr tree)
+{
+}
+
+static void
+moon_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
+{
+  node->angle[0] += 3.0f;
+}
+
+
+static void
+tyre_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
+{
+
+    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
+    Pad *pad = sgroot->getController();
+
+    if (pad->left.isHold()) {
+      node->angle[1] += 10;
+    } else if (pad->right.isHold()) {
+      node->angle[1] -= 10;
+    }
+    if (pad->up.isHold()) {
+      node->angle[0] += 10;
+    } else if (pad->down.isHold()) {
+      node->angle[0] -= 10;
+    }
+}
+
+MainLoopPtr
+ladybug::init(Viewer *sgroot, int screen_w, int screen_h)
+{
+    SceneGraphPtr body;
+    SceneGraphPtr body2;
+    SceneGraphPtr tyre;
+    SceneGraphPtr tyre2;
+    SceneGraphPtr tyre3;
+    SceneGraphPtr tyre4;
+    SceneGraphPtr antenna;
+    
+    //camera
+     SceneGraphPtr camera = sgroot-> getCamera();
+
+    sgroot->createFromXMLfile( "xml_file/ladybug4.xml");    
+    sgroot->OnLightSysSwitch();
+    SceneGraphPtr light = sgroot->getLight(0); 
+    sgroot->OnLightSwitch(1);
+    light->xyz[2] -= 10;
+
+    // SceneGraph ID から SceneGraph を生成する
+    body = sgroot->createSceneGraph("body");
+    //body->set_move_collision(tyre_move, obj_collision);
+
+    tyre = sgroot->createSceneGraph("tyre");
+    //tyre->set_move_collision(tyre_move, obj_collision);
+
+    tyre2 = sgroot->createSceneGraph("tyre2");
+    //tyre2->set_move_collision(tyre_move, obj_collision);
+
+    tyre3 = sgroot->createSceneGraph("tyre3");
+    //tyre3->set_move_collision(tyre_move, obj_collision);
+
+    tyre4 = sgroot->createSceneGraph("tyre4");
+    //tyre4->set_move_collision(tyre_move, obj_collision);
+
+    
+    camera->set_move_collision(tyre_move, obj_collision);
+
+
+    // SceneGraph の move と collision を設定
+    //body->set_move_collision(earth_move, earth_collision);
+
+    body->xyz[0] = screen_w / 2;
+    body->xyz[1] = screen_h / 2;
+    body->stack_xyz[0] = 3.0f;
+    body->stack_xyz[1] = 3.0f;
+    
+    body2 = sgroot->createSceneGraph("body2");
+    //body2->set_move_collision(moon_move, moon_collision);
+    
+    // SceneGraph 同士の親子関係を設定 (今回は 親 earth、子 moon)
+
+    body->addChild(body2);
+    body->addChild(tyre);
+    body->addChild(tyre2);
+    body->addChild(tyre3);
+    body->addChild(tyre4);
+
+    // SceneGraphRoot に、使用する SceneGraph を設定する
+    // このとき、ユーザーは SceneGraph の root を渡す。
+    sgroot->setSceneData(body);
+    return sgroot;
+}
+
+extern Application *
+application() {
+    return new ladybug();
+}
+
+const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n";
+
+extern int init(TaskManager *manager, int argc, char *argv[]);
+extern void task_initialize();
+static void TMend(TaskManager *manager);
+
+int
+TMmain(TaskManager *manager, int argc, char *argv[])
+{
+    task_initialize();
+    manager->set_TMend(TMend);
+    return init(manager, argc, argv);
+
+}
+
+void
+TMend(TaskManager *manager)
+{
+    printf("test_nogl end\n");
+}
+
+/* end */
+