void MakeNoiseToDrawingModel( BodyParts [] parts ) { foreach( var p in parts ) { p.angle.X = p.angle.X +( randGen.Next() % 2 == 0 ? -1f : 1f ) * ( ( float )randGen.NextDouble() * 2f + 4f ); p.angle.Y = p.angle.Y +( randGen.Next() % 2 == 0 ? -1f : 1f ) * ( ( float )randGen.NextDouble() * 2f + 4f ); p.angle.Z = p.angle.Z + ( randGen.Next() % 2 == 0 ? -1f : 1f ) * ( ( float )randGen.NextDouble() * 2f + 4f ); p.Update(); } }
public void Loop( BodyParts [] parts, PoseEvaluater ev ) { const int MIN = 0; const int MAX = 1; //�l�̃Z�b�g float[] middles = null; float[][] parameters = null; float[] minValues = null; int dimention = 6; float allowedRange = 14f; parameters = new float[ dimention ][]; middles = new float[ dimention ]; minValues = new float[ dimention ]; float [] parameterSlot = new float[ dimention ]; for( int i = 0; i < parameters.Length; ++i ) { parameters[ i ] = new float[ 2 ]; } parameters[ 0 ][ 0 ] = parts[ 0 ].angle.X - allowedRange; parameters[ 0 ][ 1 ] = parts[ 0 ].angle.X + allowedRange; parameters[ 1 ][ 0 ] = parts[ 0 ].angle.Y - allowedRange; parameters[ 1 ][ 1 ] = parts[ 0 ].angle.Y + allowedRange; parameters[ 2 ][ 0 ] = parts[ 0 ].angle.Z - allowedRange; parameters[ 2 ][ 1 ] = parts[ 0 ].angle.Z + allowedRange; parameters[ 3 ][ 0 ] = parts[ 1 ].angle.X - allowedRange; parameters[ 3 ][ 1 ] = parts[ 1 ].angle.X + allowedRange; parameters[ 4 ][ 0 ] = parts[ 1 ].angle.Y - allowedRange; parameters[ 4 ][ 1 ] = parts[ 1 ].angle.Y + allowedRange; parameters[ 5 ][ 0 ] = parts[ 1 ].angle.Z - allowedRange; parameters[ 5 ][ 1 ] = parts[ 1 ].angle.Z + allowedRange; float [] degrees = new float[ dimention ]; float minValue = 1000f; int [] minIndex = new int[ 6 ]; int challangeCount = 9; for( int counter = 0; counter < challangeCount; ++counter ) { for (int i = 0; i < parameters[0].Length; i++) { for (int j = 0; j < parameters[1].Length; j++) { for (int k = 0; k < parameters[2].Length; k++) { for (int l = 0; l < parameters[3].Length; l++) { for (int m = 0; m < parameters[4].Length; m++) { for(int n = 0; n < parameters[5].Length; n++) { //�l��Z�b�g parts[ 0 ].angle.X = parameters[ 0 ][ i ]; parts[ 0 ].angle.Y = parameters[ 1 ][ j ]; parts[ 0 ].angle.Z = parameters[ 2 ][ k ]; parts[ 1 ].angle.X = parameters[ 3 ][ l ]; parts[ 1 ].angle.Y = parameters[ 4 ][ m ]; parts[ 1 ].angle.Z = parameters[ 5 ][ n ]; GraphicsDevice.Clear( XNABackColor ); captureDevice.BeginCapture( GraphicsDevice ); parts[ 0 ].Update(); parts[ 1 ].Update(); parts[ 0 ].Draw( models ); parts[ 1 ].Draw( models ); captureDevice.Capture( tmpTexture ); var evalresult = poseEvaluater.evaluate( tmpTexture, TeacherTex ); //SaveAsPng( tmpTexture, "loopTmpTex.png" ); //SaveAsPng( TeacherTex, "loopTeacher.png" ); if( evalresult < minValue ) { minValue = evalresult; minIndex[ 0 ] = i; minIndex[ 1 ] = j; minIndex[ 2 ] = k; minIndex[ 3 ] = l; minIndex[ 4 ] = m; minIndex[ 5 ] = n; } } } } } } } //�ŏ���index��o�����̂ł����ŃZ�b�g for( int i = 0; i < 6; ++i ) { var tmpMin = Math.Min( parameters[ i ][ minIndex[ i ] ], middles[ i ] ); var tmpMax = Math.Max( parameters[ i ][ minIndex[ i ] ], middles[ i ] ); parameters[ i ][ MIN ] = tmpMin; parameters[ i ][ MAX ] = tmpMax; middles[ i ] = ( tmpMax + tmpMin ) / 2f; } minValue = 1000f;//���Z�b�g } Draw2D( TeacherTex, Color.CadetBlue ); parts[ 0 ].angle.X = parameters[ 0 ][ minIndex[ 0 ] ]; parts[ 0 ].angle.Y = parameters[ 1 ][ minIndex[ 1 ] ]; parts[ 0 ].angle.Z = parameters[ 2 ][ minIndex[ 2 ] ]; parts[ 1 ].angle.X = parameters[ 3 ][ minIndex[ 3 ] ]; parts[ 1 ].angle.Y = parameters[ 4 ][ minIndex[ 4 ] ]; parts[ 1 ].angle.Z = parameters[ 5 ][ minIndex[ 5 ] ]; logFiles.OutputPose( parts ); }
/// <summary> /// ���f����ǂݍ��� /// </summary> void LoadModel() { models[ ( int )BodyPartsName.ArmR ] = Content.Load<Model>( "rarm" ); models[ ( int )BodyPartsName.UpperArmR ] = Content.Load<Model>( "ruarm" ); models[ ( int )BodyPartsName.Trunk ] = Content.Load<Model>( "body" ); bodyParts = new BodyParts[ ( int )BodyPartsName.Size ]; for( int i = 0; i < ( int )BodyPartsName.Size; ++i ) { bodyParts[ i ] = new BodyParts(); bodyParts[ i ].bodyPartsName = ( BodyPartsName ) i; } bodyParts[ ( int )BodyPartsName.ArmR ].parent = bodyParts[ ( int )BodyPartsName.UpperArmR ]; //bodyParts[ ( int )BodyPartsName.UpperArmR ].parent = // bodyParts[ ( int )BodyPartsName.Trunk ]; bodyParts[ ( int )BodyPartsName.UpperArmR ].basePosition.Y = 0f; bodyParts[ ( int )BodyPartsName.UpperArmR ].position.Y = 0f; bodyParts[ ( int )BodyPartsName.UpperArmR ].position.X = 0f; bodyParts[ ( int )BodyPartsName.ArmR ].basePosition.Y = 0.5f; bodyParts[ ( int )BodyPartsName.ArmR ].position.Y = 0.8f; }