Mercurial > hg > Members > kono > Cerium
changeset 507:735f76483bb2
Reorganization..
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 12 Oct 2009 09:39:35 +0900 |
parents | 1d4a8a86f26b |
children | f6daf964f483 |
files | Renderer/Application/Chain.h Renderer/Application/back_action.cc Renderer/Application/back_action.h Renderer/Application/ball_action.cc Renderer/Application/ball_action.h Renderer/Application/ball_bound.cc Renderer/Application/boss1_action.cc Renderer/Application/boss1_action.h Renderer/Application/bullet_action.cc Renderer/Application/bullet_action.h Renderer/Application/camera_action.cc Renderer/Application/camera_action.h Renderer/Application/chain.cc Renderer/Application/chain_old.cc Renderer/Application/cube.cc Renderer/Application/cube_action.cc Renderer/Application/demonstration.h Renderer/Application/direction.cc Renderer/Application/enemy_action.cc Renderer/Application/enemy_action.h Renderer/Application/game_over.cc Renderer/Application/gaplant.cc Renderer/Application/gaplant.h Renderer/Application/gaplant_action.cc Renderer/Application/gaplant_action.h Renderer/Application/hit_judge.cc Renderer/Application/hit_judge.h Renderer/Application/icon.png Renderer/Application/ieshoot.cc Renderer/Application/init_position.cc Renderer/Application/long_cube.cc Renderer/Application/node.cc Renderer/Application/panel.cc Renderer/Application/player_action.cc Renderer/Application/player_action.h Renderer/Application/title.cc Renderer/Application/universe.cc Renderer/Application/untitled.cc Renderer/Application/vacuum.cc Renderer/Application/vacuum.h Renderer/Cell/Engine.cpp Renderer/Cell/Engine.h Renderer/Cell/SceneGraph2PolygonTask.h Renderer/DataPack/DataPackEngine.cpp Renderer/DataPack/DataPackEngine.h Renderer/DataPack/Test/SpanPack/main.cpp Renderer/DataPack/Test/SpanPack/polygonpack.cpp Renderer/DataPack/Test/SpanPack/polygonpack.h Renderer/Engine/Application.cc Renderer/Engine/Application.h Renderer/Engine/Button.cc Renderer/Engine/Button.h Renderer/Engine/Camera.cc Renderer/Engine/Camera.h Renderer/Engine/ChangeLog Renderer/Engine/Func.h Renderer/Engine/Joystick.cc Renderer/Engine/Joystick.h Renderer/Engine/KeyStat.h Renderer/Engine/Keyboard.cc Renderer/Engine/Keyboard.h Renderer/Engine/Makefile Renderer/Engine/Makefile.cell Renderer/Engine/Makefile.def Renderer/Engine/Makefile.linux Renderer/Engine/Makefile.macosx Renderer/Engine/Pad.cc Renderer/Engine/Pad.h Renderer/Engine/SceneGraph.cc Renderer/Engine/SceneGraph.h Renderer/Engine/SceneGraphArray.h Renderer/Engine/SceneGraphIterator.cc Renderer/Engine/SceneGraphIterator.h Renderer/Engine/SceneGraphRoot.cc Renderer/Engine/SceneGraphRoot.h Renderer/Engine/Span.h Renderer/Engine/SpanC.cc Renderer/Engine/SpanC.h Renderer/Engine/SpanPack.h Renderer/Engine/TODO Renderer/Engine/Tapestry.h Renderer/Engine/TextureHash.cc Renderer/Engine/TextureHash.h Renderer/Engine/base64_de.cc Renderer/Engine/fb.h Renderer/Engine/global_alloc.h Renderer/Engine/hash_texture.h Renderer/Engine/lindaapi.cc Renderer/Engine/lindaapi.h Renderer/Engine/main.cc Renderer/Engine/polygon.cc Renderer/Engine/polygon.h Renderer/Engine/polygon_pack.h Renderer/Engine/post.cc Renderer/Engine/scene.h Renderer/Engine/scene_graph_pack.h Renderer/Engine/show_time.cc Renderer/Engine/show_time.h Renderer/Engine/spe/ChainCal.cc Renderer/Engine/spe/ChainCal.h Renderer/Engine/spe/ChainInit.cc Renderer/Engine/spe/ChainInit.h Renderer/Engine/spe/CreatePolygon.cc Renderer/Engine/spe/CreatePolygon.h Renderer/Engine/spe/CreateSpan.cc Renderer/Engine/spe/CreateSpan.h Renderer/Engine/spe/DrawBack.cc Renderer/Engine/spe/DrawBack.h Renderer/Engine/spe/DrawSpan.cc Renderer/Engine/spe/DrawSpan.h Renderer/Engine/spe/DrawSpanRenew.cc Renderer/Engine/spe/DrawSpanRenew.h Renderer/Engine/spe/InitKey.cc Renderer/Engine/spe/InitKey.h Renderer/Engine/spe/Load_Texture.cc Renderer/Engine/spe/Load_Texture.h Renderer/Engine/spe/Makefile Renderer/Engine/spe/Set_Texture.cc Renderer/Engine/spe/Set_Texture.h Renderer/Engine/spe/ShowTime.cc Renderer/Engine/spe/ShowTime.h Renderer/Engine/spe/TileHash.cc Renderer/Engine/spe/TileHash.h Renderer/Engine/spe/UpdateKey.cc Renderer/Engine/spe/UpdateKey.h Renderer/Engine/spe/spe-main.cc Renderer/Engine/spe/texture.h Renderer/Engine/spe/viewer_types.cc Renderer/Engine/sys.cc Renderer/Engine/sys.h Renderer/Engine/task/ChainMove.cc Renderer/Engine/task/ChainMove.h Renderer/Engine/task/CreatePolygon.cc Renderer/Engine/task/CreatePolygon.h Renderer/Engine/task/CreatePolygonFromSceneGraph.cc Renderer/Engine/task/CreatePolygonFromSceneGraph.h Renderer/Engine/task/CreateSpan.cc Renderer/Engine/task/CreateSpan.h Renderer/Engine/task/Draw.cc Renderer/Engine/task/Draw.h Renderer/Engine/task/DrawBack.cc Renderer/Engine/task/DrawBack.h Renderer/Engine/task/DrawSpan.cc Renderer/Engine/task/DrawSpan.h Renderer/Engine/task/DrawSpanRenew.cc Renderer/Engine/task/DrawSpanRenew.h Renderer/Engine/task/InitKey.cc Renderer/Engine/task/InitKey.h Renderer/Engine/task/Load_Texture.cc Renderer/Engine/task/Load_Texture.h Renderer/Engine/task/Move.cc Renderer/Engine/task/Move.h Renderer/Engine/task/SendKey.cc Renderer/Engine/task/SendKey.h Renderer/Engine/task/Set_Texture.cc Renderer/Engine/task/Set_Texture.h Renderer/Engine/task/ShowTime.cc Renderer/Engine/task/ShowTime.h Renderer/Engine/task/Switch.cc Renderer/Engine/task/Switch.h Renderer/Engine/task/TileHash.cc Renderer/Engine/task/TileHash.h Renderer/Engine/task/UpdateKey.cc Renderer/Engine/task/UpdateKey.h Renderer/Engine/task/create_sgp.cc Renderer/Engine/task/create_sgp.h Renderer/Engine/task/dummy.cc Renderer/Engine/task/dummy.h Renderer/Engine/task/task_init.cc Renderer/Engine/task/texture.h Renderer/Engine/task/update_sgp.cc Renderer/Engine/task/update_sgp.h Renderer/Engine/texture.cc Renderer/Engine/texture.h Renderer/Engine/tools/create_sglist.pl Renderer/Engine/triangle.cc Renderer/Engine/triangle.h Renderer/Engine/vertex.cc Renderer/Engine/vertex.h Renderer/Engine/viewer.cc Renderer/Engine/viewer.h Renderer/Engine/viewerFB.cc Renderer/Engine/viewerFB.h Renderer/Engine/viewerSDL.cc Renderer/Engine/viewerSDL.h Renderer/Engine/viewer_types.cc Renderer/Engine/viewer_types.h Renderer/Engine/xml.cc Renderer/Engine/xml.h Renderer/Engine/xml_file/Ball.h Renderer/Engine/xml_file/Ball.xml Renderer/Engine/xml_file/LongCube.h Renderer/Engine/xml_file/LongCube.xml Renderer/Engine/xml_file/Venus.h Renderer/Engine/xml_file/Venus.xml Renderer/Engine/xml_file/blast.h Renderer/Engine/xml_file/blast.xml Renderer/Engine/xml_file/blend/Ball.blend Renderer/Engine/xml_file/blend/LongCube.blend Renderer/Engine/xml_file/blend/blast.blend Renderer/Engine/xml_file/blend/boss1.blend Renderer/Engine/xml_file/blend/direction.blend Renderer/Engine/xml_file/blend/ieboss.blend Renderer/Engine/xml_file/blend/iejiki.blend Renderer/Engine/xml_file/blend/ietama.blend Renderer/Engine/xml_file/blend/images/ball.jpg Renderer/Engine/xml_file/blend/images/boss1_organ.png Renderer/Engine/xml_file/blend/images/icon.jpg Renderer/Engine/xml_file/blend/images/iejiki.jpg Renderer/Engine/xml_file/blend/images/ietama.jpg Renderer/Engine/xml_file/blend/images/laser_1.png Renderer/Engine/xml_file/blend/images/panel_1024.jpg Renderer/Engine/xml_file/blend/images/panel_2048.jpg Renderer/Engine/xml_file/blend/images/panel_512.jpg Renderer/Engine/xml_file/blend/images/player_idle.png Renderer/Engine/xml_file/blend/images/player_leftmove.png Renderer/Engine/xml_file/blend/images/player_rightmove.png Renderer/Engine/xml_file/blend/images/player_turntoleft.png Renderer/Engine/xml_file/blend/images/player_turntoright.png Renderer/Engine/xml_file/blend/images/redbomb_anim_0.png Renderer/Engine/xml_file/blend/images/redbomb_anim_1.png Renderer/Engine/xml_file/blend/images/redbomb_anim_2.png Renderer/Engine/xml_file/blend/images/redbomb_anim_3.png Renderer/Engine/xml_file/blend/images/redbomb_anim_4.png Renderer/Engine/xml_file/blend/images/redbomb_anim_5.png Renderer/Engine/xml_file/blend/images/redbomb_anim_6.png Renderer/Engine/xml_file/blend/images/redbomb_anim_7.png Renderer/Engine/xml_file/blend/p_shot.blend Renderer/Engine/xml_file/blend/panel_1024.blend Renderer/Engine/xml_file/blend/panel_2048.blend Renderer/Engine/xml_file/blend/panel_512.blend Renderer/Engine/xml_file/blend/player.blend Renderer/Engine/xml_file/boss1.h Renderer/Engine/xml_file/boss1.xml Renderer/Engine/xml_file/chain.h Renderer/Engine/xml_file/chain.xml Renderer/Engine/xml_file/cube.h Renderer/Engine/xml_file/cube.xml Renderer/Engine/xml_file/cube_big.h Renderer/Engine/xml_file/cube_big.xml Renderer/Engine/xml_file/cube_split.h Renderer/Engine/xml_file/cube_split.xml Renderer/Engine/xml_file/direction.h Renderer/Engine/xml_file/direction.xml Renderer/Engine/xml_file/gamecube.h Renderer/Engine/xml_file/gamecube.xml Renderer/Engine/xml_file/gameover.h Renderer/Engine/xml_file/gameover.xml Renderer/Engine/xml_file/gap_plane_test.h Renderer/Engine/xml_file/gap_plane_test.xml Renderer/Engine/xml_file/ieboss.h Renderer/Engine/xml_file/ieboss.xml Renderer/Engine/xml_file/iejiki.h Renderer/Engine/xml_file/iejiki.xml Renderer/Engine/xml_file/ietama.h Renderer/Engine/xml_file/ietama.xml Renderer/Engine/xml_file/mcube.xml Renderer/Engine/xml_file/p_shot.h Renderer/Engine/xml_file/p_shot.xml Renderer/Engine/xml_file/panel_1024.h Renderer/Engine/xml_file/panel_1024.xml Renderer/Engine/xml_file/panel_2048.h Renderer/Engine/xml_file/panel_2048.xml Renderer/Engine/xml_file/panel_512.h Renderer/Engine/xml_file/panel_512.xml Renderer/Engine/xml_file/player.h Renderer/Engine/xml_file/player.xml Renderer/Engine/xml_file/player1.xml Renderer/Engine/xml_file/sphere.h Renderer/Engine/xml_file/sphere.xml Renderer/Engine/xml_file/sphere_big.h Renderer/Engine/xml_file/sphere_big.xml Renderer/Engine/xml_file/title.xml Renderer/Engine/xml_file/universe.h Renderer/Engine/xml_file/universe.xml Renderer/Simple/SimpleEngine.cpp Renderer/Simple/SimpleEngine.h Renderer/test_render/Button.cpp Renderer/test_render/Button.h Renderer/test_render/Camera.cpp Renderer/test_render/Camera.h Renderer/test_render/ChangeLog Renderer/test_render/Func.h Renderer/test_render/Joystick.cpp Renderer/test_render/Joystick.h Renderer/test_render/Keyboard.cpp Renderer/test_render/Keyboard.h Renderer/test_render/Makefile Renderer/test_render/Makefile.def Renderer/test_render/Makefile.linux Renderer/test_render/Makefile.macosx Renderer/test_render/Makefile.ps3 Renderer/test_render/Pad.cpp Renderer/test_render/Pad.h Renderer/test_render/SGList.cpp Renderer/test_render/SGList.h Renderer/test_render/SceneGraph.cpp Renderer/test_render/SceneGraph.h Renderer/test_render/SceneGraphArray.h Renderer/test_render/SceneGraphIterator.cpp Renderer/test_render/SceneGraphIterator.h Renderer/test_render/SceneGraphRoot.cpp Renderer/test_render/SceneGraphRoot.h Renderer/test_render/Span.h Renderer/test_render/SpanC.cpp Renderer/test_render/SpanC.h Renderer/test_render/SpanPack.h Renderer/test_render/Tapestry.h Renderer/test_render/TextureHash.cpp Renderer/test_render/TextureHash.h Renderer/test_render/ball_bound.cpp Renderer/test_render/base64_de.cpp Renderer/test_render/boss1_action.cpp Renderer/test_render/boss1_action.h Renderer/test_render/bullet_action.cpp Renderer/test_render/bullet_action.h Renderer/test_render/camera_action.cpp Renderer/test_render/camera_action.h Renderer/test_render/cube_action.cpp Renderer/test_render/demonstration.h Renderer/test_render/direction.cpp Renderer/test_render/enemy_action.cpp Renderer/test_render/enemy_action.h Renderer/test_render/fb.h Renderer/test_render/hash_texture.h Renderer/test_render/hit_judge.cpp Renderer/test_render/hit_judge.h Renderer/test_render/icon.png Renderer/test_render/ieshoot.cpp Renderer/test_render/init_position.cpp Renderer/test_render/long_cube.cpp Renderer/test_render/main.cpp Renderer/test_render/node.cpp Renderer/test_render/panel.cpp Renderer/test_render/player_action.cpp Renderer/test_render/player_action.h Renderer/test_render/polygon.cpp Renderer/test_render/polygon.h Renderer/test_render/polygon_pack.h Renderer/test_render/post.cpp Renderer/test_render/renderer.xml Renderer/test_render/scene.h Renderer/test_render/scene_graph_pack.h Renderer/test_render/spe/CreatePolygon.cpp Renderer/test_render/spe/CreatePolygon.h Renderer/test_render/spe/CreateSpan.cpp Renderer/test_render/spe/CreateSpan.h Renderer/test_render/spe/DrawBack.cpp Renderer/test_render/spe/DrawBack.h Renderer/test_render/spe/DrawSpan.cpp Renderer/test_render/spe/DrawSpan.h Renderer/test_render/spe/DrawSpanRenew.cpp Renderer/test_render/spe/DrawSpanRenew.h Renderer/test_render/spe/Load_Texture.cpp Renderer/test_render/spe/Load_Texture.h Renderer/test_render/spe/Set_Texture.cpp Renderer/test_render/spe/Set_Texture.h Renderer/test_render/spe/TileHash.cpp Renderer/test_render/spe/TileHash.h Renderer/test_render/spe/spe-main.cpp Renderer/test_render/spe/texture.h Renderer/test_render/spe/viewer_types.cpp Renderer/test_render/sys.cpp Renderer/test_render/sys.h Renderer/test_render/task/CreatePolygon.cpp Renderer/test_render/task/CreatePolygon.h Renderer/test_render/task/CreatePolygonFromSceneGraph.cpp Renderer/test_render/task/CreatePolygonFromSceneGraph.h Renderer/test_render/task/CreateSpan.cpp Renderer/test_render/task/CreateSpan.h Renderer/test_render/task/DrawBack.cpp Renderer/test_render/task/DrawBack.h Renderer/test_render/task/DrawSpan.cpp Renderer/test_render/task/DrawSpan.h Renderer/test_render/task/DrawSpanRenew.cpp Renderer/test_render/task/DrawSpanRenew.h Renderer/test_render/task/Load_Texture.cpp Renderer/test_render/task/Load_Texture.h Renderer/test_render/task/Set_Texture.cpp Renderer/test_render/task/Set_Texture.h Renderer/test_render/task/TileHash.cpp Renderer/test_render/task/TileHash.h Renderer/test_render/task/create_sgp.cpp Renderer/test_render/task/create_sgp.hpp Renderer/test_render/task/dummy.cpp Renderer/test_render/task/dummy.hpp Renderer/test_render/task/task_init.cpp Renderer/test_render/task/texture.h Renderer/test_render/task/update_sgp.cpp Renderer/test_render/task/update_sgp.hpp Renderer/test_render/texture.cpp Renderer/test_render/texture.h Renderer/test_render/tools/create_sglist.pl Renderer/test_render/triangle.cpp Renderer/test_render/triangle.h Renderer/test_render/universe.cpp Renderer/test_render/untitled.cpp Renderer/test_render/vacuum.cpp Renderer/test_render/vertex.cpp Renderer/test_render/vertex.h Renderer/test_render/viewer.cpp Renderer/test_render/viewer.h Renderer/test_render/viewerFB.cpp Renderer/test_render/viewerFB.h Renderer/test_render/viewerSDL.cpp Renderer/test_render/viewerSDL.h Renderer/test_render/viewer_types.cpp Renderer/test_render/viewer_types.h Renderer/test_render/xml.cpp Renderer/test_render/xml.h Renderer/test_render/xml_file/Ball.h Renderer/test_render/xml_file/Ball.xml Renderer/test_render/xml_file/LongCube.h Renderer/test_render/xml_file/LongCube.xml Renderer/test_render/xml_file/Venus.h Renderer/test_render/xml_file/Venus.xml Renderer/test_render/xml_file/blast.h Renderer/test_render/xml_file/blast.xml Renderer/test_render/xml_file/blend/Ball.blend Renderer/test_render/xml_file/blend/LongCube.blend Renderer/test_render/xml_file/blend/direction.blend Renderer/test_render/xml_file/blend/ieboss.blend Renderer/test_render/xml_file/blend/iejiki.blend Renderer/test_render/xml_file/blend/ietama.blend Renderer/test_render/xml_file/blend/images/ball.jpg Renderer/test_render/xml_file/blend/images/icon.jpg Renderer/test_render/xml_file/blend/images/iejiki.jpg Renderer/test_render/xml_file/blend/images/ietama.jpg Renderer/test_render/xml_file/blend/images/panel_1024.jpg Renderer/test_render/xml_file/blend/images/panel_2048.jpg Renderer/test_render/xml_file/blend/images/panel_512.jpg Renderer/test_render/xml_file/blend/panel_1024.blend Renderer/test_render/xml_file/blend/panel_2048.blend Renderer/test_render/xml_file/blend/panel_512.blend Renderer/test_render/xml_file/boss1.h Renderer/test_render/xml_file/boss1.xml Renderer/test_render/xml_file/cube.h Renderer/test_render/xml_file/cube.xml Renderer/test_render/xml_file/cube_big.h Renderer/test_render/xml_file/cube_big.xml Renderer/test_render/xml_file/cube_split.h Renderer/test_render/xml_file/cube_split.xml Renderer/test_render/xml_file/direction.h Renderer/test_render/xml_file/direction.xml Renderer/test_render/xml_file/ieboss.h Renderer/test_render/xml_file/ieboss.xml Renderer/test_render/xml_file/iejiki.h Renderer/test_render/xml_file/iejiki.xml Renderer/test_render/xml_file/ietama.h Renderer/test_render/xml_file/ietama.xml Renderer/test_render/xml_file/mcube.xml Renderer/test_render/xml_file/p_shot.h Renderer/test_render/xml_file/p_shot.xml Renderer/test_render/xml_file/panel_1024.h Renderer/test_render/xml_file/panel_1024.xml Renderer/test_render/xml_file/panel_2048.h Renderer/test_render/xml_file/panel_2048.xml Renderer/test_render/xml_file/panel_512.h Renderer/test_render/xml_file/panel_512.xml Renderer/test_render/xml_file/player.h Renderer/test_render/xml_file/player.xml Renderer/test_render/xml_file/sphere.h Renderer/test_render/xml_file/sphere.xml Renderer/test_render/xml_file/sphere_big.h Renderer/test_render/xml_file/sphere_big.xml Renderer/test_render/xml_file/universe.h Renderer/test_render/xml_file/universe.xml TaskManager/Test/simple_pack/Makefile TaskManager/Test/simple_pack/base64_de.cpp TaskManager/Test/simple_pack/cube-p.xml TaskManager/Test/simple_pack/cube.h TaskManager/Test/simple_pack/cube.xml TaskManager/Test/simple_pack/cube_tes.xml TaskManager/Test/simple_pack/cylinder.xml TaskManager/Test/simple_pack/demonstration.h TaskManager/Test/simple_pack/fb.cpp TaskManager/Test/simple_pack/icon.png TaskManager/Test/simple_pack/main.cpp TaskManager/Test/simple_pack/out.txt TaskManager/Test/simple_pack/pad.h TaskManager/Test/simple_pack/panel.xml TaskManager/Test/simple_pack/panel_texture.xml TaskManager/Test/simple_pack/polygon.cpp TaskManager/Test/simple_pack/polygon.h TaskManager/Test/simple_pack/polygon_pack.h TaskManager/Test/simple_pack/scene.h TaskManager/Test/simple_pack/scene_graph_pack.h TaskManager/Test/simple_pack/span.cpp TaskManager/Test/simple_pack/span.h TaskManager/Test/simple_pack/span_pack.h TaskManager/Test/simple_pack/spu_span.h TaskManager/Test/simple_pack/sys.cpp TaskManager/Test/simple_pack/sys.h TaskManager/Test/simple_pack/task/create_pp.cpp TaskManager/Test/simple_pack/task/create_sgp.cpp TaskManager/Test/simple_pack/task/create_span.cpp TaskManager/Test/simple_pack/task/spu_draw.cpp TaskManager/Test/simple_pack/task/spu_span.cpp TaskManager/Test/simple_pack/task/task_init.cpp TaskManager/Test/simple_pack/task/update_sgp.cpp TaskManager/Test/simple_pack/tes.xml TaskManager/Test/simple_pack/texture.cpp TaskManager/Test/simple_pack/texture.h TaskManager/Test/simple_pack/trash/demonstration.cpp TaskManager/Test/simple_pack/trash/mygl.cpp TaskManager/Test/simple_pack/trash/pad.cpp TaskManager/Test/simple_pack/trash/scene.cpp TaskManager/Test/simple_pack/trash/scene_graph_to_polygon_pack.cpp TaskManager/Test/simple_pack/trash/scene_graph_update.cpp TaskManager/Test/simple_pack/triangle.cpp TaskManager/Test/simple_pack/triangle.h TaskManager/Test/simple_pack/vertex.cpp TaskManager/Test/simple_pack/vertex.h TaskManager/Test/simple_pack/viewer.cpp TaskManager/Test/simple_pack/viewer.h TaskManager/Test/simple_pack/xml.cpp TaskManager/Test/simple_pack/xml.h TaskManager/Test/simple_render/Func.h TaskManager/Test/simple_render/Makefile TaskManager/Test/simple_render/Span.h TaskManager/Test/simple_render/SpanC.cpp TaskManager/Test/simple_render/SpanC.h TaskManager/Test/simple_render/SpanPack.cpp TaskManager/Test/simple_render/SpanPack.h TaskManager/Test/simple_render/SpanPackList.h TaskManager/Test/simple_render/SpuSpan.cpp TaskManager/Test/simple_render/SpuSpan.h TaskManager/Test/simple_render/base64_de.cpp TaskManager/Test/simple_render/cube-p.xml TaskManager/Test/simple_render/cube.h TaskManager/Test/simple_render/cube.xml TaskManager/Test/simple_render/cube_big.h TaskManager/Test/simple_render/cube_big.xml TaskManager/Test/simple_render/cube_tes.xml TaskManager/Test/simple_render/cylinder.xml TaskManager/Test/simple_render/demonstration.h TaskManager/Test/simple_render/fb.cpp TaskManager/Test/simple_render/fb.h TaskManager/Test/simple_render/icon.png TaskManager/Test/simple_render/main.cpp TaskManager/Test/simple_render/out.txt TaskManager/Test/simple_render/pad.h TaskManager/Test/simple_render/panel.xml TaskManager/Test/simple_render/panel_texture.xml TaskManager/Test/simple_render/polygon.cpp TaskManager/Test/simple_render/polygon.h TaskManager/Test/simple_render/polygon_pack.h TaskManager/Test/simple_render/scene.h TaskManager/Test/simple_render/scene_graph_pack.h TaskManager/Test/simple_render/spe/CreatePolygonPack.cpp TaskManager/Test/simple_render/spe/CreatePolygonPack.h TaskManager/Test/simple_render/spe/Load_Texture.cpp TaskManager/Test/simple_render/spe/Load_Texture.h TaskManager/Test/simple_render/spe/Makefile TaskManager/Test/simple_render/spe/SpuDraw.cpp TaskManager/Test/simple_render/spe/SpuDraw.h TaskManager/Test/simple_render/spe/spe-main.cpp TaskManager/Test/simple_render/sys.cpp TaskManager/Test/simple_render/sys.h TaskManager/Test/simple_render/task/create_pp.cpp TaskManager/Test/simple_render/task/create_sgp.cpp TaskManager/Test/simple_render/task/create_span.cpp TaskManager/Test/simple_render/task/dummy.cpp TaskManager/Test/simple_render/task/span_pack_draw.cpp TaskManager/Test/simple_render/task/task_init.cpp TaskManager/Test/simple_render/task/update_sgp.cpp TaskManager/Test/simple_render/tes.xml TaskManager/Test/simple_render/test/LoadTexture/Makefile TaskManager/Test/simple_render/test/LoadTexture/base64_de.cpp TaskManager/Test/simple_render/test/LoadTexture/cube.xml TaskManager/Test/simple_render/test/LoadTexture/fb.cpp TaskManager/Test/simple_render/test/LoadTexture/main.cpp TaskManager/Test/simple_render/test/LoadTexture/polygon.cpp TaskManager/Test/simple_render/test/LoadTexture/polygon.h TaskManager/Test/simple_render/test/LoadTexture/spe/Load_Texture.cpp TaskManager/Test/simple_render/test/LoadTexture/spe/Load_Texture.h TaskManager/Test/simple_render/test/LoadTexture/spe/Makefile TaskManager/Test/simple_render/test/LoadTexture/spe/spe-main.cpp TaskManager/Test/simple_render/test/LoadTexture/viewer.cpp TaskManager/Test/simple_render/test/LoadTexture/viewer.h TaskManager/Test/simple_render/texture.cpp TaskManager/Test/simple_render/texture.h TaskManager/Test/simple_render/trash/demonstration.cpp TaskManager/Test/simple_render/trash/mygl.cpp TaskManager/Test/simple_render/trash/pad.cpp TaskManager/Test/simple_render/trash/scene.cpp TaskManager/Test/simple_render/trash/scene_graph_to_polygon_pack.cpp TaskManager/Test/simple_render/trash/scene_graph_update.cpp TaskManager/Test/simple_render/triangle.cpp TaskManager/Test/simple_render/triangle.h TaskManager/Test/simple_render/vertex.cpp TaskManager/Test/simple_render/vertex.h TaskManager/Test/simple_render/viewer.cpp TaskManager/Test/simple_render/viewer.h TaskManager/Test/simple_render/viewer_types.h TaskManager/Test/simple_render/xml.cpp TaskManager/Test/simple_render/xml.h TaskManager/kernel/ppe/HTask.cc TaskManager/kernel/ppe/HTask.h TaskManager/kernel/ppe/TaskManagerImpl.cc TaskManager/kernel/ppe/TaskManagerImpl.h TaskManager/kernel/schedule/SchedExit.cc TaskManager/kernel/schedule/SchedMail.cc TaskManager/kernel/schedule/SchedNop.cc TaskManager/kernel/schedule/SchedNop2Ready.cc TaskManager/kernel/schedule/SchedTaskList.cc old/simple_pack/Makefile old/simple_pack/base64_de.cpp old/simple_pack/cube-p.xml old/simple_pack/cube.h old/simple_pack/cube.xml old/simple_pack/cube_tes.xml old/simple_pack/cylinder.xml old/simple_pack/demonstration.h old/simple_pack/fb.cpp old/simple_pack/icon.png old/simple_pack/main.cpp old/simple_pack/out.txt old/simple_pack/pad.h old/simple_pack/panel.xml old/simple_pack/panel_texture.xml old/simple_pack/polygon.cpp old/simple_pack/polygon.h old/simple_pack/polygon_pack.h old/simple_pack/scene.h old/simple_pack/scene_graph_pack.h old/simple_pack/span.cpp old/simple_pack/span.h old/simple_pack/span_pack.h old/simple_pack/spu_span.h old/simple_pack/sys.cpp old/simple_pack/sys.h old/simple_pack/task/create_pp.cpp old/simple_pack/task/create_sgp.cpp old/simple_pack/task/create_span.cpp old/simple_pack/task/spu_draw.cpp old/simple_pack/task/spu_span.cpp old/simple_pack/task/task_init.cpp old/simple_pack/task/update_sgp.cpp old/simple_pack/tes.xml old/simple_pack/texture.cpp old/simple_pack/texture.h old/simple_pack/trash/demonstration.cpp old/simple_pack/trash/mygl.cpp old/simple_pack/trash/pad.cpp old/simple_pack/trash/scene.cpp old/simple_pack/trash/scene_graph_to_polygon_pack.cpp old/simple_pack/trash/scene_graph_update.cpp old/simple_pack/triangle.cpp old/simple_pack/triangle.h old/simple_pack/vertex.cpp old/simple_pack/vertex.h old/simple_pack/viewer.cpp old/simple_pack/viewer.h old/simple_pack/xml.cpp old/simple_pack/xml.h old/simple_render/Func.h old/simple_render/Makefile old/simple_render/Span.h old/simple_render/SpanC.cpp old/simple_render/SpanC.h old/simple_render/SpanPack.cpp old/simple_render/SpanPack.h old/simple_render/SpanPackList.h old/simple_render/SpuSpan.cpp old/simple_render/SpuSpan.h old/simple_render/base64_de.cpp old/simple_render/cube-p.xml old/simple_render/cube.h old/simple_render/cube.xml old/simple_render/cube_big.h old/simple_render/cube_big.xml old/simple_render/cube_tes.xml old/simple_render/cylinder.xml old/simple_render/demonstration.h old/simple_render/fb.cpp old/simple_render/fb.h old/simple_render/icon.png old/simple_render/main.cpp old/simple_render/out.txt old/simple_render/pad.h old/simple_render/panel.xml old/simple_render/panel_texture.xml old/simple_render/polygon.cpp old/simple_render/polygon.h old/simple_render/polygon_pack.h old/simple_render/scene.h old/simple_render/scene_graph_pack.h old/simple_render/spe/CreatePolygonPack.cpp old/simple_render/spe/CreatePolygonPack.h old/simple_render/spe/Load_Texture.cpp old/simple_render/spe/Load_Texture.h old/simple_render/spe/Makefile old/simple_render/spe/SpuDraw.cpp old/simple_render/spe/SpuDraw.h old/simple_render/spe/spe-main.cpp old/simple_render/sys.cpp old/simple_render/sys.h old/simple_render/task/create_pp.cpp old/simple_render/task/create_sgp.cpp old/simple_render/task/create_span.cpp old/simple_render/task/dummy.cpp old/simple_render/task/span_pack_draw.cpp old/simple_render/task/task_init.cpp old/simple_render/task/update_sgp.cpp old/simple_render/tes.xml old/simple_render/test/LoadTexture/Makefile old/simple_render/test/LoadTexture/base64_de.cpp old/simple_render/test/LoadTexture/cube.xml old/simple_render/test/LoadTexture/fb.cpp old/simple_render/test/LoadTexture/main.cpp old/simple_render/test/LoadTexture/polygon.cpp old/simple_render/test/LoadTexture/polygon.h old/simple_render/test/LoadTexture/spe/Load_Texture.cpp old/simple_render/test/LoadTexture/spe/Load_Texture.h old/simple_render/test/LoadTexture/spe/Makefile old/simple_render/test/LoadTexture/spe/spe-main.cpp old/simple_render/test/LoadTexture/viewer.cpp old/simple_render/test/LoadTexture/viewer.h old/simple_render/texture.cpp old/simple_render/texture.h old/simple_render/trash/demonstration.cpp old/simple_render/trash/mygl.cpp old/simple_render/trash/pad.cpp old/simple_render/trash/scene.cpp old/simple_render/trash/scene_graph_to_polygon_pack.cpp old/simple_render/trash/scene_graph_update.cpp old/simple_render/triangle.cpp old/simple_render/triangle.h old/simple_render/vertex.cpp old/simple_render/vertex.h old/simple_render/viewer.cpp old/simple_render/viewer.h old/simple_render/viewer_types.h old/simple_render/xml.cpp old/simple_render/xml.h |
diffstat | 736 files changed, 426694 insertions(+), 395458 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/Chain.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,25 @@ +#include "Application.h" + +typedef struct { + double x, y, next_x, next_y; + double vx, vy, next_vx, next_vy; + double angle[3]; + int can_move; + SceneGraphPtr parent; + int id; + int parent_id; +} *ChainPropertyPtr, ChainProperty; + + +class Chain : public Application { +public: + Chain(){} + + SceneGraphPtr scenegraph_factory(void *p, int size); + SceneGraphPtr scenegraph_connector(void *p, int size, SceneGraphPtr s, SceneGraphPtr sg_available_list); + void init(TaskManager *manager, int w, int h); + void init_chain_vars(ChainPropertyPtr cv); + void chain_move(TaskManager *manager, SceneGraphPtr sg, int w, int h); + void chain_collision(SceneGraphPtr sg, int w, int h, SceneGraphPtr osg); + +};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/back_action.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,24 @@ +#include <iostream> +#include "SceneGraphRoot.h" +#include "SGList.h" +#include "ball_action.h" +using namespace std; + +void +back_move(SceneGraphPtr node, int w, int h) +{ + Pad *pad = sgroot->getController(); + + if (pad->triangle.isPush()) { + SceneGraphPtr ball = sgroot->createSceneGraph(Ball); + ball->xyz[0] = -100; + ball->set_move_collision(ball_move, ball_coll); + node->addChild(ball); + } +} + +void +back_coll(SceneGraphPtr node, int w, int h, SceneGraphPtr tree) +{ + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/back_action.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,2 @@ +void back_move(SceneGraphPtr, int, int); +void back_coll(SceneGraphPtr, int, int, SceneGraphPtr);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/ball_action.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,16 @@ +#include <iostream> +#include "SceneGraphRoot.h" +#include "SGList.h" +using namespace std; + +void +ball_move(SceneGraphPtr node, int w, int h) +{ + node->xyz[0] += 4; +} + +void +ball_coll(SceneGraphPtr node, int w, int h, SceneGraphPtr tree) +{ + if (node->xyz[0] > 600) node->remove(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/ball_action.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,2 @@ +void ball_move(SceneGraphPtr, int, int); +void ball_coll(SceneGraphPtr, int, int, SceneGraphPtr);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/ball_bound.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,128 @@ +#include <math.h> +#include <stdlib.h> +#include "SceneGraphRoot.h" +#include "SGList.h" + +// prototype +static void ball_move(SceneGraphPtr node, int screen_w, int screen_h); +static void ball_collision(SceneGraphPtr node, int screen_w, int screen_h, SceneGraphPtr tree); +static void ball_collision_idle(SceneGraphPtr, int w, int h, SceneGraphPtr tree); + + +static float vy = 0.0f; // y 方向速度 +static float dt = 1.0/1.0f; // frame rate + +static float e = -0.8f; // 反発係数 +static float g = 9.8f; // 重力加速度 +//static float v0 = 0.0f; // 初速は 0 + +static float h0; // 初期高さ +static float ball_radius = 100.0f; + +static float speed = 10.0f; + +static void +ball_move_idle2(SceneGraphPtr node, int screen_w, int screen_h) +{ + Pad *pad = sgroot->getController(); + + if (pad->circle.isHold()) { + if (pad->left.isHold()) { + node->xyz[0] -= speed; + if(node->xyz[0] < ball_radius) + node->xyz[0] = ball_radius; + } else if (pad->right.isHold()) { + node->xyz[0] += speed; + if(node->xyz[0] > screen_w - ball_radius) + node->xyz[0] = screen_w - ball_radius; + } + + if (pad->up.isHold()) { + node->xyz[1] -= speed; + } else if (pad->down.isHold()) { + node->xyz[1] += speed; + if(node->xyz[1] > screen_h - ball_radius) + node->xyz[1] = screen_h - ball_radius; + } + } else { + node->set_move_collision(ball_move, ball_collision); + } +} + +static int time = 0; + +static void +ball_move_idle(SceneGraphPtr node, int screen_w, int screen_h) +{ + Pad *pad = sgroot->getController(); + + if (pad->circle.isPush()) { + node->set_move_collision(ball_move_idle2, ball_collision_idle); + time = 0; + } + + time++; + + if (time > 90) { + float w = (float)random(); + + w = fmodf(w, screen_w - ball_radius*2); + node->xyz[0] = w + ball_radius; + node->xyz[1] = h0; + node->set_move_collision(ball_move, ball_collision); + time = 0; + } +} + +static void +ball_move(SceneGraphPtr node, int screen_w, int screen_h) +{ + vy += g * dt; + node->xyz[1] += vy * dt; + // node->xyz[0] += 10.0f; +} + +static void +ball_collision_idle(SceneGraphPtr, int w, int h, SceneGraphPtr tree) +{ +} + +static void +ball_collision(SceneGraphPtr node, int screen_w, int screen_h, + SceneGraphPtr tree) +{ + if (node->xyz[1] > screen_h - ball_radius) { + node->xyz[1] = screen_h - ball_radius; + + vy *= e; + if (vy > -g && vy < 0) { + vy = 0.0; + node->set_move_collision(ball_move_idle, ball_collision_idle); + } + } +} + + +void +ball_bound_init(TaskManager *manager, int screen_w, int screen_h) +{ + SceneGraphPtr ball; + + // 固定した値で srandom すると、毎回同じ、random() 列が生成される + // random な値が欲しいなら、man random に方法が書いてあります。 + srandom(100); + + sgroot->createFromXMLfile(manager, "xml_file/Ball.xml"); + ball = sgroot->createSceneGraph(Ball); + ball->set_move_collision(ball_move, ball_collision); + + h0 = screen_h/2; + h0 = -1000; + + ball->xyz[0] = screen_w/2; + //ball->xyz[0] = 0.0f; + ball->xyz[1] = h0; + ball->xyz[2] = 30.0f; + + sgroot->setSceneData(ball); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/boss1_action.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,269 @@ +#include "SGList.h" +#include "boss1_action.h" + +/* +static void +null_move(SceneGraphPtr node, int screen_w, int screen_h) +{ +} +*/ + +static void +null_collision(SceneGraphPtr node, int screen_w, int screen_h, + SceneGraphPtr tree) +{ +} + + +static void +boss1_move_right(SceneGraphPtr node, int screen_w, int screen_h) { + node->xyz[0] += node->stack_xyz[0]; + if(node->xyz[0] > (screen_w - boss_radius_x)) { + node->set_move_collision(boss1_move_left, null_collision); + } +} + +//ボスが左に移動する動作 +static void +boss1_move_left(SceneGraphPtr node, int screen_w, int screen_h) { + node->xyz[0] -= node->stack_xyz[0]; + if(node->xyz[0] < boss_radius_x) { + node->set_move_collision(boss1_move_right, null_collision); + } +} + +//ボスが戦闘位置へ戻る時の動作 +/* +static void +boss1_move_return(SceneGraphPtr node, int screen_w, int screen_h) +{ + node->xyz[1] -= node->stack_xyz[1]; + node->xyz[2] -= node->stack_xyz[2]; + + if((node->xyz[2] = 0)) { + node->stack_xyz[0] = 1.0; + node->set_move_collision(boss1_move_left, null_collision); + } +} +*/ + +//ボス登場時の動き +/* +static void +boss1_first_move(SceneGraphPtr node, int screen_w, int screen_h) +{ + node->xyz[1] += node->stack_xyz[1]; + if(node->xyz[1] > screen_h) { + float time = first_boss1_depth / node->stack_xyz[2]; + node->stack_xyz[1] = (screen_h - boss_radius_y) / time; + node->stack_xyz[2] = return_boss1_depth_speed; + node->set_move_collision(boss1_move_return, null_collision); + } +} +*/ + +static void +player_move(SceneGraphPtr node, int screen_w, int screen_h) +{ + Pad *pad = sgroot->getController(); + + if (pad->left.isPush() + || pad->left.isHold()) { +#if 0 + SceneGraphPtr player_left; + player_left = sgroot->createSceneGraph(PLAYER_L); + player_left->set_move_collision(player_move_left, null_collision); + player_left->xyz[0] = node->xyz[0]; + player_left->xyz[1] = node->xyz[1]; + node->addChild(player_left); + node->flag_drawable = 1; +#endif + node->xyz[0] -= player_speed; + + if (node->xyz[0] - player_radius< 0) { + node->xyz[0] = player_radius; + } + } + + + if (pad->right.isPush() + || pad->right.isHold()) { + node->xyz[0] += player_speed; + + if (node->xyz[0] + player_radius > screen_w) { + node->xyz[0] = screen_w - player_radius; + } + } + + if (pad->up.isPush() + || pad->up.isHold()) { + node->xyz[1] -= player_speed; + + if (node->xyz[1] - player_radius < 0) { + node->xyz[1] = player_radius; + } + } + + if (pad->down.isPush() + || pad->down.isHold()) { + node->xyz[1] += player_speed; + + if (node->xyz[1] + player_radius > screen_h) { + node->xyz[1] = screen_h - player_radius; + } + } + + if (pad->circle.isPush()) { + SceneGraphPtr shot = sgroot->createSceneGraph(P_SHOT1); + shot->set_move_collision(shot_move, shot_collision); + shot->xyz[0] = node->xyz[0]; + shot->xyz[1] = node->xyz[1] - player_radius; + node->addBrother(shot); + } +} + +static void +player_collision(SceneGraphPtr node, int screen_w, int screen_h, + SceneGraphPtr tree) +{ + //自機とボスのx,y座標での距離と2点間の距離 + static float x_distant, y_distant, distance; + //ボスの四角形の四隅の座標 + // static float boss_low_x, boss_low_y, boss_high_x, boss_high_y; + + SceneGraphIteratorPtr it = sgroot->getIterator(tree); + + + for (; it->hasNext(BOSS1);) { + it->next(BOSS1); + SceneGraphPtr enemy = it->get(); + + //各変数の初期化 + x_distant = node->xyz[0] - enemy->xyz[0]; + y_distant = node->xyz[1] - enemy->xyz[1]; + + //hypotfで2点間の距離を求める + distance = hypotf(x_distant, y_distant); + + /*四角形と円のcollision + if( (fabs( node->xyz[1] - ( boss_low_y ))) + */ + + //円同士のcollision + if(distance < (player_radius + boss_radius_y)) { + printf("!!!CAUTION!!!\n"); + } + } +} + +static void +shot_move(SceneGraphPtr node, int screen_w, int screen_h) +{ + node->xyz[1] -= shot_speed; + + // 描画領域から抜けたら削除 + if (node->xyz[1] < 0) { + node->remove(); + } +} + +static void +shot_collision(SceneGraphPtr node, int screen_2, int screen_h, + SceneGraphPtr tree) +{ + //自機とボスのx,y座標での距離と2点間の距離 + static float x_distant, y_distant, distance; + //ボスの四角形の四隅の座標 + // static float boss_low_x, boss_low_y, boss_high_x, boss_high_y; + + SceneGraphIteratorPtr it = sgroot->getIterator(tree); + + + for (; it->hasNext(BOSS1);) { + it->next(BOSS1); + SceneGraphPtr enemy = it->get(); + + x_distant = node->xyz[0] - enemy->xyz[0]; + y_distant = node->xyz[1] - enemy->xyz[1]; + + //hypotfで2点間の距離を求める + distance = hypotf(x_distant, y_distant); + + //円同士のcollision + if(distance < boss_radius_y) { + SceneGraphPtr blast = sgroot->createSceneGraph(BLAST1); + + blast->set_move_collision(blast_move, null_collision); + blast->xyz[0] = node->xyz[0]; + blast->xyz[1] = node->xyz[1]; + node->addBrother(blast); + node->remove(); + } + } +} + +static void +blast_move(SceneGraphPtr node, int screen_w, int screen_h) +{ + if(node->sgid > BLAST8) { + SceneGraphPtr blast = sgroot->createSceneGraph(node->sgid - 1); + blast->set_move_collision(blast_move, null_collision); + blast->xyz[0] = node->xyz[0]; + blast->xyz[1] = node->xyz[1]; + node->addBrother(blast); + } + + if (node->sgid == BLAST8) { + node->flag_drawable = 1; + } + + if((node->frame > 1)) { + node->remove(); + } + node->frame += 1; +} + +void +boss1_init(TaskManager *manager, int screen_w, int screen_h) +{ + SceneGraphPtr root; + SceneGraphPtr player; + SceneGraphPtr boss1; + SceneGraphPtr left_parts; + SceneGraphPtr right_parts; + + sgroot->createFromXMLfile(manager, "xml_file/boss1.xml"); + sgroot->createFromXMLfile(manager, "xml_file/player1.xml"); + sgroot->createFromXMLfile(manager, "xml_file/p_shot.xml"); + sgroot->createFromXMLfile(manager, "xml_file/blast.xml"); + + //rootとなるSceneGraphを生成 + root = sgroot->createSceneGraph(); + + //自機の初期化 + player = sgroot->createSceneGraph(PLAYER); + player->xyz[0] = screen_w/2; + player->xyz[1] = screen_h - player_radius; + root->addChild(player); + + //ボスの初期化 + boss1 = sgroot->createSceneGraph(BOSS1); + boss1->xyz[0] = screen_w/2; + boss1->xyz[1] = boss_radius_y; + // boss1->xyz[2] = first_boss1_depth; + boss1->stack_xyz[0] = first_boss1_speed; + root->addChild(boss1); + + //ボスの左右パーツを追加 + left_parts = sgroot->createSceneGraph(BOSS1_L); + boss1->addChild(left_parts); + right_parts = sgroot->createSceneGraph(BOSS1_R); + boss1->addChild(right_parts); + + //各機体の動きと当たり判定をセット + player->set_move_collision(player_move, player_collision); + boss1->set_move_collision(boss1_move_left, null_collision); + + //仕上げ + sgroot->setSceneData(root); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/boss1_action.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,66 @@ +#ifndef BOSS1_ACCTION_H +#define BOSS1_ACCTION_H + +#include <math.h> +#include "SceneGraphRoot.h" +#include "SGList.h" + +static const float player_speed = 10.0f; +static const float player_radius = 42.0f; + +static const float boss_radius_x = 65.4f; +static const float boss_radius_y = 130.8f; +static const float first_boss1_speed = 10.0; +static const float first_boss1_depth = 500.0; +static const float return_boss1_depth_speed = 10.0; + +static const float shot_speed = 30.0f; +static const float shot_radius = 42.4f; + + +/* +static void +null_move(SceneGraphPtr node, int screen_w, int screen_h); +*/ + +static void +null_collision(SceneGraphPtr node, int screen_w, int screen_h, + SceneGraphPtr tree); + +static void +boss1_move_right(SceneGraphPtr node, int screen_w, int screen_h); + +static void +boss1_move_left(SceneGraphPtr node, int screen_w, int screen_h); + +/* +static void +boss1_move_return(SceneGraphPtr node, int screen_w, int screen_h); +*/ + +/* +static void +boss1_first_move(SceneGraphPtr node, int screen_w, int screen_h); +*/ + +static void +player_move(SceneGraphPtr node,int screen_2, int screen_h); + +/* +static void +player_move_left(SceneGraphPtr node,int screen_2, int screen_h); +*/ + +static void +player_collision(SceneGraphPtr node, int screen_w, int screen_h, + SceneGraphPtr tree); +static void +shot_move(SceneGraphPtr node, int screen_w, int screen_h); + +static void +shot_collision(SceneGraphPtr node, int screen_2, int screen_h, + SceneGraphPtr tree); +static void +blast_move(SceneGraphPtr node, int screen_w, int screen_h); + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/bullet_action.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,65 @@ +#include <math.h> +#include "SceneGraphRoot.h" +#include "SGList.h" +#include "hit_judge.h" +#define PI M_PI + +int i = 0; + +void +bullet_init(SceneGraphPtr bullet, SceneGraphPtr player) +{ + bullet->xyz[0] = player->xyz[0]; + bullet->xyz[1] = player->xyz[1]; + bullet->xyz[2] = player->xyz[2]; + + bullet->angle[0] = player->angle[0]; + bullet->angle[1] = player->angle[1]; + bullet->angle[2] = player->angle[2]; +} + +void +bluebullet_move(SceneGraphPtr node, int screen_w, int screen_h) +{ + double a = (node->angle[2]+90)*PI/180; + double b = (node->angle[0]+90)*PI/180; + + double y = sin(a); + double x = cos(a); + double z = -cos(b); + + node->xyz[0] += x * 5;//x軸方向 + node->xyz[1] += y * 5;//y軸方向 + node->xyz[2] += z * 5;//z軸方向 +} + +void +bullet_collision(SceneGraphPtr node, int screen_w, int screen_h, SceneGraphPtr tree) +{ + SceneGraphIteratorPtr it = sgroot->getIterator(tree); + //static int damage = 0; + + for (; it->hasNext(E_PLANE);) { + it->next(E_PLANE); + SceneGraphPtr enemy = it->get(); + + int judge = square_judge(node, enemy); + if(judge == HIT) + { + //node->set_move_collision(null_move, bullet_collision); + //E_PLANE->set_move_collision(null_move, enemy_collision); + enemy->remove(); + node->remove(); + //printf("hit!!!\n"); + //bullet_delete(node, scene_graph); + } + } + + if(node->xyz[1] > 100) + { + node->remove(); + //scene_graph->delete_object(node, node->next,node->prev); + //i -= 1; + //printf("bullet_delete:残り弾数=%d\n",i); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/bullet_action.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,8 @@ +#ifndef BULLET_ACTION_H +#define BULLET_ACTION_H + +void bullet_init(SceneGraphPtr scene_graph, SceneGraphPtr node); +void bluebullet_move(SceneGraphPtr node, int screen_w, int screen_h); +void bullet_collision(SceneGraphPtr node, int screen_w, int screen_h ,SceneGraphPtr tree); + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/camera_action.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,58 @@ +#include "SceneGraphRoot.h" +#include "SGList.h" +#include "camera_action.h" + +#define MOVE_SPEED 0.10 + +void +camera_init(SceneGraphPtr node, int screen_w, int screen_h) +{ + node->xyz[0] = screen_w/2; + node->xyz[1] = screen_h/2 + 50; + node->xyz[2] = 0; + node->angle[0] = 120; +} + +void +c_move(SceneGraphPtr node, int screen_w, int screen_h) +{ + Pad *pad = sgroot->getController(); + + if(pad->right.isHold()) + { + if(node->xyz[0]>screen_w/2 - 50) + { + node->xyz[0]-=MOVE_SPEED; + } + } + + if(pad->left.isHold()) + { + if(node->xyz[0]<screen_w/2 + 50) + { + node->xyz[0]+=MOVE_SPEED; + } + } + + if(pad->down.isHold()) + { + if(node->xyz[2]>-25) + { + node->xyz[2]-=MOVE_SPEED; + } + } + + if(pad->up.isHold()) + { + if(node->xyz[2]<25) + { + node->xyz[2]+=MOVE_SPEED; + } + } + +} + +void +camera_collision(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree) +{ +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/camera_action.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,3 @@ +void camera_init(SceneGraphPtr node, int screen_w, int screen_h); +void c_movet(SceneGraphPtr node, int screen_w, int screen_h); +void camera_collision(SceneGraphPtr node, int screen_w, int screen_h, SceneGraphPtr tree);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/chain.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,163 @@ +#include <iostream> +#include <math.h> +#include "SceneGraphRoot.h" +#include "SceneGraph.h" +#include "SGList.h" +#include "TaskManager.h" +#include "Func.h" +#include "Chain.h" +#define FALSE 0 +#define TRUE !FALSE +#define CHAIN_LEN 50 + +static double chain_width = 10; + + +/* SceneGraph の property */ +ChainPropertyPtr properties[2]; +ChainPropertyPtr property; + + +//void createSceneGraphFromProperty(ChainPropertyPtr p) ; +void createSceneGraphFromProperty(void* p) ; + +void +Chain::init_chain_vars(ChainPropertyPtr cv) { + cv->x = 0, cv->y = 0, cv->next_x = 0, cv->next_y = 0; + cv->vx = 0, cv->vy = 0, cv->next_vx = 0, cv->next_vy = 0; + cv->can_move = TRUE; +} + +void +set_vector(ChainPropertyPtr p, SceneGraphPtr sg) { + sg->xyz[0] = p->next_x; + sg->xyz[1] = p->next_y; + sg->xyz[2] = 0.0f; + sg->angle[0] = p->angle[0]; + sg->angle[1] = p->angle[1]; + sg->angle[2] = p->angle[2]; +} + +#if 0 +static void +chain_move_ope(SceneGraphPtr node, int screen_w, int screen_h) +{ + Pad *pad = sgroot->getController(); + + if (pad->circle.isHold()) { + property[CHAIN_LEN-1].can_move = FALSE; + if (pad->left.isHold()) { + property[CHAIN_LEN-1].x += -5.0; + } else if (pad->right.isHold()) { + property[CHAIN_LEN-1].x += 5.0; + } + + if (pad->up.isHold()) { + property[CHAIN_LEN-1].y += -5.0; + } else if (pad->down.isHold()) { + property[CHAIN_LEN-1].y += 5.0; + } + } else { + property[CHAIN_LEN-1].can_move = TRUE; + } +} +#endif + +void +Chain::chain_move(TaskManager *manager, SceneGraphPtr sg, int w, int h) +{ + int id = sg->id; + //ChainPropertyPtr p = (ChainPropertyPtr)sg->propertyptr; + HTaskPtr chain_cal; + ChainPropertyPtr output; + + // SceneGraph の切り替えもここでやる + if (property == properties[0]) { + property = properties[1]; + output = properties[0]; + }else{ + property = properties[0]; + output = properties[1]; + } + chain_cal = manager->create_task(CHAINCAL_TASK); + chain_cal->add_inData(property, sizeof(ChainProperty)*CHAIN_LEN); + chain_cal->add_param(id); + chain_cal->add_outData(output, sizeof(ChainProperty)*CHAIN_LEN); + chain_cal->set_post(createSceneGraphFromProperty, (void*)id); + chain_cal->spawn(); + +} + +void +Chain::chain_collision(SceneGraphPtr sg, int w, int h, SceneGraphPtr osg) +{ + +} + +void +createSceneGraphFromProperty(void* p) +{ + ChainPropertyPtr chain_p = (ChainPropertyPtr)p; + SceneGraphPtr chain_copy = sgroot->createSceneGraph(CHAIN); + chain_copy->propertyptr = (void*)chain_p; + chain_copy->property_size = sizeof(ChainProperty); + set_vector(chain_p, chain_copy); + chain_p->parent->addChild(chain_copy); +} + +void +Chain::init(TaskManager *manager, int w, int h) +{ + SceneGraphPtr root_chain, chain; + ChainPropertyPtr rcv; + ChainProperty r; + HTaskPtr chain_init; + + rcv = &r; + + sgroot->createFromXMLfile(manager, "xml_file/chain.xml"); + + /* SPE に送る property の配列の領域確保 */ + properties[0] = (ChainPropertyPtr)manager->allocate(sizeof(ChainProperty)*CHAIN_LEN); + properties[1] = (ChainPropertyPtr)manager->allocate(sizeof(ChainProperty)*CHAIN_LEN); + property = properties[0]; + + root_chain = sgroot->createSceneGraph(CHAIN); + // set_move_collision()ではだめ +// root_chain->set_move_collision(chain_move_ope, chain_collision); + init_chain_vars(rcv); + rcv->next_x = w / 2; + rcv->next_y = 0.0; + rcv->angle[0] = 0; + rcv->angle[1] = 0; + rcv->angle[2] = 0; + + set_vector(rcv, root_chain); + + for(int i = 0; i < CHAIN_LEN; i++) { + chain = sgroot->createSceneGraph(CHAIN); + property[i].id = i; + init_chain_vars(&property[i]); + property[i].x = 0; + property[i].y = chain_width * i; + set_vector(&property[i], chain); + property->angle[1] = -90 * (i % 2); + //chain->set_move_collision(chain_move, chain_collision); + chain->propertyptr = &property[i]; + chain->property_size = sizeof(ChainProperty); + root_chain->addChild(chain); + property[i].parent = root_chain; + } + property[0].can_move = FALSE; + + // property を SPU の共有領域へコピーする + chain_init = manager->create_task(CHAININIT_TASK); + chain_init->add_inData(property, sizeof(ChainProperty)*CHAIN_LEN); + chain_init->add_param(CHAIN_LEN); + chain_init->set_cpu(SPE_0); + chain_init->set_post(createSceneGraphFromProperty, (void*)property); + chain_init->spawn(); + + sgroot->setSceneData(root_chain); +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/chain_old.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,159 @@ +#include <iostream> +#include <math.h> +#include "SceneGraphRoot.h" +#include "SGList.h" +#include "SceneGraph.h" +#include "TaskManager.h" +#include "Func.h" + + +#define FALSE 0 +#define TRUE !FALSE +#define CHAIN_LEN 50 + +static double m = 100.0; +static double k = 7000.0; +static double g = 9.8; +static double dt = 0.003; +static double chain_width = 10; +static double safe = 0.995; + +typedef struct { + double x, y, next_x, next_y; + double vx, vy, next_vx, next_vy; + int can_move; +} CHAIN_VARS; + +CHAIN_VARS cv[CHAIN_LEN]; + +void +init_chainold_vars(CHAIN_VARS *cv) { + cv->x = 0, cv->y = 0, cv->next_x = 0, cv->next_y = 0; + cv->vx = 0, cv->vy = 0, cv->next_vx = 0, cv->next_vy = 0; + cv->can_move = TRUE; +} + +void +set_old_vector(CHAIN_VARS *cv, SceneGraphPtr sg) { + sg->xyz[0] = (float)cv->next_x; + sg->xyz[1] = (float)cv->next_y; + sg->xyz[2] = 0.0f; +} + + +static void +chain_old_move_ope(SceneGraphPtr node, int screen_w, int screen_h) +{ + Pad *pad = sgroot->getController(); + + if (pad->start.isHold()) { + cv[CHAIN_LEN-1].can_move = FALSE; + if (pad->left.isHold()) { + cv[CHAIN_LEN-1].x += -5.0; + } else if (pad->right.isHold()) { + cv[CHAIN_LEN-1].x += 5.0; + } + + if (pad->up.isHold()) { + cv[CHAIN_LEN-1].y += -5.0; + } else if (pad->down.isHold()) { + cv[CHAIN_LEN-1].y += 5.0; + } + } else { + cv[CHAIN_LEN-1].can_move = TRUE; + } +} + +void +chain_old_move(SceneGraphPtr sg, int w, int h) +{ + int id = sg->id; + if(id == 0) { + for(int cnt = 0; cnt < 600; cnt++) { + for(int i = 0; i < CHAIN_LEN; i++) { + if(cv[i].can_move) { + double dx = cv[i-1].x - cv[i].x; + double dy = cv[i-1].y - cv[i].y; + double l = sqrt(dx * dx + dy * dy); + double a = k * (l - chain_width) / m; + double ax = a * dx / l; + double ay = a * dy / l; + if(i < CHAIN_LEN - 1) { + dx = cv[i+1].x - cv[i].x; + dy = cv[i+1].y - cv[i].y; + l = sqrt(dx * dx + dy * dy); + a = k * (l - chain_width) / m; + ax += a * dx / l; + ay += a * dy / l; + } + ay += g; + cv[i].vx *= safe; + cv[i].vy *= safe; + cv[i].next_vx = cv[i].vx + ax * dt; + cv[i].next_vy = cv[i].vy + ay * dt; + cv[i].next_x = cv[i].x + cv[i].vx * dt; + cv[i].next_y = cv[i].y + cv[i].vy * dt; + } else { + cv[i].next_x = cv[i].x; + cv[i].next_y = cv[i].y; + } + } + for(int i = 0; i < CHAIN_LEN; i++) { + cv[i].vx = cv[i].next_vx; + cv[i].vy = cv[i].next_vy; + cv[i].x = cv[i].next_x; + cv[i].y = cv[i].next_y; + } + } + // cout << id << ", " << sg->xyz[1] << endl; + } + set_old_vector(&cv[id], sg); + int p, n; + p = n = id; + if(p != 0) { + p--; + } + if(n != CHAIN_LEN - 1) { + n++; + } + sg->angle[2-(id%2)*2] + = 90 + atan((cv[p].next_y - cv[n].next_y) / (cv[p].next_x - cv[n].next_x)) * 180 / M_PI; +} + +void +chain_old_collision(SceneGraphPtr sg, int w, int h, SceneGraphPtr osg) +{ + +} + +void +chain_old_init(TaskManager *manager, int w, int h) +{ + SceneGraphPtr root_old_chain, chain; + CHAIN_VARS rcv; + + sgroot->createFromXMLfile(manager,"xml_file/chain.xml"); + + root_old_chain = sgroot->createSceneGraph(CHAIN); + root_old_chain->set_move_collision(chain_old_move_ope, chain_old_collision); + init_chainold_vars(&rcv); + rcv.next_x = w / 2; + rcv.next_y = 0.0; + set_old_vector(&rcv, root_old_chain); + + for(int i = 0; i < CHAIN_LEN; i++) { + chain = sgroot->createSceneGraph(CHAIN); + chain->id = i; + init_chainold_vars(&cv[i]); + cv[i].x = 0; + cv[i].y = chain_width * i; + set_old_vector(&cv[i], chain); + chain->angle[1] = -90 * (i % 2); + chain->set_move_collision(chain_old_move, chain_old_collision); + + root_old_chain->addChild(chain); + } + cv[0].can_move = FALSE; + + sgroot->setSceneData(root_old_chain); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/cube.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,174 @@ +#include <math.h> +#include "SceneGraphRoot.h" +#include "vacuum.h" +#include "SGList.h" +#define SELECT 2 + +void +cube_collision(SceneGraphPtr node, int screen_w, int screen_h, + SceneGraphPtr tree) +{ + if (node->frame > 120) { + cube_split(node,tree); + } +} + +void +cube_move_left(SceneGraphPtr node, int screen_w, int screen_h) +{ + node->xyz[0] -= node->stack_xyz[0]; + node->xyz[1] += node->stack_xyz[1]; + + if (node->xyz[0] < 0) { + node->set_move_collision(cube_move_right, cube_collision); + } + + if (node->xyz[1] < 0 || node->xyz[1] > screen_h) { + node->stack_xyz[1] = -node->stack_xyz[1]; + } +} + +void +cube_rotate(SceneGraphPtr node, int w, int h) +{ + node->angle[0] += 2.0f; + node->angle[1] += 2.0f; + node->angle[2] += 2.0f; +} + +void +cube_move_right(SceneGraphPtr node, int screen_w, int screen_h) +{ + node->xyz[0] += node->stack_xyz[0]; + node->xyz[1] += node->stack_xyz[1]; + + if (node->xyz[0] > screen_w) { + node->set_move_collision(cube_move_left, cube_collision); + } + + if (node->xyz[1] < 0 || node->xyz[1] > screen_h) { + node->stack_xyz[1] = -node->stack_xyz[1]; + } + +} + + +void +cube_split(SceneGraphPtr root,SceneGraphPtr tree) +{ + + SceneGraphPtr p; + // SceneGraphPtr common_move = sgroot->createSceneGraph(); + // SceneGraphPtr root_common_move = root->parent; + + if(random()%SELECT) { + p = sgroot->createSceneGraph(REDCUBE); + } + else { + p = sgroot->createSceneGraph(ENEMY); + } + + root->set_move_collision(cube_move_right, cube_collision); + p->set_move_collision(cube_move_left, cube_collision); + + root->frame = 0; + p->frame = 0; + + p->xyz[0] = root->xyz[0] + 2; + p->xyz[1] = root->xyz[1]; + p->xyz[2] = root->xyz[2]; + + p->stack_xyz[0] = 2.0f; + p->stack_xyz[1] = random()%3-1; + p->stack_xyz[2] = 0.0f; + + root->xyz[0] -= 2; + root->stack_xyz[0] = 2.0f; + root->stack_xyz[1] = random()%3-1; + + //common_move->addChild(p); + root->addBrother(p); + +} + + +void +collision_red(SceneGraphIteratorPtr it,SceneGraphPtr node) +{ + float dx, dy,ddx,ddy, r; + float q = 0; + + for (; it->hasNext(REDCUBE);) { + + it->next(REDCUBE); + SceneGraphPtr mcube = it->get(); + dx = node->xyz[0] - mcube->xyz[0]; + dy = node->xyz[1] - mcube->xyz[1]; + + ddx = dx*dx; + ddy = dy*dy; + + if(sqrt(ddx) < 10 && sqrt(ddy) < 10) { + mcube->remove(); + continue; + } + r = sqrt(ddx + ddy); + if (r >= 1) q = 200/r; + if (dx == 0) { + if(mcube->xyz[1] > node->xyz[1]) { + mcube->stack_xyz[1] -= q; + } else if(mcube->xyz[1] < node->xyz[1]) { + mcube->stack_xyz[1] += q; + } + } else { + if(mcube->xyz[0] > node->xyz[0]) { + mcube->xyz[0] -= q*cos(atan(dy/dx)); + mcube->xyz[1] -= q*sin(atan(dy/dx)); + } else if(mcube->xyz[0] < node->xyz[0]) { + mcube->xyz[0] += q*cos(atan(dy/dx)); + mcube->xyz[1] += q*sin(atan(dy/dx)); + } + } + } +} + +void +collision_purple(SceneGraphIteratorPtr it,SceneGraphPtr node,int w,int h) +{ + float dx, dy,ddx,ddy, r; + float q = 0; + + for (; it->hasNext(ENEMY);) { + it->next(ENEMY); + SceneGraphPtr mcube = it->get(); + + dx = node->xyz[0] - mcube->xyz[0]; + dy = node->xyz[1] - mcube->xyz[1]; + ddx = dx*dx; + ddy = dy*dy; + + if(sqrt(ddx) < 10 && sqrt(ddy) < 10) { + gameover_scene(w,h,mcube); + node->remove(); + break; + } + r = sqrt(ddx + ddy); + if (r >= 1) q = 200/r; + if (dx == 0) { + if(mcube->xyz[1] > node->xyz[1]) { + mcube->stack_xyz[1] -= q; + } else if(mcube->xyz[1] < node->xyz[1]) { + mcube->stack_xyz[1] += q; + } + } else { + + if(mcube->xyz[0] > node->xyz[0]) { + mcube->xyz[0] -= q*cos(atan(dy/dx)); + mcube->xyz[1] -= q*sin(atan(dy/dx)); + } else if(mcube->xyz[0] < node->xyz[0]) { + mcube->xyz[0] += q*cos(atan(dy/dx)); + mcube->xyz[1] += q*sin(atan(dy/dx)); + } + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/cube_action.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,132 @@ +#include <math.h> +#include "SceneGraphRoot.h" +#include "SGList.h" + +static void cube_move_left(SceneGraphPtr node, int screen_w, int screen_h); +static void cube_move_right(SceneGraphPtr node, int screen_w, int screen_h); +static void cube_move_idle(SceneGraphPtr node, int screen_w, int screen_h); +static void cube_collision(SceneGraphPtr node, int screen_w, int screen_h, + SceneGraphPtr tree); + +static void cube_split(SceneGraphPtr root); + +static void +cube_move_left(SceneGraphPtr node, int screen_w, int screen_h) +{ + node->xyz[0] -= node->stack_xyz[0]; + node->xyz[1] -= node->stack_xyz[0] * node->stack_xyz[1]; + node->xyz[2] -= node->stack_xyz[0] * node->stack_xyz[2]; + + if (node->xyz[0] < 0) { + node->set_move_collision(cube_move_right, cube_collision); + } + + if (node->xyz[1] < 0 || node->xyz[1] > screen_h) { + node->stack_xyz[1] = -node->stack_xyz[1]; + } + + node->angle[0] += 2.0f; + node->angle[1] += 2.0f * node->stack_xyz[1]; + node->angle[2] += 2.0f * node->stack_xyz[2]; + + node->angle[0] = fmodf(node->angle[0], 360.0f); + node->angle[1] = fmodf(node->angle[1], 360.0f); + node->angle[2] = fmodf(node->angle[2], 360.0f); + + if (node->frame > 10 && sgroot->controller->circle.isPush()) { + cube_split(node); + } +} + +static void +cube_move_right(SceneGraphPtr node, int screen_w, int screen_h) +{ + node->xyz[0] += node->stack_xyz[0]; + node->xyz[1] -= node->stack_xyz[0] * node->stack_xyz[1]; + node->xyz[2] -= node->stack_xyz[0] * node->stack_xyz[2]; + + if (node->xyz[0] > screen_w) { + node->set_move_collision(cube_move_left, cube_collision); + } + + if (node->xyz[1] < 0 || node->xyz[1] > screen_h) { + node->stack_xyz[1] = -node->stack_xyz[1]; + } + + node->angle[0] += 2.0f; + node->angle[1] += 2.0f * node->stack_xyz[1]; + node->angle[2] += 2.0f * node->stack_xyz[2]; + + node->angle[0] = fmodf(node->angle[0], 360.0f); + node->angle[1] = fmodf(node->angle[1], 360.0f); + node->angle[2] = fmodf(node->angle[2], 360.0f); + + if (node->frame > 10 && sgroot->controller->circle.isPush()) { + cube_split(node); + } +} + +static void +cube_split(SceneGraphPtr root) +{ + SceneGraphPtr p = root->clone(); + root->addBrother(p); + + root->set_move_collision(cube_move_left, cube_collision); + p->set_move_collision(cube_move_right, cube_collision); + + p->xyz[0] = root->xyz[0] + 2; + p->xyz[1] = root->xyz[1]; + p->xyz[2] = root->xyz[2]; + + p->stack_xyz[0] = 2.0f; + p->stack_xyz[1] = random()%3-1; + p->stack_xyz[2] = random()%3-1; + + root->xyz[0] -= 2; + root->stack_xyz[0] = 2.0f; + root->stack_xyz[1] = random()%3-1; + root->stack_xyz[2] = random()%3-1; +} + + +static void +cube_move_idle(SceneGraphPtr node, int screen_w, int screen_h) +{ + node->xyz[0] = screen_w/2; + node->xyz[1] = screen_h/2; + //node->xyz[2] = -300.0f; + + if (sgroot->controller->circle.isPush()) { + cube_split(node); + } +} + +static void +cube_collision(SceneGraphPtr node, int screen_w, int screen_h, + SceneGraphPtr tree) +{ +} + +void +create_cube_split(TaskManager *manager, int number) +{ + SceneGraphPtr cube; + SceneGraphPtr back; + + sgroot->createFromXMLfile(manager, "xml_file/cube.xml"); + + // 何もしない親 + // cube は brother として繋がっていくので + // 親が居ないとだめ。 + back = sgroot->createSceneGraph(); + + cube = sgroot->createSceneGraph(Cube); + cube->xyz[0] = 960.0f; + cube->xyz[1] = 540.0f; + cube->set_move_collision(cube_move_idle, cube_collision); + + back->addChild(cube); + + sgroot->setSceneData(back); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/demonstration.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,18 @@ +#ifndef INCLUDED_DEMONSTRATION +#define INCLUDED_DEMONSTRATION + +#include "polygon.h" + +class Demonstration{ + public: + Polygon *list; + void (Demonstration::*action_demo)(); + + Demonstration(); + //~Demonstration(); + void test_init(); + void test_play(); + void test_end(); +}; + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/direction.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,93 @@ +#include "SceneGraphRoot.h" +#include "SGList.h" + +static void +x_move(SceneGraphPtr node, int w, int h) +{ + Pad *pad = sgroot->getController(); + + node->xyz[0] = w/2; + node->xyz[1] = h/2; + + if (pad->circle.isPush() || pad->circle.isHold()) { + node->angle[1] += 10.0f; + if (node->angle[1] > 360.0f) node->angle[1] = 0.0f; + } + + if (pad->triangle.isPush() || pad->triangle.isHold()) { + node->angle[0] += 10.0f; + if (node->angle[0] > 360.0f) node->angle[0] = 0.0f; + } + + if (pad->start.isPush()) { + node->angle[0] = 0.0f; + node->angle[1] = 90.0f; + } + +} + +static void +y_move(SceneGraphPtr node, int w, int h) +{ + Pad *pad = sgroot->getController(); + + node->xyz[0] = w/2; + node->xyz[1] = h/2; + + if (pad->cross.isPush() || pad->cross.isHold()) { + node->angle[2] += 10.0f; + } + + if (pad->square.isPush() || pad->square.isHold()) { + node->angle[0] += 10.0f; + } + + if (pad->start.isPush()) { + node->angle[0] = 90.0f; + node->angle[1] = 0.0f; + } + +} + +static void +z_move(SceneGraphPtr node, int w, int h) +{ + node->xyz[0] = w/2; + node->xyz[1] = h/2; +} + +static void +dir_collision(SceneGraphPtr node, int w, int h, SceneGraphPtr tree) +{ +} + +void +direction_init(TaskManager *manager) +{ + SceneGraphPtr dx; + SceneGraphPtr dy; + SceneGraphPtr dz; + SceneGraphPtr back; + + sgroot->createFromXMLfile(manager, "xml_file/direction.xml"); + + dx = sgroot->createSceneGraph(Dirx); + dy = sgroot->createSceneGraph(Diry); + dz = sgroot->createSceneGraph(Dirz); + back = sgroot->createSceneGraph(); + + back->addChild(dx); + back->addChild(dy); + back->addChild(dz); + + dx->set_move_collision(x_move, dir_collision); + dx->angle[1] = 90.0f; + dy->set_move_collision(y_move, dir_collision); + dy->angle[0] = 90.0f; + dz->set_move_collision(z_move, dir_collision); + + back->angle[0] = 30.0f; + back->angle[1] = -30.0f; + + sgroot->setSceneData(back); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/enemy_action.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,38 @@ +#include <math.h> +#include "SceneGraph.h" +#include "enemy_action.h" + +#define PI M_PI + +double vx = 5.0; + +void +enemy_move(SceneGraphPtr node, int screen_w, int screen_h) +{ + double vxr = (node->xyz[0])*PI/180; + if(node->xyz[0] > screen_w/2 || node->xyz[0] < -screen_w/2) + { + vx *= -1; + } + //printf("%f\n", vx); + node->angle[1]+=vx; + + node->xyz[0] += vx; + node->xyz[1] = -sin(vxr*2)*20*vx; + node->xyz[2] = sin(vxr*4)*2*vx; +} + + +void +enemy_collision(SceneGraphPtr node, int screen_w, int screen_h, SceneGraphPtr tree) +{ +#if 0 + int judge = square_judge(E_PLANE, BULEBULLET, tree); + if(judge == HIT) + { + E_PLANE->set_move_collision(null_move, enemy_collision); + printf("ENEMY_hit!!!\n"); + //scene_graph->delete_object(node, node->next,node->prev); + } +#endif +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/enemy_action.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,2 @@ +extern void enemy_move(SceneGraphPtr node, int screen_w, int screen_h); +extern void enemy_collision(SceneGraphPtr node, int screen_w, int screen_h, SceneGraphPtr tree);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/game_over.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,42 @@ +#include "SceneGraphRoot.h" +#include "vacuum.h" +#include "SGList.h" + + +void +gameover_scene(int w,int h,SceneGraphPtr node) +{ + + SceneGraphPtr over; + + over = sgroot->createSceneGraph(GAMEOVER); + over->xyz[0] = w/2; + over->xyz[1] = h/2; + over->set_move_collision(gameover_idle,gameover_collision); + node->addBrother(over); +} + +void +gameover_idle(SceneGraphPtr node,int screen_w,int screen_h) +{ +} + +void +gameover_collision(SceneGraphPtr node,int screen_w,int screen_h,SceneGraphPtr tree) +{ + + Pad *pad = sgroot->getController(); + + if(pad->start.isPush()) { + + SceneGraphPtr title; + + title = sgroot->createSceneGraph(TITLE); + title->xyz[0] = screen_w/2; + title->xyz[1] = screen_h/2; + title->set_move_collision(no_move_idle, title_collision); + sgroot->setSceneData(title); + + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/gaplant.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,30 @@ +#include "SceneGraphRoot.h" +#include "SGList.h" +#include "gaplant_action.h" +#include "back_action.h" + +void +init_gaplant(TaskManager *manager, int w, int h) +{ + SceneGraphPtr back; + SceneGraphPtr gaplant; + sgroot->createFromXMLfile(manager, "xml_file/gap_plane_test.xml"); + sgroot->createFromXMLfile(manager, "xml_file/Ball.xml"); + + back = sgroot->createSceneGraph(); + back->set_move_collision(back_move, back_coll); + gaplant = sgroot->createSceneGraph(); + gaplant->xyz[0] = 200; + gaplant->angle[0] = -60; + gaplant->angle[1] = 0; + gaplant->angle[2] = 0; + gaplant->set_move_collision(gaplant_move, gaplant_coll); + + for (int i = arm_L_D; i <= foot_L_A; i++) { + SceneGraphPtr p = sgroot->createSceneGraph(i); + gaplant->addChild(p); + } + + back->addChild(gaplant); + sgroot->setSceneData(back); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/gaplant.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,2 @@ +const double CHECK_HIT_RAD = 110; +const double BALL_RAD = 100;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/gaplant_action.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,98 @@ +#include <iostream> +#include <cmath> +#include "SceneGraphRoot.h" +#include "SGList.h" +#include "gaplant.h" +using namespace std; + +void +move_right(SceneGraphPtr node) +{ + /*cout << "右を押したんだ " << node->angle[2] << "\n"; + node->angle[2] -= 1; + if (node->angle[2] < -30) { + node->angle[2] = -30; + }*/ + node->xyz[0] += 5; +} + +void +move_left(SceneGraphPtr node) +{ + /*cout << "左を押したんだ " << node->angle[2] << "\n"; + node->angle[1] += 1; + if (node->angle[2] > 30) { + node->angle[2] = 30; + }*/ + node->xyz[0] -= 5; +} + +void +move_down(SceneGraphPtr node) +{ + /*cout << "下だって押したくなる時はある "<< node->angle[0] << "\n"; + node->angle[0] += 1; + if (node->angle[0] > -60) { + node->angle[0] = -60; + }*/ + node->xyz[1] += 5; +} + +void +move_up(SceneGraphPtr node) +{ + /*cout << "上を押したんだ "<< node->angle[0] << "\n"; + node->angle[0] -= 1; + if (node->angle[0] < -120) { + node->angle[0] = -120; + }*/ + node->xyz[1] -= 5; +} + +void +gaplant_move(SceneGraphPtr node, int w, int h) +{ + Pad *pad = sgroot->getController(); + + if (pad->right.isHold() || pad->left.isHold() || pad->down.isHold() || pad->up.isHold()) { + if (pad->right.isHold()) { + move_right(node); + } else if (pad->left.isHold()) { + move_left(node); + } else if (pad->down.isHold()) { + move_down(node); + } else if (pad->up.isHold()) { + move_up(node); + } + } + + if (pad->cross.isHold() || pad->circle.isHold()) { + if (pad->cross.isHold()) { + node->xyz[2] += 5; + } else if (pad->circle.isHold()) { + node->xyz[2] -= 5; + } + } +} + +void +gaplant_coll(SceneGraphPtr node, int w, int h, SceneGraphPtr tree) +{ + SceneGraphIteratorPtr it = sgroot->getIterator(tree); + //static int damage = 0; + + for (; it->hasNext(Ball);) { + it->next(Ball); + SceneGraphPtr ball = it->get(); + + double dis_x = node->xyz[0] - ball->xyz[0]; + double dis_y = node->xyz[1] - ball->xyz[1]; + double dis_z = node->xyz[2] - ball->xyz[2]; + double distance = sqrt(dis_x*dis_x + dis_y*dis_y + dis_z*dis_z); + + if (distance < CHECK_HIT_RAD + BALL_RAD) { + cout << "今からもっと細かく判定するよ ^q^\n"; + ball->remove(); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/gaplant_action.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,2 @@ +void gaplant_move(SceneGraphPtr, int, int); +void gaplant_coll(SceneGraphPtr, int, int, SceneGraphPtr);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/hit_judge.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,80 @@ +#include "SceneGraph.h" +#include "hit_judge.h" +#include "SGList.h" + +#define FUSELAGE_W 6 +#define FUSELAGE_H 6 +#define FUSELAGE_Z 6 +#define E_PLANE_W 6*4 +#define E_PLANE_H 6*4 +#define E_PLANE_Z 6*4 +#define BULLTE_W 2*4 +#define BULLTE_H 6*4 +#define BULLTE_Z 2*4 + +int +square_judge(SceneGraphPtr oneself, SceneGraphPtr partner) +{ + int ow = 0, oh = 0, oz = 0; + int pw = 0, ph = 0, pz = 0; + if (oneself->sgid == IDLE) + { + ow = FUSELAGE_W; + oh = FUSELAGE_H; + oz = FUSELAGE_Z; + } + else if (oneself->sgid == E_PLANE) + { + ow = E_PLANE_W; + oh = E_PLANE_H; + oz = E_PLANE_Z; + } + else if(oneself->sgid == BULEBULLET) + { + ow = BULLTE_W; + oh = BULLTE_H; + oz = BULLTE_Z; + } + if(partner->sgid == IDLE) + { + pw = FUSELAGE_W; + ph = FUSELAGE_H; + pz = FUSELAGE_Z; + } + else if(partner->sgid == E_PLANE) + { + pw = E_PLANE_W; + ph = E_PLANE_H; + pz = E_PLANE_Z; + } + else if(partner->sgid == BULEBULLET) + { + pw = BULLTE_W; + ph = BULLTE_H; + pz = BULLTE_Z; + } + + + int ox_min = (int)(oneself->xyz[0] + oneself->c_xyz[0] - ow/2); + int oy_min = (int)(oneself->xyz[1] + oneself->c_xyz[1] - oh/2); + int oz_min = (int)(oneself->xyz[2] + oneself->c_xyz[2] - oz/2); + + int ox_max = (int)(oneself->xyz[0] + oneself->c_xyz[0] + ow/2); + int oy_max = (int)(oneself->xyz[1] + oneself->c_xyz[1] + oh/2); + int oz_max = (int)(oneself->xyz[2] + oneself->c_xyz[2] + oz/2); + + int px_min = (int)(partner->xyz[0] + partner->c_xyz[0] - pw/2); + int py_min = (int)(partner->xyz[1] + partner->c_xyz[1] - ph/2); + int pz_min = (int)(partner->xyz[2] + partner->c_xyz[2] - pz/2); + + int px_max = (int)(partner->xyz[0] + partner->c_xyz[0] + pw/2); + int py_max = (int)(partner->xyz[1] + partner->c_xyz[1] + ph/2); + int pz_max = (int)(partner->xyz[2] + partner->c_xyz[2] + pz/2); + + if(ox_max < px_min || px_max < ox_min || oy_max < py_min || py_max < oy_min || oz_max < pz_min || pz_max < oz_min) + { + } else { + return HIT; + } + return 0; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/hit_judge.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,11 @@ +#ifndef HIT_JUDGE_H +#define HIT_JUDGE_H + +#define TOUCH_LOWER 1 +#define TOUCH_TOP 2 +#define TOUCH_RIGHT 3 +#define TOUCH_LEFT 4 +#define HIT 5 + +extern int square_judge(SceneGraphPtr oneself, SceneGraphPtr partner); +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/ieshoot.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,216 @@ +#include "SceneGraphRoot.h" +#include "SGList.h" + +static const float jiki_speed = 6.0f; +static const float jiki_radius = 32.0f; + +static const float tama_speed = 10.0f; +static const float tama_radius = 16.0f; + +static const float boss_radius_x = 64.0f; +static const float boss_radius_y = 128.0f; + +static const float iebosstama_speed = 15.0f; + +static void +ieboss_collision(SceneGraphPtr node, int screen_w, int screen_h, + SceneGraphPtr tree); +static void +ieboss_collision_invincibil(SceneGraphPtr node, int screen_w, int screen_h, SceneGraphPtr tree); +static void ieboss_move(SceneGraphPtr node, int screen_w, int screen_h); + +static void iebosstama_move(SceneGraphPtr node, int screen_w, int screen_h); + + +static void +iejiki_collision(SceneGraphPtr node, int screen_w, int screen_h, + SceneGraphPtr tree) +{ +} + +static void +ietama_collision(SceneGraphPtr node, int screen_w, int screen_h, + SceneGraphPtr tree) +{ +} + +static void +ieboss_collision(SceneGraphPtr node, int screen_w, int screen_h, + SceneGraphPtr tree) +{ + SceneGraphIteratorPtr it = sgroot->getIterator(tree); + static int damage = 0; + + for (; it->hasNext(IETAMA);) { + it->next(IETAMA); + SceneGraphPtr tama = it->get(); + + if (node->xyz[0] - boss_radius_x < tama->xyz[0] + tama_radius + && node->xyz[0] + boss_radius_x > tama->xyz[0] - tama_radius + && node->xyz[1] + boss_radius_y > tama->xyz[1] - tama_radius) { + tama->remove(); + + node->set_move_collision(ieboss_move, ieboss_collision_invincibil); + + SceneGraphPtr iebosstama = sgroot->createSceneGraph(Earth); + iebosstama->set_move_collision(iebosstama_move, ietama_collision); + iebosstama->xyz[0] = node->xyz[0]; + iebosstama->xyz[1] = node->xyz[1] + boss_radius_y; + //iebosstama->xyz[2] = 50.0f; + node->addBrother(iebosstama); + + damage++; + } + } + + if (damage > 10) { + node->remove(); + } +} + +static void +ieboss_move(SceneGraphPtr node, int screen_w, int screen_h) +{ + /** + * TODO + * Boss が複数居た場合、これじゃ駄目 + */ + static float x_speed = 5.0f; + static float z_speed = 5.0f; + + node->xyz[0] += x_speed; + + if (node->xyz[0] - boss_radius_x < 0) { + x_speed = -x_speed; + node->xyz[0] = boss_radius_x; + } else if (node->xyz[0] + boss_radius_x > screen_w) { + x_speed = -x_speed; + node->xyz[0] = screen_w - boss_radius_x; + } + + //node->xyz[2] += z_speed; + if (node->xyz[2] >= 100.0f) { + node->xyz[2] = 99.99f; + z_speed = -z_speed; + } else if (node->xyz[2] <= -100.0f) { + node->xyz[2] = -99.99f; + z_speed = -z_speed; + } +} + +static void +ieboss_collision_invincibil(SceneGraphPtr node, int screen_w, int screen_h, + SceneGraphPtr tree) +{ + static int frame = 0; + + frame++; + + node->flag_drawable ^= 1; + + if (frame > 60) { + frame = 0; + node->flag_drawable = 1; + node->set_move_collision(ieboss_move, ieboss_collision); + } +} + +static void +iebosstama_move(SceneGraphPtr node, int screen_w, int screen_h) +{ + node->xyz[1] += iebosstama_speed; + + // 描画領域から抜けたら削除 + if (node->xyz[1] > screen_h) { + node->remove(); + } +} + +static void +ietama_move(SceneGraphPtr node, int screen_w, int screen_h) +{ + node->xyz[1] -= tama_speed; + + // 描画領域から抜けたら削除 + if (node->xyz[1] < 0) { + node->remove(); + } +} + +static void +iejiki_move(SceneGraphPtr node, int screen_w, int screen_h) +{ + Pad *pad = sgroot->getController(); + + if (pad->left.isPush() + || pad->left.isHold()) { + node->xyz[0] -= jiki_speed; + + if (node->xyz[0] - jiki_radius< 0) { + node->xyz[0] = jiki_radius; + } + } + + if (pad->right.isPush() + || pad->right.isHold()) { + node->xyz[0] += jiki_speed; + + if (node->xyz[0] + jiki_radius > screen_w) { + node->xyz[0] = screen_w - jiki_radius; + } + } + + if (pad->up.isPush() + || pad->up.isHold()) { + node->xyz[1] -= jiki_speed; + + if (node->xyz[1] - jiki_radius < 0) { + node->xyz[1] = jiki_radius; + } + } + + if (pad->down.isPush() + || pad->down.isHold()) { + node->xyz[1] += jiki_speed; + + if (node->xyz[1] + jiki_radius > screen_h) { + node->xyz[1] = screen_h - jiki_radius; + } + } + + if (pad->circle.isPush()) { + SceneGraphPtr ietama = sgroot->createSceneGraph(IETAMA); + ietama->set_move_collision(ietama_move, ietama_collision); + ietama->xyz[0] = node->xyz[0]; + ietama->xyz[1] = node->xyz[1]; + node->addBrother(ietama); + } +} + + +void +ieshoot_init(TaskManager *manager) +{ + SceneGraphPtr iejiki; + SceneGraphPtr enemy; + SceneGraphPtr back; + + sgroot->createFromXMLfile(manager, "xml_file/ietama.xml"); + sgroot->createFromXMLfile(manager, "xml_file/ieboss.xml"); + sgroot->createFromXMLfile(manager, "xml_file/iejiki.xml"); + sgroot->createFromXMLfile(manager, "xml_file/universe.xml"); + + back = sgroot->createSceneGraph(); + + iejiki = sgroot->createSceneGraph(IEJIKI); + iejiki->set_move_collision(iejiki_move, iejiki_collision); + iejiki->xyz[2] = 20; + back->addChild(iejiki); + + enemy = sgroot->createSceneGraph(IEBOSS); + enemy->set_move_collision(ieboss_move, ieboss_collision); + enemy->xyz[1] = boss_radius_y; + back->addChild(enemy); + + sgroot->setSceneData(back); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/init_position.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,36 @@ +#include "SceneGraphRoot.h" +#include "SGList.h" +#include "player_action.h" +#include "enemy_action.h" +#include "camera_action.h" + +void +init_position(TaskManager *manager, int w, int h) +{ + SceneGraphPtr back; + SceneGraphPtr player; + SceneGraphPtr enemy; + //SceneGraphPtr bullet; + + sgroot->createFromXMLfile(manager, "xml_file/player.xml"); + back = sgroot->createSceneGraph(BACK); + //back = sgroot->createSceneGraph(); + player = sgroot->createSceneGraph(IDLE); + //bullet = sgroot->createSceneGraph(BULEBULLET); + + camera_init(back, w, h); + back->set_move_collision(camera_init, camera_collision); + player->set_move_collision(player_move_all, player_collision); + + + back->addChild(player); + + for (int i = 0; i < 10; i++) { + enemy = sgroot->createSceneGraph(E_PLANE); + enemy->set_move_collision(enemy_move, enemy_collision); + enemy->xyz[0] = 50.0*i; + back->addChild(enemy); + } + + sgroot->setSceneData(back); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/long_cube.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,31 @@ +#include "SceneGraphRoot.h" +#include "SGList.h" + +// prototype +static void lcube_move(SceneGraphPtr node, int screen_w, int screen_h); +//static void lcube_collision(SceneGraphPtr node, int screen_w, int screen_h); + + +static void +lcube_move(SceneGraphPtr node, int screen_w, int screen_h) +{ +} + +static void +lcube_collision(SceneGraphPtr node, int screen_w, int screen_h, + SceneGraphPtr tree) +{ +} + + +void +lcube_init(TaskManager *manager, int screen_w, int screen_h) +{ + SceneGraphPtr lcube; + + sgroot->createFromXMLfile(manager, "xml_file/LongCube.xml"); + lcube = sgroot->createSceneGraph(LongCube); + lcube->set_move_collision(lcube_move, lcube_collision); + + sgroot->setSceneData(lcube); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/node.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,72 @@ +#include <stdlib.h> +#include "SceneGraphRoot.h" +#include "SceneGraph.h" +#include "xml_file/cube.h" + +static void +cube_collision(SceneGraphPtr node, int screen_w, int screen_h, + SceneGraphPtr tree) +{ +} + +static void +cube_move2(SceneGraphPtr node, int screen_w, int screen_h) +{ + node->angle[1] += 1.0f; + if (node->angle[1] > 360.0f) { + node->angle[1] = 0.0f; + } + + node->xyz[0] += node->stack_xyz[0]; + if ((int)node->xyz[0] > screen_w || (int)node->xyz[0] < 0) { + node->stack_xyz[0] = -node->stack_xyz[0]; + } + + node->xyz[1] += node->stack_xyz[1]; + if ((int)node->xyz[1] > screen_h || (int)node->xyz[1] < 0) { + node->stack_xyz[1] = -node->stack_xyz[1]; + } +} + +static void +cube_move(SceneGraphPtr node, int screen_w, int screen_h) +{ + node->angle[1] += 1.0f; + if (node->angle[1] > 360.0f) { + node->angle[1] = 0.0f; + } + + node->xyz[0] += node->stack_xyz[0]; + if ((int)node->xyz[0] > screen_w || (int)node->xyz[0] < 0) { + node->stack_xyz[0] = -node->stack_xyz[0]; + } + + node->xyz[1] += node->stack_xyz[1]; + if ((int)node->xyz[1] > screen_h || (int)node->xyz[1] < 0) { + + // 実は微妙に意味が無い + // そうじゃなくて、やっちゃいけないことです。 + // srandom(random()); + + SceneGraphPtr p = node->clone(); + p->position_init(); + node->addBrother(p); + p->set_move_collision(cube_move2, cube_collision); + p->stack_xyz[0] = (float)(random() % 5); + p->stack_xyz[1] = (float)(random() % 5); + //p->xyz[0] = screen_w/2; + //p->xyz[1] = screen_h/2; + p->xyz[2] = node->xyz[2]+1000.0f; + + node->stack_xyz[1] = -node->stack_xyz[1]; + } +} + +void +node_init(TaskManager *manager) +{ + sgroot->createFromXMLfile(manager, "xml_file/cube.xml"); + Cube->set_move_collision(cube_move, cube_collision); + Cube->stack_xyz[0] = 2.0f; + Cube->stack_xyz[1] = 2.0f; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/panel.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,38 @@ +#include "SceneGraphRoot.h" +#include "SGList.h" + +static void panel_move(SceneGraphPtr node, int screen_w, int screen_h); +static void panel_collision(SceneGraphPtr node, int screen_w, int screen_h, + SceneGraphPtr tree); + +static void +panel_move(SceneGraphPtr node, int screen_w, int screen_h) +{ +} + +static void +panel_collision(SceneGraphPtr node, int screen_w, int screen_h, + SceneGraphPtr tree) +{ +} + +void +panel_init(TaskManager *manager, int bg) +{ + SceneGraphPtr panel; + + if (bg == 2) { + sgroot->createFromXMLfile(manager, "xml_file/panel_512.xml"); + panel = sgroot->createSceneGraph(PANEL_512); + } else if (bg == 3) { + sgroot->createFromXMLfile(manager, "xml_file/panel_1024.xml"); + panel = sgroot->createSceneGraph(PANEL_1024); + } else { + sgroot->createFromXMLfile(manager, "xml_file/panel_2048.xml"); + panel = sgroot->createSceneGraph(PANEL_2048); + } + + panel->set_move_collision(panel_move, panel_collision); + panel->xyz[2] = 30.0f; + sgroot->setSceneData(panel); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/player_action.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,146 @@ +#include "SceneGraphRoot.h" +#include "bullet_action.h" +#include "SGList.h" + +#define MOVE_SPEED 5.00 + + +void +player_move_right(SceneGraphPtr node, int screen_w, int screen_h) +{ + if(node->xyz[0]<screen_w/2) + { + node->xyz[0] += MOVE_SPEED; + } + if(node->angle[1]<=20) + { + node->angle[1]+=1.0; + } + if(node->angle[2]>=-45) + { + node->angle[2]-=1.0; + } +} + +void +player_move_left(SceneGraphPtr node, int screen_w, int screen_h) +{ + if(node->xyz[0]> -screen_w/2) + { + node->xyz[0] -= MOVE_SPEED; + } + if(node->angle[1]>=-20) + { + node->angle[1]-=1.0; + } + if(node->angle[2]<=45) + { + node->angle[2]+=1.0; + } +} + +void +player_move_up(SceneGraphPtr node, int screen_w, int screen_h) +{ + if(node->xyz[2]<screen_h/2 + 100) + { + node->xyz[2] += MOVE_SPEED; + } + if(node->angle[0]<45) + { + node->angle[0] += 2.0; + } +} + +void +player_move_down(SceneGraphPtr node, int screen_w, int screen_h) +{ + if(node->xyz[2]> -screen_h/2) + { + node->xyz[2] -= MOVE_SPEED; + } + if(node->angle[0]>-45) + { + node->angle[0] -= 2.0; + } +} + +void +player_move_idle(SceneGraphPtr node) +{ + if (node->angle[1]>0) + { + node->angle[1]-=1.0; + } + else if(node->angle[1]<0) + { + node->angle[1]+=1.0; + } + + if(node->angle[2]<0) + { + node->angle[2]+=0.5; + } + else if(node->angle[2]>0) + { + node->angle[2]-=0.5; + } + + if(node->angle[0]<0) + { + node->angle[0]+=1.0; + } + else if(node->angle[0]>0) + { + node->angle[0]-=1.0; + } +} + +void +player_move_all(SceneGraphPtr node, int screen_w, int screen_h) +{ + Pad *pad = sgroot->getController(); + + if (pad->right.isHold() || pad->left.isHold() || + pad->up.isHold() || pad->down.isHold()) { + if (pad->right.isHold()) { + player_move_right(node, screen_w, screen_h); + } else if (pad->left.isHold()) { + player_move_left(node, screen_w, screen_h); + } + + if (pad->down.isHold()) { + player_move_up(node, screen_w, screen_h); + } else if(pad->up.isHold()) { + player_move_down(node, screen_w, screen_h); + } + } else { + player_move_idle(node); + } + + if (pad->r2.isHold()) { + node->xyz[2] -= 10.0f; + } + + if (pad->circle.isPush()) { + SceneGraphPtr bullet = sgroot->createSceneGraph(BULEBULLET); + bullet->set_move_collision(bluebullet_move, bullet_collision); + bullet_init(bullet, node); + node->addBrother(bullet); + } +} + +void +player_collision(SceneGraphPtr node, int screen_w, int screen_h, + SceneGraphPtr tree) +{ +#if 0 + int judge = square_judge(node, BULEBULLET, scene_graph); + + if (judge == HIT) + { + node->set_move_collision(player_move_all,player_collision); + } +#endif +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/player_action.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,7 @@ +void player_move_right(SceneGraphPtr node, int screen_w, int screen_h); +void player_move_left(SceneGraphPtr node, int screen_w, int screen_h); +void player_move_up(SceneGraphPtr node, int screen_w, int screen_h); +void player_move_down(SceneGraphPtr node, int screen_w, int screen_h); +void player_move_idle(SceneGraphPtr node); +void player_move_all(SceneGraphPtr node, int screen_w, int screen_h); +void player_collision(SceneGraphPtr node, int screen_w, int screen_h ,SceneGraphPtr tree);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/title.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,28 @@ +#include "SceneGraphRoot.h" +#include "vacuum.h" +#include "SGList.h" + +void +title_collision(SceneGraphPtr node, int w, int h,SceneGraphPtr tree) +{ + + Pad *pad = sgroot->getController(); + + if(pad->start.isPush()) { + + SceneGraphPtr vacuum; + SceneGraphPtr back = sgroot->createSceneGraph(); + + vacuum = sgroot->createSceneGraph(BIGCUBE); + vacuum->xyz[0] = w/2; + vacuum->xyz[1] = h*0.8; + vacuum->set_move_collision(vacuum_move, vacuum_coll); + + back->addChild(vacuum); + + add_cubecollision_object(REDCUBE,vacuum,w,h); + + sgroot->setSceneData(back); + + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/universe.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,68 @@ +#include <stdlib.h> +#include "SceneGraphRoot.h" +#include "SGList.h" + +static void +earth_collision(SceneGraphPtr node, int screen_w, int screen_h, + SceneGraphPtr tree) +{ +} + +static void +moon_collision(SceneGraphPtr node, int screen_w, int screen_h, + SceneGraphPtr tree) +{ +} + +static void +moon_move(SceneGraphPtr node, int screen_w, int screen_h) +{ + node->angle[0] += 3.0f; +} + + +static void +earth_move(SceneGraphPtr node, int screen_w, int screen_h) +{ + node->angle[1] += 1.0f; + if (node->angle[1] > 360.0f) { + node->angle[1] = 0.0f; + } + + node->xyz[0] += node->stack_xyz[0]; + if ((int)node->xyz[0] > screen_w || (int)node->xyz[0] < 0) { + node->stack_xyz[0] = -node->stack_xyz[0]; + } + + node->xyz[1] += node->stack_xyz[1]; + if ((int)node->xyz[1] > screen_h || (int)node->xyz[1] < 0) { + node->stack_xyz[1] = -node->stack_xyz[1]; + } +} + +void +universe_init(TaskManager *manager) +{ + SceneGraphPtr earth; + SceneGraphPtr moon; + + sgroot->createFromXMLfile(manager, "xml_file/universe.xml"); + + // SGList.h にある SceneGraph ID から SceneGraph を生成する + earth = sgroot->createSceneGraph(Earth); + + // SceneGraph の move と collision を設定 + earth->set_move_collision(earth_move, earth_collision); + earth->stack_xyz[0] = 3.0f; + earth->stack_xyz[1] = 3.0f; + + moon = sgroot->createSceneGraph(Moon); + moon->set_move_collision(moon_move, moon_collision); + + // SceneGraph 同士の親子関係を設定 (今回は 親 earth、子 moon) + earth->addChild(moon); + + // SceneGraphRoot に、使用する SceneGraph を設定する + // このとき、ユーザーが記述した SceneGraph の root を渡す。 + sgroot->setSceneData(earth); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/untitled.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,149 @@ +#include <stdlib.h> +#include "SceneGraphRoot.h" +#include "SGList.h" +#include <math.h> + +static void +cubetest_collision(SceneGraphPtr node, int screen_w, int screen_h, + SceneGraphPtr tree) +{ +} + +static void +test_collision(SceneGraphPtr node, int screen_w, int screen_h, + SceneGraphPtr tree) +{ + // test +} + +static void +test_move(SceneGraphPtr node, int screen_w, int screen_h) +{ + + node->angle[0] += 10.0f; + /* + node->stack_xyz[0] = 2.0f; + node->stack_xyz[1] = 2.0f; + + //node->xyz[0] += node->stack_xyz[0]; + node->xyz[0] += node->stack_xyz[0]; + node->xyz[1] += node->stack_xyz[1]; + + if ((int)node->xyz[0] > screen_w + || (int)node->xyz[0] < 0) { + node->stack_xyz[0] = -node->stack_xyz[0]; + } + + if ((int)node->xyz[1] > screen_w + || (int)node->xyz[1] < 0) { + node->stack_xyz[1] = -node->stack_xyz[1]; + } + + if ((int)node->xyz[2] > 1000 + || (int)node->xyz[2] < 100) { + node->stack_xyz[1] = -node->stack_xyz[1]; + } + */ + +} + +static void +cubetest_move(SceneGraphPtr node, int screen_w, int screen_h) +{ + node->angle[1] += 10.0f; + if (node->angle[1] > 360.0f) { + node->angle[1] = 0.0f; + } + //node->xyz[0] = screen_w/2; + node->xyz[0] += node->stack_xyz[0]; + if ((int)node->xyz[0] > screen_w || (int)node->xyz[0] < 0) { + node->stack_xyz[0] = -node->stack_xyz[0]; + } + //node->xyz[1] = screen_h/2; + node->xyz[1] += node->stack_xyz[1]; + if ((int)node->xyz[1] > screen_h || (int)node->xyz[1] < 0) { + node->stack_xyz[1] = -node->stack_xyz[1]; + } + + node->xyz[2] = 1000; + //node->xyz[2] += node->stack_xyz[2]; + //if ((int)node->xyz[2] > screen_h || (int)node->xyz[2] < 100) { + //node->stack_xyz[2] = -node->stack_xyz[2]; + //} + +} + +void +untitled_init(TaskManager *manager) +{ + SceneGraphPtr test00; + SceneGraphPtr test01; + SceneGraphPtr test02; + SceneGraphPtr test03; + SceneGraphPtr test04; + SceneGraphPtr test05; + SceneGraphPtr test06; + SceneGraphPtr test07; + SceneGraphPtr test08; + SceneGraphPtr test09; + + sgroot->createFromXMLfile(manager, "xml_file/Venus.xml"); + + // SGList.h にある SceneGraph ID から SceneGraph を生成する + /* + test00 = sgroot->createSceneGraph(cubetest000); + test01 = sgroot->createSceneGraph(cubetest009); + test02 = sgroot->createSceneGraph(cubetest008); + test03 = sgroot->createSceneGraph(cubetest007); + test04 = sgroot->createSceneGraph(cubetest006); + test05 = sgroot->createSceneGraph(cubetest005); + test06 = sgroot->createSceneGraph(cubetest004); + test07 = sgroot->createSceneGraph(cubetest003); + test08 = sgroot->createSceneGraph(cubetest002); + test09 = sgroot->createSceneGraph(cubetest001); + */ + test00 = sgroot->createSceneGraph(Venus000); + test01 = sgroot->createSceneGraph(Venus009); + test02 = sgroot->createSceneGraph(Venus008); + test03 = sgroot->createSceneGraph(Venus007); + test04 = sgroot->createSceneGraph(Venus006); + test05 = sgroot->createSceneGraph(Venus005); + test06 = sgroot->createSceneGraph(Venus004); + test07 = sgroot->createSceneGraph(Venus003); + test08 = sgroot->createSceneGraph(Venus002); + test09 = sgroot->createSceneGraph(Venus001); + + // SceneGraph の move と collision を設定 + test00->set_move_collision(cubetest_move, cubetest_collision); + test00->stack_xyz[0] = 3.0f; + test00->stack_xyz[1] = 3.0f; + test00->stack_xyz[2] = 3.0f; + + + + test01->set_move_collision(test_move, test_collision); + test02->set_move_collision(test_move, test_collision); + test03->set_move_collision(test_move, test_collision); + test04->set_move_collision(test_move, test_collision); + test05->set_move_collision(test_move, test_collision); + test06->set_move_collision(test_move, test_collision); + test07->set_move_collision(test_move, test_collision); + test08->set_move_collision(test_move, test_collision); + test09->set_move_collision(test_move, test_collision); + + // SceneGraph 同士の親子関係を設定 (今回は 親 test00、子 その他) + test00->addChild(test01); + test00->addChild(test02); + test00->addChild(test03); + test00->addChild(test04); + test00->addChild(test05); + test00->addChild(test06); + test00->addChild(test07); + test00->addChild(test08); + test00->addChild(test09); + + // SceneGraphRoot に、使用する SceneGraph を設定する + // このとき、ユーザーが記述した SceneGraph の root を渡す。 + sgroot->setSceneData(test00); + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/vacuum.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,174 @@ +#include <math.h> +#include "vacuum.h" +#include "SceneGraphRoot.h" +#include "SGList.h" +#define ENCOUNT 55 +using namespace std; + +static float vacuum_speed = 10.0f; + + +/*オブジェクト毎にファイルを分けてみた + * + * + */ + + + +void +no_move_idle(SceneGraphPtr node, int screen_w, int screen_h) +{ + +} + +void +no_collision_idle(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree) +{ + +} + +void +vacuum_coll(SceneGraphPtr node, int screen_w, int screen_h, + SceneGraphPtr tree) +{ + Pad *pad = sgroot->getController(); + + if(node->frame%ENCOUNT == ENCOUNT-1) { + if(random()%2) { + add_cubecollision_object(REDCUBE,node,screen_w,screen_h); + } + else { + add_cubecollision_object(ENEMY,node,screen_w,screen_h); + } + } + + if (pad->cross.isHold()) { + SceneGraphIteratorPtr it = sgroot->getIterator(tree); + collision_red(it,node); + it = sgroot->getIterator(tree); + collision_purple(it,node,screen_w,screen_h); + } + + else if(pad->circle.isHold()) { + SceneGraphIteratorPtr it = sgroot->getIterator(tree); + lock_attack(node,it); + } + +} + +void +lock_attack(SceneGraphPtr node,SceneGraphIteratorPtr it) +{ + + SceneGraphPtr enemy; + SceneGraphPtr near_enemy = NULL; + float dx,dy,r,range = 100; + // Pad *pad = sgroot->getController(); + + for(;it->hasNext(ENEMY);) { + + it->next(ENEMY); + enemy = it->get(); + dx = enemy->xyz[0] - node->xyz[0]; + dy = enemy->xyz[1] - node->xyz[1]; + r = sqrt(dx*dx+dy*dy); + + if(range > r && enemy->stack_xyz[2] == 0) { + range = r; + near_enemy = enemy; + } + } + + + if(near_enemy != NULL) { + /*stack_xyz[2]をlockonフラグとして使うかな?*/ + SceneGraphPtr lockon; + // SceneGraphPtr near_enemy_common_move = near_enemy->parent; + near_enemy->stack_xyz[2] = 1; + lockon = sgroot->createSceneGraph(LOCK); + lockon->set_move_collision(no_move_idle,lockon_collision); + //near_enemy_common_move->addChild(lockon); + near_enemy->addChild(lockon); + } + +} + +void +lockon_collision(SceneGraphPtr node,int w,int h,SceneGraphPtr tree) { + + Pad *pad = sgroot->getController(); + SceneGraphPtr lockon_enemy = node->parent; + + /* node->angle[0] = -lockon_enemy->angle[0]; + node->angle[1] = -lockon_enemy->angle[1]; + node->angle[2] = -lockon_enemy->angle[2];*/ + + if(pad->circle.isRelease()) { + lockon_enemy->remove(); + } + +} + + +void +vacuum_move(SceneGraphPtr node , int w, int h) +{ + Pad *pad = sgroot->getController(); + + if (pad->right.isHold() && w > node->xyz[0]) { + node->xyz[0] += vacuum_speed; + node->angle[0] += 2; + } else if (pad->left.isHold() && 0 < node->xyz[0]) { + node->xyz[0] -= vacuum_speed; + node->angle[0] -= 2; + } + + if (pad->up.isHold() && 0 < node->xyz[1]) { + node->xyz[1] -= vacuum_speed; + node->angle[1] -= 2; + } else if (pad->down.isHold() && h > node->xyz[1]) { + node->xyz[1] += vacuum_speed; + node->angle[1] += 2; + } + + if (pad->start.isPush()) { + node->xyz[0] = w/2; + node->xyz[1] = h*0.8; + } +} + + + +/*cubeをランダムな場所に生成*/ +void +add_cubecollision_object(int id,SceneGraphPtr root,int w,int h) +{ + SceneGraphPtr object; + SceneGraphPtr common_move; + + common_move = sgroot->createSceneGraph(); + object = sgroot->createSceneGraph(id); + object->xyz[0] = random()%w; + object->xyz[1] = random()%h; + object->set_move_collision(no_move_idle,cube_collision); + //common_move->addChild(object); + root->addBrother(object); +} + + +void +vacuum_init2(TaskManager *manager, int w, int h) +{ + SceneGraphPtr title; + + sgroot->createFromXMLfile(manager, "xml_file/gamecube.xml"); + sgroot->createFromXMLfile(manager, "xml_file/title.xml"); + sgroot->createFromXMLfile(manager, "xml_file/gameover.xml"); + + title = sgroot->createSceneGraph(TITLE); + title->xyz[0] = w/2; + title->xyz[1] = h/2; + title->set_move_collision(no_move_idle, title_collision); + + sgroot->setSceneData(title); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/vacuum.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,28 @@ +#ifndef VACUUM_H +#define VACUUM_H + +#include "SGList.h" +#include "SceneGraphRoot.h" + +void cube_move_left(SceneGraphPtr node, int screen_w, int screen_h); +void cube_move_right(SceneGraphPtr node, int screen_w, int screen_h); +void no_move_idle(SceneGraphPtr node, int screen_w, int screen_h); +void cube_collision_idle(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree); +void cube_collision(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree); +void cube_split(SceneGraphPtr root,SceneGraphPtr tree); +void vacuum_move(SceneGraphPtr node, int w, int h); +void vacuum_coll(SceneGraphPtr node, int w, int h,SceneGraphPtr tree); +void title_idle(SceneGraphPtr node, int screen_w, int screen_h); +void title_collision(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree); +void scene_change(int w,int h,SceneGraphPtr node); +void gameover_idle(SceneGraphPtr node, int screen_w, int screen_h); +void gameover_collision(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree); +void collision_red(SceneGraphIteratorPtr it,SceneGraphPtr node); +void collision_purple(SceneGraphIteratorPtr it,SceneGraphPtr node,int w,int h); +void gameover_scene(int w,int h, SceneGraphPtr node); +void add_cubecollision_object(int id,SceneGraphPtr root,int w,int h); +void lock_attack(SceneGraphPtr node,SceneGraphIteratorPtr it); +void lockon_collision(SceneGraphPtr node,int w,int h,SceneGraphPtr tree); +void cube_rotate(SceneGraphPtr node,int w,int h); + +#endif
--- a/Renderer/Cell/Engine.cpp Mon Oct 12 02:50:01 2009 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -CellEngine::CellEngine() -{ - TaskManager manager = new TaskManager(); -} - -void -CellEngine::init(int width, int height, int bpp) -{ - if(SDL_Init( SDL_INIT_VIDEO ) < 0) - { - cout << "Couldn't initialize SDL:" << SDL_GetError() << endl; - exit(1); - } - - // etc... -} - -TaskDepend -CellEngine::update_all(SceneGraph* next, SceneGraph* now, TaskDepend wait) -{ - SceneGraph *t, *nt; - t = now; - nt = next; - - SceneGraphPack *nt_pack = nt->data_pack(); - SceneGraphPack *t_pack; - Task* t_task = now->get_task(); - TaskDepend task; - - task = manager->create_task(function_id, now->task_size(), - (unsigned int *)now->get_task(), - (unsigned int *)next->get_task()); - - manager->set_task_depend(task, wait); - - task->run(); - - return task; -} - -TaskDepend -CellEngin::draw_all(SceneGraph* now, TaskDepend wait) -{ - /** - * SceneGraph => Polygon - * Polygon => Span, Texture - * Texture, Span => Rendering - */ - - SceneGraph *t, *nt; - t = now; - nt = next; - - SceneGraphPack *nt_pack = nt->data_pack(); - SceneGraphPack *t_pack; - Task* t_task = now->get_task(); - TaskDepend task; - - task = manager->create_task(function_id, now->task_size(), - (unsigned int *)now->get_task(), - (unsigned int *)next->get_task()); - - manager->set_task_depend(task, wait); - - task->run(); -}
--- a/Renderer/Cell/Engine.h Mon Oct 12 02:50:01 2009 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -class CellEngine : RenderingEngine { -public: - CellEngine(int width, int height, int bpp); -};
--- a/Renderer/Cell/SceneGraph2PolygonTask.h Mon Oct 12 02:50:01 2009 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -class SceneGraph2PolygonTask : Task { -};
--- a/Renderer/DataPack/DataPackEngine.cpp Mon Oct 12 02:50:01 2009 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -void -DataPackEngine::init(int width, int height, int bpp) -{ - if(SDL_Init( SDL_INIT_VIDEO ) < 0) - { - cout << "Couldn't initialize SDL:" << SDL_GetError() << endl; - exit(1); - } - - // etc... -} - -TaskDepend -DataPackEngine::update_all(SceneGraph* next, SceneGraph* now, TaskDepend wait) -{ - SceneGraph *t, *nt; - t = now; - nt = next; - - SceneGraphPack *nt_pack = nt->data_pack(); - SceneGraphPack *t_pack; - Task* t_task = now->get_task(); - - for (t_pack = now->data_pack(); t_pack < not->data_pack;) { - t_task->update(t_pack, nt_pack); - t_pack = t_pack->next(); - nt_pack = nt_pack->next(); - } -} - -TaskDepend -DataPackEngin::draw_all(SceneGraph* now, TaskDepend wait) -{ - SceneGraph *t, *nt; - t = now; - nt = next; - - SceneGraphPack *t_pack; - Task* t_task = now->get_task(); - - for (t_pack = now->data_pack(); t_pack < now->data_pack;) { - t_task->draw(t_pack, nt_pack); - t_pack = t_pack->next(); - } -}
--- a/Renderer/DataPack/DataPackEngine.h Mon Oct 12 02:50:01 2009 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -class DataPackEngine : RenderingEngine { -public: - DataPackEngine(int width, int height, int bpp); -};
--- a/Renderer/DataPack/Test/SpanPack/main.cpp Mon Oct 12 02:50:01 2009 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -#include <iostream> -#include "polygonpack.h" - -int main(int argc, char *argv[]) { - Polygon_Pack *akira = new Polygon_Pack(); - PolygonPack *hoge; - SPANPACK *hoge2; - hoge->info.size =0; - hoge->tri[0].ver1.x = 34.345901; - hoge->tri[0].ver1.y = -26.347542; - hoge->tri[0].ver1.z = -1.079739; - hoge->tri[0].ver1.tex_x = 0.000000; - hoge->tri[0].ver1.tex_y = 1.000000; - - hoge->tri[0].ver2.x = -9.054828; - hoge->tri[0].ver2.y = -36.410835; - hoge->tri[0].ver2.z = 21.616213; - hoge->tri[0].ver2.tex_x = 0.000000; - hoge->tri[0].ver2.tex_y = 0.000000; - - hoge->tri[0].ver3.x = -33.877331; - hoge->tri[0].ver3.y = -19.684675; - hoge->tri[0].ver3.z = -18.434740; - hoge->tri[0].ver3.tex_x = 1.000000; - hoge->tri[0].ver3.tex_y = 0.000000; - akira->create_span((void*)hoge,(void*)hoge2); - return 0; -}
--- a/Renderer/DataPack/Test/SpanPack/polygonpack.cpp Mon Oct 12 02:50:01 2009 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,139 +0,0 @@ -#include <iostream> -#include "polygonpack.h" -using namespace std; - -static float calc(float f1, float f2,int i, float base){ - float ans; - ans = f1/f2*i + base; - return ans; -} - - -static vertex *vMid1(Vertex *vMid1,Vertex *vMin, Vertex *vMid, Vertex *vMax) { - float d,d1; - d = (int)vMax->y-(int)vMin->y; - d1 = (int)vMid->y - (int)vMin->y; - vMid1->tex_x = calc(vMax->tex_x - vMin->tex_x, d, (int)d1 , vMin->tex_x); - vMid1->tex_y = calc(vMax->tex_y - vMin->tex_y, d, (int)d1 , vMin->tex_y); - vMid1->x = calc(vMax->x - vMin->x, d, (int)d1 , vMin->x); - vMid1->y = vMid->y; - vMid1->z = calc(vMax->z - vMin->z, d, (int)d1 , vMin->z); - printf("x:%f y:%f z:%f tex_x:%f tex_y:%f\n",vMid1->x,vMid1->y,vMid1->z,vMid1->tex_x, vMid1->tex_y); - return vMid1; - -} - - -int Polygon_Pack::create_span(void *wbuf,void *rbuf) { - POLYGONPACK *polygon = (POLYGONPACK*)wbuf; - SPANPACK *span = (SPANPACK*)rbuf; - Vertex *vMin, *vMid, *vMax, *vMid10; - Vertex ver; - vMid10 = &ver; - if(polygon->tri[0].ver1.y <= polygon->tri[0].ver2.y) { - if(polygon->tri[0].ver2.y <= polygon->tri[0].ver3.y) { - vMin = &polygon->tri[0].ver1; - vMid = &polygon->tri[0].ver2; - vMax = &polygon->tri[0].ver3; - } else if(polygon->tri[0].ver3.y <= polygon->tri[0].ver1.y) { - vMin = &polygon->tri[0].ver3; - vMid = &polygon->tri[0].ver1; - vMax = &polygon->tri[0].ver2; - } else { - vMin = &polygon->tri[0].ver1; - vMid = &polygon->tri[0].ver3; - vMax = &polygon->tri[0].ver2; - } - } else { - if(polygon->tri[0].ver1.y <= polygon->tri[0].ver3.y) { - vMin = &polygon->tri[0].ver2; - vMid = &polygon->tri[0].ver1; - vMax = &polygon->tri[0].ver3; - } else if(polygon->tri[0].ver3.y <= polygon->tri[0].ver2.y) { - vMin = &polygon->tri[0].ver3; - vMid = &polygon->tri[0].ver2; - vMax = &polygon->tri[0].ver1; - } else { - vMin = &polygon->tri[0].ver2; - vMid = &polygon->tri[0].ver3; - vMax = &polygon->tri[0].ver1; - } - } - - cout << vMid->y << endl; - - vMid1(vMid10,vMin,vMid,vMax); - - half_triangle(polygon->tri[0].tex_addr,polygon->tri[0].tex_width,polygon->tri[0].tex_height,vMin,vMid,vMid10); - half_triangle(polygon->tri[0].tex_addr,polygon->tri[0].tex_width,polygon->tri[0].tex_height,vMax,vMid,vMid10); - return 0; -} - - -void Polygon_Pack::half_triangle(long *tex_addr,long tex_width,long tex_height,Vertex *vMin, Vertex *vMid, Vertex *vMid1) { - float tmp_z,tmp_tex1, tmp_tex2 ,tmp_tey1,tmp_tey2; - float tmp_xpos,tmp_end,tmp_zpos; - int i,j; - float div_y; - float start_z,end_z; - float start_tex_x,end_tex_x,start_tex_y,end_tex_y; - int x,y,length; - int k =0; - int l = 1; - int start_y = (int)vMid->y; - int end_y = (int)vMin->y; - - if (start_y<end_y) { - int i; i=end_y; end_y=start_y; start_y = i; //yの入れ替え - k = 1; - l = -1; - } - - div_y = start_y - end_y; // > 0 - - for(i = k; i < div_y+1; i++) { - //ここでspanの左端と右端のx,zを求めてる - tmp_xpos = calc(vMid1->x - vMin->x ,div_y, i, vMin->x); - tmp_end = calc(vMid->x - vMin->x ,div_y, i, vMin->x); - tmp_z = calc(vMid1->z - vMin->z ,div_y, i, vMin->z); - tmp_zpos = calc(vMid->z - vMin->z ,div_y, i, vMin->z); - //printf("x:%f end:%f z:%f zpos:%f\n",tmp_xpos,tmp_end,tmp_z,tmp_zpos); - //ここからspanの左端と右端に対応するテクスチャを計算する - tmp_tex1 =((i/(div_y)) * vMid1->tex_x) + \ - ( ((div_y - i)/(div_y)) * vMin->tex_x); - tmp_tex2 =( (i/(div_y)) * vMid->tex_x) + \ - ( ((div_y - i)/(div_y)) * vMin->tex_x); - - tmp_tey1 =( (i/(div_y)) * vMid1->tex_y) + \ - ( ((div_y - i)/(div_y)) * vMin->tex_y); - tmp_tey2 =( (i/(div_y)) * vMid->tex_y) + \ - ( ((div_y - i)/(div_y)) * vMin->tex_y); - if(tmp_xpos > tmp_end) { - x = (int)tmp_end; - y = (int)vMin->y + i*l; - length = (int)(tmp_xpos)-(int)(tmp_end)+1; - start_z = tmp_zpos; - end_z = tmp_z; - start_tex_x = tmp_tex2; - end_tex_x = tmp_tex1; - start_tex_y = tmp_tey2; - end_tex_y = tmp_tey1; - } else { - x = (int)tmp_xpos; - y = (int)vMin->y + i*l; - length = (int)(tmp_end)-(int)(tmp_xpos)+1; - start_z = tmp_z; - end_z = tmp_zpos; - start_tex_x = tmp_tex1; - end_tex_x = tmp_tex2; - start_tex_y = tmp_tey1; - end_tex_y = tmp_tey2; - } - printf("x:%d y:%d end:%d z:%f zpos:%f\n",x,y,length,start_z , end_z); - printf("start_tex_x:%f end_tex_x:%f start_tex_y:%f end_tex_y:%f\n",start_tex_x,end_tex_x,start_tex_y,end_tex_y); - - //add(tex_addr,tex_width,tex_height,x,y,length,start_z,end_z,start_tex_x,end_tex_x,start_tex_y,end_tex_y); - } -} - -
--- a/Renderer/DataPack/Test/SpanPack/polygonpack.h Mon Oct 12 02:50:01 2009 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -#ifndef INCLUDE_POLYGON_PACK -#define INCLUDE_POLYGON_PACK - - -typedef struct vertex { - float x; - float y; - float z; - float tex_x; - float tex_y; -}Vertex, *Vertex_ptr; - -typedef struct Triangle { - long *tex_addr, tex_width, tex_height; - Vertex ver1; - Vertex ver2; - Vertex ver3; - //float x1, y1, z1, tex_x1, tex_y1; - //float x2, y2, z2, tex_x2, tex_y2; - //float x3, y3, z3, tex_x3, tex_y3; -} TRIANGLEPACK, *TRIANGLEPACK_PTR; - -typedef struct PolygonPack { - struct PORIGON_INFO { - int size; - int light_pos[3]; - int light_rgb[3]; - }info; - TRIANGLEPACK tri[16]; -} POLYGONPACK,*POLYGONPACK_PTR; - -typedef struct Span { - long tex_addr, tex_width, tex_height; - int x, y, length_x; - float start_z, end_z; - float tex_x1, tex_x2, tex_y1, tex_y2; -} SPAN, *SPNA_PTR; - -typedef struct SpanPack { - struct PORIGON_INFO { - int size; - int light_pos[3]; - int light_rgb[3]; - } info; - SPAN span[16]; -} SPANPACK, *SPANPACK_PTR; - - - -class Polygon_Pack { - public: - int create_span(void *wbuf, void *rbuf); - void half_triangle(long *tex_addr,long tex_width,long tex_height,Vertex *vMin, Vertex *vMid, Vertex *vMid1); -}; - -#endif -
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/Application.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,84 @@ +#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_; +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/Application.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,27 @@ +#ifndef INCLUDED_APPLICATION +#define INCLUDED_APPLICATION + +#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 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) ; + +}; + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/Button.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,55 @@ +#include "Button.h" + +/** + * ボタン押下時に push, hold, release の状態を変更する + * push は押した瞬間にだけ 1 を持つ + * hold の状態では 0 を持つ + */ +void +Button::push_work(void) +{ + push = (!hold); + hold = 1; + release = 0; +} + +/** + * ボタンを離した時に push, hold, release の状態を変更する + */ +void +Button::release_work(void) +{ + push = 0; + hold = 0; + release = 1; +} + +/** + * @retval 1 ボタンが押された(このフレームのみ) + * @retval 0 押されていない + */ +int +Button::isPush(void) +{ + return push; +} + +/** + * @retval 1 ボタンは押され続けている + * @retval 0 ボタンは押されていない + */ +int +Button::isHold(void) +{ + return hold; +} + +/** + * @retval 1 ボタンは押されていない + * @retval 0 ボタンが押されている + */ +int +Button::isRelease(void) +{ + return release; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/Button.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,19 @@ +#ifndef INCLUDED_BUTTON +#define INCLUDED_BUTTON + +class Button { +public: + int push; + int hold; + int release; + + Button(void) : push(0), hold(0), release(0) {} + + void push_work(void); + void release_work(void); + int isPush(void); + int isHold(void); + int isRelease(void); +}; + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/Camera.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,263 @@ +#include <math.h> +#include "SceneGraphRoot.h" +#include "Camera.h" +#include "sys.h" +#include "Scheduler.h" +#include "show_time.h" +#include "TaskManager.h" + +static void +camera_move(SceneGraphPtr _node, int screen_w, int screen_h) +{ + Pad *pad = sgroot->getController(); + CameraPtr node = (CameraPtr)_node; + +#if 0 + if (pad->right.isHold()) { + node->xyz[0] += 10.0f; + } else if (pad->left.isHold()) { + node->xyz[0] -= 10.0f; + } + + 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 + + /* + * ここに show_dma_wait 表示をいれようか + */ + + /* + if (pad->r1.isPush()) { + show_time(manager); + } + */ + + 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 +camera_collision(SceneGraphPtr node, int screen_w, int screen_h, + SceneGraphPtr tree) +{ +} + +/** + * @param w Width of screen + * @param h Height of screen + */ +Camera::Camera(float w, float h) +{ + name = (char*)"Camera"; + + + fov = 60.0f; + near = 0.0f; + far = 1000.0f; + + zd[0] = 0.0f; + zd[1] = 0.0f; + zd[2] = 1.0f; + zd[3] = 1.0f; + + yd[0] = 0.0f; + yd[1] = 1.0f; + yd[2] = 0.0f; + yd[3] = 1.0f; + + // 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[2] = -200.0f; + xyz[3] = 1.0f; + + m_view = new float[16]; + m_pers = new float[16]; + m_screen = new float[16]; + + this->set_move_collision(camera_move, camera_collision); +} + +Camera::~Camera(void) +{ + delete [] m_view; + delete [] m_pers; + delete [] m_screen; +} + +void +Camera::updateView(void) +{ + float radx,rady,radz; + float cx[4], cy[4], cz[4], p[4]; + float tm[16]; + + radx = angle[0]*3.14/180; + rady = angle[1]*3.14/180; + radz = angle[2]*3.14/180; + + float sinx = sin(radx); + float cosx = cos(radx); + float siny = sin(rady); + float cosy = cos(rady); + float sinz = sin(radz); + float cosz = cos(radz); + + /* View Transform */ + 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, tm, zd); + applyMatrix(cy, tm, yd); + applyMatrix(p, tm, xyz); + + outerProduct(cx, cy, cz); + 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::updatePerspective(float w, float h) +{ + 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; + + m_pers[ 4] = 0.0f; + m_pers[ 5] = sy; + m_pers[ 6] = 0.0f; + m_pers[ 7] = 0.0f; + + m_pers[ 8] = 0.0f; + m_pers[ 9] = 0.0f; + m_pers[10] = sz; + m_pers[11] = 1.0f; + + m_pers[12] = 0.0f; + m_pers[13] = 0.0f; + m_pers[14] = -near*sz; + m_pers[15] = 0.0f; +} + +void +Camera::updateScreen(float _w, float _h) +{ + float w = _w/2.0f; + float h = _h/2.0f; + + m_screen[ 0] = w; + m_screen[ 1] = 0.0f; + m_screen[ 2] = 0.0f; + m_screen[ 3] = 0.0f; + + m_screen[ 4] = 0.0f; + m_screen[ 5] = h; + m_screen[ 6] = 0.0f; + m_screen[ 7] = 0.0f; + + m_screen[ 8] = 0.0f; + m_screen[ 9] = 0.0f; + m_screen[10] = 1.0f; + m_screen[11] = 0.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); +} + +void +Camera::update(float w, float h) +{ +#if 1 + float tmp[16]; + + updateView(); + updatePerspective(w, h); + updateScreen(w, h); + + matrix4x4(tmp, this->m_pers, this->m_screen); + matrix4x4(this->matrix, this->m_view, tmp); +#else + get_matrix(matrix, angle, xyz, NULL); +#endif +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/Camera.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,31 @@ +#ifndef INCLUDED_CAMERA +#define INCLUDED_CAMERA + +#include "SceneGraph.h" + +class Camera : public SceneGraph { +public: + Camera(float w = 640, float h = 480); + ~Camera(void); + + float zd[4]; // direction z + float yd[4]; // direction y + float fov; + float near; + float far; + + 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(float screen_w, float screen_h); +}; + +typedef Camera *CameraPtr; + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/ChangeLog Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,402 @@ +2009-08-06 Shinji Kono <kono@ie.u-ryukyu.ac.jp> + +DrawSpan の reboot/ TASK_DRAW_SPAN2 は、使ってないのね。 + + + +2009-03-29 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp> + + * Makefile + SGlist.{cpp,h} を make clean で消去し、 + make で自動生成するようにしました。 + けどなんか他のファイルと同じ書きかたしても + 上手く行かなかった。何か見落としてるかもしれない。誰か直(ry + +2009-02-12 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp> + + * task/CreatePolygonFromSceneGraph.cpp (CreatePolygonFromSceneGraph::run): fix + 下にあわせる様に + + * SceneGraph.cpp (SceneGraph::SceneGraph, SceneGraph::init) + (SceneGraph::finalize_original): fix + 今まで、Polygon が持つ vertex, normal, texture coordinate ってのが + + --------------------------------------- + data = | vertex | normal | texture | sizeof(data) = size*3 + --------------------------------------- + \ size / \ size / \ size / + + てな感じで、SceneGraph->data の中に 3 つ入ってたわけです。 + これだと、アクセスする時にどれがどれかわからんくなるし、 + ソース読む時に迷う(経験談)ので、data を消して、代わりに + coord_xyz, normal, coord_tex を作りました。 + + * polygon.cpp (Polygon::pickup_coordinate) + (Polygon::pickup_normal, Polygon::pickup_texture): + +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) + (SceneGraphRoot): fix + SceneGraph を root から走査していきながら + その都度コピーしていき、最終的に全体の新しい SceneGraph ができる。 + 削除されていればコピーしない、っていうのは簡単だけど + 追加された場合、コピー元に追加されるのは困るので + コピーしたやつに追加って形にしたら今のコードになった。 + めんどくさいっちゃめんどくさい。もっと綺麗な書き方あるかね + + +2009-02-01 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp> + + * SceneGraph.cpp (SceneGraph::SceneGraph) + (SceneGraph::SceneGraph, SceneGraph::SceneGraph) + (SceneGraph::finalize_original, SceneGraph) + (SceneGraph::finalize_copy): add, fix + 今のところ、SceneGraph の作られ方は + + a1. xml ファイルから生成 (sgid 毎、sg_src[] に格納) + a2. ID を指定し、sg_src[id] の SceneGraph を複製 + a3. xml も ID も指定しない、何も表示しない SceneGraph + + a1 の時はポリゴンデータ(data[])を生成するわけだけど、 + a2 でも、オリジナルと同じ data[] を持つ必要は(今は)ない。 + なので、a2 の場合、data[] は a1 と同じ場所を指せば良い。 + しかし、今までは、SceneGraph::~SceneGraph では + どんな SceneGraph でも + + delete [] data; + + とかやってたので、それならということで + + b1. a1 用の、Desturctor で data[] を delete する finalize_original() + b2. a2,a3 用の、data[] を削除しない finalize_copy() + + を用意し、a1,a2,a3 の Consturoctor で、どっちかを設定する。 + +2009-01-30 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp> + + * spe/DrawSpan.cpp (DrawSpan::drawDot1): add + span->length_x == 1 の処理。 + + (DrawSpan::drawDot2): add + Dot1 の続き。要は Dot1 で load して、Dot2 で wait->書き込みって感じ + しかし、1ドットだとそこまで待つ必要もないかなって感じなので + 今は Dot 2には何も書いてない。ちゃんとしらべて、必要そうだったら + ここで書き込みを行う + + (DrawSpan::drawLine1): add + span->length_x > 1 の処理。 + いくつか Load パターンを考えてる途中 + + 1. 全部 load + 1. z buf で描きこむと判断したとき、その pixel の texture tile を + load する。(すでにある、ないに関わらず。ある場合は、実際には + Load の処理は行われないが) + 2. Line2 で描画する(ここで使う tile はすでに全部読み込まれてるとする + + 2. 無い物だけload + 1. 書き込むと判断したとき、tile があるかどうかを調べ + あればそのまま linebuf に、無ければ load を掛けて continue; + このとき、load した(つまりまだ書き込まれてない) 場所を覚えておく + 2. Line2 で、1. で覚えた場所から再び計算して描画する。 + tile はすでに全部読み込まれているとする + + まだあったけど忘れた。 + 今のところ描画領域が 256x8、もしくは512x8 で、 + 単純に考えて、領域pixel と texture pixel が一緒だと考えると + 一個の Span で最大 64 (512/8) 個の tile があればいいと考えられる。 + 一個の SPE には Tile を 128 個持っておけるし、 + 今は Span を二つ平行して処理しているので、 + 途中で Tile が足りなくなる!ってことはないはず。 + とまあ、いろいろ考えてたんだけど、何書けばいいのか忘れた。。 + 思い出したらまた書きます。 + +2009-01-26 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp> + + * spe/CreateSpan.cpp (CreateSpan::run): fix + ポリゴンをx軸に水平に分割し、その二つを計算するってのが + half_triangelで、上としたで、何故か渡すテクスチャの情報が違う。 + なんでだろうと思いつつも、今まで特に問題が出なかったから無視してたが、 + 今回、三つのSceneGraph を動かしてる時に問題発生。 + それぞれ違うテクスチャを貼ってるのに、なぜかそれらのうちの半分が + 別のテクスチャが貼られていた。簡単に言うと、A,B,C の SG があった。 + + A: 正常 + B: 右上だけ A のテクスチャ + C: 右上だけ A のテクスチャ + + といった具合。わけがわからなかったんだが、 + half_triangle に渡すやつの所為だと気づきました + なんでここだけ pp->tri[0].tex_info.addr とか渡してんのか未だに謎。 + 単なる書き間違いか直し間違いか。微妙なところ。 + これ書いた後輩はもう居ない + + + * SceneGraphIterator.cpp (SceneGraphIterator::hasNext) + (SceneGraphIterator::next): fix + 検索する引数を int id に変更。 + + * SceneGraph.h (class SceneGraph): add variable + int flag_drawbale : この SceneGraph は描画する物かどうか + int sgid : SceneGraph の ID 。ID は SGList.h にあるものを使う + + * SceneGraphIterator.cpp : add file + SceneGraph を走査する用。 + 基本、Java の Iterator を参考にしてます。 + 追加機能としては + + - hasNext(const char* name); + 名前が name の SceneGraph があるかどうか + + - next(const char* name); + 名前が name の SceneGraph まで進ませる + + * SceneGraphIterator.cpp : TODO + hasNext とかは名前じゃなくて ID が良いかなーとも思うけどね。 + てかその方がいいな。あとで直します + + * ieshoot.cpp (ieboss_move): add + (ieboss_collision): add + BOSSの動きを追加。 + IETAMA が数回衝突したら BOSS を消すって処理。 + + * SceneGraphIterator.cpp (SceneGraphIterator::next): fix + break してなかった。そりゃ取れないわ + + * SceneGraph.cpp (SceneGraph::realRemoveFromTree): fix + + < p1 = p1->next; + < p = p->next; + ===== + > p1 = p1->brother; + > p = p->brother; + + + * viewer.cpp (Viewer::run_draw): fix + Spanの無い部分を塗りつぶす処理はタスクを走らせず、 + そのまま memset とかの方が早い。 + まとめてするタスクを立ち上げるってのもいいかもしれない。 + あと、memsetで指定する値が、0xFF と 0x00 とで速度が違う。 + universe だと、 + + 0xFF 24fps + 0x00 30fps + + なんだろう。0x00 だと、ただのクリアになるから速いってことかな。 + + * Camera.h (class Camera): add + とりあえず Camera を作って、これを SceneGraph の Top にした。 + + * SceneGraph.cpp (SceneGraph::realRemoveFromTree): add + realRemove() の Tree構造用。削除後の tree top を返す様にしている。 + まあ top が消えなければ返す必要も無いし、top が消えるってことは + SceneGraph そのものが消えるってことでそうは無い・・はずだけどね。 + (SceneGraph::realRemoveFromList): add + realRemove() の list用。削除後の list top を返す様にしている。 + (SceneGraph::realRemoveFromTree): fix + < p->next = p1->next; + === + > p->brother = p1->brother; + +2009-01-25 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp> + + * add (tools/create_sglist): new + 必要な SceneGraph xml file から SceneGraph を抽出し、 + 名前と対応する ID を SGList.h に出力する。 + また、名前から ID を求める sglist_table を SGList.cpp に出力する。 + + * SceneGraph.cpp (SceneGraph::remove): add + User API。ここで削除するのではなく、まずはフラグを立てるだけ + ここですぐに消すと、allExecute() の走査で何気に困る + + (SceneGraph::isRemoved): add + この SceneGraph 削除フラグが立っているかどうか + + (SceneGraph::realRemove): TODO + 子を持つ SceneGraph が消された場合、 + その子孫を全て削除するかどうか。まあ削除するのかな。 + + (SceneGraph::realRemove): add + Cerium System で呼ばれる。 + remove flag の立った SceneGraph を削除する。 + parentやbrother、next は繋ぎ直す。 + + * SceneGraphRoot.cpp (SceneGraphRoot::addNext): add + sg_available_list に追加していく + 木の操作が要らないアクセスの際にはこっちの方がいい。 + + (SceneGraphRoot::setSceneData): add + Cerium に SceneGraph の tree を渡す。Cerium はこの tree を辿って + 処理を行う + + (SceneGraphRoot::createFromXMLfile): add + xml file を指定して、そこから SceneGraph を生成し、 + sg_src に格納する。ユーザはこの SceneGraph を直接は扱えない。 + 以下に示す createSceneGraph の、読み込み元データとして保存しておく。 + + (SceneGraphRoot::createSceneGraph): add + オリジナルの SceneGraph を clone してユーザに返す。 + この SceneGraph をユーザが操作する。 + + * SceneGraphRoot.h (class SceneGraphRoot): new variables + sg_src, sg_exec_list, sg_draw_list, sg_available_list + + * addfile (SceneGraphRoot.cpp) + SceneGraph を管理するクラス、ってところか。 + Root ってのは SceneGraph という名前からすると + 一番親と思われそうで微妙です。変えるかも。 + +2009-01-12 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp> + + * Joystick.cpp: TODO + 使用している Joystick が + + 1. PS3 コントローラ + 2. PS2 コントローラにUSB変換をかましたやつ + + によってボタンの番号配置が違うので + そこを自動的に取得して割り振りたい + + SDL_JoystickName() で名前取れるんだけど + 全部共通なのかなー。「PS3って文字列があるか否か」でわけてもいいけど + + * Joystick.cpp: fix + コントローラボタンの番号を PS3 コントローラに合わせました。 + + - 参考 + PS3 Linux SDLでプログラミング -コントローラを使う- + http://yun.cup.com/ps3sdl007.html + + アナログスティックの方はまだです + +2009-01-08 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp> + + * spe/DrawSpanRenew.cpp (DrawSpanRenew::run): fix + next_spack を free() していたが、do-while の最初で + next_spack = NULL とかやっている。 + DrawSpan だと、free するのは free_spack ってやつなので + 問題なかったが、なぜここは free(next_spack) とかやってるのか。 + というわけで、next_spack,spack 両方用の + free_spack1, free_spack2 を生成して、これを free させることに。 + これで、ようやくまともに動くようになった。けど微妙です。 + 遅いですね。 + + * addFile : DrawSpanRenew.cpp + DrawSpan の再起動 ver。 + +2008-12-22 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp> + + * fix + charles を Fedora 10 に上げて、コンパイラが新しくなったせいか、 + 以下のような warning が出始めた + + warning: deprecated conversion from string constant to 'char *' + + まあよくわからんが、例えば + + char *str = "hoge"; + + みたいな所だとこの warning が出る。これを + + const char *str = "hoge"; + + にすると消えた。 + 以後こういう形に統一しろよ的なやつなのかな。 + +2008-12-19 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp> + + * viewer.cpp (Viewer::run_draw): fix + startx, endx に対して、start_y, end_y って名前は統一されてなくて + わかりづらいので、starty, endy に変更 + + * main.cpp (init): fix + bpp (BitsPerPixel) の値がデフォルトで 0 になっていた。 + 今のレンダリング方式では 32 がデフォルトなので、間違ってた。 + 今まで気づかなかったのは + + 1. SDL_SetVideoMode に bpp = 0 で渡される + 2. SDL が開発・実行環境に合わせて bpp を設定 + 3. 今までそれが 32 になってた + + しかし、ゲーム班の環境では bpp = 16 になってしまったため、 + その次の bitmap の allocate の時に + screen->pitch*height = 16*width*height となり、 + DrawSpan では 32 のつもりで書き込んでいたため領域外への + メモリ書き込み->エラー + + ゲーム班ありがとう + +2008-12-16 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp> + + * SceneGraph.cpp (makeTapestry): add + SceneGraph::get_data にあったけど、ごちゃごちゃしてたので + 関数として生成 + + * viewer.cpp (Viewer::run_init, Viewer::run_draw): fix + * spe/DrawSpan.cpp (DrawSpan::zRow_init): delete + + Z Buffering に使う zRow は DrawSpan で毎回生成、初期化するのではなく、 + PPE で生成、初期化を行っておき、DrawSpan に add_inData で + DMA で渡すという方法に変更。速度的にはほんのちょっとしか(ry + + * spe/CreateSpan.cpp (CreateSpan::half_triangle): fix + getScale に渡す tex_width,tex_height を修正。 + 比較にそのまま tex_width, tex_height を使うと、 + Span が持つテクスチャが全体の一部分だったとしても + 比較結果で縮小が行われてしまうため。 + + - 例 + span->length_x = 32; + tex_width = 128; + tex_x_len = (span->tex_x2 - span->tex_x1) = (0.5 - 0.3) = 0.2; + + 今までの処理だと、span->length_x < tex_width の結果により + 縮小されたテクスチャを使うことになる。 + しかし、実際に Span が使う Texture の長さは + + tex_width*tex_x_len = 24 + + なので、縮小を行う必要は無い + + +2008-12-12 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp> + + * SceneGraph.cpp (SceneGraph::get_data): Todo + テクスチャの縦横が 8 の倍数でなければ弾く処理を入れる。 + + * spe/DrawSpan.cpp (DrawSpan::run): Todo + テクスチャの座標計算と、そこから取得できる Tile の DMA を + 一スレッドで処理しているのでそれを分けないといけない + + * spe/CreateSpan.cpp (getTapestry): Add + (getScale): Add + + * memo: 雑記 + ようやくこいつに ChangeLog を加えました。 + なんか emacs で「C-x 4 a」とかすると、ChangeLog の entry が + 加えれられるんだけど、上の階層のを探しにいくので、TaskManager/ のに + 加えようとしてたわけさ。まあそういう仕様なんだけど。 + で、だからといって不可能ってわけじゃないから書けばよかったんだが。 + + 要するに、これからはちゃんと書いていこうと思います。
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/Func.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,38 @@ +enum { + INIT, + SDL_INIT, + FINISH, + VIEWER_RUN_INIT, + VIEWER_RUN_LOOP, + VIEWER_RUN_DRAW, + VIEWER_RUN_FINISH, + + TASK_INIT_TEXTURE, + TASK_CREATE_SGP, + TASK_UPDATE_SGP, + TASK_CREATE_PP, + TASK_CREATE_PP2, + TASK_CREATE_SPAN, + TASK_CS_START, + TASK_CS_RUN, + TASK_DRAW_SPAN, + TASK_DRAW_SPAN_END, + TASK_DRAW_BACK, + TASK_SET_TEXTURE, + TASK_MOVE, + TASK_DRAW, + TASK_DUMMY, + + CHAINCAL_TASK, + CHAININIT_TASK, + RUN_FINISH, + + TASK_SWITCH, + SHOW_TIME, + UPDATE_KEY, + INIT_KEY_TASK, + + CHAIN_MOVE, +}; + +#define DATA_ID 0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/Joystick.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,178 @@ +#include <SDL.h> +#include "Joystick.h" + +/** + * PS3 コントローラの配置 + */ +static const int SELECT = 0; +static const int L3 = 1; +static const int R3 = 2; +static const int START = 3; +static const int UP = 4; +static const int RIGHT = 5; +static const int DOWN = 6; +static const int LEFT = 7; +static const int L2 = 8; +static const int R2 = 9; +static const int L1 = 10; +static const int R1 = 11; +static const int TRIANGLE = 12; +static const int CIRCLE = 13; +static const int CROSS = 14; +static const int SQUARE = 15; +static const int PS = 16; + +#if 0 // PS2 コントローラ +static const int CROSS = 0; +static const int CIRCLE = 1; +static const int SQUARE = 2; +static const int TRIANGLE = 3; +static const int L1 = 4; +static const int R1 = 5; +static const int L2 = 6; +static const int R2 = 7; +static const int START = 8; +static const int SELECT = 9; +static const int L3 = 10; +static const int R3 = 11; +static const int UP = 12; +static const int DOWN = 13; +static const int RIGHT = 14; +static const int LEFT = 15; +static const int ESCAPE = 16; +static const int SPACE = 17; +#endif + +Joystick::Joystick(SDL_Joystick *j) +{ + joy = j; +} + +Joystick::~Joystick(void) +{ + SDL_JoystickClose(joy); +} + +void +Joystick::check(void) +{ + SDL_JoystickUpdate(); + + if (SDL_JoystickGetButton(joy,CROSS)==SDL_PRESSED) { + cross.push_work(); + } else { + cross.release_work(); + } + + if (SDL_JoystickGetButton(joy,CIRCLE)==SDL_PRESSED) { + circle.push_work(); + } else { + circle.release_work(); + } + + if (SDL_JoystickGetButton(joy,SQUARE)==SDL_PRESSED) { + square.push_work(); + } else { + square.release_work(); + } + + if (SDL_JoystickGetButton(joy,TRIANGLE)==SDL_PRESSED) { + triangle.push_work(); + } else { + triangle.release_work(); + } + + if (SDL_JoystickGetButton(joy,L1)==SDL_PRESSED) { + l1.push_work(); + } else { + l1.release_work(); + } + + if (SDL_JoystickGetButton(joy,R1)==SDL_PRESSED) { + r1.push_work(); + } else { + r1.release_work(); + } + + if (SDL_JoystickGetButton(joy,L2)==SDL_PRESSED) { + l2.push_work(); + } else { + l2.release_work(); + } + + if (SDL_JoystickGetButton(joy,R2)==SDL_PRESSED) { + r2.push_work(); + } else { + r2.release_work(); + } + + if (SDL_JoystickGetButton(joy,START)==SDL_PRESSED) { + start.push_work(); + } else { + start.release_work(); + } + + if (SDL_JoystickGetButton(joy,SELECT)==SDL_PRESSED) { + select.push_work(); + } else { + select.release_work(); + } + + if (SDL_JoystickGetButton(joy,L3)==SDL_PRESSED) { + l3.push_work(); + } else { + l3.release_work(); + } + + if (SDL_JoystickGetButton(joy,R3)==SDL_PRESSED) { + r3.push_work(); + } else { + r3.release_work(); + } + + if (SDL_JoystickGetButton(joy,UP)==SDL_PRESSED) { + up.push_work(); + } else { + up.release_work(); + } + + if (SDL_JoystickGetButton(joy,DOWN)==SDL_PRESSED) { + down.push_work(); + } else { + down.release_work(); + } + if (SDL_JoystickGetButton(joy,RIGHT)==SDL_PRESSED) { + right.push_work(); + } else { + right.release_work(); + } + if (SDL_JoystickGetButton(joy,LEFT)==SDL_PRESSED) { + left.push_work(); + } else { + left.release_work(); + } + + axis = SDL_JoystickGetAxis(joy,0); + if (axis >= 3200) { + left.release_work(); + right.push_work(); + } else if (axis <= -3200) { + right.release_work(); + left.push_work(); + } else { + left.release_work(); + right.release_work(); + } + + axis = SDL_JoystickGetAxis(joy,1); + if (axis>=3200) { + up.release_work(); + down.push_work(); + } else if (axis<=-3200) { + down.release_work(); + up.push_work(); + } else { + up.release_work(); + down.release_work(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/Joystick.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,19 @@ +#ifndef INCLUDED_JOYSTICK +#define INCLUDED_JOYSTICK + +#include "SDL.h" + +#include "Pad.h" + +class Joystick : public Pad { +public: + SDL_Joystick *joy; + Sint16 axis; + + Joystick(SDL_Joystick *j); + ~Joystick(void); + + void check(void); +}; + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/KeyStat.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,22 @@ +#ifndef INCLUDED_KEY_STATUS +#define INCLUDED_KEY_STATUS + +enum { + NONE, + HOLD, + PUSH, +}; + +// 可変長の構造体にする。 +// int で1つ送り bit field でやると +struct key_stat { + int length; + int right; + int left; + int up; + int down; + int circle; + unsigned char data[0]; +}; + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/Keyboard.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,92 @@ +#include <SDL.h> +#include "Keyboard.h" + +void +Keyboard::check(void) +{ + Uint8 *keys = SDL_GetKeyState(NULL); + + if (keys[SDLK_UP] == SDL_PRESSED) { + up.push_work(); + } else { + up.release_work(); + } + + if (keys[SDLK_DOWN] == SDL_PRESSED) { + down.push_work(); + } else { + down.release_work(); + } + + if (keys[SDLK_RIGHT] == SDL_PRESSED) { + right.push_work(); + } else { + right.release_work(); + } + + if (keys[SDLK_LEFT] == SDL_PRESSED) { + left.push_work(); + } else { + left.release_work(); + } + + if (keys[SDLK_RETURN] == SDL_PRESSED) { + start.push_work(); + } else { + start.release_work(); + } + + if (keys[SDLK_ESCAPE] == SDL_PRESSED) { + select.push_work(); + } else { + select.release_work(); + } + + if (keys[SDLK_a] == SDL_PRESSED) { + square.push_work(); + } else { + square.release_work(); + } + + if (keys[SDLK_s] == SDL_PRESSED) { + triangle.push_work(); + } else { + triangle.release_work(); + } + + if (keys[SDLK_z] == SDL_PRESSED) { + cross.push_work(); + } else { + cross.release_work(); + } + + if (keys[SDLK_x] == SDL_PRESSED) { + circle.push_work(); + } else { + circle.release_work(); + } + + if (keys[SDLK_k] == SDL_PRESSED) { + l1.push_work(); + } else { + l1.release_work(); + } + + if (keys[SDLK_o] == SDL_PRESSED) { + l2.push_work(); + } else { + l2.release_work(); + } + + if (keys[SDLK_l] == SDL_PRESSED) { + r1.push_work(); + } else { + r1.release_work(); + } + + if (keys[SDLK_p] == SDL_PRESSED) { + r2.push_work(); + } else { + r2.release_work(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/Keyboard.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,11 @@ +#ifndef INCLUDED_KEYBOARD +#define INCLUDED_KEYBOARD + +#include "Pad.h" + +class Keyboard : public Pad { +public: + void check(void); +}; + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/Makefile Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,41 @@ +default: macosx + +macosx: FORCE SGList.h + @echo "Make for Mac OS X" + @$(MAKE) -f Makefile.macosx + +cell: FORCE SGList.h + @echo "Make for PS3 (Cell)" + @$(MAKE) -f Makefile.cell + +linux: FORCE SGList.h + @echo "Make for Linux" + @$(MAKE) -f Makefile.linux + +macosx-depend: FORCE + @$(MAKE) -f Makefile.macosx depend + +cell-depend: FORCE + @$(MAKE) -f Makefile.cell depend + +linux-depend: FORCE + @$(MAKE) -f Makefile.linux depend + +FORCE: + +clean: + @$(MAKE) -f Makefile.macosx clean + @$(MAKE) -f Makefile.cell clean + @$(MAKE) -f Makefile.linux clean + rm -f depend.inc + +SGList.h: xml_file/*.xml + perl tools/create_sglist.pl xml_file/*.xml + +run-ps3: + /usr/*bin/ps3-video-mode -v 133 + ./test_nogl -video fb -width 1920 -height 1080 $(CPU) $(SG) + +run-ps3tv: + ./test_nogl -video fb -width 576 -height 384 -bpp 32 +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/Makefile.cell Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,61 @@ +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 += -lCellManager -lspe2 -lpthread + +CFLAGS += `sdl-config --cflags` `xml2-config --cflags` +LIBS += `sdl-config --libs` -lSDL_image -lGL `xml2-config --libs` + +.SUFFIXES: .cc .o + +.cc.o: + $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ + +default: all + +all: $(TARGET) speobject + +$(TARGET): $(OBJS) $(TASK_OBJS) + $(CC) -o $@ $(OBJS) $(TASK_OBJS) $(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 + +speobject: + cd spe; $(MAKE) + +run: $(TARGET) + sudo ./$(TARGET) -width 576 -height 384 -bpp 32 +run-hd: $(TARGET) + sudo /usr/sbin/ps3-video-mode -v 133 + sudo ./$(TARGET) -video fb -width 1920 -height 1080 -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 + cd task; rm -f *~ \#* + cd spe; $(MAKE) clean
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/Makefile.def Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,9 @@ +TARGET = test_nogl + +CERIUM = ../../.. + +CC = g++ +CFLAGS = -O9 -g -Wall -DUSE_MEMLIST=1 -DUSE_MEMHASH=1 # -DDEBUG + +INCLUDE = -I$(CERIUM)/include/TaskManager -I. +LIBS = -L$(CERIUM)/TaskManager
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/Makefile.linux Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,52 @@ +include ./Makefile.def + +SRCS_TMP = $(wildcard *.cpp) +SRCS_EXCLUDE = # +SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP)) +OBJS = $(SRCS:.cpp=.o) + +TASK_DIR = task +TASK_SRCS_TMP = $(wildcard $(TASK_DIR)/*.cpp) +TASK_SRCS_EXCLUDE = span_pack_draw.cpp +TASK_SRCS = $(filter-out $(TASK_SRCS_EXCLUDE),$(TASK_SRCS_TMP)) +TASK_OBJS = $(TASK_SRCS:.cpp=.o) + +LIBS += -lFifoManager + +CFLAGS += `sdl-config --cflags` `xml2-config --cflags` +LIBS += `sdl-config --libs` -lSDL_image -lGL `xml2-config --libs` + +.SUFFIXES: .cpp .o + +.cpp.o: + $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ + +all: $(TARGET) + +$(TARGET): SGList.o $(OBJS) $(TASK_OBJS) + $(CC) -o $@ $(OBJS) $(TASK_OBJS) SGList.o $(LIBS) + +SGList.o: create_sg_list + $(CC) $(CFLAGS) $(INCLUDE) -c SGList.cpp -o $@ + +create_sg_list: + @if [ ! -f SGList.h ]; then \ + cd tools/;\ + ./create_sglist.pl ../xml_file/*.xml;\ + cd ../;\ + 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.cpp \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/Makefile.macosx Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,55 @@ +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: SGList.o $(TARGET) + +$(TARGET): $(OBJS) $(TASK_OBJS) + $(CC) -o $@ $(OBJS) $(TASK_OBJS) $(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/Engine/Pad.cc Mon Oct 12 09:39:35 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; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/Pad.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,34 @@ +#ifndef INCLUDED_PAD +#define INCLUDED_PAD + +#include "Button.h" + +class Pad { +public: + Button count; + Button cross; + Button circle; + Button square; + Button triangle; + Button l1; + Button r1; + Button l2; + Button r2; + Button start; + Button select; + Button l3; + Button r3; + Button up; + Button down; + Button right; + Button left; + Button escape; + Button space; + + virtual ~Pad(void) {} + virtual void check(void) = 0; +}; + +#endif + +extern Pad *create_controller(void);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/SceneGraph.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,761 @@ +#include <iostream> +#include <SDL.h> +#include <SDL_opengl.h> +#include <SDL_image.h> +#include <libxml/parser.h> +#include "SceneGraph.h" +#include "xml.h" +#include "sys.h" +#include "TextureHash.h" +#include "texture.h" +#include "TaskManager.h" + +using namespace std; + +SceneGraphPtr scene_graph = NULL; +SceneGraphPtr scene_graph_viewer = NULL; + +static TextureHash texture_hash; +struct texture_list list[TABLE_SIZE]; + +extern int decode(char *cont, FILE *outfile); + +static void +no_move(SceneGraphPtr self, int screen_w, int screen_h) {} + +static void +no_collision(SceneGraphPtr self, int screen_w, int screen_h, + SceneGraphPtr tree) {} + +/** + * 事前に計算したテクスチャの最大縮小率 scale まで、 + * テクスチャを 1/2 縮小していく。 + * このとき、テクスチャは TEXTURE_SPLIT_PIXELx2 のブロック (Tile) で分割し、 + * これらを連続したメモリ領域に格納していく。 + * 以下の (1), (2), (3) を Tapestry と呼ぶ + * + * 例 scale = 4 の場合 + * + * Tapestry(1) 1/1 + * +---+---+---+---+ + * | 0 | 1 | 2 | 3 | + * +---+---+---+---+ + * | 4 | 5 | 6 | 7 | (2) 1/2 + * +---+---+---+---+ +---+---+ + * | 8 | 9 | 10| 11| | 16| 17| (3) 1/4 + * +---+---+---+---+ +---+---+ +---+ + * | 12| 13| 14| 15| | 18| 19| | 20| + * +---+---+---+---+ +---+---+ +---| + * + * (1) (2) (3) + * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ + * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * | * | * | 14| 15| 16| 17| 18| 19| 20| + * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ + * + * @param[in] tex_w Width of orignal texture + * @param[in] tex_h Height of orignal texture + * @param[in] tex_src Original texture + * @param[in] all_pixel_num Tapestry の合計 pixel 数 + * @param[in] scale テクスチャの最大縮小率 (= 2^n) + * @return (1) のアドレス + */ +static uint32* +makeTapestry(TaskManager *manager, int tex_w, int tex_h, uint32 *tex_src, + int all_pixel_num, int scale_cnt) +{ + + int t = 0; + int diff = TEXTURE_SPLIT_PIXEL; + int p_diff = 1; + + uint32 *tex_dest = (uint32*)manager->allocate(sizeof(int)*all_pixel_num); + + while (scale_cnt) { + for (int y = 0; y < tex_h; y += diff) { + for (int x = 0; x < tex_w; x += diff) { + for (int j = 0; j < diff; j += p_diff) { + for (int i = 0; i < diff; i += p_diff) { + tex_dest[t++] + = tex_src[(x+i) + tex_w*(y+j)]; + } + } + } + } + + diff <<= 1; + p_diff <<= 1; + scale_cnt >>= 1; + } + + return tex_dest; +} + + +/** + * 何の情報も持ってない SceneGraph の生成 + * 今のところ、とりあえず木構造の繋がりに使うぐらい + */ +SceneGraph::SceneGraph(void) +{ + init(); + finalize = &SceneGraph::finalize_copy; + + this->name = "NULLPO"; +} + +/** + * orig のコピーとして SceneGraph を生成する + */ +SceneGraph::SceneGraph(SceneGraphPtr orig) +{ + init(); + memcpy(this, orig, sizeof(SceneGraph)); + + // コピーしない + //flag_remove = 0; + //flag_drawable = 1; + next = NULL; + prev = NULL; + last = NULL; + + parent = NULL; + brother = NULL; + children = NULL; + lastChild = NULL; + + finalize = &SceneGraph::finalize_copy; + + + frame = 0; +} + + +/* construct polygon from xmlNode. */ +SceneGraph::SceneGraph(TaskManager *manager, xmlNodePtr surface) +{ + init(); + + size = atoi((char *)xmlGetProp(surface,(xmlChar *)"size")); + name = (char *)xmlGetProp(surface,(xmlChar *)"name"); + parent_name = (char *)xmlGetProp(surface,(xmlChar *)"parent"); + + //data = new float[size*3*3]; + coord_xyz = (float*)manager->allocate(sizeof(float)*size*3); + coord_tex = (float*)manager->allocate(sizeof(float)*size*3); + normal = (float*)manager->allocate(sizeof(float)*size*3); + + get_data(manager, surface->children); + + finalize = &SceneGraph::finalize_original; +} + +void +SceneGraph::init(void) +{ + next = NULL; + prev = NULL; + last = NULL; + + parent = NULL; + brother = NULL; + children = NULL; + lastChild = NULL; + + stack_xyz[0] = 0.0f; + stack_xyz[2] = 0.0f; + stack_xyz[1] = 0.0f; + stack_angle[0] = 0.0f; + stack_angle[1] = 0.0f; + stack_angle[2] = 0.0f; + + size = 0; + //data = NULL; + coord_xyz = NULL; + normal = NULL; + coord_tex = NULL; + + texture_id = -1; + move = no_move; + collision = no_collision; + + flag_remove = 0; + flag_drawable = 1; + sgid = -1; + gid = -1; + + frame = 0; +} + +SceneGraph::~SceneGraph(void) +{ + (this->*finalize)(); +} + +/** + * xml ファイルから生成されたオリジナル SceneGraph なので + * polygon data を削除 + */ +void +SceneGraph::finalize_original(void) +{ + //delete [] data; + free(coord_xyz); + free(coord_tex); + free(normal); +} + +/** + * SceneGraph ID から生成された、コピー SceneGraph なので + * polygon data は削除しない。オリジナルの方で削除する。 + */ +void +SceneGraph::finalize_copy(void) +{ +} + + +/** + * add Children + * 親の登録と、brother のリストへ加える + * + * @param child new child + */ +SceneGraphPtr +SceneGraph::addChild(SceneGraphPtr child) +{ + /* childrenのリストの最後に加える (brother として)*/ + if (this->lastChild != NULL) { + SceneGraphPtr last = this->lastChild; + last->brother = child; + } + + this->lastChild = child; + + if (this->children == NULL) { + this->children = child; + } + + child->parent = this; + + return child; +} + + +/** + * add Brother + * addChild() でも brother の操作をしないといけないので、そっちに回す + * + * @param bro new Brother + */ +SceneGraphPtr +SceneGraph::addBrother(SceneGraphPtr bro) +{ + if (this->parent) { + parent->addChild(bro); + } else { + fprintf(stderr, "error : SceneGraph::%s : %s doesn't have parent\n", + __FUNCTION__, this->name); + } + + return bro; +} + +/* thisの子や子孫にnameのものが存在すればそいつを返す なければNULL. */ +SceneGraphPtr +SceneGraph::searchSceneGraph(const char *name) +{ + SceneGraphPtr tmp; + SceneGraphPtr result; + + /* 本人か */ + if( 0==strcmp(this->name, name) ) return this; + + /* 子供から再帰的に探す */ + for(tmp = this->children; tmp; tmp = tmp->next) { + if ((result=tmp->searchSceneGraph(name)) != NULL) + return result; + } + + /* 無かったら NULL. */ + return NULL; +} + +void +SceneGraph::tree_check(void) +{ + SceneGraphPtr t = this; + + while(t) + { + cout << "my_name : " << t->name << endl; + if(t->children != NULL) + { + cout << "--move children : " << t->children->name << endl; + t = t->children; + } + else if(t->brother != NULL) + { + cout << "--move brother : " << t->brother->name << endl; + t = t->brother; + } + else + { + while(t) + { + if(t->brother != NULL) + { + cout << "--move brother : " << t->brother->name << endl; + t = t->brother; + break; + } + else + { + if(t->parent) + { + cout << "--move parent : " << t->parent->name << endl; + } + t = t->parent; + } + } + } + } +} + + +void +SceneGraph::print_member(void) +{ + cout << "size = " << size << endl; + cout << "name = " << name << endl; + cout << "parent_name = " << parent_name << endl; + + if (parent != NULL) { + cout << "parent->name = " << parent->name << endl; + } + + if (children != NULL) { + cout << "children->name = " << children->name << endl; + } +} + + +/* + * surface nodeからポリゴンの情報を読み出す 再帰しない + */ +void +SceneGraph::get_data(TaskManager *manager, xmlNodePtr cur) +{ + //char *image_name; + + for(;cur;cur=cur->next) + { + if(!xmlStrcmp(cur->name,(xmlChar*)"coordinate")) + { + char *cont = (char *)xmlNodeGetContent(cur); + pickup_coordinate(cont); + } + else if(!xmlStrcmp(cur->name,(xmlChar*)"normal")) + { + char *cont = (char *)xmlNodeGetContent(cur); + pickup_normal(cont); + } + else if(!xmlStrcmp(cur->name,(xmlChar*)"model")) + { + char *cont = (char *)xmlNodeGetContent(cur); + pickup_model(cont); + } + else if(!xmlStrcmp(cur->name,(xmlChar*)"texture")) + { + char *cont = (char *)xmlNodeGetContent(cur); + pickup_texture(cont); + } + else if(!xmlStrcmp(cur->name,(xmlChar*)"imageflag")) + { + int id; + char *filename = (char *)xmlGetProp(cur, (xmlChar *)"name"); + texture_hash.hash_regist(filename, id); + } + else if(!xmlStrcmp(cur->name,(xmlChar*)"image")) + { + get_image(manager, cur); + } + } +} + +SDL_Surface* +SceneGraph::load_decode_image(char *image_name, xmlNodePtr cur) +{ + int fd = mkstemp(image_name); + FILE *outfile = fdopen(fd, "wb"); + + if (NULL == outfile) { + cout << "error open file\n"; + return 0; + } + + char *cont = (char *)xmlNodeGetContent(cur); + //decode(cont, image_name); + decode(cont, outfile); + fclose(outfile); + + +/** + * image を 32bit(RGBA) に変換する + */ + SDL_Surface *texture_image = IMG_Load(image_name); + SDL_Surface *tmpImage + = SDL_CreateRGBSurface(SDL_HWSURFACE, texture_image->w, + texture_image->h, 32, redMask, + greenMask, blueMask, alphaMask); + SDL_Surface *converted; + converted = SDL_ConvertSurface(texture_image, tmpImage->format, + SDL_HWSURFACE); + if (converted != NULL) { + SDL_FreeSurface(texture_image); + texture_image = converted; + } + + return texture_image; +} + +int +SceneGraph::makeTapestries(TaskManager *manager, SDL_Surface *texture_image, int id) { + uint32 *tapestry; + int scale = 1; + int tex_w = texture_image->w; + int tex_h = texture_image->h; + int all_pixel_num = 0; + + /** + * テクスチャの w or h が 8 pixel で分割できる間、 + * 1/2 の縮小画像を作る。 + * ここでは、最大の scale (1/scale) を見つける + * + * (ex) + * (128,128) => 64,64 : 32,32: 16,16 : 8,8 + * scale = 16 + * (128, 64) => 64,32 : 32,16: 16,8 + * scale = 8 + */ + while (tex_w % TEXTURE_SPLIT_PIXEL == 0 && + tex_h % TEXTURE_SPLIT_PIXEL == 0) { + all_pixel_num += tex_w*tex_h; + tex_w >>= 1; /* tex_w /= 2 */ + tex_h >>= 1; + scale <<= 1; /* scale *= 2 */ + } + + scale >>= 1; + + tapestry = makeTapestry(manager, texture_image->w, texture_image->h, + (uint32*)texture_image->pixels, + all_pixel_num, scale); + + list[id].t_w = texture_image->w; + list[id].t_h = texture_image->h; + list[id].pixels_orig = (Uint32*)texture_image->pixels; + list[id].pixels = tapestry; + list[id].scale_max = scale; + + return id; + } + +void +SceneGraph::get_image(TaskManager *manager, xmlNodePtr cur) +{ + char image_name[20] = "/tmp/image_XXXXXX"; + char *filename = (char *)xmlGetProp(cur, (xmlChar *)"name"); + + if (filename == NULL || filename[0] == 0) { + return; + } + + /** + * image_name を既に Load していれば何もしない + */ + int tex_id; + if (!texture_hash.hash_regist(filename, tex_id)) { + + SDL_Surface *texture_image = load_decode_image(image_name, cur); + + texture_id = makeTapestries(manager, texture_image, tex_id); + + if (unlink(image_name)) { + cout << "unlink error\n"; + } + } else { + /** + * 以前に Load されている Texture を共用 + */ + texture_id = tex_id; + } + + // こんなことすると list[] のいみあるのかなーと + // 微妙に思う、自分で書き換えた感想 by gongo + texture_info.t_w = list[texture_id].t_w; + texture_info.t_h = list[texture_id].t_h;; + texture_info.pixels_orig = list[texture_id].pixels_orig; + texture_info.pixels = list[texture_id].pixels; + texture_info.scale_max = list[texture_id].scale_max; +} + + +void +SceneGraph::delete_data(void) +{ + SceneGraphPtr n = this->next, m; + + //n = this; + //delete [] n->data; + + if (next) { + while (n) { + m = n->next; + delete n; + n = m; + } + } +} + +void +SceneGraph::move_execute(int w, int h) +{ + (*move)(this, w, h); +} + +void +SceneGraph::collision_check(int w, int h, SceneGraphPtr tree) +{ + (*collision)(this, w, h, tree); +} + +void +SceneGraph::all_execute(int screen_w, int screen_h) +{ + SceneGraphPtr top = this; + SceneGraphPtr t = top; + + while (t) { + t->move_execute(screen_w, screen_h); + t->collision_check(screen_w, screen_h, top); + + t->frame++; + + if (t->parent != NULL) { + get_matrix(t->matrix, t->angle, t->xyz, t->parent->matrix); + } else { + get_matrix(t->matrix, t->angle, t->xyz, NULL); + } + + if (t->children != NULL) { + t = t->children; + } else if (t->brother != NULL) { + t = t->brother; + } else { + while (t) { + if (t->brother != NULL) { + t = t->brother; + break; + } else { + if (t->parent == NULL) { + t = NULL; + break; + } else { + t = t->parent; + } + } + } + } + } +} + +void +SceneGraph::set_move_collision(SceneGraphPtr node, move_func new_move, + collision_func new_collision) +{ + node->move = new_move; + node->collision = new_collision; +} + +void +SceneGraph::set_move_collision(move_func new_move, + collision_func new_collision) +{ + this->move = new_move; + this->collision = new_collision; +} + +void +SceneGraph::add_next(SceneGraphPtr next) +{ + /* next のリストの最後に加える */ + if (this->next != NULL) { + SceneGraphPtr tmp = this->last; + tmp->next = next; + } else { + this->next = next; + } + + this->last = next; +} + +/** + * SceneGraph の clone + * @return clone SceneGraph + */ +SceneGraphPtr +SceneGraph::clone(void) { + SceneGraphPtr p = new SceneGraph(this); + return p; +} + +/** + * SceneGraph の clone + * 予め allocate されてる領域への placement new を行う + * + * @param buf clone 領域 + * @return clone SceneGraph + */ +SceneGraphPtr +SceneGraph::clone(void *buf) { + SceneGraphPtr p = new(buf) SceneGraph(this); + return p; +} + +void +SceneGraph::remove(void) +{ + this->flag_remove = 1; +} + +/** + * tree から node を削除する + * + * @param tree SceneGraphTree + * @return node削除後の SceneGraphTree + */ +SceneGraphPtr +SceneGraph::realRemoveFromTree(SceneGraphPtr tree) +{ + SceneGraphPtr node = this; + SceneGraphPtr parent = node->parent; + SceneGraphPtr ret = tree; + + if (parent) { + SceneGraphPtr brother = parent->children; + SceneGraphPtr p, p1 = NULL; + + p = brother; + if (p) { + if (p == node) { + parent->children = NULL; + parent->lastChild = NULL; + } else { + p1 = p->brother; + + while (p1 && p1 != node) { + p1 = p1->brother; + p = p->brother; + } + + if (p1) { + p->brother = p1->brother; + + // node が最後尾なら、lastChild を変更 + if (parent->lastChild == p1) { + parent->lastChild = p; + } + } else { + // Can't find remove node + } + } + } + } else { + // 親が居ない = tree root なので + // NULL を返す + ret = NULL; + } + + return ret; +} + +/** + * list から node を削除する + * + * @param list SceneGraphList + * @return node削除後の SceneGraphList + */ +SceneGraphPtr +SceneGraph::realRemoveFromList(SceneGraphPtr list) +{ + SceneGraphPtr node = this; + SceneGraphPtr prev = node->prev; + SceneGraphPtr next = node->next; + SceneGraphPtr ret = list; + + if (prev) { + prev->next = next; + } else { + ret = next; + } + + if (next) { + next->prev = prev; + } + + return ret; +} + +int +SceneGraph::isRemoved(void) +{ + return flag_remove; +} + +/** + * 平行移動 + * + * @param x Ttranslate in the x direction + * @param y Ttranslate in the y direction + * @param z Ttranslate in the z direction + */ +void +SceneGraph::translate(float x, float y, float z) +{ + this->xyz[0] = x; + this->xyz[1] = y; + this->xyz[2] = z; +} + +/** + * x 軸方向への平行移動 + * + * @param x Ttranslate in the x direction + */ +void +SceneGraph::translateX(float x) +{ + this->xyz[0] = x; +} + +/** + * y 軸方向への平行移動 + * + * @param y Ttranslate in the y direction + */ +void +SceneGraph::translateY(float y) +{ + this->xyz[1] = y; +} + +/** + * z 軸方向への平行移動 + * + * @param z Ttranslate in the z direction + */ +void +SceneGraph::translateZ(float z) +{ + this->xyz[2] = z; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/SceneGraph.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,109 @@ +#ifndef INCLUDED_SCENE_GRAPH +#define INCLUDED_SCENE_GRAPH + +#include "polygon.h" +#include "Pad.h" +#include "TaskManager.h" +class SceneGraph; + +typedef void (*move_func)(SceneGraph* node, int screen_w, int screen_h); +typedef void (*collision_func)(SceneGraph* node, int screen_w, int screen_h, + SceneGraph* tree); +typedef SceneGraph* SceneGraphPtr; + +class SceneGraph : public Polygon { +public: + SceneGraph(void); + SceneGraph(TaskManager *manager, xmlNodePtr surface); + SceneGraph(SceneGraphPtr orig); + ~SceneGraph(void); + + // Node がもつ状態変数(というべきか否か + // xyz,angle ぐらいあればおk? + float stack_xyz[3]; + float stack_angle[3]; + int id; + + int property_size; + void* propertyptr; + + // xml ファイルから生成した時のオブジェクトリスト + SceneGraphPtr next; + SceneGraphPtr prev; + SceneGraphPtr last; + + // Tree Structure + SceneGraphPtr parent; + SceneGraphPtr brother; + SceneGraphPtr children; + SceneGraphPtr lastChild; + + // Tree から削除されていたら 1 をセット。default = 0 + int flag_remove; + + // SceneGraph ID (SGList.h) + int sgid; + + // この SceneGraph は描画するものかどうか (0:しない 1:する + int flag_drawable; + + // anime frame num + int frame; + + // Group ID + int gid; + + // 関数ポインタ + move_func move; + collision_func collision; + + // desutroctor で呼ばれる + void (SceneGraph::*finalize)(void); + + void init(void); + void finalize_original(void); + void finalize_copy(void); + void move_execute(int screen_w, int screen_h); + void collision_check(int screen_w, int screen_h, SceneGraphPtr tree); + void all_execute(int screen_w, int screen_h); + + void add_next(SceneGraphPtr next); + SceneGraphPtr addChild(SceneGraphPtr child); + SceneGraphPtr addBrother(SceneGraphPtr bro); + SceneGraphPtr clone(void); + SceneGraphPtr clone(void *buf); + SceneGraphPtr searchSceneGraph(const char *name); + void set_move_collision(SceneGraphPtr node, + move_func new_move, collision_func new_collision); + void set_move_collision(move_func new_move, collision_func new_collision); + void remove(void); + SceneGraphPtr realRemoveFromTree(SceneGraphPtr tree); + SceneGraphPtr realRemoveFromList(SceneGraphPtr list); + int isRemoved(void); + + static SceneGraphPtr createSceneGraph(int id); + + void translate(float x, float y, float z); + void translateX(float x); + void translateY(float y); + void translateZ(float z); + + + void tree_check(void); + void print_member(void); + void get_data(TaskManager *manager, xmlNodePtr cur); + void delete_data(void); + + SDL_Surface* load_decode_image(char *image_name, xmlNodePtr cur); + int makeTapestries(TaskManager *manager, SDL_Surface *texture_image, int id); + void get_image(TaskManager *manager, xmlNodePtr cur); +}; + +#endif + +// 帯域変数を使うのは禁止なので削除すること +// オリジナル (Linked List) +extern SceneGraphPtr scene_graph; + +// 描画用 (同じオブジェクトが複数ある) Tree +extern SceneGraphPtr scene_graph_view;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/SceneGraphArray.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,43 @@ +#ifndef INCUDED_SCENE_GRAPH_ARRAY +#define INCUDED_SCENE_GRAPH_ARRAY + +#include "SceneGraph.h" + +// 下ですぐ #undef してます +#define MAX_SIZE 32 + +class SceneGraphArray { +public: + SceneGraph buf[MAX_SIZE]; + int size; + int pad[3]; + + SceneGraphArray(void) : size(0) {} + + /** + * array の初期化 + */ + void init(void) { + size = 0; + } + + /** + * buf から SceneGraph buffer を返す + * + * @retval SceneGraph if size < MAX_SIZE + * @retval NULL if size >= MAX_SIZE + */ + SceneGraphPtr getNext(void) { + if (size >= MAX_SIZE) { + return NULL; + } else { + return &buf[size++]; + } + } +}; + +typedef SceneGraphArray *SceneGraphArrayPtr; + +#undef MAX_SIZE + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/SceneGraphIterator.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,128 @@ +#include "SceneGraphIterator.h" + +void +SceneGraphIterator::set(SceneGraphPtr _list) +{ + list = cur = _list; +} + +/** + * 次の SceneGraph があるか返す + * + * @retval 1 next がある + * @retval 0 next がない + */ +int +SceneGraphIterator::hasNext(void) +{ + return (cur->next) ? 1 : 0; +} + +/** + * 指定した名前をもつ SceneGraph が以降存在するか + * + * @param id 検索したい SceneGraph の ID + * @retval 1 next がある + * @retval 0 next がない + */ +int +SceneGraphIterator::hasNext(int id) +{ + SceneGraphPtr p; + + for (p = cur->next; p; p = p->next) { + if (p->sgid == id) { + return 1; + } + } + + return 0; +} + +/*! + 指定したグループが以降存在するか + + @param id 検索したい Group の ID + @retval 1 next がある + @retval 0 next がない + */ +int +SceneGraphIterator::hasNextGroup(int id) +{ + SceneGraphPtr p; + for (p = cur->next; p; p = p->next) { + if (p->gid == id) { + return 1; + } + } + + return 0; +} + +/** + * iterator を次に進める + */ +void +SceneGraphIterator::next(void) +{ + cur = cur->next; +} + +/** + * iterator を指定した ID を持つ SceneGraph まで進める + * SceneGraph が無い場合、NULL にする + * + * @param id 検索したい SceneGraph の ID + */ +void +SceneGraphIterator::next(int id) +{ + SceneGraphPtr p; + + for (p = cur->next; p; p = p->next) { + if (p->sgid == id) { + break; + } + } + + cur = p; +} + +/*! + iterator を指定した Group ID を持つ SceneGraph まで進める + + @param id 検索したい SceneGraph の Group ID + */ +void +SceneGraphIterator::nextGroup(int id) +{ + SceneGraphPtr p; + + for (p = cur->next; p; p = p->next) { + if (p->gid == id) { + break; + } + } + + cur = p; +} + +/** + * 参照中の SceneGraph を削除する + */ +void +SceneGraphIterator::remove(void) +{ + cur->remove(); +} + +/** + * 参照中の SceneGraph を返す + * + * @return current SceneGraph + */ +SceneGraphPtr +SceneGraphIterator::get(void) +{ + return cur; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/SceneGraphIterator.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,27 @@ +#ifndef INCLUDED_SCENE_GRAPH_ITERATOR +#define INCLUDED_SCENE_GRAPH_ITERATOR + +#include "SceneGraph.h" + +class SceneGraphIterator { +public: + // 走査する SceneGraphList + SceneGraphPtr list; + + // 現在参照中の SceneGraph + SceneGraphPtr cur; + + void set(SceneGraphPtr list); + int hasNext(void); + int hasNext(int id); + int hasNextGroup(int id); + void next(void); + void next(int id); + void nextGroup(int id); + void remove(void); + SceneGraphPtr get(void); +}; + +typedef SceneGraphIterator *SceneGraphIteratorPtr; + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/SceneGraphRoot.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,389 @@ +#include <SDL.h> +#include <SDL_image.h> +#include <libxml/parser.h> +#include "SceneGraphRoot.h" +#include "xml.h" +#include "sys.h" +#include "TextureHash.h" +#include "texture.h" +#include "SGList.h" + +int cnt = 0; + +SceneGraphRoot::SceneGraphRoot(float w, float h) +{ + sg_src = new SceneGraphPtr[SGLIST_LENGTH]; + camera = new Camera(w, h); + iterator = new SceneGraphIterator; + controller = create_controller(); + + sg_exec_tree = NULL; + sg_draw_tree = NULL; + sg_available_list = NULL; + sg_remove_list = NULL; + + // TODO + // 今はとりあえず camera を Root にしています + // 今はそれすらもしてません + //sg_exec_tree = camera; +} + +SceneGraphRoot::~SceneGraphRoot(void) +{ + SceneGraphPtr p = sg_available_list; + + while (p) { + SceneGraphPtr tmp = p->next; + delete p; + p = tmp; + cnt--; + } + + p = sg_remove_list; + + while (p) { + SceneGraphPtr tmp = p->next; + delete p; + p = tmp; + cnt--; + } + + delete [] sg_src; + delete camera; + delete iterator; + delete controller; +} + +/** + * xml ファイルから生成された SceneGraph を sg_src に登録する。 + * + * @param sg SceneGraph created by xmlfile + */ +void +SceneGraphRoot::registSceneGraph(SceneGraphPtr sg) +{ + for (int i = 0; i < SGLIST_LENGTH; i++) { + if (strcmp(sg->name, sglist_table[i]) == 0) { + sg->sgid = i; + sg_src[i] = sg; + return; + } + } + + fprintf(stderr, "error: (%s:%3d) Can't find Scene \"%s\"\n", + __FUNCTION__, __LINE__, sg->name); +} + +void +SceneGraphRoot::addNext(SceneGraphPtr sg) +{ + SceneGraphPtr last = sg_available_list; + + if (!last) { + sg_available_list = sg; + } else { + while (last->next) { + last = last->next; + } + last->next = sg; + sg->prev = last; + } + + cnt++; +} + +/* XMLファイルからポリゴンを作成 */ +void +SceneGraphRoot::createFromXMLfile(TaskManager *manager, const char *xmlfile) +{ + xmlDocPtr doc; + xmlNodePtr cur; + SceneGraphPtr tmp; + + /* パース DOM生成 */ + doc = xmlParseFile(xmlfile); + cur = xmlDocGetRootElement(doc); + + /* ?? */ + xmlStrcmp(cur->name,(xmlChar*)"OBJECT-3D"); + + /* XMLのノードを一つずつ解析 */ + for (cur=cur->children; cur; cur=cur->next) { + /* 扱うのはsurfaceオンリー */ + if (xmlStrcmp(cur->name,(xmlChar*)"surface") != 0) { + continue; + } + + /* ポリゴン(SceneGraph)生成 */ + tmp = new SceneGraph(manager, cur); + + registSceneGraph(tmp); + } + + xmlFreeDoc(doc); +} + +SceneGraphPtr +SceneGraphRoot::createSceneGraph(int id) +{ + SceneGraphPtr src; + SceneGraphPtr p; + + if (id < 0 || id > SGLIST_LENGTH) { + return NULL; + } + + /* オリジナルの SceneGraph */ + src = sg_src[id]; + + /* ユーザーにはオリジナルの clone を返す */ + p = src->clone(); + + addNext(p); + + return p; +} + +/** + * 何も表示しない、move,collision もしない SceneGraph を生成 + * いずれ、Transform3D 的なものに回す予定 + */ +SceneGraphPtr +SceneGraphRoot::createSceneGraph(void) +{ + SceneGraphPtr p = new SceneGraph; + + addNext(p); + p->flag_drawable = 0; + + return p; +} + +void +SceneGraphRoot::speExecute(int screen_w, int screen_h) +{ + + SceneGraphPtr list = sg_available_list; + // SceneGraphPtr t = sg_exec_tree; + // SceneGraphPtr cur_parent = camera; + + // 前フレームで描画した SceneGraph は削除 + allRemove(sg_remove_list); + + // 前フレームに作られた SceneGraph は描画用に移行 + // 現フレームでの操作は以下の tree,list には適用されない + sg_draw_tree = sg_exec_tree; + sg_remove_list = sg_available_list; + + // 現フレームで新しく SceneGraph がコピーされるので初期化 + sg_exec_tree = NULL; + sg_available_list = NULL; + + camera->move_execute(screen_w, screen_h); + camera->update(screen_w, screen_h); + + camera->children = NULL; + camera->lastChild = NULL; + + list->move_execute(screen_w, screen_h); + list->collision_check(screen_w, screen_h, list); + + list->frame++; + list = list->next; + + if(sg_exec_tree != NULL) { + return; + } + + /*removeのflagをもとにtreeを形成*/ + /* spe から送り返されてきた property の配列を見て生成する for()*/ + /* + for (Property *t = property[0]; is_end(t); t++){ + SceneGraphPtr s = application->scenegraph_factory(t); // SceneGraphNode を作る + t->scenegraph = s; // property list には SceneGraphへのポインタが入っている + application->scenegraph_connector(property[0], s); // add する + } + */ + + + + // 現在、allExecute が終わった時点では + // camera->children が User SceneGraph の root になる + + /** + * NULL じゃなかったら、setSceneData が呼ばれてるから + * そっちを次の Scene にする + */ + + sg_exec_tree = camera->children; +} + + +void +SceneGraphRoot::allExecute(int screen_w, int screen_h) +{ + SceneGraphPtr list = sg_available_list; + SceneGraphPtr t = sg_exec_tree; + SceneGraphPtr cur_parent = camera; + + // 前フレームで描画した SceneGraph は削除 + allRemove(sg_remove_list); + + // 前フレームに作られた SceneGraph は描画用に移行 + // 現フレームでの操作は以下の tree,list には適用されない + sg_draw_tree = sg_exec_tree; + sg_remove_list = sg_available_list; + + // 現フレームで新しく SceneGraph がコピーされるので初期化 + sg_exec_tree = NULL; + sg_available_list = NULL; + + camera->move_execute(screen_w, screen_h); + camera->update(screen_w, screen_h); + + camera->children = NULL; + camera->lastChild = NULL; + + /*まずは全部動作させる*/ + while (list) { + + list->move_execute(screen_w, screen_h); + list->collision_check(screen_w, screen_h, list); + + list->frame++; + list = list->next; + + } + + if(sg_exec_tree != NULL) { + return; + } + + /*removeのflagをもとにtreeを形成*/ + while (t) { + SceneGraphPtr c = NULL; + if (!t->isRemoved()) { + c = t->clone(); + addNext(c); + cur_parent->addChild(c); + c->frame = t->frame; + /*親の回転、座標から、子の回転、座標を算出*/ + get_matrix(c->matrix, c->angle, c->xyz, cur_parent->matrix); + } + + if (t->children != NULL && c != NULL) { + cur_parent = c; + t = t->children; + } else if (t->brother != NULL) { + t = t->brother; + } else { + while (t) { + if (t->brother != NULL) { + t = t->brother; + break; + } else { + if (t->parent == NULL) { + t = NULL; + break; + } else { + cur_parent = cur_parent->parent; + t = t->parent; + + } + } + } + } + } + + + + // 現在、allExecute が終わった時点では + // camera->children が User SceneGraph の root になる + + /** + * NULL じゃなかったら、setSceneData が呼ばれてるから + * そっちを次の Scene にする + */ + + sg_exec_tree = camera->children; +} + +void +SceneGraphRoot::allRemove(SceneGraphPtr list) +{ + SceneGraphPtr p = list; + + while (p) { + SceneGraphPtr p1 = p->next; + delete p; + p = p1; + cnt--; + } +} + +void +SceneGraphRoot::checkRemove(void) +{ + SceneGraphPtr p = sg_available_list; + SceneGraphPtr p1; + + while (p) { + p1 = p->next; + if (p->isRemoved()) { + sg_exec_tree = p->realRemoveFromTree(sg_exec_tree); + sg_available_list = p->realRemoveFromList(sg_available_list); + } + delete p; + p = p1; + } +} + +SceneGraphPtr +SceneGraphRoot::getExecuteSceneGraph(void) +{ + return sg_exec_tree; +} + +SceneGraphPtr +SceneGraphRoot::getDrawSceneGraph(void) +{ + return sg_draw_tree; +} + +void +SceneGraphRoot::updateControllerState(void) +{ + controller->check(); +} + +void +SceneGraphRoot::setSceneData(SceneGraphPtr sg) +{ + sg_exec_tree = sg; +} + +Pad* +SceneGraphRoot::getController(void) +{ + return controller; +} + +SceneGraphIteratorPtr +SceneGraphRoot::getIterator(void) +{ + iterator->set(sg_remove_list); + return iterator; +} + +SceneGraphIteratorPtr +SceneGraphRoot::getIterator(SceneGraphPtr list) +{ + iterator->set(list); + return iterator; +} + +CameraPtr +SceneGraphRoot::getCamera(void) +{ + return camera; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/SceneGraphRoot.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,79 @@ +#ifndef INCLUDED_SCENE_GRAPH_ROOT +#define INCLUDED_SCENE_GRAPH_ROOT + +#include "SceneGraph.h" +#include "SceneGraphArray.h" +#include "Camera.h" +#include "SceneGraphIterator.h" + +class SceneGraphRoot { +public: + /* Constructor, Destructor */ + SceneGraphRoot(float w, float h); + ~SceneGraphRoot(void); + + /* Variables */ + // xml から読み込んだ、オリジナルの SceneGraph + SceneGraphPtr *sg_src; + + // move, collision 用の SceneGraph (tree) + SceneGraphPtr sg_exec_tree; + + // 描画用の SceneGraph List (tree) + SceneGraphPtr sg_draw_tree; + + // sg_exec_tree に対応する list + SceneGraphPtr sg_available_list; + + // sg_draw_tree に対応する list + // draw_tree は描画後削除される + SceneGraphPtr sg_remove_list; + + SceneGraphArrayPtr sg_array1; + SceneGraphArrayPtr sg_array2; + SceneGraphArrayPtr sg_curArray; + + // コントローラーオブジェクト (Keyboard, Joystick, ..) + Pad *controller; + + // カメラオブジェクト + Camera *camera; + + // SceneGraphIterator + SceneGraphIteratorPtr iterator; + + /** + * Functions + */ + /* User API */ + void createFromXMLfile(TaskManager *manager, const char *); + SceneGraphPtr createSceneGraph(int id); + SceneGraphPtr createSceneGraph(void); + void setSceneData(SceneGraphPtr sg); + Pad *getController(void); + SceneGraphIteratorPtr getIterator(void); + SceneGraphIteratorPtr getIterator(SceneGraphPtr list); + CameraPtr getCamera(void); + + /* Other System API */ + void allExecute(int screen_w, int screen_h); + void checkRemove(void); + SceneGraphPtr getExecuteSceneGraph(void); + SceneGraphPtr getDrawSceneGraph(void); + void updateControllerState(void); + + void speExecute(int screen_w, int screen_h); + + /* System API */ + void registSceneGraph(SceneGraphPtr sg); + void addNext(SceneGraphPtr sg); + void allRemove(SceneGraphPtr list); +}; + +typedef SceneGraphRoot *SceneGraphRootPtr; + +#endif + +// 大域変数は無くすこと +extern SceneGraphRootPtr sgroot; +extern SceneGraphRootPtr sgroot_2;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/Span.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,73 @@ +#ifndef INCLUDED_SPAN +#define INCLUDED_SPAN + +#include "Tapestry.h" +#include "types.h" + +#define MAX_TILE_LIST 64 + +#if 0 +typedef struct tile { + void *tile; + int tix, tiy; + //int padding; // 16バイト倍数にする用 +} TileInfo, *TileInfoPtr; + +typedef struct tile_list { + int size; + struct tile_list *next; + int pad[2]; + TileInfo tileinfo[MAX_TILE_LIST]; + + void init(void) { + size = 0; + next = 0; + } +} TileInfoList, *TileInfoListPtr; // 4*4+64*sizeof(Tile) = 16+768 +#endif + +class Span { +public: + uint32 *tex_addr; + int tex_width; + int tex_height; + int x; + int y; + int length_x; + float start_z; + float end_z; + float tex_x1; + float tex_x2; + float tex_y1; + float tex_y2; + float normal_x; + float normal_y; + float normal_z; + +#if 0 + TileInfoListPtr tilelist; +#endif + +#if 0 + void init(void) { + tilelist = 0; + } + + void reinit(void) { + TileInfoListPtr tlist = this->tilelist; + TileInfoListPtr t; + + while (tlist) { + t = tlist->next; + free(tlist); + tlist = t; + } + + tilelist = 0; + } +#endif +}; + +typedef Span* SpanPtr; + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/SpanC.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,398 @@ +#include <iostream> +#include "SpanC.h" +#include "triangle.h" +#include "polygon.h" +using namespace std; + + +// f1:xの増加量 f2:yの増加量 i:....... base:基本となる頂点のy座標 +static float calc(float f1, float f2,int i, float base){ + float ans; + ans = f1/f2*i + base; + return ans; +} + + +static Vertex *vMid1(Vertex *vMid1,Vertex *vMin, Vertex *vMid, Vertex *vMax) { + float d,d1; + + vMid1->y = vMid->y; + //vMid1->tex_y = vMid->tex_y; + d = (int)vMax->y-(int)vMin->y; + d1 = (int)vMid->y - (int)vMin->y; + /* + + if (-1.0<=vMax->y&&vMax->y<=1.0) { + a = 0.5; + } else { + a = (vMax->x-vMin->x)/d; + } + */ + //vMid1->tex_x = vMin->tex_x + a * (vMax->tex_x-vMin->tex_x); + vMid1->tex_x = calc(vMax->tex_x - vMin->tex_x, d, (int)d1 , vMin->tex_x); + vMid1->tex_y = calc(vMax->tex_y - vMin->tex_y, d, (int)d1 , vMin->tex_y); + //vMid1->x = vMin->x + a * (vMax->y -vMin->y); + vMid1->x = calc(vMax->x - vMin->x, d, (int)d1 , vMin->x); + //vMid1->z = vMin->z + a * (vMax->y -vMin->y); + vMid1->z = calc(vMax->z - vMin->z, d, (int)d1 , vMin->z); + //printf("x:%f y:%f z:%f tex_x:%f tex_y:%f\n",vMid1->x,vMid1->y,vMid1->z,vMid1->tex_x, vMid1->tex_y); + return vMid1; +} + + + +void +Span_c::half_triangle(Vertex *vMin, Vertex *vMid, Vertex *vMid1, + SDL_Surface *image) +{ + + float tmp_z,tmp_tex1, tmp_tex2 ,tmp_tey1,tmp_tey2; + //tmp_x,tmp_y,tmp_ypos ......unused + float tex_x, tex_y,tex_z; + float tmp_xpos,tmp_end,tmp_zpos; + int tex_xpos,tex_ypos,tex_zpos; + int i,j; + float div_y; + Uint32 rgb; + float z,zpos; + int x,y; + int k =0; + int l = 1; + //float incli_x1, incli_x2; + //float incli_z1, incli_z2; + //float base_x1, base_x2 , base_z1, base_z2; + //int base_y; + + /* + incli_x1 = vMid1->x - vMin->x; + incli_x2 = vMid->x - vMin->x; + incli_z1 = vMid1->z - vMin->z; + incli_z2 = vMid->z - vMin->z; + base_x1 = vMin->x; + base_x2 = vMin->x; + base_z1 = vMin->z; + base_z2 = vMin->z; + */ + //cout << vMin->x << vMin->y << vMin->z << endl; + int start_y = (int)vMid->y; + int end_y = (int)vMin->y; + + if (start_y<end_y) { + int i; i=end_y; end_y=start_y; start_y = i; //yの入れ替え + //Vertex *v; v = vMin; vMin = vMid; vMid = v; + /* + incli_x1 = vMin->x - vMid->x; incli_x2 = vMin->x - vMid1->x; + incli_z1 = vMin->z - vMid->z; incli_z2 = vMin->z - vMid1->z; + base_z1 = vMid->z; base_z2 = vMid1->z; + base_y = (int)vMid->y; + */ + k = 1; + l = -1; + } + + + + div_y = start_y - end_y; // > 0 + + //if(div_y < 1 && div_y > -1) div_y = 1; + for(i = k; i < div_y+1; i++) { + //ここでspanの左端と右端のx,zを求めてる + tmp_xpos = calc(vMid1->x - vMin->x ,div_y, i, vMin->x); + tmp_end = calc(vMid->x - vMin->x ,div_y, i, vMin->x); + tmp_z = calc(vMid1->z - vMin->z ,div_y, i, vMin->z); + tmp_zpos = calc(vMid->z - vMin->z ,div_y, i, vMin->z); + //printf("x:%f end:%f z:%f zpos:%f\n",tmp_xpos,tmp_end,tmp_z,tmp_zpos); + //ここからspanの左端と右端に対応するテクスチャを計算する + tmp_tex1 =((i/(div_y)) * vMid1->tex_x) + \ + ( ((div_y - i)/(div_y)) * vMin->tex_x); + tmp_tex2 =( (i/(div_y)) * vMid->tex_x) + \ + ( ((div_y - i)/(div_y)) * vMin->tex_x); + + tmp_tey1 =( (i/(div_y)) * vMid1->tex_y) + \ + ( ((div_y - i)/(div_y)) * vMin->tex_y); + tmp_tey2 =( (i/(div_y)) * vMid->tex_y) + \ + ( ((div_y - i)/(div_y)) * vMin->tex_y); + + //ここで左端がxposかendを判断し、描画するspanを作る + if(tmp_xpos > tmp_end) { + x = (int)tmp_end; + y = (int)vMin->y + i*l; + end = (int)(tmp_xpos)-(int)(tmp_end)+1; + z = tmp_zpos; + zpos = tmp_z; + tex1 = tmp_tex2; + tex2 = tmp_tex1; + tey1 = tmp_tey2; + tey2 = tmp_tey1; + } else { + x = (int)tmp_xpos; + y = (int)vMin->y + i*l; + end = (int)(tmp_end)-(int)(tmp_xpos)+1; + z = tmp_z; + zpos = tmp_zpos; + tex1 = tmp_tex1; + tex2 = tmp_tex2; + tey1 = tmp_tey1; + tey2 = tmp_tey2; + } + //printf("%d:%f,%f ",(int)vMin->y + i,xpos,end); + //printf("%d:%d:%d:x:%d,end:%d\n",x, y , end,(int)(tmp_end),(int)(tmp_xpos)); + //printf("x:%d y:%d end:%d z:%f zpos:%f\n",x,y,end,z , zpos); + //printf("tex1:%f tex2:%f tey1:%f tey2:%f\n",tex1,tex2,tey1,tey2); + if(end == 1) { + //printf("tex_x:%f tex_y:%f\n",tex1,tex2); + if(tex1 > 1) tex1 = 1; + if(tey1 > 1) tey1 = 1; + tex_xpos = (int)((image->h-1) * tex1); + tex_ypos = (int)((image->w-1) * tey1); + tex_zpos = (int)z; + //printf("tex_xpos:%d tex_ypos:%d\n",tex_xpos,tex_ypos); + //printf("image->h:%d tex_x:%f\n",image->h,tex1); + rgb = p->get_rgb(tex_xpos,tex_ypos); + //viewer->write_pixel(x,y,zpos,rgb); + }else { + for(j = 0; j < end; j++) { + tex_x = tex1*(end-1-j)/(end-1) + tex2*j/(end-1); + tex_y = tey1*(end-1-j)/(end-1) + tey2*j/(end-1); + tex_z = z*(end-1-j)/(end-1) + zpos*j/(end-1); + if(tex_x > 1) tex_x = 1; + if(tex_y > 1) tex_y = 1; + tex_xpos = (int)((image->h-1) * tex_x); + tex_ypos = (int)((image->w-1) * tex_y); + //printf("tex_xpos:%d tex_ypos:%d\n",tex_xpos,tex_ypos); + //printf("z:%f zpos:%f tex_z:%f\n",z,zpos,tex_z); + //printf("tex_x:%f tex_y:%f\n",tex_x,tex_y); + rgb = p->get_rgb(tex_xpos,tex_ypos); + //viewer->write_pixel(j+x,y,tex_z,rgb); + } + } + } +} + +void Span_c::create_span(Triangle *tri,SDL_Surface *image) { + Vertex *vMin , *vMid, *vMax; + /* + float tmp_z,tmp_tex1, tmp_tex2 ,tmp_tey1,tmp_tey2; + //tmp_x,tmp_y,tmp_ypos ......unused + float tex_x, tex_y,tex_z; + float tmp_xpos,tmp_end,tmp_zpos; + int top_triangle; + int tex_xpos,tex_ypos,tex_zpos; + int i,j; + float div_x,div_y; + float z,zpos; + Uint32 rgb; + */ + + //cout << "x = " << tri->vertex1->x << endl; + if(tri->vertex1->y <= tri->vertex2->y) { + if(tri->vertex2->y <= tri->vertex3->y) { + //printf("condition 1\n"); + vMin = tri->vertex1; + vMid = tri->vertex2; + vMax = tri->vertex3; + } else if(tri->vertex3->y <= tri->vertex1->y) { + //printf("condition 2\n"); + vMin = tri->vertex3; + vMid = tri->vertex1; + vMax = tri->vertex2; + } else { + //printf("condition 3\n"); + vMin = tri->vertex1; + vMid = tri->vertex3; + vMax = tri->vertex2; + } + } else { + if(tri->vertex1->y <= tri->vertex3->y) { + //printf("condition 4\n"); + vMin = tri->vertex2; + vMid = tri->vertex1; + vMax = tri->vertex3; + } else if(tri->vertex3->y <= tri->vertex2->y) { + //printf("condition 5\n"); + vMin = tri->vertex3; + vMid = tri->vertex2; + vMax = tri->vertex1; + } else { + //printf("condition 6\n"); + vMin = tri->vertex2; + vMid = tri->vertex3; + vMax = tri->vertex1; + } + } + + Vertex *vMid10 = new Vertex(0,0,0,0,0); + vMid1(vMid10,vMin,vMid,vMax); + + half_triangle(vMin,vMid,vMid10,image); + half_triangle(vMax,vMid,vMid10,image); + + free(vMid10); +#if 0 + //cout << vMin->x << vMin->y << vMin->z << endl; + div_x = (int)vMid->y - (int)vMin->y; + if(div_x < 1 && div_x > -1) div_x = 1; + div_y = (int)vMax->y - (int)vMin->y; + if(div_y < 1 && div_y > -1) div_y = 1; + + for(i = 0; i < div_x+1; i++) { + //ここでspanの左端と右端のx,zを求めてる + tmp_xpos = calc(vMax->x - vMin->x,div_y, i, vMin->x); + tmp_end = calc(vMid->x - vMin->x,div_x, i, vMin->x); + tmp_z = calc(vMax->z - vMin->z,div_y, i, vMin->z); + tmp_zpos = calc(vMid->z - vMin->z,div_x, i, vMin->z); + + //ここからspanの左端と右端に対応するテクスチャを計算する + tmp_tex1 =( (i/(div_y)) * vMax->tex_x) + \ + ( ((div_y - i)/(div_y)) * vMin->tex_x); + tmp_tex2 =( (i/(div_x)) * vMid->tex_x) + \ + ( ((div_x - i)/(div_x)) * vMin->tex_x); + + tmp_tey1 =( (i/(div_y)) * vMax->tex_y) + \ + ( ((div_y - i)/(div_y)) * vMin->tex_y); + tmp_tey2 =( (i/(div_x)) * vMid->tex_y) + \ + ( ((div_x - i)/(div_x)) * vMin->tex_y); + + //ここで左端がxposかendを判断し、描画するspanを作る + if(tmp_xpos > tmp_end) { + x = (int)tmp_end; + y = (int)vMin->y + i; + end = (int)(tmp_xpos)-(int)(tmp_end)+1; + z = tmp_z; + zpos = tmp_zpos; + tex1 = tmp_tex2; + tex2 = tmp_tex1; + tey1 = tmp_tey2; + tey2 = tmp_tey1; + } else { + x = (int)tmp_xpos; + y = (int)vMin->y + i; + end = (int)(tmp_end)-(int)(tmp_xpos)+1; + z = tmp_zpos; + zpos = tmp_z; + tex1 = tmp_tex1; + tex2 = tmp_tex2; + tey1 = tmp_tey1; + tey2 = tmp_tey2; + } + //printf("%d:%f,%f ",(int)vMin->y + i,xpos,end); + //printf("%d:%d:%d:x:%d,end:%d\n",x, y , end,(int)(tmp_end),(int)(tmp_xpos)); + //printf("x:%d y:%d end:%d z:%f zpos:%f\n",x,y,end,z , zpos); + //printf("tex1:%f tex2:%f tey1:%f tey2:%f\n",tex1,tex2,tey1,tey2); + if(end == 1) { + //printf("tex_x:%f tex_y:%f\n",tex1,tex2); + if(tex1 > 1) tex1 = 1; + if(tey1 > 1) tey1 = 1; + tex_xpos = (int)(image->h-1) * tex1; + tex_ypos = (int)(image->w-1) * tey1; + tex_zpos = z; + //printf("tex_xpos:%d tex_ypos:%d\n",tex_xpos,tex_ypos); + //printf("image->h:%d tex_x:%f\n",image->h,tex1); + rgb = p->get_rgb(tex_xpos,tex_ypos); + //viewer->write_pixel(x,y,zpos,rgb); + }else { + for(j = 0; j < end; j++) { + tex_x = tex1*(end-1-j)/(end-1) + tex2*j/(end-1); + tex_y = tey1*(end-1-j)/(end-1) + tey2*j/(end-1); + tex_z = z*(end-1-j)/(end-1) + zpos*j/(end-1); + if(tex_x > 1) tex_x = 1; + if(tex_y > 1) tex_y = 1; + tex_xpos = (int)(image->h-1) * tex_x; + tex_ypos = (int)(image->w-1) * tex_y; + //printf("tex_xpos:%d tex_ypos:%d\n",tex_xpos,tex_ypos); + //printf("z:%f zpos:%f tex_z:%f\n",z,zpos,tex_z); + //printf("tex_x:%f tex_y:%f\n",tex_x,tex_y); + rgb = p->get_rgb(tex_xpos,tex_ypos); + //viewer->write_pixel(j+x,y,tex_z,rgb); + } + } + } + + top_triangle = (int)vMid->y - (int)vMin->y; + div_x = (int)vMax->y - (int)vMid->y; + if(div_x < 1 && div_x > -1) div_x = 1; + div_y = (int)vMax->y - (int)vMin->y; + if(div_y < 1 && div_y > -1) div_y = 1; + + for(i = 0; i < div_x; i++) { + //ここでspanの左端と右端のx,zを求めてる + tmp_xpos = calc(vMax->x-vMin->x, div_y, (i+1+top_triangle), vMin->x); + tmp_end = calc(vMax->x-vMid->x, div_x, (i+1), vMid->x); + tmp_z = calc(vMax->z-vMin->z, div_y, (i+1+top_triangle), vMin->z); + tmp_zpos = calc(vMax->z-vMid->z, div_x, (i+1), vMid->z); + + tmp_tex1 =( ((i + 1 +top_triangle)/(div_y)) * vMax->tex_x) + \ + ( ((div_y - i - 1 - top_triangle)/(div_y)) * vMin->tex_x); + tmp_tex2 =( ((i+1)/(div_x)) * vMax->tex_x) + \ + ( ((div_x - i -1)/(div_x)) * vMid->tex_x); + + tmp_tey1 =( ((i+1+top_triangle)/(div_y)) * vMax->tex_y) + \ + ( ((div_y - i - 1 - top_triangle)/(div_y)) * vMin->tex_y); + tmp_tey2 =( ((i+1)/(div_x)) * vMax->tex_y) + \ + ( ((div_x - i -1)/(div_x)) * vMid->tex_y); + if(tmp_xpos > tmp_end) { + x = (int)tmp_end; + y = (int)vMid->y+i+1; + end = (int)(tmp_xpos)-(int)(tmp_end)+1; + z = tmp_z; + zpos = tmp_zpos; + tex1 = tmp_tex2; + tex2 = tmp_tex1; + tey1 = tmp_tey2; + tey2 = tmp_tey1; + } else { + x = (int)tmp_xpos; + y = (int)vMid->y+i+1; + end = (int)(tmp_end)-(int)(tmp_xpos)+1; + z = tmp_zpos; + zpos = tmp_z; + tex1 = tmp_tex1; + tex2 = tmp_tex2; + tey1 = tmp_tey1; + tey2 = tmp_tey2; + } + if(end == 0) end = 1; + //printf("%d:%d:%d\n",x, y , end); + //printf("x:%d y:%d end:%d z:%f zpos:%f\n",x,y,end,z,zpos); + //printf("tex1:%f tex2:%f tey1:%f tey2:%f\n",tex1,tex2,tey1,tey2); + if(end == 1) { + //printf("tex_x:%f tex_y:%f\n",tex1,tex2); + if(tex1 > 1) tex1 = 1; + if(tey1 > 1) tey1 = 1; + tex_xpos = (int)(image->h-1) * tex1; + tex_ypos = (int)(image->w-1) * tey1; + tex_zpos = z; + //printf("tex_x:%f tex_y:%f\n",tex_x,tex_y); + //printf("tex_xpos:%d tex_ypos:%d\n",tex_xpos,tex_ypos); + //printf("tex_x:%f tex_y:%f\n",tex_x,tex_y); + rgb = p->get_rgb(tex_xpos,tex_ypos); + //viewer->write_pixel(x,y,tex_zpos,rgb); + }else { + for(j = 0; j < end; j++) { + tex_x = tex1*(end-1-j)/(end-1) + tex2*j/(end-1); + tex_y = tey1*(end-1-j)/(end-1) + tey2*j/(end-1); + tex_z = z*(end-1-j)/(end-1) + zpos*j/(end-1); + //printf("tex_x:%f tex_y:%f\n",tex_x,tex_y); + if(tex_x > 1) tex_x = 1; + if(tex_y > 1) tex_y = 1; + tex_xpos = (int)(image->h-2) * tex_x; + tex_ypos = (int)(image->w-1) * tex_y; + //printf("z:%f zpos:%f tex_z:%f\n",z,zpos,tex_z); + //printf("tex_xpos:%d tex_ypos:%d\n",tex_xpos,tex_ypos); + //printf("tex_x:%f tex_y:%f\n",tex_x,tex_y); + //printf("tex_x:%f tex_y:%f\n",tex_x,tex_y); + rgb = p->get_rgb(tex_xpos,tex_ypos); + //viewer->write_pixel(j+x,y,tex_z,rgb); + } + } + } +#endif +} + +// i:分子、f1:長さ f2:対応する頂点1 f3:対応する頂点2 +/* +float Span::calc2(int i, float f1, float f2, float f3) { + float ans; + ans = i/f1 * f2 + (f1-i)/f1 * f3; + + */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/SpanC.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,20 @@ +#ifndef INCLUDE_Span +#define INCLUDE_Span + +#include "triangle.h" +#include "viewer.h" +#include "polygon.h" + +class Span_c { +public: + int x,y,end; + float z,zpos; + float tex1,tex2,tey1,tey2; + void create_span(Triangle *tri,SDL_Surface *image); + // float calc(float f1, float f2,int i, float base); + void half_triangle(Vertex*, Vertex*, Vertex*, SDL_Surface *image); + Viewer *viewer; + Polygon *p; +}; + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/SpanPack.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,51 @@ +#ifndef INCLUDED_SPAN_PACK +#define INCLUDED_SPAN_PACK + +#include "Span.h" + +#define MAX_SIZE_SPAN 64 + +class SpanPack { +public: /* fields */ + struct SpanInfo { + int start; + int size; + int y_top; + int light_pos[3]; + int light_rgb[3]; + } info; // 36 + + Span span[MAX_SIZE_SPAN]; // 48*MAX_SIZE_SPAN = 3072 + SpanPack *next; // 4 + + int pad[2]; // 8 + + void init(int ytop) { + this->info.start = 0; + this->info.size = 0; + this->info.y_top = ytop; + this->next = NULL; + } + + void reinit(int ytop) { + SpanPack* top = this; + SpanPack* p; + SpanPack* p1; + + p = top->next; + while (p != NULL) { + p1 = p->next; + free(p); + p = p1; + } + + this->info.start = 0; + this->info.size = 0; + this->info.y_top = ytop; + this->next = NULL; + } +}; + +typedef SpanPack* SpanPackPtr; + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/TODO Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,11 @@ +Tue Sep 22 21:32:17 JST 2009 + +* SceneGraph の中の Property をlenear array する :Done +* ユーザ入力を spe の global allocate に書く (SWITCHで) :hiroki +* spe 側で lenear array を move_task で update する :kazz +* option (spe 側で衝突判定するデータを gloval alloc する) :TODO +* spe 側で lenear array を collision 側で update する :TODO +* lenear array から SceneGraph を再構築する :yutaka +* rendering_task と task_next で待ち合わせる :kaito +* ダブルバッファリングされている Property、SceneGraph を入れ替える :kaito +* rendering_task と move_task の起動 :kaito \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/Tapestry.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,137 @@ +#ifndef INCLUDED_TAPESTRY +#define INCLUDED_TAPESTRY + +#include "types.h" +#include "viewer_types.h" +#include "MemorySegment.h" +#include "MemList.h" + +/** + * image file name と tapestry DB の binary tree + * + * // PPE + * main memory の tapestry DB (Array) + * tapestry DB への accessor + * + * TapestryPtr getTapestry(int TapestryID); + * TilePtr getTile(TapestryPtr tapsetry, int tx, int ty, int scale); + * + * SPE が生成する tapestry List (in CreateSpan) + * (no texture image) + * @in TapestryDBPtr, Tapestry ID, x, y, tx, ty, px, py + * x, y : polygon の中の平面座標 + * tx, ty : texture の座標 + * px, py : texture の分割数 + * + * @out (TilePtr, tix1, tiy1, tix2, tiy2)* + * + * + * SPE に渡す tapestry List + * @in Tile + * + * // SPE + * SPE 内部での tapestry DB (Hash) + * TapestryID, scale, TilePtr, Tile + * + * + * SPE 内部での tapestry DB への accessor + * TileEntryPtr getTile(int TapestryID, int tx, int ty, int scale); + * + * if (TileEntry == NULL) { + * DMA read + * } + * + * + * Rendering + * 1pass Zbuffer と Texture の有無の判定 + * if (zbuffer ok) { + * if (texture ある) { + * zbuffer 、linebunf に書き込む + * } else { + * texture の load list に加える + * zbuffer だけ更新しておく + * } + * } else { + * 無視 + * } + * + * 1pass で texture が一杯になったら、中断して + * ここまでのを書き込んどけ + * + * + * 2pass rgb の書き込み + * + * if (zbuffer の値が自分と一緒) { + * read した texture みて + * 書き込め! + * } + * + */ +struct texture_block { + +}; + +#ifdef USE_MEMLIST +typedef MemorySegment Tile, *TilePtr; +#else +typedef struct { + uint32 data[TEXTURE_BLOCK_SIZE]; // 8*8 + uint32 *address; + int pad[3]; +} Tile, *TilePtr; +#endif + +#define MAX_TILE 128 + +/** + * TileList 中の Tile の追い出しは、現在 FIFO で実装している + * これは汎用のサイズ別 freelist に置き換える + * freelist は double linked list で、LRU をサポートする +*/ +#ifdef USE_MEMLIST +class TileList : public MemList { + TileList(MemorySegment* ms) : MemList(ms) {} + +/*! + 中身は同じ + */ +}; +#else +class TileList { +public: + int curIndex; + int pad[3]; + Tile tile[MAX_TILE]; + + TileList(void) { + curIndex = 0; + } + + /** + * 次に扱う tile を取得する + * + * @return tile + * + * tile[] をリングバスっぽく扱うことで + * FIFO を実現することに。 + */ + TilePtr nextTile(void) { + TilePtr t = &tile[curIndex]; + curIndex = (curIndex + 1) % MAX_TILE; + return t; + } + + /** + * TileList のクリア + * //tile 自体は clear する必要は無い + * あるかもしれない + */ + void clear(void) { + curIndex = 0; + } +}; +#endif + +typedef TileList* TileListPtr; + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/TextureHash.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,53 @@ +#include <string.h> +#include <stdlib.h> +#include "TextureHash.h" + +static int id_count; + +TextureHash::TextureHash(void) +{ + table = (hashtable*)malloc(sizeof(hashtable)*TABLE_SIZE); + + for (int i = 0; i < TABLE_SIZE; i++) { + table[i].tx_id = -1; + table[i].key = NULL; + } +} + +TextureHash::~TextureHash(void) +{ + free(table); +} + +int +TextureHash::hash_function(const char *key) +{ + //float value = 0.0; + int value = 0; + + for (int i = 0; key[i]; i++) { + value += key[i]*(i+1)*17+1; + } + + return value%TABLE_SIZE; +} + +int +TextureHash::hash_regist(const char* key, int &id) +{ + int hash = hash_function(key); + + for (int i = 0; ; i++) { + if (table[hash].tx_id == -1) { + table[hash].key = (char*)key; + id = id_count++; + return 0; + + } else if (strcmp(key, table[hash].key) == 0 + && table[hash].tx_id != -1){ + id = table[hash].tx_id; + return 1; + } + hash = ((37*hash)^(11*i)) % TABLE_SIZE; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/TextureHash.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,21 @@ +#ifndef INCLUDED_TEXTURE_HASH +#define INCLUDED_TEXTURE_HASH + +const int TABLE_SIZE = 8192; + +struct hashtable{ + int tx_id; + char* key; +}; + +class TextureHash { +public: + hashtable *table; + + TextureHash(void); + ~TextureHash(void); + int hash_function(const char* image_name); + int hash_regist(const char* image_name, int &tx_id); +}; + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/base64_de.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,91 @@ +#include <iostream> +#include <fstream> +using namespace std; + +class tagTT +{ +public: + unsigned char buf; + char *cont; + int nlen; +}; + + +unsigned char CtoNum(int c) +{ + if (c >= 'A' && c <= 'Z') return c-'A'; + if (c >= 'a' && c <= 'z') return (c - 'a')+26; + if (c >= '0' && c <= '9') return (c - '0')+52; + if (c == '+') return 62; + if (c == '/') return 63; + return 0; +} + + +int GetNumB64(tagTT &pWork) +{ + char wr; + unsigned char w; + unsigned char r; + + wr = *pWork.cont; + pWork.cont++; + if (wr=='\0' || wr=='=') + return -1; + + while(wr=='\n' || wr=='\t') + { + wr = *pWork.cont; + pWork.cont++; + } + + w = CtoNum(wr); + if (pWork.nlen == 0) + { + unsigned char w2; + + wr = *pWork.cont; + pWork.cont++; + if (wr!='\0' && wr!='=') + w2 = CtoNum(wr); + else + w2 = 0; + + pWork.buf = w << 2; + w = w2; + pWork.nlen = 6; + } + + pWork.nlen -= 2; + + r = pWork.buf | (w >> pWork.nlen); + + pWork.buf = (w << (8 - pWork.nlen)); + return r; +} + + +//int decode(char *cont, char *file_name) +int decode(char *cont, FILE *outfile) +{ + int rw; + tagTT work; + + //ofstream outfile(file_name); + + work.buf = 0; + work.nlen = 0; + work.cont = cont; + + rw = GetNumB64(work); + while ( rw != -1 ) + { + //outfile << (char)rw; + putc(rw, outfile); + rw = GetNumB64(work); + } + + //outfile.close(); + + return 0; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/fb.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,101 @@ +#ifndef FB_H +#define FB_H + +#if defined(__linux__) + +#include <unistd.h> +#include <stdio.h> +#include <fcntl.h> +#include <linux/fb.h> +#include <linux/fs.h> +#include <sys/mman.h> +#include <sys/ioctl.h> +#include <stdlib.h> +#include <iostream> +using namespace std; + +#define DEVICE_NAME "/dev/fb0" +#define DIV_BYTE 8 + +/* function prototype */ +void send_current_error_msg(const char *ptr); +void send_current_information(const char *ptr); + +/* + Don't put real function in a header... + */ + +int get_fbdev_addr(void) +{ + int fd_framebuffer ; + struct fb_var_screeninfo vinfo; + struct fb_fix_screeninfo finfo; + long int screensize ; + //long int location; + char *fbptr ; + char tmp[DIV_BYTE*10]; + + //int x , y ; + int xres,yres,vbpp,line_len; + //unsigned short tcolor ; + + /* 読み書き用にファイルを開く */ + fd_framebuffer = open( DEVICE_NAME , O_RDWR); + if ( !fd_framebuffer ) { + send_current_error_msg("Framebuffer device open error !"); + exit(1); + } + send_current_information("The framebuffer device was opened !"); + + /* 固定スクリーン情報取得 */ + if ( ioctl( fd_framebuffer , FBIOGET_FSCREENINFO , &finfo ) ) { + send_current_error_msg("Fixed information not gotton !"); + exit(2); + } + + /* 変動スクリーン情報取得 */ + if ( ioctl( fd_framebuffer , FBIOGET_VSCREENINFO , &vinfo ) ) { + send_current_error_msg("Variable information not gotton !"); + exit(3); + } + xres = vinfo.xres ; + yres = vinfo.yres ; + vbpp = vinfo.bits_per_pixel ; + line_len = finfo.line_length ; + sprintf( tmp , "%d(pixel)x%d(line), %dbpp(bits per pixel)",xres,yres,vbpp); + send_current_information( tmp ); + + /* バイト単位でのスクリーンのサイズを計算 */ + screensize = xres * yres * vbpp / DIV_BYTE ; + + /* デバイスをメモリにマップする */ + fbptr = (char *)mmap(0,screensize,PROT_READ | PROT_WRITE,MAP_SHARED,fd_framebuffer,0); + if ( (int)fbptr == -1 ) { + send_current_error_msg("Don't get framebuffer device to memory !"); + exit(4); + } + send_current_information("The framebuffer device was mapped !"); + + printf("fb: 0x%x \n", (unsigned int)fbptr); + return (int)fbptr; + //munmap(fbptr,screensize); + //close(fd_framebuffer); + //return 0; +} + +void send_current_error_msg(const char *ptr) +{ + fprintf( stderr , "%s\n" , ptr ); +} + +void send_current_information(const char *ptr) +{ + fprintf( stdout , "%s\n" , ptr ); +} +#else /* !defined(__linux__) */ +int get_fbdev_addr(void) {return 0;} +#endif /* defined(__linux__) */ + +extern int get_fbdev_addr(void); + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/global_alloc.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,17 @@ +#ifndef GLOBAL_ACCLOC_H +#define GLOBAL_ACCLOC_H + +/*! + global_alloc 用の ID + + should be auto genarated. + */ +enum global_allocate_id { + + TEXTURE_ID, + GLOBAL_TEXTURE_HASH, + GLOBAL_TILE_LIST, + KEY_STATUS, +}; + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/hash_texture.h Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,20 @@ +#ifndef HASH_TEXTURE_H +#define HASH_TEXTURE_H + +const int N = 8192; + +struct +hashtable{ + int tx_id; + char* key; +}; + +class TextureHash { + hashtable table[N]; +public: + hash(void); + int hash_function(const char*); + int hash_regist(const char*); +}; + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/lindaapi.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,627 @@ +// $Id: lindaapi.c,v 1.9 2006/04/03 08:17:11 kono Exp $ +// + +/*---------------------------------------------------------------------- + 롼ɥեɤ߹ +----------------------------------------------------------------------*/ +#include <sys/file.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <fcntl.h> +#include <sys/uio.h> +#include <sys/time.h> +#include <sys/select.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <sys/un.h> +#include <netinet/in.h> +#include <netinet/tcp.h> +#include <signal.h> +#include <termios.h> +#include <netdb.h> +#include <errno.h> +#include <sys/select.h> + +#include "lindaapi.h" + +#define TIMEDELTA 10 +#if 0 +#define PSX_Debug(deb) (putchar(PS_DEB)),\ + (printf deb ),\ + (putchar(PS_DEB)) +#define DEB(a) +#else +#define PSX_Debug(deb) +#define DEB(a) /* a */ +#endif + +COMMAND *q_top, *q_end; +REPLY *reply, *r_end; + +int qsize, ps; +unsigned short seq; + +#ifdef COUNT_PACKET +// print packet count message per PRINT_INTERVAL sec +#define PRINT_INTERVAL 4 + +/*-------------------------------------------------------------------/ + void + count_packet (char type): + ѥåȤȤ + + : + type - (char: s,r) +/-------------------------------------------------------------------*/ +void count_packet(char type) +{ + static int send_packet=-1,receive_packet=0; + static struct timeval start,now,previous; + + if (out_packet == -1) { + gettimeofday(&start,NULL); + gettimeofday(&previous,NULL); + send_packet = 0; + printf("packet\tout\tread\t\ttime\n"); + } + + if (type == 's') { + send_packet++; + } else if (type == 'r') { + receive_packet++; + } else { + fprintf(stderr,"No type in count_packet function\n"); + return; + } + + gettimeofday(&now,NULL); + if ((now.tv_sec-previous.tv_sec) > PRINT_INTERVAL) { + printf("log\t%d\t%d\t%ld\n", + send_packet,receive_packet,now.tv_sec-start.tv_sec); + fflush(stdout); + + previous.tv_sec = now.tv_sec; + send_packet = receive_packet = 0; + } +} +#endif + + +#define unix_open open +#define unix_read_w read +/*-------------------------------------------------------------------/ + int + unix_read (int fd, char *buf, unsigned int size): + ФTUPLEɤߤࡣ + ߤϻȤƤʤ + + : + fd - ФΥեǥץ + buf - ǡγǼ(TUPLEإåޤ) + size - bufbyte + ֤: + ɤߤbyte +/-------------------------------------------------------------------*/ +int +unix_read(int fd,char *buf,unsigned int size) { + int len,a,i; + if(read(fd,buf,INT_SIZE)!=INT_SIZE) { // INT_SIZE is sizeof(int) + fprintf(stderr, "read error! on fd:%d len=%d %s\n", fd, + *(unsigned int*)&buf[0], + strerror(errno)); + exit(1); + } + len = ntohl(*(unsigned int*)&buf[0]); + if((unsigned int)len>size) len=(int)size; + for(a=0;a<len;a+=i) { + if((i=read(fd,buf+a,len-a))<0) { + fprintf(stderr, "ldserv: client read error! on i=%d len= %d %s\n", + i, len, strerror(errno)); + exit(1); + } + } + return len; +} + +/*-------------------------------------------------------------------/ + int + unix_write (int fd, unsigned char *buf, unsigned int size): + ФTUPLE롣 + + : + fd - ФΥեǥץ + buf - Фǡ(TUPLEإåޤ) + size - bufbyte + ֤: + ä()ǡbyte +/-------------------------------------------------------------------*/ +int +unix_write(int fd,unsigned char *buf,unsigned int size) { + int i,nsize; + nsize = htonl(size); + i = write(fd,&nsize,INT_SIZE); + i += write(fd,buf,size); // size == datasize + LINDA_HEADER_SIZE +#ifdef COUNT_PACKET + count_packet('s'); +#endif + return(i); +} + +#define unix_write_w unix_write + +#define SERV_NAME unix_port +#define PROTO_NAME "tcp" +#define SERVER_NAME hostname +#define MAX_REQ 16 + +int fd,paddrlen; +struct hostent *hoste; +struct sockaddr_in serv_addr; +struct sockaddr_un serv_addr_un; +unsigned char ipaddr[4]; + + +/*-------------------------------------------------------------------/ + int + start_linda (char * hostname): + ФȤΥͥΩCOMMAND塼REPLY塼 + Ԥʤ + + : + hostname - ФΥۥ̾ + ֤: + ͥΩȤΥեǥץ֤ + Ԥ -1 ֤ +/-------------------------------------------------------------------*/ +int +start_linda(char * hostname){ + char *p; + const char *hostname0 = "/tmp/ldserv"; + + if (! hostname) { + hostname = (char *)hostname0; + } + if (hostname[0]=='/') { + /* Unix domain */ + if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == FAIL){ + fprintf(stderr, "socket open error! errno :%d %s\n", errno, + strerror(errno)); + return(-1); + } + serv_addr_un.sun_family = AF_UNIX; + strcpy(serv_addr_un.sun_path, hostname); + fprintf(stdout,"connecting ... %d\n", ntohs(serv_addr.sin_port)); + if (connect(fd, (struct sockaddr *)&serv_addr_un,sizeof(serv_addr_un)) == FAIL){ + fprintf(stderr,"connection error! errno :%d %s\n", errno, + strerror(errno)); + close(fd); + return(-1); + } + + } else { + /* INET domain */ + if ((fd = socket(AF_INET, SOCK_STREAM, 0)) == FAIL){ + fprintf(stderr, "socket open error! errno :%d %s\n", errno, + strerror(errno)); + return(-1); + } + /* check optional port number */ + serv_addr.sin_port = htons(10000); + p = (char *)malloc(strlen(hostname)); + strcpy(p,hostname); + hostname = p; + while(*p) { + if (*p==':') { + serv_addr.sin_port = htons(atoi(p+1)); + *p = 0; + break; + } + p++; + } + if ((hoste = gethostbyname(hostname)) == NULL){ + fprintf(stderr,"hostname error\n"); + close(fd); + return(-1); + } + free(hostname); hostname=0; + serv_addr.sin_family = AF_INET; + serv_addr.sin_addr.s_addr = ((struct in_addr *)(hoste->h_addr))->s_addr; + if (serv_addr.sin_family == AF_INET) { + int tmp = 1; + setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, + (char *) &tmp, sizeof (int)); + } + fprintf(stdout,"connecting ... %d\n", ntohs(serv_addr.sin_port)); + if (connect(fd, (struct sockaddr *)&serv_addr,sizeof(serv_addr)) == FAIL){ + fprintf(stderr,"connection error! errno :%d %s\n", errno, + strerror(errno)); + close(fd); + return(-1); + } + } + + ps = fd; + fprintf(stdout," connect middle server %d\n", fd); + q_end = q_top = NULL; + r_end = reply = NULL; + qsize = seq = 0; + seq = 120; + return ps; +} + +/*-------------------------------------------------------------------/ + int + psx_out (unsigned int id, unsigned char *data, unsigned int size): + outޥɤCOMMAND塼ί롣 + + : + id - TUPLE SpaceID + data - ǡ + size - dataΥ + ֤: + ֹ +/-------------------------------------------------------------------*/ +int +psx_out(unsigned int id, unsigned char *data, unsigned int size){ + if (psx_queue(id, size, data, 'o', NULL, NULL) == FAIL){ + return(FAIL); + } + DEB( fprintf(stdout, "psx_out: size = %d, command = %s\n", + q_end->size, q_end->command+LINDA_HEADER_SIZE)); + return(seq); +} + +/*-------------------------------------------------------------------/ + int + psx_ld (unsigned int id, char mode, void(*callback)(char*,void*), + void * obj): + in,read,waitʤɤμޥɤCOMMAND塼ί롣 + psx_in,psx_rd,psx_wait_rdʤɤ֤Ƥ롣 + + : + id - TUPLE SpaceID + mode - i,r,w ʸꡢơin,read,waitɽƤ롣 + callback - ХåѤδؿؤΥݥ + ѤʤNULL롣 + obj - ХåѤؿΰ + ֤: + psx_queuemalloc줿REPLY¤ΤؤΥݥ +/-------------------------------------------------------------------*/ +int +psx_ld(unsigned int id, char mode,void(*callback)(char *,void *),void * obj){ + int r; + if ((r=psx_queue(id, 0, NULL, mode, callback, obj)) == FAIL){ + return(FAIL); + } + return(r); +} + +/*-------------------------------------------------------------------/ + unsigned char * + psx_reply (int seq): + Ф褿ǡ֤ + + : + seq - psx_ld()֤͡ + ֤: + seqбǡ֤ǡޤƤʤ + NULL֤ +/-------------------------------------------------------------------*/ +unsigned char * +psx_reply(int seq){ + REPLY *p, *q; + char *ans; + + DEB(fprintf(stdout, "psx_reply: search of seq = %d\n", seq)); + PSX_Debug(("psx_reply: seq %d", seq)); + for(q = NULL,p = reply;p;q = p,p = p->next){ + if (p->seq == (unsigned)seq){ + DEB(fprintf(stdout, "psx_reply: match of seq = %d\n", seq)); + if (p->mode == '!'){ + ans = (char *)p->answer; + if (q == NULL){ + reply = p->next; + if(p==r_end) { + r_end = p->next; + } + } else { + q->next = p->next; + if(p==r_end) { + r_end = q; + } + } + PSX_Debug(("psx_reply: reply %x r_end %x p %x q %x",reply,r_end,p,q)); + free(p); + DEB( for(p=reply;p;p=p->next) { PSX_Debug(("psx_queue dump: seq %d mode %c %x %x",p->seq,p->mode,p,p->next))}); + DEB( fprintf(stdout, "psx_reply: returned answer = %s\n", ans)); + PSX_Debug(("psx_reply: answer %s",ans)); + return((unsigned char *)ans); + } else { + if (p->mode == '?'){ + DEB(fprintf(stdout, "psx_reply: don't accept anser\n")); + return(NULL); + } + } + } + + } + PSX_Debug(("psx_reply: no match seq %d",seq)); + DEB(fprintf(stdout, "psx_reply: no match of seq\n")); + return(NULL); +} + +/*-------------------------------------------------------------------/ + void + psx_sync_n (): + Фȥǡ롣COMMAND塼ίޤäǡ + Ф褿ǡбREPLYؤ롣 +/-------------------------------------------------------------------*/ +void +psx_sync_n(){ + int acount; + COMMAND *c, *t; + + fd_set tmp, fds; + struct timeval timeout; + timeout.tv_sec=0; + timeout.tv_usec=TIMEDELTA * 1000; + + acount = 0; + while (q_top != NULL){ +