changeset 510:97e1b0346597

continue...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 12 Oct 2009 15:48:40 +0900
parents 8148c81d2660
children 997490a061ee
files Renderer/Engine/Application.cc Renderer/Engine/Application.h Renderer/Engine/MainLoop.h Renderer/Engine/Makefile Renderer/Engine/viewer.cc Renderer/Engine/viewer.h Renderer/Test/Makefile Renderer/Test/Makefile.def Renderer/Test/Makefile.macosx Renderer/Test/ball_bound.cc Renderer/Test/ball_bound.h
diffstat 11 files changed, 157 insertions(+), 101 deletions(-) [+]
line wrap: on
line diff
--- a/Renderer/Engine/Application.cc	Mon Oct 12 10:17:09 2009 +0900
+++ b/Renderer/Engine/Application.cc	Mon Oct 12 15:48:40 2009 +0900
@@ -1,84 +1,7 @@
 #include "Application.h"
 
-// void
-// Application::set_move_func(move_func new_move)
-// {
-//     this->move = new_move;
-// }
-
-// void
-// Application::set_move_coll(coll_func new_coll)
-// {
-//     this->coll = new_coll;
-// }
 
 Application::Application(){}
 Application::~Application(){}
-// void
-// Application::apply_property(PropertyPtr p, SceneGraphPtr sgptr)
-// {
-//     sgptr->xyz[0] = p->xyz[0];
-//     sgptr->xyz[1] = p->xyz[1];
-//     sgptr->xyz[2] = p->xyz[2];
-
-//     sgptr->angle[0] = p->angle[0];
-//     sgptr->angle[1] = p->angle[1];
-//     sgptr->angle[2] = p->angle[2];
-
-//     sgptr->frame++;
-
-// }
-
-SceneGraphPtr 
-Application::scenegraph_factory(void *p, int size)
-{
-    //SceneGraphPtr sgptr =  p->scenegraph;
-    //apply_property(p, sgptr);
-
-    return NULL;
-}
-
-SceneGraphPtr 
-Application::scenegraph_connector(void *p, int size, SceneGraphPtr sg,
-				  SceneGraphPtr sg_available_list)
-{
-//     SceneGraphPtr last = sg_available_list;
-
-//     if (!last) {
-// 	sg_available_list = sg;
-//     } else {
-// 	while (last->next) {
-// 	    last = last->next;
-// 	}
-// 	last->next = sg;
-// 	sg->prev = last;
-//     }
-
-//     PropertyPtr p_curent = (PropertyPtr)sg->propertyPtr;
-//     PropertyPtr p_parent = p[p_curent->parent_id];
-//     SceneGraphPtr s_parent = p_parent->scenegraph;
-
-//     /* childrenのリストの最後に加える (brother として)*/
-//     if (s_parent->lastChild != NULL) {
-//         SceneGraphPtr last = s_parent->lastChild;
-//         last->brother = sg;
-//     }
-
-//     s_parent->lastChild = sg;
-
-//     if (s_parent->children == NULL) {
-//         s_parent->children = sg;
-//     }
-
-//     sg->parent = s_parent;
-    return NULL;
-}
 
 
-void Application::init(TaskManager *manager, int w, int h) {
-}
-
-int Application::move_task_id() {
-    return move_task_id_;
-}
-
--- a/Renderer/Engine/Application.h	Mon Oct 12 10:17:09 2009 +0900
+++ b/Renderer/Engine/Application.h	Mon Oct 12 15:48:40 2009 +0900
@@ -3,24 +3,17 @@
 
 #include "SceneGraph.h"
 
-typedef void (*move_func)(SceneGraph* node, int screen_w, int screen_h);
-typedef void (*coll_func)(SceneGraph* node, int screen_w, int screen_h, SceneGraphPtr tree);
+class Viewer;
+
+typedef void (*Move_func)(SceneGraph* node, int screen_w, int screen_h);
+typedef void (*Coll_func)(SceneGraph* node, int screen_w, int screen_h, SceneGraphPtr tree);
 
 class Application {
 public:
     Application();
     virtual ~Application();
     
-    void *propertyPtr;
-    int property_size;
-	int move_task_id_;
-
-    int move_task_id();
-    void set_move_func(move_func move);
-    void set_coll_func(coll_func coll);
-    SceneGraphPtr scenegraph_factory(void *p, int size);
-    SceneGraphPtr scenegraph_connector(void *p, int size, SceneGraphPtr s, SceneGraphPtr sg_available_list);
-    virtual void init(TaskManager *manager, int w, int h) ;
+    virtual void init(Viewer *viewer, int w, int h)  = 0;
 
 };
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Engine/MainLoop.h	Mon Oct 12 15:48:40 2009 +0900
@@ -0,0 +1,8 @@
+
+
+
+class MainLoop {
+    virtual void mainLoop() = 0;
+};
+
+typedef MainLoop *MainLoopPtr;
--- a/Renderer/Engine/Makefile	Mon Oct 12 10:17:09 2009 +0900
+++ b/Renderer/Engine/Makefile	Mon Oct 12 15:48:40 2009 +0900
@@ -1,4 +1,4 @@
-default: macosx
+default: macosx FORCE
 
 macosx: 
 	@echo "Make for Mac OS X"
@@ -22,6 +22,9 @@
 	@$(MAKE) -f Makefile.linux depend
 
 FORCE:
+	-mkdir -p ../include/Cerium
+	rsync `find . -name Test -prune -or -name '*.h' -print` ../../include/Cerium
+
 
 clean:
 	@$(MAKE) -f Makefile.macosx clean
--- a/Renderer/Engine/viewer.cc	Mon Oct 12 10:17:09 2009 +0900
+++ b/Renderer/Engine/viewer.cc	Mon Oct 12 15:48:40 2009 +0900
@@ -102,7 +102,7 @@
 
     sgroot = new SceneGraphRoot(this->width, this->height);
 
-    app->init(manager, this->width, this->height);
+    app->init(this, this->width, this->height);
 
     mainLoop();
 }
--- a/Renderer/Engine/viewer.h	Mon Oct 12 10:17:09 2009 +0900
+++ b/Renderer/Engine/viewer.h	Mon Oct 12 15:48:40 2009 +0900
@@ -6,16 +6,17 @@
 #include "viewer_types.h"
 #include "TaskManager.h"
 #include "KeyStat.h"
-
+#include "MainLoop.h"
 #include "Application.h"
 
 
-class Viewer {
+class Viewer : MainLoop {
+
 public:
-    //Viewer(TaskManager *manager, int bpp, int width, int height, int spenum);
+
     Viewer(int bpp, int width, int height, int spenum);
 
-    virtual ~Viewer(void) {}
+    virtual ~Viewer() {}
 
     Application *app;
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Test/Makefile	Mon Oct 12 15:48:40 2009 +0900
@@ -0,0 +1,50 @@
+include ./Makefile.def
+
+
+TASK_DIR  = task
+TASK_SRCS_TMP = $(wildcard $(TASK_DIR)/*.cc)
+TASK_SRCS_EXCLUDE = 
+TASK_SRCS = $(filter-out $(TASK_SRCS_EXCLUDE),$(TASK_SRCS_TMP))
+TASK_OBJS = $(TASK_SRCS:.cc=.o)
+
+LIBS += -lFifoManager -lCerium
+
+CFLAGS += `sdl-config --cflags` `xml2-config --cflags`
+LIBS   += `sdl-config --libs` `xml2-config --libs` -lSDL_image -Wl,-framework,OpenGL
+
+.SUFFIXES: .cc .o
+
+.cc.o:
+	$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
+
+all: ball_bound
+
+ball_bound : ball_bound.o
+	$(CC) -o $@ $< $(LIBS)
+
+# SGList.o: create_sg_list
+# 	$(CC) $(CFLAGS) $(INCLUDE) -c SGList.cc -o $@
+
+create_sg_list:
+	@if [ ! -f SGList.h ]; then \
+		cd tools/;\
+		./create_sglist.pl ../xml_file/*.xml;\
+	fi
+
+
+run: $(TARGET)
+	sudo ./$(TARGET) -width 576 -height 384 -bpp 32
+
+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 *~ \#*
+	rm -f SGList.h SGList.cc
+
+-include depend.inc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Test/Makefile.def	Mon Oct 12 15:48:40 2009 +0900
@@ -0,0 +1,9 @@
+TARGET = libCerium.a
+
+CERIUM = ../..
+
+CC      = g++
+CFLAGS  = -O9 -g -Wall -DUSE_MEMLIST=1 -DUSE_MEMHASH=1 # -DDEBUG
+
+INCLUDE = -I$(CERIUM)/include/TaskManager -I. -I$(CERIUM)/include/Cerium
+LIBS = -L$(CERIUM)/TaskManager -L$(CERIUM)/Renderer/Engine
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Test/Makefile.macosx	Mon Oct 12 15:48:40 2009 +0900
@@ -0,0 +1,54 @@
+include ./Makefile.def
+
+SRCS_TMP = $(wildcard *.cc) $(wildcard Application/*.cc)
+SRCS_EXCLUDE =  # 
+SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP))
+OBJS = $(SRCS:.cc=.o)
+
+TASK_DIR  = task
+TASK_SRCS_TMP = $(wildcard $(TASK_DIR)/*.cc)
+TASK_SRCS_EXCLUDE = span_pack_draw.cc
+TASK_SRCS = $(filter-out $(TASK_SRCS_EXCLUDE),$(TASK_SRCS_TMP))
+TASK_OBJS = $(TASK_SRCS:.cc=.o)
+
+LIBS += -lFifoManager
+
+CFLAGS += `sdl-config --cflags` `xml2-config --cflags`
+LIBS   += `sdl-config --libs` `xml2-config --libs` -lSDL_image -Wl,-framework,OpenGL
+
+.SUFFIXES: .cc .o
+
+.cc.o:
+	$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
+
+all: $(TARGET)
+
+$(TARGET) : $(OBJS) $(TASK_OBJS)
+	$(AR) crus $@ $(OBJS) $(TASK_OBJS) 
+
+# SGList.o: create_sg_list
+# 	$(CC) $(CFLAGS) $(INCLUDE) -c SGList.cc -o $@
+
+create_sg_list:
+	@if [ ! -f SGList.h ]; then \
+		cd tools/;\
+		./create_sglist.pl ../xml_file/*.xml;\
+	fi
+
+
+run: $(TARGET)
+	sudo ./$(TARGET) -width 576 -height 384 -bpp 32
+
+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 *~ \#*
+	rm -f SGList.h SGList.cc
+
+-include depend.inc
--- a/Renderer/Test/ball_bound.cc	Mon Oct 12 10:17:09 2009 +0900
+++ b/Renderer/Test/ball_bound.cc	Mon Oct 12 15:48:40 2009 +0900
@@ -102,9 +102,8 @@
     }
 }
 
-
-void
-ball_bound_init(TaskManager *manager, int screen_w, int screen_h)
+MainLoopPtr 
+ball_bound::init(Viewer *viewer, int screen_w, int screen_h)
 {
     SceneGraphPtr ball;
 
@@ -112,8 +111,9 @@
     // random な値が欲しいなら、man random に方法が書いてあります。
     srandom(100);
 
-    sgroot->createFromXMLfile(manager, "xml_file/Ball.xml");
-    ball = sgroot->createSceneGraph(Ball);
+    viewer->createFromXMLfile("xml_file/Ball.xml");
+
+    ball = viewer->createSceneGraph(Ball);
     ball->set_move_collision(ball_move, ball_collision);
 
     h0 = screen_h/2;
@@ -124,5 +124,9 @@
     ball->xyz[1] = h0;
     ball->xyz[2] = 30.0f;
 
-    sgroot->setSceneData(ball);
+    viewer->setSceneData(ball);
+
+    return viewer;
 }
+
+/* end */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Test/ball_bound.h	Mon Oct 12 15:48:40 2009 +0900
@@ -0,0 +1,11 @@
+#include <math.h>
+#include <stdlib.h>
+#include "SceneGraphRoot.h"
+#include "Application.h"
+#include "MainLoop.h"
+
+class ball_bound : public Application {
+
+    MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
+
+}