changeset 597:5c5cd31b9d43

add Light Object
author yutaka@henri.cr.ie.u-ryukyu.ac.jp
date Thu, 05 Nov 2009 20:17:59 +0900
parents cfeca966f571
children a64e729a8072
files Renderer/Engine/Light.cc Renderer/Engine/Light.h Renderer/Engine/SceneGraphRoot.cc Renderer/Engine/SceneGraphRoot.h Renderer/Engine/task/CreatePolygonFromSceneGraph.cc
diffstat 5 files changed, 71 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Engine/Light.cc	Thu Nov 05 20:17:59 2009 +0900
@@ -0,0 +1,42 @@
+#include <math.h>
+#include "SceneGraphRoot.h"
+#include "Light.h"
+#include "sys.h"
+#include "Scheduler.h"
+#include "show_time.h"
+#include "TaskManager.h"
+
+static void
+light_move(SceneGraphPtr node, int screen_w, int screen_h)
+{
+
+}
+
+static void
+light_collision(SceneGraphPtr node, int screen_w, int screen_h,
+		 SceneGraphPtr tree)
+{
+}
+
+/**
+ * @param w Width of screen
+ * @param h Height of screen
+ */
+Light::Light(float w, float h)
+{
+    name = (char*)"Light";
+
+    // Screen の真ん中を初期値とする
+    xyz[0] = w/2.0f;
+    xyz[1] = h/2.0f;
+    xyz[2] = 0;
+    xyz[3] = 1.0f;
+
+    this->set_move_collision(light_move, light_collision);
+}
+
+Light::~Light(void)
+{
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Engine/Light.h	Thu Nov 05 20:17:59 2009 +0900
@@ -0,0 +1,13 @@
+#ifndef INCLUDED_LIGHT
+#define INCLUDED_LIGHT
+#include "SceneGraph.h"
+
+class Light : public SceneGraph {
+public:
+  Light(float w, float h);
+  ~Light(void);
+};
+
+typedef Light *LightPtr;
+
+#endif
--- a/Renderer/Engine/SceneGraphRoot.cc	Wed Nov 04 22:52:06 2009 +0900
+++ b/Renderer/Engine/SceneGraphRoot.cc	Thu Nov 05 20:17:59 2009 +0900
@@ -25,6 +25,7 @@
     sg_src = (SceneGraphPtr*) malloc(sizeof(SceneGraphPtr)*SGLIST_LENGTH);
 
     camera = new Camera(w, h);
+    light = new Light(w, h);
     iterator = new SceneGraphIterator;
     controller = create_controller();
 
@@ -63,6 +64,7 @@
 
     free(sg_src);
     delete camera;
+    delete light;
     delete iterator;
     delete controller;
 }
@@ -527,3 +529,11 @@
 {
     return camera;
 }
+
+LightPtr
+SceneGraphRoot::getLight()
+{
+
+  return light;
+
+}
--- a/Renderer/Engine/SceneGraphRoot.h	Wed Nov 04 22:52:06 2009 +0900
+++ b/Renderer/Engine/SceneGraphRoot.h	Thu Nov 05 20:17:59 2009 +0900
@@ -4,6 +4,7 @@
 #include "SceneGraph.h"
 #include "SceneGraphArray.h"
 #include "Camera.h"
+#include "Light.h"
 #include "SceneGraphIterator.h"
 #include <sys/types.h>
 
@@ -51,6 +52,9 @@
     // カメラオブジェクト
     Camera *camera;
 
+    // 光源のオブジェクト
+    Light *light;
+
     // SceneGraphIterator
     SceneGraphIteratorPtr iterator;
 
@@ -73,6 +77,7 @@
     SceneGraphIteratorPtr getIterator();
     SceneGraphIteratorPtr getIterator(SceneGraphPtr list);
     CameraPtr getCamera();
+    LightPtr getLight();
 
     /* Other System API */
     void allExecute(int screen_w, int screen_h);
--- a/Renderer/Engine/task/CreatePolygonFromSceneGraph.cc	Wed Nov 04 22:52:06 2009 +0900
+++ b/Renderer/Engine/task/CreatePolygonFromSceneGraph.cc	Thu Nov 05 20:17:59 2009 +0900
@@ -171,7 +171,6 @@
 		triangle->ver3.tex_x = sg->coord_tex[(i+2)*3];
 		triangle->ver3.tex_y = sg->coord_tex[(i+2)*3+1];
 
-                //法線もApplyMatrixとかするのかな?一応値をとっておくby yutaka
 
                 normal1[0] = sg->normal[(i+0)*3];
                 normal1[1] = sg->normal[(i+0)*3+1];
@@ -190,7 +189,7 @@
 
                 ApplyNormalMatrix(normal1,sg->matrix);
 
-                //ここでpolygonに法線ベクトルの情報がわたったby yutaka
+                //ここでpolygonに法線ベクトルの情報がわたった
 
                 triangle->normal1.x = normal1[0];
                 triangle->normal1.y = normal1[1];