changeset 221:d61fded0729e

Cameraの設定、Makefile 修正
author gongo@gendarme.local
date Tue, 10 Feb 2009 01:47:12 +0900
parents 29e338dbc280
children 5ffee529dc59
files TaskManager/Test/test_render/Camera.cpp TaskManager/Test/test_render/Camera.h TaskManager/Test/test_render/ChangeLog TaskManager/Test/test_render/Joystick.cpp TaskManager/Test/test_render/Joystick.h TaskManager/Test/test_render/Makefile TaskManager/Test/test_render/Makefile.def TaskManager/Test/test_render/Makefile.linux TaskManager/Test/test_render/Makefile.macosx TaskManager/Test/test_render/Makefile.ps3 TaskManager/Test/test_render/Pad.cpp TaskManager/Test/test_render/Pad.h TaskManager/Test/test_render/SceneGraphRoot.cpp TaskManager/Test/test_render/SceneGraphRoot.h TaskManager/Test/test_render/panel.cpp TaskManager/Test/test_render/task/CreatePolygonFromSceneGraph.cpp TaskManager/Test/test_render/task/DrawSpan.cpp TaskManager/Test/test_render/viewer.cpp
diffstat 18 files changed, 244 insertions(+), 193 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Test/test_render/Camera.cpp	Mon Feb 09 21:58:45 2009 +0900
+++ b/TaskManager/Test/test_render/Camera.cpp	Tue Feb 10 01:47:12 2009 +0900
@@ -9,31 +9,43 @@
     Pad *pad = sgroot->getController();
     CameraPtr node = (CameraPtr)_node;
 
-    if (pad->r2.isHold()) {
-	node->angle[1] += 2.0f;
-	if (node->angle[1] > 360.0f) {
-	    node->angle[1] -= 360.0f;
-	}
-    } else if (pad->l2.isHold()) {
-	node->angle[1] -= 2.0f;
-	if (node->angle[1] < 0.0f) {
-	    node->angle[1] += 360.0f;
-	}
+    if (pad->right.isHold()) {
+	node->xyz[0] += 10.0f;
+    } else if (pad->left.isHold()) {
+	node->xyz[0] -= 10.0f;
     }
 
-#if 0
     if (pad->up.isPush() || pad->up.isHold()) {
 	node->xyz[1] += 2.0f;
     } else if (pad->down.isPush() || pad->down.isHold()) {
 	node->xyz[1] -= 2.0f;
     }
-#endif
 
     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;
+    }
+
 }
 
 static void
@@ -42,7 +54,11 @@
 {
 }
 
-Camera::Camera(void)
+/**
+ * @param w Width of screen
+ * @param h Height of screen
+ */
+Camera::Camera(float w, float h)
 {
     name = (const char*)"Camera";
 
@@ -60,21 +76,34 @@
     near = 0.0f;
     far  = 1000.0f;
 
-    //xyz[0] = 320.0f;
-    //xyz[1] = 240.0f;
-    //xyz[2] = -100.0f;
-    //xyz[3] = 1.0f;
+    m_view = new float[16];
+    m_pers = new float[16];
+    m_screen = new float[16];
+
+    // Screen の真ん中を初期値とする
+    xyz[0] = w/2.0f;
+    xyz[1] = h/2.0f;
+
+    // min(w, h) がちょうど一杯見えるような z の位置の計算
+    xyz[2] = -(((xyz[1] < xyz[0]) ? xyz[1] : xyz[0])/tanf((fov/2.0f)*M_PI/180.0f));
+    xyz[3] = 1.0f;
     
     this->set_move_collision(camera_move, camera_collision);
 }
 
+Camera::~Camera(void)
+{
+    delete [] m_view;
+    delete [] m_pers;
+    delete [] m_screen;
+}
+
 void
-Camera::createRotMatrix(float *m)
+Camera::updateView(void)
 {
     float radx,rady,radz;
-    float cx[4], cy[4], cz[4];
-    float p[4];
-    float *matrix = new float[16];
+    float cx[4], cy[4], cz[4], p[4];
+    float tm[16];
 
     radx = angle[0]*3.14/180;
     rady = angle[1]*3.14/180;
@@ -88,145 +117,130 @@
     float cosz = cos(radz);
 
     /* View Transform */
-    matrix[0] = cosz*cosy+sinz*sinx*siny;
-    matrix[1] = sinz*cosx;
-    matrix[2] = -cosz*siny+sinz*sinx*cosy;
-    matrix[3] = 0.0f;
-    matrix[4] = -sinz*cosy+cosz*sinx*siny;
-    matrix[5] = cosz*cosx;
-    matrix[6] = sinz*siny+cosz*sinx*cosy;
-    matrix[7] = 0.0f;
-    matrix[8] = cosx*siny;
-    matrix[9] = -sinx;
-    matrix[10] = cosx*cosy;
-    matrix[11] = 0.0f;
-    matrix[12] = 0.0f;
-    matrix[13] = 0.0f;
-    matrix[14] = 0.0f;
-    matrix[15] = 1.0f;
+    tm[0] = cosz*cosy+sinz*sinx*siny;
+    tm[1] = sinz*cosx;
+    tm[2] = -cosz*siny+sinz*sinx*cosy;
+    tm[3] = 0.0f;
+    tm[4] = -sinz*cosy+cosz*sinx*siny;
+    tm[5] = cosz*cosx;
+    tm[6] = sinz*siny+cosz*sinx*cosy;
+    tm[7] = 0.0f;
+    tm[8] = cosx*siny;
+    tm[9] = -sinx;
+    tm[10] = cosx*cosy;
+    tm[11] = 0.0f;
+    tm[12] = 0.0f;
+    tm[13] = 0.0f;
+    tm[14] = 0.0f;
+    tm[15] = 1.0f;
 
-    applyMatrix(cz, matrix, zd);
-    applyMatrix(cy, matrix, yd);
-    applyMatrix(p, matrix, xyz);
-
-    // matrix 使い回すためにクリア
-    unitMatrix(matrix);
+    applyMatrix(cz, tm, zd);
+    applyMatrix(cy, tm, yd);
+    applyMatrix(p, tm, xyz);
 
     outerProduct(cx, cy, cz);
-    normalize(&matrix[0], cx);
-    normalize(&matrix[8], cz);
-    outerProduct(&matrix[4], &matrix[8], &matrix[0]);
-    transMatrix(matrix, matrix, p);
-    inversMatrix(m, matrix);
+    normalize(cx, cx);
+    normalize(cz, cz);
+    outerProduct(cy, cz, cx);
+
+    m_view[ 0] = cx[0];
+    m_view[ 1] = cy[0];
+    m_view[ 2] = cz[0];
+    m_view[ 3] = 0.0f;
+
+    m_view[ 4] = cx[1];
+    m_view[ 5] = cy[1];
+    m_view[ 6] = cz[1];
+    m_view[ 7] = 0.0f;
+
+    m_view[ 8] = cx[2];
+    m_view[ 9] = cy[2];
+    m_view[10] = cz[2];
+    m_view[11] = 0.0f;
+
+    m_view[12] = innerProduct(xyz, cx)*(-1);
+    m_view[13] = innerProduct(xyz, cy)*(-1);
+    m_view[14] = innerProduct(xyz, cz)*(-1);
+    m_view[15] = 1.0f;
 }
 
 void
-Camera::createViewTransformMatrix(float *view, float *cx, float *cy, float *cz)
+Camera::updatePerspective(float w, float h)
 {
-    view[ 0] = cx[0];
-    view[ 1] = cy[0];
-    view[ 2] = cz[0];
-    view[ 3] = 0.0f;
+    float sx, sy, sz;
+    float aspect = w/h;
+
+    sy = (1.0f/tanf((fov/2.0f)*M_PI/180.0f));
+    sx = sy/aspect;
+    //sz = far/(far+near);
+    sz = far/(far-near);
+
+    m_pers[ 0] = sx;
+    m_pers[ 1] = 0.0f;
+    m_pers[ 2] = 0.0f;
+    m_pers[ 3] = 0.0f;
 
-    view[ 4] = cx[1];
-    view[ 5] = cy[1];
-    view[ 6] = cz[1];
-    view[ 7] = 0.0f;
+    m_pers[ 4] = 0.0f;
+    m_pers[ 5] = sy;
+    m_pers[ 6] = 0.0f;
+    m_pers[ 7] = 0.0f;
 
-    view[ 8] = cx[2];
-    view[ 9] = cy[2];
-    view[10] = cz[2];
-    view[11] = 0.0f;
+    m_pers[ 8] = 0.0f;
+    m_pers[ 9] = 0.0f;
+    m_pers[10] = sz;
+    m_pers[11] = 1.0f;
 
-    view[12] = innerProduct(xyz, cx)*(-1);
-    view[13] = innerProduct(xyz, cy)*(-1);
-    view[14] = innerProduct(xyz, cz)*(-1);
-    view[15] = 1.0f;
+    m_pers[12] = 0.0f;
+    m_pers[13] = 0.0f;
+    m_pers[14] = -near*sz;
+    m_pers[15] = 0.0f;
 }
 
 void
-Camera::createPerspectiveTransformMatrix(float *pm, float aspect)
-{
-    float sx, sy, sz;
-
-    sy = 1.0f/tanf((fov/2.0f)*M_PI/180.0f);
-    sx = sy / aspect;
-    sz = far/(far+near);
-
-    pm[ 0] = sx;
-    pm[ 1] = 0.0f;
-    pm[ 2] = 0.0f;
-    pm[ 3] = 0.0f;
-
-    pm[ 4] = 0.0f;
-    pm[ 5] = sy;
-    pm[ 6] = 0.0f;
-    pm[ 7] = 0.0f;
-
-    pm[ 8] = 0.0f;
-    pm[ 9] = 0.0f;
-    pm[10] = sz;
-    pm[11] = -near*sz;
-
-    pm[12] = 0.0f;
-    pm[13] = 0.0f;
-    pm[14] = -1.0f;
-    pm[15] = 0.0f;
-}
-
-void
-Camera::createScreenTransformMatrix(float *sm, float _w, float _h)
+Camera::updateScreen(float _w, float _h)
 {
     float w = _w/2.0f;
     float h = _h/2.0f;
-    float r = far/(far-near);
 
-    sm[ 0] = w;
-    sm[ 1] = 0.0f;
-    sm[ 2] = 0.0f;
-    sm[ 3] = 0.0f;
+    m_screen[ 0] = w;
+    m_screen[ 1] = 0.0f;
+    m_screen[ 2] = 0.0f;
+    m_screen[ 3] = 0.0f;
 
-    sm[ 4] = 0.0f;
-    sm[ 5] = h;
-    sm[ 6] = 0.0f;
-    sm[ 7] = 0.0f;
+    m_screen[ 4] = 0.0f;
+    m_screen[ 5] = h;
+    m_screen[ 6] = 0.0f;
+    m_screen[ 7] = 0.0f;
 
-    sm[ 8] = 0.0f;
-    sm[ 9] = 0.0f;
-    sm[10] = 1.0f;
-    sm[11] = 0.0f;
+    m_screen[ 8] = 0.0f;
+    m_screen[ 9] = 0.0f;
+    m_screen[10] = 1.0f;
+    m_screen[11] = 0.0f;
 
-    sm[12] = w;
-    sm[13] = h;
-    sm[14] = 0.0f;
-    sm[15] = 1.0f;    
+    m_screen[12] = w;
+    m_screen[13] = h;
+    m_screen[14] = 0.0f;
+    m_screen[15] = 1.0f;    
 }
 
 void
 Camera::setCamera(float *pose)
 {
-    memcpy(xyz, &pose[12], sizeof(float)*4);
+    //memcpy(xyz, &pose[12], sizeof(float)*4);
 }
 
 void
-Camera::update(int w, int h)
+Camera::update(float w, float h)
 {
-#if 0
-    // うーん。。。
-    float view[16]; // view transform matrix
-    float pers[16]; // perspective transform matrix
-    float screen[16]; // screen transform matrix
+#if 1
     float tmp[16];
 
-    // view tansform
-    createRotMatrix(view);
-    createPerspectiveTransformMatrix(pers, (float)w/(float)h);
-    createScreenTransformMatrix(screen, (float)w, (float)h);
+    updateView();
+    updatePerspective(w, h);
+    updateScreen(w, h);
     
-    matrix4x4(tmp, view, pers);
-    matrix4x4(matrix, tmp, screen);
-    //matrix4x4(tmp, pers, view);
-    //matrix4x4(matrix, screen, tmp);
+    matrix4x4(tmp, this->m_pers, this->m_screen);
+    matrix4x4(this->matrix, this->m_view, tmp);
 #else
     get_matrix(matrix, angle, xyz, NULL);
 #endif
--- a/TaskManager/Test/test_render/Camera.h	Mon Feb 09 21:58:45 2009 +0900
+++ b/TaskManager/Test/test_render/Camera.h	Tue Feb 10 01:47:12 2009 +0900
@@ -7,7 +7,8 @@
 
 class Camera : public SceneGraph {
 public:
-    Camera(void);
+    Camera(float w = 640, float h = 480);
+    ~Camera(void);
 
     float zd[4]; // direction z
     float yd[4]; // direction y
@@ -15,14 +16,16 @@
     float near;
     float far;
 
-    void createRotMatrix(float *m);
-    void createViewTransformMatrix(float*, float*, float*, float*);
-    void createPerspectiveTransformMatrix(float *, float);
-    void createScreenTransformMatrix(float *sm, float _w, float _h);
+    float *m_view;
+    float *m_pers;
+    float *m_screen;
 
+    void updateView(void);
+    void updatePerspective(float w, float h);
+    void updateScreen(float w, float h);
 
     void setCamera(float *pose);
-    void update(int screen_w, int screen_h);
+    void update(float screen_w, float screen_h);
 };
 
 typedef Camera *CameraPtr;
--- a/TaskManager/Test/test_render/ChangeLog	Mon Feb 09 21:58:45 2009 +0900
+++ b/TaskManager/Test/test_render/ChangeLog	Tue Feb 10 01:47:12 2009 +0900
@@ -1,3 +1,24 @@
+2009-02-10  Wataru MIYAGUNI  <gongo@cr.ie.u-ryukyu.ac.jp>
+
+	* Makefile.macosx (depend): fix
+	depend.inc とかを吐き出す様にしました
+
+	* Camera.cpp (Camera::Camera, Camera::updateView)
+	(Camera::updatePerspective, Camera::updateScreen)
+	(Camera::update): fix
+	なんとかカメラできてるっぽいです。
+	Perspective とかも聞いてるし、中心に向かって遠くなってる。
+	あとは行列演算をもうちょいこぎれいにすればいい感じかなー。
+
+	残りは、ユーザ側からの設定。例えば
+	1. 車の運転席目線(FPS)
+	2. 車の後ろから(TPS)
+	3. 車の前から(SPS)
+
+	的なのを、ユーザが CameraData みたいな構造体に
+	zd とか yd とかを設定して camera->set(data) とかやれば
+	反映するみたいな!みたいな!
+	
 2009-02-09  Wataru MIYAGUNI  <gongo@cr.ie.u-ryukyu.ac.jp>
 
 	* SceneGraphRoot.cpp (SceneGraphRoot::allExecute)
--- a/TaskManager/Test/test_render/Joystick.cpp	Mon Feb 09 21:58:45 2009 +0900
+++ b/TaskManager/Test/test_render/Joystick.cpp	Tue Feb 10 01:47:12 2009 +0900
@@ -22,7 +22,7 @@
 static const int SQUARE   = 15;
 static const int PS       = 16;
 
-#if 0
+#if 0 // PS2 コントローラ
 static const int CROSS = 0;
 static const int CIRCLE = 1;
 static const int SQUARE = 2;
@@ -48,6 +48,11 @@
     joy = j;
 }
 
+Joystick::~Joystick(void)
+{
+    SDL_JoystickClose(joy);    
+}
+
 void
 Joystick::check(void)
 {
@@ -171,9 +176,3 @@
 	down.release_work();
     }
 }
-
-void
-Joystick::close(void)
-{
-    SDL_JoystickClose(joy);
-}
--- a/TaskManager/Test/test_render/Joystick.h	Mon Feb 09 21:58:45 2009 +0900
+++ b/TaskManager/Test/test_render/Joystick.h	Tue Feb 10 01:47:12 2009 +0900
@@ -1,6 +1,8 @@
 #ifndef INCLUDED_JOYSTICK
 #define INCLUDED_JOYSTICK
 
+#include "SDL.h"
+
 #ifndef INCLUDED_PAD
 #  include "Pad.h"
 #endif
@@ -11,9 +13,9 @@
     Sint16 axis;
 
     Joystick(SDL_Joystick *j);
+    ~Joystick(void);
 
     void check(void);
-    void close(void);
 };
 
 #endif
--- a/TaskManager/Test/test_render/Makefile	Mon Feb 09 21:58:45 2009 +0900
+++ b/TaskManager/Test/test_render/Makefile	Tue Feb 10 01:47:12 2009 +0900
@@ -18,10 +18,13 @@
 ps3-depend: FORCE
 	@$(MAKE) -f Makefile.ps3 depend
 
+linux-depend: FORCE
+	@$(MAKE) -f Makefile.linux depend
+
 FORCE:
 
 clean:
 	@$(MAKE) -f Makefile.macosx clean
 	@$(MAKE) -f Makefile.ps3 clean
 	@$(MAKE) -f Makefile.linux clean
-
+	rm -f depend.inc
\ No newline at end of file
--- a/TaskManager/Test/test_render/Makefile.def	Mon Feb 09 21:58:45 2009 +0900
+++ b/TaskManager/Test/test_render/Makefile.def	Tue Feb 10 01:47:12 2009 +0900
@@ -3,10 +3,10 @@
 # include/library path
 # ex: macosx
 #CERIUM = /Users/gongo/Source/Concurrency/Game_project/Cerium
-#CERIUM = /Users/gongo/Source/hg/Cerium
+CERIUM = /Users/gongo/Source/hg/Cerium
 
 # ex: linux/ps3
-CERIUM = /home/gongo/Cerium
+#CERIUM = /home/gongo/Cerium
 #CERIUM = /Users/tkaito/hg/Game/Cerium
 
 #CERIUM = ../../..
--- a/TaskManager/Test/test_render/Makefile.linux	Mon Feb 09 21:58:45 2009 +0900
+++ b/TaskManager/Test/test_render/Makefile.linux	Tue Feb 10 01:47:12 2009 +0900
@@ -32,6 +32,10 @@
 debug: $(TARGET)
 	sudo ppu-gdb ./$(TARGET) 
 
+depend:
+	$(RM) depend.inc
+	$(CC) -MM -MG $(INCLUDE) $(CFLAGS) $(SRCS) $(TASK_SRCS) > depend.inc
+
 clean:
 	rm -f $(TARGET) $(OBJS) $(TASK_OBJS)
 	rm -f *~ \#*
\ No newline at end of file
--- a/TaskManager/Test/test_render/Makefile.macosx	Mon Feb 09 21:58:45 2009 +0900
+++ b/TaskManager/Test/test_render/Makefile.macosx	Tue Feb 10 01:47:12 2009 +0900
@@ -13,7 +13,6 @@
 
 LIBS += -lFifoManager
 
-
 CFLAGS += `sdl-config --cflags` `xml2-config --cflags`
 LIBS   += `sdl-config --libs` `xml2-config --libs` -lSDL_image -Wl,-framework,OpenGL
 
@@ -33,6 +32,12 @@
 debug: $(TARGET)
 	sudo ppu-gdb ./$(TARGET) 
 
+depend:
+	$(RM) depend.inc
+	$(CC) -MM -MG $(INCLUDE) $(CFLAGS) $(SRCS) $(TASK_SRCS) > depend.inc
+
 clean:
 	rm -f $(TARGET) $(OBJS) $(TASK_OBJS)
-	rm -f *~ \#*
\ No newline at end of file
+	rm -f *~ \#*
+
+-include depend.inc
\ No newline at end of file
--- a/TaskManager/Test/test_render/Makefile.ps3	Mon Feb 09 21:58:45 2009 +0900
+++ b/TaskManager/Test/test_render/Makefile.ps3	Tue Feb 10 01:47:12 2009 +0900
@@ -36,7 +36,8 @@
 	sudo ppu-gdb ./$(TARGET) 
 
 depend:
-	makedepend -- $(CFLAGS)	$(LIBS) $(INCLUDE) -- $(SRCS) $(TASK_SRCS)
+	$(RM) depend.inc
+	$(CC) -MM -MG $(INCLUDE) $(CFLAGS) $(SRCS) $(TASK_SRCS) > depend.inc
 
 clean:
 	rm -f $(TARGET) $(OBJS) $(TASK_OBJS)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/Test/test_render/Pad.cpp	Tue Feb 10 01:47:12 2009 +0900
@@ -0,0 +1,26 @@
+#include <stdio.h>
+#include "Keyboard.h"
+#include "Joystick.h"
+
+/**
+ * Joystick があればそれを使い、
+ * 無ければキーボードを返す
+ */
+Pad*
+create_controller(void)
+{
+    if (SDL_NumJoysticks()) {
+	SDL_Joystick *joy = SDL_JoystickOpen(0);
+	if (!joy) {
+	    printf("%s: failed to open joystick", __FUNCTION__);
+	    printf("Instead use Keyboard\n");
+	    return new Keyboard;
+	} else {
+	    printf("Use Joystick\n");
+	    return new Joystick(joy);
+	}
+    } else {
+	printf("Use Keyboard\n");
+	return new Keyboard;
+    }
+}
--- a/TaskManager/Test/test_render/Pad.h	Mon Feb 09 21:58:45 2009 +0900
+++ b/TaskManager/Test/test_render/Pad.h	Tue Feb 10 01:47:12 2009 +0900
@@ -29,7 +29,8 @@
 
     virtual ~Pad(void) {}
     virtual void check(void) = 0;
-    virtual void close(void) {}
 };
 
 #endif
+
+extern Pad *create_controller(void);
--- a/TaskManager/Test/test_render/SceneGraphRoot.cpp	Mon Feb 09 21:58:45 2009 +0900
+++ b/TaskManager/Test/test_render/SceneGraphRoot.cpp	Tue Feb 10 01:47:12 2009 +0900
@@ -10,11 +10,12 @@
 
 int cnt = 0;
 
-SceneGraphRoot::SceneGraphRoot(void)
+SceneGraphRoot::SceneGraphRoot(float w, float h)
 {
     sg_src = new SceneGraphPtr[SGLIST_LENGTH];
-    camera = new Camera;
+    camera = new Camera(w, h);
     iterator = new SceneGraphIterator;
+    controller = create_controller();
 
     sg_exec_tree = NULL;
     sg_draw_tree = NULL;
@@ -50,6 +51,7 @@
     delete [] sg_src;
     delete camera;
     delete iterator;
+    delete controller;
 }
 
 /**
@@ -176,7 +178,7 @@
     sg_exec_tree = NULL;
     sg_available_list = NULL;
 
-    //camera->move_execute(screen_w, screen_h);
+    camera->move_execute(screen_w, screen_h);
     camera->update(screen_w, screen_h);
 
     camera->children = NULL;
--- a/TaskManager/Test/test_render/SceneGraphRoot.h	Mon Feb 09 21:58:45 2009 +0900
+++ b/TaskManager/Test/test_render/SceneGraphRoot.h	Tue Feb 10 01:47:12 2009 +0900
@@ -16,7 +16,7 @@
 class SceneGraphRoot {
 public:
     /* Constructor, Destructor */
-    SceneGraphRoot(void);
+    SceneGraphRoot(float w, float h);
     ~SceneGraphRoot(void);
 
     /* Variables */
--- a/TaskManager/Test/test_render/panel.cpp	Mon Feb 09 21:58:45 2009 +0900
+++ b/TaskManager/Test/test_render/panel.cpp	Tue Feb 10 01:47:12 2009 +0900
@@ -33,5 +33,6 @@
     }
 
     panel->set_move_collision(panel_move, panel_collision);
+    panel->xyz[2] = 30.0f;
     sgroot->setSceneData(panel);
 }
--- a/TaskManager/Test/test_render/task/CreatePolygonFromSceneGraph.cpp	Mon Feb 09 21:58:45 2009 +0900
+++ b/TaskManager/Test/test_render/task/CreatePolygonFromSceneGraph.cpp	Tue Feb 10 01:47:12 2009 +0900
@@ -123,7 +123,7 @@
 		ApplyMatrix(xyz2, sg->matrix);
 		ApplyMatrix(xyz3, sg->matrix);
 
-#if 0
+#if 1
 		xyz1[0] /= xyz1[2];
 		xyz1[1] /= xyz1[2];
 		xyz2[0] /= xyz2[2];
--- a/TaskManager/Test/test_render/task/DrawSpan.cpp	Mon Feb 09 21:58:45 2009 +0900
+++ b/TaskManager/Test/test_render/task/DrawSpan.cpp	Tue Feb 10 01:47:12 2009 +0900
@@ -315,8 +315,8 @@
     tex_xpos = (int)((span->tex_width-1) * tex);
     tex_ypos = (int)((span->tex_height-1) * tey);
 
-    //if (0 < zpos && zpos < zRow[localx + (rangex*localy)]) {
-    if (zpos < zRow[localx + (rangex*localy)]) {
+    if (0 < zpos && zpos < zRow[localx + (rangex*localy)]) {
+	//if (zpos < zRow[localx + (rangex*localy)]) {
 	tex_addr = getTile(tex_xpos, tex_ypos,
 			   span->tex_width, span->tex_addr);
 	tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
@@ -378,8 +378,8 @@
 	localx = getLocalX(x-1+j);
 	tex_z = zpos1*(x_len-1-j)/(x_len-1) + zpos2*j/(x_len-1);
 		    
-	//if (0 < tex_z && tex_z < zRow[localx + (rangex*localy)]) {
-	if (tex_z < zRow[localx + (rangex*localy)]) {
+	if (0 < tex_z && tex_z < zRow[localx + (rangex*localy)]) {
+	    //if (tex_z < zRow[localx + (rangex*localy)]) {
 	    // (tex_xpos, tex_ypos) の、Tile 内(上の図参照)での座標と
 	    // そのブロックのアドレス(MainMemory)
 	    uint32 *tex_addr;
@@ -484,8 +484,8 @@
 	tex_xpos = (int)((span->tex_width-1) * tex_x);
 	tex_ypos = (int)((span->tex_height-1) * tex_y);
 
-	//if (0 < tex_z && tex_z < zRow[localx + (rangex*localy)]) {
-	if (tex_z < zRow[localx + (rangex*localy)]) {
+	if (0 < tex_z && tex_z < zRow[localx + (rangex*localy)]) {
+	    //if (tex_z < zRow[localx + (rangex*localy)]) {
 	    tex_addr = getTile(tex_xpos, tex_ypos,
 			       span->tex_width, span->tex_addr);
 	    tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
--- a/TaskManager/Test/test_render/viewer.cpp	Mon Feb 09 21:58:45 2009 +0900
+++ b/TaskManager/Test/test_render/viewer.cpp	Tue Feb 10 01:47:12 2009 +0900
@@ -8,9 +8,8 @@
 #include "Func.h"
 #include "error.h"
 #include "TaskManager.h"
-#include "Keyboard.h"
-#include "Joystick.h"
 #include <wchar.h>
+#include "Pad.h"
 
 
 extern void post2runLoop(void *);
@@ -36,30 +35,6 @@
  *
  */
 
-/**
- * Joystick があればそれを使い、
- * 無ければキーボードを返す
- */
-static Pad*
-create_controller(void)
-{
-    if (SDL_NumJoysticks()) {
-	SDL_Joystick *joy = SDL_JoystickOpen(0);
-	if (!joy) {
-	    printf("%s: failed to open joystick", __FUNCTION__);
-	    printf("Instead use Keyboard\n");
-	    return new Keyboard;
-	} else {
-	    printf("Use Joystick\n");
-	    return new Joystick(joy);
-	}
-    } else {
-	printf("Use Keyboard\n");
-	return new Keyboard;
-    }
-}
-
-
 Viewer::Viewer(int b, int w, int h, int _num)
 {
     bpp = b;
@@ -128,7 +103,7 @@
     this_time  = 0;
     frames     = 0;
 
-    sgroot = new SceneGraphRoot;
+    sgroot = new SceneGraphRoot(this->width, this->height);
     //sgroot->createFromXMLFile(xml);
 
     switch (sg_number) {
@@ -164,8 +139,6 @@
 	break;
     }
 
-    sgroot->controller = create_controller();
-
     sgpack = (SceneGraphPack*)manager->allocate(sizeof(SceneGraphPack));
     sgpack->init();
     ppack  = (PolygonPack*)manager->allocate(sizeof(PolygonPack));
@@ -393,10 +366,6 @@
 	printf("%f FPS\n", (((float)frames)/(this_time-start_time))*1000.0);
     }
 
-    //scene_graph->delete_data();
-    //scene_graph->controller->close();
-    //delete scene_graph;
-
     delete sgroot;
 
     quit();