# HG changeset patch # User tokumoritaichirou@w-133-13-243-110.cc.u-ryukyu.ac.jp # Date 1265166177 -32400 # Node ID 4727e16018cd12d22d05b5971b9f490de45627d0 # Parent 5727d511a13a7d274409adfaeb9f17eaeb8d5f9c change src. punch motion using array diff -r 5727d511a13a -r 4727e16018cd src/Robot.cpp --- a/src/Robot.cpp Wed Feb 03 03:39:04 2010 +0900 +++ b/src/Robot.cpp Wed Feb 03 12:02:57 2010 +0900 @@ -38,25 +38,25 @@ bodyForm->setMatrix(osg::Matrix()); collisionNode = new CollisionNode("Body-Node1", new osg::Sphere(osg::Vec3(0, 0, 0), 50)); - bodyForm->addChild(collisionNode->getGeode()); + //bodyForm->addChild(collisionNode->getGeode()); collisionNodeList.push_back(collisionNode); collisionNode = new CollisionNode("Body-Node2", new osg::Sphere(osg::Vec3(0, 0, 60), 50)); - bodyForm->addChild(collisionNode->getGeode()); + //bodyForm->addChild(collisionNode->getGeode()); collisionNodeList.push_back(collisionNode); collisionNode = new CollisionNode("Body-Node3", new osg::Sphere(osg::Vec3(0, 0, -60), 50)); - bodyForm->addChild(collisionNode->getGeode()); + //bodyForm->addChild(collisionNode->getGeode()); collisionNodeList.push_back(collisionNode); collisionNode = new CollisionNode("Left-Arm-Node", new osg::Sphere(osg::Vec3(100, -40, -70), 30)); - leftUpperArmForm->addChild(collisionNode->getGeode()); + //leftUpperArmForm->addChild(collisionNode->getGeode()); collisionNodeList.push_back(collisionNode); collisionNode = new CollisionNode("Right-Arm-Node", new osg::Sphere(osg::Vec3(-100, -40, -70), 30)); - rightUpperArmForm->addChild(collisionNode->getGeode()); + //rightUpperArmForm->addChild(collisionNode->getGeode()); collisionNodeList.push_back(collisionNode); collisionNode = new CollisionNode("Left-Leg-Node", new osg::Sphere(osg::Vec3(0, 0, 0), 30)); - leftUpperLegForm->addChild(collisionNode->getGeode()); + //leftUpperLegForm->addChild(collisionNode->getGeode()); collisionNodeList.push_back(collisionNode); collisionNode = new CollisionNode("Right-Leg-Node", new osg::Sphere(osg::Vec3(0, 0, 0), 30)); - rightUpperLegForm->addChild(collisionNode->getGeode()); + //rightUpperLegForm->addChild(collisionNode->getGeode()); collisionNodeList.push_back(collisionNode); SearchGeodeVisitor gvisitor = SearchGeodeVisitor(); @@ -215,16 +215,20 @@ /* Robotの各モーションを定義 */ void Robot::punch() { - moveCount += 0.5; float sinVal = sin(moveCount); float cosVal = cos(moveCount); - + double punch[6][3] = {{5.0,-30.0,-30.0},{10.0,-30.0,-90.0},{15.0,-120.0,60.0}}; osg::Matrixd roteMatrix; osg::Matrixd dirMatrix; osg::Matrixd accMatrix; + + bodyForm->setMatrix(osg::Matrixf::rotate(osg::DegreesToRadians(punch[(int)moveCount%3][0]), osg::Vec3(0,0,1))); + rightUpperArmForm->setMatrix(osg::Matrixf::rotate(osg::DegreesToRadians(punch[(int)moveCount%3][1]), osg::Vec3(1,0,0))); + rightDownArmForm->setMatrix(osg::Matrixf::rotate(osg::DegreesToRadians(punch[(int)moveCount%3][2]), osg::Vec3(1,0,0))); + moveCount += 1; //if(moveCount <= 0.5){ - bodyForm->setMatrix(osg::Matrixf::rotate(osg::DegreesToRadians(sinVal*10.0), osg::Vec3(0,0,1))); - rightUpperArmForm->setMatrix(osg::Matrixf::rotate(osg::DegreesToRadians(sinVal*60.0-90), osg::Vec3(1,0,0))); + //bodyForm->setMatrix(osg::Matrixf::rotate(osg::DegreesToRadians(sinVal*10.0), osg::Vec3(0,0,1))); + //rightUpperArmForm->setMatrix(osg::Matrixf::rotate(osg::DegreesToRadians(sinVal*60.0-90), osg::Vec3(1,0,0))); //rightDownArmForm->setMatrix(osg::Matrixf::rotate(osg::DegreesToRadians(sinVal*60.0-20), osg::Vec3(1,0,0))); //} } @@ -271,7 +275,7 @@ } void Robot::stop() { - moveCount = 0; + //moveCount = 0; motionTime = 0; velocity = osg::Vec3(0,0,0); angularVelocity = osg::Vec3(0,0,0);