Mercurial > hg > Game > Cerium
changeset 1383:fa3d77953998 draft
change Makefile.macosx motion_man.cc
author | Kakeru TAMASIRO <e095736@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 27 Jan 2012 02:03:57 +0900 |
parents | de990f3e0a21 |
children | 207e0ed76cf1 |
files | Renderer/Test/Makefile.macosx Renderer/Test/motion_man.cc |
diffstat | 2 files changed, 64 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/Renderer/Test/Makefile.macosx Fri Jan 27 01:34:21 2012 +0900 +++ b/Renderer/Test/Makefile.macosx Fri Jan 27 02:03:57 2012 +0900 @@ -13,10 +13,14 @@ %.pb.cc: $(PROTODIR)/%.proto $(PROTO) $(PROTOFLAGS) $< -ALL = motion_man ball_bound boss1_action direction gaplant ieshoot node panel universe untitled vacuum property_test send_linda dynamic writer chain_old SgRootChange viewer aquarium network init_aquarium test_linda viewer_2 +ALL = collada motion_man ball_bound boss1_action direction gaplant ieshoot node panel universe untitled vacuum property_test send_linda dynamic writer chain_old SgRootChange viewer aquarium network init_aquarium test_linda viewer_2 all: $(ALL) +COLLADA_OBJ = collada.o +collada : $(COLLADA_OBJ) + $(CC) $(CFLAGS) -o $@ $? $(LIBS) + STR_OBJ = print_string.o print_string : $(STR_OBJ) $(CC) $(CFLAGS) -o $@ $? $(LIBS)
--- a/Renderer/Test/motion_man.cc Fri Jan 27 01:34:21 2012 +0900 +++ b/Renderer/Test/motion_man.cc Fri Jan 27 02:03:57 2012 +0900 @@ -10,17 +10,60 @@ float dx=0,dy=80; float tx=0,ty=10; float cx=0,cy=-10; +static int cube_subID,cub5ID,cub6ID; static void push_move_false(SceneGraphPtr, void *sgroot_, int w, int h, SceneGraphPtr tree) { } static void +walk(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree) { + SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; + SceneGraphIteratorPtr it1 = sgroot->getIterator(tree); + SceneGraphIteratorPtr it2 = sgroot->getIterator(tree); + + Pad *pad = sgroot->getController(); + it1->next(cub5ID); + SceneGraphPtr cub5 = it1->get(); + + if (pad->left.isHold()) { + if (x==80) { + cub5->angle[0] -= 10; + y=cub5->angle[0]; + if (y==-80) + x=0; + } else if (y==-80) { + cub5->angle[0] += 10; + x=cub5->angle[0]; + } + } + + it2->next(cub6ID); + SceneGraphPtr cub6 = it2->get(); + if (pad->left.isHold()) { + if (dx==-80) { + cub6->angle[0] += 10; + dy=cub6->angle[0]; + if (dy==80) + dx=0; + } else if (dy==80) { + cub6->angle[0] -= 10; + dx=cub6->angle[0]; + } + } +} + +static void move_left(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) { + SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; + Pad *pad = sgroot->getController(); + + if (pad->left.isHold()) { node->xyz[0] -= 10; if (node->xyz[0] < 0) node->xyz[0] = screen_w; + } } static void @@ -60,43 +103,6 @@ } } } -static void -push_right_foot(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) { - - SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; - Pad *pad = sgroot->getController(); - - if (pad->circle.isHold()) { - if (x==80) { - node->angle[0] -= 10; - y=node->angle[0]; - if (y==-80) - x=0; - } else if (y==-80) { - node->angle[0] += 10; - x=node->angle[0]; - } - } -} - -static void -push_left_foot(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) { - - SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; - Pad *pad = sgroot->getController(); - - if (pad->cross.isHold()) { - if (dx==-80) { - node->angle[0] += 10; - dy=node->angle[0]; - if (dy==80) - dx=0; - } else if (dy==80) { - node->angle[0] -= 10; - dx=node->angle[0]; - } - } -} MainLoopPtr motion_man::init(Viewer *sgroot, int screen_w, int screen_h) { @@ -116,31 +122,41 @@ light->xyz[1] = screen_h / 2; light->xyz[2] = -100; + SceneGraphPtr root = sgroot->createSceneGraph(); cube1 = sgroot->createSceneGraph("Cube"); - cube1->xyz[0] = screen_w / 2; + cube1->xyz[0] = (screen_w / 2) / 2 + (screen_w / 2); cube1->xyz[1] = screen_h / 2; cube1->xyz[2] = 0; - //cube1->angle[1] = 90; + cube1->angle[1] = 90; + + root->addChild(cube1); cube2 = sgroot->createSceneGraph("Cube.001"); cube3 = sgroot->createSceneGraph("Cube.002"); cube4 = sgroot->createSceneGraph("Cube.003"); cube5 = sgroot->createSceneGraph("Cube.004"); + cub5ID = cube5->sgid; cube6 = sgroot->createSceneGraph("Cube.005"); + cub6ID = cube6->sgid; cube1->addChild(cube2); cube1->addChild(cube3); cube1->addChild(cube4); cube1->addChild(cube5); cube1->addChild(cube6); - //cube1->set_move_collision(move_left, push_move_false); + cube1->set_move_collision(move_left, walk); cube3->set_move_collision(push_right_arm, push_move_false); cube2->set_move_collision(push_left_arm, push_move_false); - cube5->set_move_collision(push_right_foot, push_move_false); - cube6->set_move_collision(push_left_foot, push_move_false); - sgroot->setSceneData(cube1); + SceneGraphPtr cube_sub = sgroot->createSceneGraph("Cube"); + cube_subID = cube_sub->sgid; + cube_sub->xyz[0] = screen_w / 3; + cube_sub->xyz[1] = screen_h / 2; + cube_sub->xyz[2] = 0; + root->addChild(cube_sub); + + sgroot->setSceneData(root); return sgroot; }