changeset 11:4727e16018cd

change src. punch motion using array
author tokumoritaichirou@w-133-13-243-110.cc.u-ryukyu.ac.jp
date Wed, 03 Feb 2010 12:02:57 +0900
parents 5727d511a13a
children d45a95c697c3
files src/Robot.cpp
diffstat 1 files changed, 16 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- 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);