changeset 1143:786e800abfb4 draft

minor fix
author Yutaka_Kinjyo
date Sat, 19 Feb 2011 01:59:14 +0900
parents 801d57ae1e29
children e068c1269292
files Renderer/Engine/Camera.cc Renderer/Engine/Camera.h Renderer/Engine/Light.cc Renderer/Engine/Light.h Renderer/Engine/SceneGraph.cc Renderer/Engine/SceneGraph.h Renderer/Engine/SceneGraphArray.h Renderer/Engine/SceneGraphRoot.cc Renderer/Engine/SceneGraphRoot.h Renderer/Engine/SgChange.cc Renderer/Engine/polygon.cc Renderer/Engine/viewer.cc
diffstat 12 files changed, 44 insertions(+), 75 deletions(-) [+]
line wrap: on
line diff
--- a/Renderer/Engine/Camera.cc	Thu Feb 17 05:23:34 2011 +0900
+++ b/Renderer/Engine/Camera.cc	Sat Feb 19 01:59:14 2011 +0900
@@ -112,7 +112,7 @@
  * @param w Width of screen
  * @param h Height of screen
  */
-Camera::Camera(float w, float h, SceneGraphRoot *sgroot_)
+Camera::Camera(float w, float h, SceneGraphRoot *sgroot_, TaskManager *manager)  : SceneGraph(manager)
 {
 
     name = (char*)"Camera";
@@ -144,6 +144,10 @@
     m_view = new float[16];
     m_pers = new float[16];
     m_screen = new float[16];
+
+    //matrix = (float*)malloc(sizeof(float)*16);
+    //real_matrix = (float*)malloc(sizeof(float)*16);
+    //texture_info = (texture_list*)malloc(sizeof(texture_list));
     
     this->set_move_collision(camera_move, camera_collision, (void *)sgroot);
 
--- a/Renderer/Engine/Camera.h	Thu Feb 17 05:23:34 2011 +0900
+++ b/Renderer/Engine/Camera.h	Sat Feb 19 01:59:14 2011 +0900
@@ -8,7 +8,7 @@
 class Camera : public SceneGraph {
 public:
     //Camera(float w = 640, float h = 480, SceneGraphRoot *sgroot);
-    Camera(float w, float h, SceneGraphRoot *sgroot);
+    Camera(float w, float h, SceneGraphRoot *sgroot, TaskManager *manager);
     ~Camera(void);    
 
     SceneGraphRoot *sgroot;
--- a/Renderer/Engine/Light.cc	Thu Feb 17 05:23:34 2011 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-#include <math.h>
-#include "SceneGraphRoot.h"
-#include "Light.h"
-#include "matrix_calc.h"
-#include "Scheduler.h"
-#include "TaskManager.h"
-
-static void
-light_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
-{
-
-}
-
-static void
-light_collision(SceneGraphPtr node, void *sgroot_, 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)
-{
-
-}
-
--- a/Renderer/Engine/Light.h	Thu Feb 17 05:23:34 2011 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-#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/SceneGraph.cc	Thu Feb 17 05:23:34 2011 +0900
+++ b/Renderer/Engine/SceneGraph.cc	Sat Feb 19 01:59:14 2011 +0900
@@ -118,10 +118,23 @@
  * 何の情報も持ってない SceneGraph の生成
  * 今のところ、とりあえず木構造の繋がりに使うぐらい
  */
-SceneGraph::SceneGraph()
+SceneGraph::SceneGraph(TaskManager *manager)
 {
 
     init();
+
+    this->matrix = (float*)manager->allocate(sizeof(float)*16);
+    this->real_matrix = (float*)manager->allocate(sizeof(float)*16);
+    this->texture_info = (texture_list*)manager->allocate(sizeof(texture_list));
+
+    texture_info->texture_id = -1;
+
+    for (int i = 0; i < 16; i++) {
+      matrix[i]      = 0;
+      real_matrix[i] = 0;
+    }
+
+
     finalize = &SceneGraph::finalize_copy;
 
     this->name = "NULLPO";
@@ -160,7 +173,13 @@
 /* construct polygon from xmlNode.  */
 SceneGraph::SceneGraph(TaskManager *manager, xmlNodePtr surface)
 {
+
     init();
+
+    this->matrix = (float*)manager->allocate(sizeof(float)*16);
+    this->real_matrix = (float*)manager->allocate(sizeof(float)*16);
+    this->texture_info = (texture_list*)manager->allocate(sizeof(texture_list));
+    texture_info->texture_id = -1;
     
     //size : 頂点の数かな
     size = atoi((char *)xmlGetProp(surface,(xmlChar *)"size"));
@@ -214,7 +233,6 @@
 
     //data = NULL;
    
-    texture_info->texture_id = -1;
     move = no_move;
     collision = no_collision;
 
@@ -674,14 +692,14 @@
     p->matrix = (float*)manager->allocate(sizeof(float)*16);
     p->real_matrix = (float*)manager->allocate(sizeof(float)*16);
     //これはいらない?
-    //p->texture_info = (texture_list*)manager->allocate(sizeof(texture_list));
+    p->texture_info = (texture_list*)manager->allocate(sizeof(texture_list));
 
     for (int i = 0; i < 16; i++) {
       p->matrix[i] = this->matrix[i];
       p->real_matrix[i] = this->real_matrix[i];
     }
 
-    //memcpy(p->texture_info, this->texture_info, sizeof(texture_list));
+    memcpy(p->texture_info, this->texture_info, sizeof(texture_list));
 
     return p;
 }
--- a/Renderer/Engine/SceneGraph.h	Thu Feb 17 05:23:34 2011 +0900
+++ b/Renderer/Engine/SceneGraph.h	Sat Feb 19 01:59:14 2011 +0900
@@ -18,7 +18,7 @@
 
 class SceneGraph : public Polygon {
 public:
-    SceneGraph();
+    SceneGraph(TaskManager *manager);
     SceneGraph(TaskManager *manager, xmlNodePtr surface);
     SceneGraph(SceneGraphPtr orig);
     ~SceneGraph(void);
--- a/Renderer/Engine/SceneGraphArray.h	Thu Feb 17 05:23:34 2011 +0900
+++ b/Renderer/Engine/SceneGraphArray.h	Sat Feb 19 01:59:14 2011 +0900
@@ -12,7 +12,8 @@
     int size;
     int pad[3];
 
-    SceneGraphArray(void) : size(0) {}
+    //SceneGraphArray(void) : size(0) {}
+    SceneGraphArray(void);
 
     /**
      * array の初期化
--- a/Renderer/Engine/SceneGraphRoot.cc	Thu Feb 17 05:23:34 2011 +0900
+++ b/Renderer/Engine/SceneGraphRoot.cc	Sat Feb 19 01:59:14 2011 +0900
@@ -18,13 +18,17 @@
 
 SceneGraphRoot *sgroot;
 
-SceneGraphRoot::SceneGraphRoot(float w, float h)
+SceneGraphRoot::SceneGraphRoot(float w, float h, TaskManager *manager)
 {
+
+    sgroot = this;
+    sgroot->tmanager = manager;
+
     // SGLIST_LENGTH 決め打ちかぁ、動的生成にする場合上限決めておいた方がいいのかな
     //
     sg_src = (SceneGraphPtr*) malloc(sizeof(SceneGraphPtr)*SGLIST_LENGTH);
 
-    camera = new Camera(w, h, this);
+    camera = new Camera(w, h, this, sgroot->tmanager);
 
     iterator = new SceneGraphIterator;
     controller = create_controller();
@@ -34,7 +38,6 @@
     sg_available_list = NULL;
     sg_remove_list = NULL;
 
-    sgroot = this;
 
     screen_w = (int)w;
     screen_h = (int)h;
@@ -42,7 +45,7 @@
     light_sysswitch = 0;
 
     for (int i = 0; i < light_num; i++) {
-	light[i] = new SceneGraph;
+        light[i] = new SceneGraph(sgroot->tmanager);
 	light[i]->xyz[0] = 0;
 	light[i]->xyz[1] = 0;
 	light[i]->xyz[2] = 0;
@@ -270,7 +273,7 @@
 SceneGraphPtr
 SceneGraphRoot::createSceneGraph()
 {
-    SceneGraphPtr p = new SceneGraph;
+    SceneGraphPtr p = new SceneGraph(sgroot->tmanager);
 
     /* move, collision に sgroot を渡したいのでここで sgroot を渡しておく*/
     p->sgroot = (void *)this;
--- a/Renderer/Engine/SceneGraphRoot.h	Thu Feb 17 05:23:34 2011 +0900
+++ b/Renderer/Engine/SceneGraphRoot.h	Sat Feb 19 01:59:14 2011 +0900
@@ -21,7 +21,7 @@
 class SceneGraphRoot {
 public:
     /* Constructor, Destructor */
-    SceneGraphRoot(float w, float h);
+    SceneGraphRoot(float w, float h, TaskManager *manager);  
     ~SceneGraphRoot();
 
     /* Variables */
--- a/Renderer/Engine/SgChange.cc	Thu Feb 17 05:23:34 2011 +0900
+++ b/Renderer/Engine/SgChange.cc	Sat Feb 19 01:59:14 2011 +0900
@@ -31,9 +31,9 @@
 {   
     int width  = viewer->width;
     int height = viewer->height;
-    sgroot_A = new SceneGraphRoot(width, height);
+    sgroot_A = new SceneGraphRoot(width, height, manager);
     sgroot_A->tmanager = viewer->manager;
-    sgroot_B = new SceneGraphRoot(width, height);
+    sgroot_B = new SceneGraphRoot(width, height, manager);
     sgroot_B->tmanager = viewer->manager;
 }
 
--- a/Renderer/Engine/polygon.cc	Thu Feb 17 05:23:34 2011 +0900
+++ b/Renderer/Engine/polygon.cc	Sat Feb 19 01:59:14 2011 +0900
@@ -19,9 +19,6 @@
 
 Polygon::Polygon()
 {
-    matrix      = (float*)polygon_allocate(sizeof(float)*16);
-    real_matrix = (float*)polygon_allocate(sizeof(float)*16);
-    texture_info = (texture_list*)polygon_allocate(sizeof(texture_list));
     position_init();
 }
 
--- a/Renderer/Engine/viewer.cc	Thu Feb 17 05:23:34 2011 +0900
+++ b/Renderer/Engine/viewer.cc	Sat Feb 19 01:59:14 2011 +0900
@@ -91,8 +91,8 @@
 
     if (spe_num == 0) spe_num = 1;
 
-    sgroot = new SceneGraphRoot(this->width, this->height);
-    sgroot->tmanager = manager;
+    sgroot = new SceneGraphRoot(this->width, this->height, manager);
+    //sgroot->tmanager = manager;
 
     int light_num = 4;
     int size = sizeof(float)*4*light_num; //xyz+alfa(4) * light_num(4)