human_sample.cpp 1 /** 2 *** キャラクタアニメーションのための人体モデルの表現 基本処理ライブラリ サンプルプログラム 3 *** Copyright (c) 2015-, Masaki OSHITA ( 4 *** Released
|
|
- うきえ さどひら
- 4 years ago
- Views:
Transcription
1 1 /** 2 *** キャラクタアニメーションのための人体モデルの表現 基本処理ライブラリ サンプルプログラム 3 *** Copyright (c) 2015-, Masaki OSHITA ( 4 *** Released under the MIT license 5 **/ 6 7 /** 8 *** 複数の基本デモのアプリケーション 9 *** ( レポート課題の作成 提出が行いやすいように 全てのデモを一つのソースファイルにまとめたもの ) 10 **/ // Windows 関数定義の読み込み 14 #ifdef WIN32 15 #include <windows.h> 16 #endif // GLUT を使用 19 #include <GL/glut.h> // 22 // 行列 ベクトルの表現には vecmath C++ ライブラリ ( を使用 23 // 24 #include <Vector3.h> 25 #include <Point3.h> 26 #include <Matrix3.h> 27 #include <Matrix4.h> 28 #include <Color3.h> // STL を使用 31 #include <vector> 32 #include <string> 33 using namespace std; // 標準算術関数 定数の定義 36 #define _USE_MATH_DEFINES 37 #include <math.h> // ライブラリ クラス定義の読み込み 41 #include "SimpleHuman.h" 42 #include "SimpleHumanGLUT.h" 43 #include "BVH.h" /////////////////////////////////////////////////////////////////////////////// 48 // 49 // 動作再生アプリケーション 50 // // 54 // 動作再生アプリケーションクラス 55 // 56 class MotionPlaybackApp : public GLUTBaseApp 57 { 58 protected: 59 // キャラクタ情報 // キャラクタの骨格 62 Skeleton * body; // キャラクタの姿勢 65 Posture * curr_posture; protected: 68 // 動作再生のための変数 // 動作データ 71 Motion * motion; // アニメーション再生中かどうかを表すフラグ 74 bool on_animation; // アニメーションの再生時間 77 float animation_time; // アニメーションの再生速度 80 float animation_speed; // 現在の表示フレーム番号 83 int frame_no; public: 86 // コンストラクタ 87 MotionPlaybackApp(); // デストラクタ 90 virtual ~MotionPlaybackApp(); public: 93 // イベント処理 // 初期化 96 virtual void Initialize(); // 開始 リセット 99 virtual void Start(); // 画面描画 102 virtual void Display(); // キーボードのキー押下 105 virtual void Keyboard( unsigned char key, int mx, int my ); // アニメーション処理 108 virtual void Animation( float delta ); 1
2 public: 111 // 補助処理 // BVH 動作ファイルの読み込み 骨格 姿勢の初期化 114 void LoadBVH( const char * file_name ); // ファイルダイアログを表示して BVH 動作ファイルを選択 読み込み 117 void OpenNewBVH(); 118 }; // 122 // コンストラクタ 123 // 124 MotionPlaybackApp::MotionPlaybackApp() 125 { 126 app_name = "Motion Playback"; 127 body = NULL; 128 curr_posture = NULL; 129 motion = NULL; 130 on_animation = true; 131 animation_time = 0.0f; 132 animation_speed = 1.0f; 133 frame_no = 0; 134 } // 138 // デストラクタ 139 // 140 MotionPlaybackApp::~MotionPlaybackApp() 141 { 142 if ( motion ) 143 delete motion; 144 if ( curr_posture ) 145 delete curr_posture; 146 if ( body ) 147 delete body; 148 } // 152 // 初期化 153 // H3 void MotionPlaybackApp::Initialize() 155 { 156 GLUTBaseApp::Initialize(); // サンプル BVH 動作データを読み込み 159 LoadBVH( "sample_walking1.bvh" ); 160 } // 164 // 開始 リセット 165 // H3 void MotionPlaybackApp::Start() 167 { 168 GLUTBaseApp::Start(); on_animation = true; 171 animation_time = 0.0f; 172 frame_no = 0; Animation( 0.0f ); 175 } // 179 // 画面描画 180 // H3 void MotionPlaybackApp::Display() 182 { 183 GLUTBaseApp::Display(); // キャラクタを描画 186 if ( curr_posture ) 187 { 188 glcolor3f( 1.0f, 1.0f, 1.0f ); 189 DrawPosture( *curr_posture ); 190 DrawPostureShadow( *curr_posture, shadow_dir, shadow_color ); 191 } // 現在のモード 時間 フレーム番号を表示 194 DrawTextInformation( 0, "Motion Playback" ); 195 char message[64]; 196 if ( motion ) 197 sprintf( message, "%.2f (%d)", animation_time, frame_no ); 198 else 199 sprintf( message, "Press 'L' key to Load a BVH file" ); 200 DrawTextInformation( 1, message ); 201 } // 205 // キーボードのキー押下 206 // H3 void MotionPlaybackApp::Keyboard( unsigned char key, int mx, int my ) 208 { 209 GLUTBaseApp::Keyboard( key, mx, my ); // s キーでアニメーションの停止 再開 212 if ( key == 's' ) 213 on_animation =!on_animation; // w キーでアニメーションの再生速度を変更 216 if ( key == 'w' ) 2
3 217 animation_speed = ( animation_speed == 1.0f )? 0.1f : 1.0f; // n キーで次のフレーム 220 if ( ( key == 'n' ) &&!on_animation && motion ) 221 { 222 on_animation = true; 223 Animation( motion->interval ); 224 on_animation = false; 225 } // p キーで前のフレーム 228 if ( ( key == 'p' ) &&!on_animation && motion && ( frame_no > 0 ) ) 229 { 230 on_animation = true; 231 Animation( - motion->interval ); 232 on_animation = false; 233 } // l キーで再生動作の変更 236 if ( key == 'l' ) 237 { 238 // ファイルダイアログを表示してBVHファイルを選択 読み込み 239 OpenNewBVH(); 240 } 241 } // 245 // アニメーション処理 246 // H3 void MotionPlaybackApp::Animation( float delta ) 248 { 249 // アニメーション再生中でなければ終了 250 if (!on_animation ) 251 return; // 動作データが読み込まれていなければ終了 254 if (!motion ) 255 return; // 時間を進める 258 animation_time += delta * animation_speed; 259 if ( animation_time > motion->getduration() ) 260 animation_time -= motion->getduration(); // 現在のフレーム番号を計算 263 frame_no = animation_time / motion->interval; // 動作データから現在時刻の姿勢を取得 266 motion->getposture( animation_time, *curr_posture ); 267 } // 271 // BVH 動作ファイルの読み込み 骨格 姿勢の初期化 272 // H3 void MotionPlaybackApp::LoadBVH( const char * file_name ) 274 { 275 // BVH 動作データを読み込み 276 BVH * bvh = new BVH( file_name ); // 読み込みに失敗したら終了 279 if (!bvh->isloadsuccess() ) 280 { 281 delete bvh; 282 bvh = NULL; 283 body = NULL; 284 return; 285 } // BVH 動作から骨格モデルと動作データをを生成 288 motion = CoustructBVHMotion( bvh ); 289 if (!motion ) 290 return; 291 body = motion->body; 292 delete bvh; // 姿勢の初期化 295 if ( curr_posture ) 296 delete curr_posture; 297 curr_posture = new Posture(); 298 InitPosture( *curr_posture, body ); // 再生開始 301 Start(); 302 } // 306 // ファイルダイアログを表示してBVH 動作ファイルを選択 読み込み 307 // H3 void MotionPlaybackApp::OpenNewBVH() 309 { 310 #ifdef WIN const int file_name_len = 256; 312 char file_name[file_name_len] = ""; // ファイルダイアログの設定 315 OPENFILENAME open_file; 316 memset( &open_file, 0, sizeof( OPENFILENAME ) ); 317 open_file.lstructsize = sizeof( OPENFILENAME ); 318 open_file.hwndowner = NULL; 319 open_file.lpstrfilter = "BVH Motion Data (*.bvh)\0*.bvh\0all (*.*)\0*.*\0"; 320 open_file.nfilterindex = 1; 321 open_file.lpstrfile = file_name; 322 open_file.nmaxfile = file_name_len; 323 open_file.lpstrtitle = "Select a BVH file"; 324 open_file.lpstrdefext = "bvh"; 3
4 325 open_file.flags = OFN_PATHMUSTEXIST OFN_FILEMUSTEXIST OFN_HIDEREADONLY; // ファイルダイアログを表示 328 BOOL ret = GetOpenFileName( &open_file ); // ファイルが指定されたら新しい動作を設定 331 if (ret) 332 { 333 // BVH 動作データの読み込み 骨格 姿勢の初期化 334 LoadBVH( file_name ); // 動作再生の開始 337 Start(); 338 } 339 #endif // WIN } /////////////////////////////////////////////////////////////////////////////// 345 // 346 // キーフレーム動作再生アプリケーション 347 // // 351 // キーフレーム動作再生アプリケーションクラス 352 // 353 class KeyframeMotionPlaybackApp : public MotionPlaybackApp 354 { 355 protected: 356 // 動作再生のための変数 // キーフレーム動作データ 359 KeyframeMotion * keyframe_motion; // キーフレーム動作からの取得姿勢 362 Posture * keyframe_posture; // キーフレーム動作と元の動作を同期して再生するための時間のオフセット 365 float motion_time_offset; protected: 368 // 描画設定 // 元の動作を並べて再生表示 371 bool draw_original_motion; // キーフレームの姿勢を並べて表示 374 bool draw_key_poses; public: 378 // コンストラクタ 379 KeyframeMotionPlaybackApp(); // デストラクタ 382 virtual ~KeyframeMotionPlaybackApp(); public: 385 // イベント処理 // 初期化 388 virtual void Initialize(); // 画面描画 391 virtual void Display(); // キーボードのキー押下 394 virtual void Keyboard( unsigned char key, int mx, int my ); // アニメーション処理 397 virtual void Animation( float delta ); 398 }; // 補助処理 ( グローバル関数 ) のプロトタイプ宣言 // キーフレーム動作から姿勢を取得 404 void GetKeyframeMotionPosture( const KeyframeMotion & motion, float time, Posture & p ); // 408 // コンストラクタ 409 // 410 KeyframeMotionPlaybackApp::KeyframeMotionPlaybackApp() 411 { 412 app_name = "Keyframe Motion Playback"; keyframe_motion = NULL; 415 keyframe_posture = NULL; 416 motion_time_offset = 0.0f; draw_original_motion = true; 419 draw_key_poses = true; 420 } // 424 // デストラクタ 425 // 426 KeyframeMotionPlaybackApp::~KeyframeMotionPlaybackApp() 427 { 428 if ( keyframe_motion ) 429 delete keyframe_motion; 430 if ( keyframe_posture ) 431 delete keyframe_posture; 432 } 4
5 // 436 // 初期化 437 // H3 void KeyframeMotionPlaybackApp::Initialize() 439 { 440 GLUTBaseApp::Initialize(); const char * sample_motions = "sample_walking1.bvh"; 443 const int num_keytimes = 3; 444 const float sample_keytimes[ num_keytimes ] = { 2.35f, 3.00f, 3.74f }; // BVH 動作データを読み込み 447 LoadBVH( sample_motions ); 448 if (!motion ) 449 return; // キーフレームの時刻を設定 452 vector< float > key_times( num_keytimes ); 453 for ( int i=0; i<num_keytimes; i++ ) 454 key_times[ i ] = sample_keytimes[ i ] - sample_keytimes[ 0 ]; // BVH 動作から取得した姿勢をキーフレームの姿勢として設定 457 vector< Posture > key_poses( num_keytimes ); 458 for ( int i=0; i<num_keytimes; i++ ) 459 motion->getposture( sample_keytimes[ i ], key_poses[ i ] ); // キーフレーム動作を初期化 462 keyframe_motion = new KeyframeMotion(); 463 keyframe_motion->init( body, num_keytimes, &key_times.front(), &key_poses.front() ); // キーフレーム動作から取得する姿勢の初期化 466 keyframe_posture = new Posture( body ); // キーフレーム動作と元の動作を同期して再生するための時間のオフセットを設定 469 motion_time_offset = sample_keytimes[ 0 ]; // サンプルBVH 動作に合わせて視点調節 472 camera_yaw += 180.0f; 473 } // 477 // 画面描画 478 // H3 void KeyframeMotionPlaybackApp::Display() 480 { 481 GLUTBaseApp::Display(); // キーフレーム動作から取得した姿勢を描画 484 if ( keyframe_posture ) 485 { 486 glcolor3f( 1.0f, 1.0f, 1.0f ); 487 DrawPosture( *keyframe_posture ); 488 DrawPostureShadow( *keyframe_posture, shadow_dir, shadow_color ); 489 } // 元のBVH 動作から取得した姿勢を描画 492 if ( draw_original_motion && curr_posture ) 493 { 494 glpushmatrix(); 495 gltranslatef( 1.0f, 0.0f, 0.0f ); glcolor3f( 0.0f, 0.0f, 1.0f ); 498 DrawPosture( *curr_posture ); 499 DrawPostureShadow( *curr_posture, shadow_dir, shadow_color ); 500 glpopmatrix(); 501 } // キーフレーム動作のキー姿勢を描画 504 if ( draw_key_poses && keyframe_posture ) 505 { 506 glpushmatrix(); 507 gltranslatef( - 1.0f, 0.0f, 0.0f ); for ( int i=0; i<keyframe_motion->num_keyframes; i++ ) 510 { 511 glpushmatrix(); 512 gltranslatef( 0.0f, 0.0f, 1.0f * ( i - ( keyframe_motion->num_keyframes - 1 ) * 0.5f ) ); glcolor3f( 0.8f, 0.8f, 0.8f ); 515 DrawPosture( keyframe_motion->key_poses[ i ] ); 516 DrawPostureShadow( keyframe_motion->key_poses[ i ], shadow_dir, shadow_color ); 517 glpopmatrix(); 518 } 519 glpopmatrix(); 520 } // 現在のモード 時間 フレーム番号を表示 523 DrawTextInformation( 0, "Keyframe Motion Playback" ); 524 char message[64]; 525 if ( motion ) 526 sprintf( message, "%.2f (%d)", animation_time, frame_no ); 527 else 528 sprintf( message, "Press 'L' key to Load a BVH file" ); 529 DrawTextInformation( 1, message ); 530 } // 534 // キーボードのキー押下 535 // H3 void KeyframeMotionPlaybackApp::Keyboard( unsigned char key, int mx, int my ) 537 { 538 // 基底クラスの処理を実行 539 MotionPlaybackApp::Keyboard( key, mx, my ); 540 5
6 541 // d キーで描画設定を変更 542 if ( key == 'd' ) 543 { 544 if ( draw_original_motion && draw_key_poses ) 545 draw_key_poses = false; 546 else if ( draw_original_motion &&!draw_key_poses ) 547 { 548 draw_original_motion = false; 549 draw_key_poses = true; 550 } 551 else if (!draw_original_motion && draw_key_poses ) 552 draw_key_poses = false; 553 else 554 { 555 draw_original_motion = true; 556 draw_key_poses = true; 557 } 558 } 559 } // 563 // アニメーション処理 564 // H3 void KeyframeMotionPlaybackApp::Animation( float delta ) 566 { 567 // アニメーション再生中でなければ終了 568 if (!on_animation ) 569 return; // 動作データが読み込まれていなければ終了 572 if (!keyframe_motion ) 573 return; // 時間を進める 576 animation_time += delta * animation_speed; 577 if ( animation_time > keyframe_motion->getduration() ) 578 animation_time -= keyframe_motion->getduration(); 579 frame_no = ( animation_time + motion_time_offset ) / motion->interval; // 動作データから現在時刻の姿勢を取得 582 motion->getposture( animation_time + motion_time_offset, *curr_posture ); // キーフレーム動作データから現在時刻の姿勢を取得 585 GetKeyframeMotionPosture( *keyframe_motion, animation_time, *keyframe_posture ); 586 } // 590 // キーフレーム動作から姿勢を取得 591 // 592 void GetKeyframeMotionPosture( const KeyframeMotion & motion, float time, Posture & p ) 593 { 594 // 指定時刻に対応する区間番号を取得 595 int no = -1; 596 for ( int i=0; i<motion.num_keyframes-1; i++ ) 597 { 598 if ( ( time >= motion.key_times[ i ] ) && ( time <= motion.key_times[ i+1 ] ) ) 599 { 600 no = i; 601 break; 602 } 603 } 604 if ( no == -1 ) 605 return; // レポート課題 // 指定時刻に応じて前後のキー姿勢の補間の割合を計算 610 float s = 0.0f; 611 // s =???; // 前後のキー姿勢を補間 614 // PostureInterpolation(??? ); 615 p = motion.key_poses[ no ]; 616 } /////////////////////////////////////////////////////////////////////////////// 621 // 622 // 順運動学計算アプリケーション 623 // // 627 // 順運動学計算アプリケーションクラス 628 // ( 動作再生アプリケーションに順運動学計算を追加 ) 629 // 630 class ForwardKinematicsApp : public MotionPlaybackApp 631 { 632 protected: 633 // 順運動学計算結果の変数 // 全体節の位置 向き ( 座標系 ) 636 vector< Matrix4f > segment_frames; // 全関節の位置 639 vector< Point3f > joint_positions; public: 642 // コンストラクタ 643 ForwardKinematicsApp(); public: 646 // イベント処理 // 開始 リセット 6
7 649 virtual void Start(); // 画面描画 652 virtual void Display(); // アニメーション処理 655 virtual void Animation( float delta ); 656 }; // 補助処理 ( グローバル関数 ) のプロトタイプ宣言 // 順運動学計算 662 void MyForwardKinematics( const Posture & posture, vector< Matrix4f > & seg_frame_array, vector< Point3f > & joi_pos_array ); // 順運動学計算のための反復計算 ( ルート体節から末端体節に向かって繰り返し再帰呼び出し ) 665 void MyForwardKinematicsIteration( const Segment * segment, const Segment * prev_segment, const Posture & posture, 666 Matrix4f * seg_frame_array, Point3f * joi_pos_array = NULL ); // 671 // コンストラクタ 672 // 673 ForwardKinematicsApp::ForwardKinematicsApp() 674 { 675 app_name = "Forward Kinematics"; 676 } // 680 // 開始 リセット 681 // H3 void ForwardKinematicsApp::Start() 683 { 684 MotionPlaybackApp::Start(); if (!body ) 687 return; // 配列初期化 690 segment_frames.resize( body->num_segments ); 691 joint_positions.resize( body->num_joints ); ForwardKinematics( *curr_posture, segment_frames, joint_positions ); 694 } // 698 // 画面描画 699 // H3 void ForwardKinematicsApp::Display() 701 { 702 GLUTBaseApp::Display(); // キャラクタを描画 705 if ( curr_posture ) 706 { 707 glcolor3f( 1.0f, 1.0f, 1.0f ); 708 DrawPosture( *curr_posture ); 709 DrawPostureShadow( *curr_posture, shadow_dir, shadow_color ); 710 } // 関節 体節の位置 向きを描画 const float axis_length = 0.2f; 716 float line_width; 717 Matrix4f frame; // デプステストを無効にして 前面に上書きする 720 gldisable( GL_DEPTH_TEST ); // 関節点を描画 ( 球を描画 ) 723 for ( int i=0; i<joint_positions.size(); i++ ) 724 { 725 // 関節位置に球を描画 726 const Point3f & pos = joint_positions[ i ]; 727 glcolor3f( 0.0f, 0.0f, 1.0f ); 728 glpushmatrix(); 729 gltranslatef( pos.x, pos.y, pos.z ); 730 glutsolidsphere( 0.025f, 16, 16 ); 731 glpopmatrix(); 732 } // 体節の座標系を描画 ( 座標軸を描画 ) 735 glgetfloatv( GL_LINE_WIDTH, &line_width ); 736 gllinewidth( 2.0f ); 737 for ( int i=0; i<segment_frames.size(); i++ ) 738 { glpushmatrix(); 741 frame.transpose( segment_frames[ i ] ); 742 glmultmatrixf( & frame.m00 ); 743 glbegin( GL_LINES ); 744 glcolor3f( 1.0f, 0.0f, 0.0f ); 745 glvertex3f( 0.0f, 0.0f, 0.0f ); 746 glvertex3f( axis_length, 0.0f, 0.0f ); 747 glcolor3f( 0.0f, 1.0f, 0.0f ); 748 glvertex3f( 0.0f, 0.0f, 0.0f ); 749 glvertex3f( 0.0f, axis_length, 0.0f ); 750 glcolor3f( 0.0f, 0.0f, 1.0f ); 751 glvertex3f( 0.0f, 0.0f, 0.0f ); 752 glvertex3f( 0.0f, 0.0f, axis_length ); 753 glend(); 754 glpopmatrix(); 755 } 756 gllinewidth( line_width ); 7
8 glenable( GL_DEPTH_TEST ); // 現在のモード 時間 フレーム番号を表示 762 DrawTextInformation( 0, "Forward Kinematics" ); 763 char message[64]; 764 if ( motion ) 765 sprintf( message, "%.2f (%d)", animation_time, frame_no ); 766 else 767 sprintf( message, "Press 'L' key to Load a BVH file" ); 768 DrawTextInformation( 1, message ); 769 } // 773 // アニメーション処理 774 // H3 void ForwardKinematicsApp::Animation( float delta ) 776 { 777 MotionPlaybackApp::Animation( delta ); // アニメーション再生中でなければ終了 780 if (!on_animation ) 781 return; if (!curr_posture ) 784 return; // 順運動学計算 787 MyForwardKinematics( *curr_posture, segment_frames, joint_positions ); 788 } // 792 // 順運動学計算 793 // 794 void MyForwardKinematics( const Posture & posture, vector< Matrix4f > & seg_frame_array, vector< Point3f > & joi_pos_array ) 795 { 796 // 配列初期化 797 seg_frame_array.resize( posture.body->num_segments ); 798 joi_pos_array.resize( posture.body->num_joints ); // ルート体節の位置 向きを設定 801 seg_frame_array[ 0 ].set( posture.root_ori, posture.root_pos, 1.0f ); // Forward Kinematics 計算のための反復計算 ( ルート体節から末端体節に向かって繰り返し計算 ) 804 MyForwardKinematicsIteration( posture.body->segments[ 0 ], NULL, posture, &seg_frame_array.front(), &joi_pos_array.front() ); 805 } // 809 // Forward Kinematics 計算のための反復計算 ( ルート体節から末端体節に向かって繰り返し再帰呼び出し ) 810 // H3 void MyForwardKinematicsIteration( 812 const Segment * segment, const Segment * prev_segment, const Posture & posture, 813 Matrix4f * seg_frame_array, Point3f * joi_pos_array ) 814 { 815 const Skeleton * body = posture.body; 816 Joint * next_joint; 817 Segment * next_segment; 818 Matrix4f mat; // 現在の体節に接続している各関節に対して繰り返し 821 for ( int j=0; j<segment->joints.size(); j++ ) 822 { 823 // 次の関節 次の体節を取得 824 next_joint = segment->joints[ j ]; 825 if ( next_joint->segments[ 0 ]!= segment ) 826 next_segment = next_joint->segments[ 0 ]; 827 else 828 next_segment = next_joint->segments[ 1 ]; // 前の体節側 ( ルート体節側 ) の関節はスキップ 831 if ( next_segment == prev_segment ) 832 continue; // 現在の体節の変換行列を取得 835 mat = seg_frame_array[ segment->index ]; // 次の関節 体節の変換行列を計算 // レポート課題 // 次の関節の位置を設定 842 // if ( joi_pos_array ) 843 // joi_pos_array[ next_joint->index ] =???; // 次の体節の変換行列を設定 846 // if ( seg_frame_array ) 847 // seg_frame_array[ next_segment->index ] =???; // 次の体節に対して繰り返し ( 再帰呼び出し ) 850 MyForwardKinematicsIteration( next_segment, segment, posture, seg_frame_array, joi_pos_array ); 851 } 852 } /////////////////////////////////////////////////////////////////////////////// 857 // 858 // 姿勢補間アプリケーション 859 // // 863 // 姿勢補間アプリケーションクラス 864 // 8
9 865 class PostureInterpolationApp : public GLUTBaseApp 866 { 867 protected: 868 // キャラクタ情報 // キャラクタの骨格 871 Skeleton * body; // キャラクタの姿勢 874 Posture * curr_posture; protected: 877 // 姿勢補間のための変数 // サンプル姿勢 880 Posture * posture0; 881 Posture * posture1; // サンプル姿勢の描画色 884 Color3f posture0_color; 885 Color3f posture1_color; // 姿勢補間の重み 888 float weight; // 現在姿勢の描画色 891 Color3f figure_color; public: 894 // コンストラクタ 895 PostureInterpolationApp(); // デストラクタ 898 virtual ~PostureInterpolationApp(); public: 901 // イベント処理 // 初期化 904 virtual void Initialize(); // 開始 リセット 907 virtual void Start(); // 画面描画 910 virtual void Display(); // マウスドラッグ 913 virtual void MouseDrag( int mx, int my ); public: 916 // 補助処理 // 姿勢更新 919 void UpdatePosture(); 920 }; // 補助処理 ( グローバル関数 ) のプロトタイプ宣言 // 姿勢補間 (2つの姿勢を補間) 926 void PostureInterpolation( const Posture & p0, const Posture & p1, float ratio, Posture & p ); // 931 // コンストラクタ 932 // 933 PostureInterpolationApp::PostureInterpolationApp() 934 { 935 app_name = "Posture Interpolation"; 936 body = NULL; 937 curr_posture = NULL; posture0 = NULL; 940 posture1 = NULL; 941 weight = 0.0f; 942 figure_color.set( 1.0f, 1.0f, 1.0f ); 943 } // 947 // デストラクタ 948 // 949 PostureInterpolationApp::~PostureInterpolationApp() 950 { 951 } // 955 // 初期化 956 // H3 void PostureInterpolationApp::Initialize() 958 { 959 GLUTBaseApp::Initialize(); // アプリケーションのテストに使用するサンプル姿勢 ( 動作データ 時刻 描画色 ) 962 const char * sample_motion = "sample_walking1.bvh"; 963 const float sample_keytimes[ 2 ] = { 3.00f, 3.74f }; 964 const Color3f sample_colors[] = { Color3f( 0.5f, 1.0f, 0.5f ), Color3f( 0.5f, 0.5f, 1.0f ) }; 965 const float sample_orientation[ 2 ] = { 180.0f, 180.0f }; // 動作データの読み込み 骨格 姿勢の初期化 968 BVH * bvh = new BVH( sample_motion ); 969 if ( bvh->isloadsuccess() ) 970 { 971 // BVH 動作から骨格モデルを生成 972 Skeleton * new_body = CoustructBVHSkeleton( bvh ); 9
10 // 姿勢の初期化 975 if ( new_body ) 976 { 977 body = new_body; 978 curr_posture = new Posture(); 979 InitPosture( *curr_posture, body ); 980 } 981 } // サンプル姿勢の初期化 984 if ( body && curr_posture && bvh && bvh->isloadsuccess() ) 985 { 986 // サンプル姿勢を動作データから取得 987 posture0 = new Posture( body ); 988 posture1 = new Posture( body ); 989 GetBVHPosture( bvh, sample_keytimes[ 0 ] / bvh->getinterval(), *posture0 ); 990 GetBVHPosture( bvh, sample_keytimes[ 1 ] / bvh->getinterval(), *posture1 ); 991 posture0_color = sample_colors[ 0 ]; 992 posture1_color = sample_colors[ 1 ]; // 水平方向の回転が指定されていれば回転を適用 995 Matrix3f rot; 996 if ( sample_orientation[ 0 ]!= 0.0f ) 997 { 998 rot.roty( sample_orientation[ 0 ] * M_PI / 180.0f ); 999 posture0->root_ori.mul( rot, posture0->root_ori ); 1000 } 1001 if ( sample_orientation[ 1 ]!= 0.0f ) 1002 { 1003 rot.roty( sample_orientation[ 1 ] * M_PI / 180.0f ); 1004 posture1->root_ori.mul( rot, posture1->root_ori ); 1005 } // サンプル姿勢を描画する位置を設定 ( 現在姿勢の左右に配置 ) 1008 posture0->root_pos.x = -1.0f; 1009 posture0->root_pos.z = 0.0f; 1010 posture1->root_pos.x = 1.0f; 1011 posture1->root_pos.z = 0.0f; // 現在姿勢を初期化 1014 *curr_posture = *posture0; 1015 } 1016 } // 1020 // 開始 リセット 1021 // H3 void PostureInterpolationApp::Start() 1023 { 1024 GLUTBaseApp::Start(); // 重みの初期化 1027 weight = 0.5f; // 姿勢更新 1030 UpdatePosture(); 1031 } // 1035 // 画面描画 1036 // H3 void PostureInterpolationApp::Display() 1038 { 1039 GLUTBaseApp::Display(); // キャラクタを描画 1042 if ( curr_posture ) 1043 { 1044 glcolor3f( figure_color.x, figure_color.y, figure_color.z ); 1045 DrawPosture( *curr_posture ); 1046 DrawPostureShadow( *curr_posture, shadow_dir, shadow_color ); 1047 } // サンプル姿勢を描画 1050 if ( posture0 ) 1051 { 1052 glcolor3f( posture0_color.x, posture0_color.y, posture0_color.z ); 1053 DrawPosture( *posture0 ); 1054 DrawPostureShadow( *posture0, shadow_dir, shadow_color ); 1055 } 1056 if ( posture1 ) 1057 { 1058 glcolor3f( posture1_color.x, posture1_color.y, posture1_color.z ); 1059 DrawPosture( *posture1 ); 1060 DrawPostureShadow( *posture1, shadow_dir, shadow_color ); 1061 } // 現在のモード 補間重みを表示 1064 DrawTextInformation( 0, "Posture Interpolation" ); 1065 char message[ 64 ]; 1066 sprintf( message, "Weight: %.2f", weight ); 1067 DrawTextInformation( 1, message ); 1068 } // 1072 // マウスドラッグ 1073 // H3 void PostureInterpolationApp::MouseDrag( int mx, int my ) 1075 { 1076 // 左ボタンの左右ドラッグに応じて重みを計算 1077 if ( drag_mouse_l ) 1078 { 1079 // 重み計算 1080 weight += (float) ( mx - last_mouse_x ) * 2.0f / win_width; 10
11 1081 if ( weight < 0.0f ) 1082 weight = 0.0f; 1083 if ( weight > 1.0f ) 1084 weight = 1.0f; // 姿勢更新 1087 UpdatePosture(); 1088 } GLUTBaseApp::MouseDrag( mx, my ); 1091 } // 1095 // 姿勢更新 1096 // H3 void PostureInterpolationApp::UpdatePosture() 1098 { 1099 if (!curr_posture!posture0!posture1 ) 1100 return; // 姿勢補間 1103 PostureInterpolation( *posture0, *posture1, weight, *curr_posture ); // 腰の水平位置は原点に固定 1106 curr_posture->root_pos.x = 0.0f; 1107 curr_posture->root_pos.z = 0.0f; // 重みに応じて描画色を設定 1110 figure_color.scaleadd( weight, posture1_color - posture0_color, posture0_color ); 1111 } // 1115 // 姿勢補間 (2つの姿勢を補間) 1116 // 1117 void PostureInterpolation( const Posture & p0, const Posture & p1, float ratio, Posture & p ) 1118 { 1119 // 2つの姿勢の骨格モデルが異なる場合は終了 1120 if ( ( p0.body!= p1.body ) ( p0.body!= p.body ) ) 1121 return; // 骨格モデルを取得 1124 const Skeleton * body = p0.body; // 2つの姿勢の各関節の回転を補間 1127 for ( int i = 0; i<body->num_joints; i++ ) 1128 { 1129 // レポート課題 1130 } // 2つの姿勢のルートの向きを補間 1133 // レポート課題 // 2つの姿勢のルートの位置を補間 1136 // レポート課題 p = p0; } /////////////////////////////////////////////////////////////////////////////// 1145 // 1146 // 動作遷移 接続アプリケーション 1147 // // 1151 // 動作のメタ情報を表す構造体 1152 // 1153 struct MotionInfo 1154 { 1155 // 動作情報 1156 Motion * motion; // 動作の開始 終了時刻 ( 動作のローカル時間 ) 1159 float begin_time; 1160 float end_time; // 動作接続 遷移のためのブレンド区間の終了 開始時刻 ( 動作のローカル時間 ) 1163 //( begin_time <= blend_end_time < blend_begin_time <= end_time ) 1164 float blend_end_time; 1165 float blend_begin_time; // キーフレーム配列 [ キーフレーム番号 ] 1168 vector< float > keytimes; // 描画色 1171 Color3f color; 1172 }; // 動作のメタ情報を初期化 1176 void InitMotionInfo( MotionInfo * info, Motion * m = NULL ); // サンプル動作セットの読み込み 1179 Skeleton * LoadSampleMotions( vector< MotionInfo * > & motion_list, Skeleton * body = NULL ); // 1184 // 動作遷移 接続アプリケーションクラス 1185 // 1186 class MotionTransitionApp : public GLUTBaseApp 1187 { 1188 protected: 11
12 1189 // キャラクタ情報 // キャラクタの骨格 1192 Skeleton * body; // キャラクタの姿勢 1195 Posture * curr_posture; protected: 1198 // 動作データの情報 // 動作データリスト ( 動作遷移 補間用の複数の動作 ) 1201 vector< MotionInfo * > motion_list; protected: 1204 // 動作再生のための変数 // 現在の再生動作データ 1207 Motion * curr_motion; // アニメーション中かどうかを表すフラグ 1210 bool on_animation; // アニメーションの再生時間 1213 float animation_time; // アニメーションの再生速度 1216 float animation_speed; // 現在の表示フレーム番号 1219 int frame_no; // 現在姿勢の描画色 1222 Color3f figure_color; protected: 1225 // 動作再生 ( 動作遷移 接続 ) の入力 // 現在の再生動作番号 1228 int curr_motion_no; // 次の再生動作番号 1231 int next_motion_no; // 次の再生動作実行待ちの再生動作番号 1234 int waiting_motion_no; // 動作接続 ( 位置 向き合わせ ) を適用するかどうかの設定 1237 bool enable_connection; // 動作遷移 ( 前後の動作のブレンディング ) を適用するかどうかの設定 1240 bool enable_transition; protected: 1243 // 動作接続のための変数 // 現在の再生動作の位置 向きを合わせるための変換行列 1246 Matrix4f curr_motion_mat; // 現在の動作の再生開始時刻 ( グローバル時刻 ) 1249 float curr_start_frame; protected: 1252 // 動作遷移のための変数 // 動作遷移のブレンド中かどうかのフラグ 1255 bool on_motion_transition; // 次の再生動作の位置 向きを合わせるための変換行列 1258 Matrix4f next_motion_mat; // 次の動作の姿勢 ( 動作遷移時のブレンド用 ) 1261 Posture * next_motion_posture; public: 1265 // コンストラクタ 1266 MotionTransitionApp(); // デストラクタ 1269 virtual ~MotionTransitionApp(); public: 1272 // イベント処理 // 初期化 1275 virtual void Initialize(); // 開始 リセット 1278 virtual void Start(); // 画面描画 1281 virtual void Display(); // マウスクリック 1284 virtual void MouseClick( int button, int state, int mx, int my ); // キーボードのキー押下 1287 virtual void Keyboard( unsigned char key, int mx, int my ); // キーボードの特殊キー押下 1290 virtual void KeyboardSpecial( unsigned char key, int mx, int my ); // アニメーション処理 1293 virtual void Animation( float delta ); public: 1296 // 補助処理 12
13 // 次の動作を変更 1299 void SetNextMotion( int no = -1 ); // 動作再生処理 ( 動作接続を考慮 動作遷移は考慮しない ) 1302 void AnimationWithConnection( float delta ); // 動作再生処理 ( 動作接続 遷移を考慮 ) 1305 void AnimationWithConnectionTransition( float delta ); 1306 }; // 補助処理 ( グローバル関数 ) のプロトタイプ宣言 // 姿勢補間 (2 つの姿勢を補間 ) 1312 void PostureInterpolation( const Posture & p0, const Posture & p1, float ratio, Posture & p ); // 変換行列の水平向き ( 方位角 ) 成分を計算 1315 float ComputeOrientation( const Matrix3f & ori ); // 2 つの姿勢の位置 向きを合わせるための変換行列を計算 1318 //(next_frame の位置 向きを prev_frame の位置向きに合わせるための変換行列 trans_mat を計算 ) 1319 void ComputeConnectionTransformation( const Matrix4f & prev_frame, const Matrix4f & next_frame, Matrix4f & trans_mat ); // 姿勢の位置 向きに変換行列を適用 1322 void TransformPosture( const Matrix4f & trans, Posture & posture ); // 1327 // 動作のメタ情報を初期化 1328 // H3 void InitMotionInfo( MotionInfo * info, Motion * m ) 1330 { 1331 info->motion = m; 1332 info->begin_time = 0.0f; 1333 info->end_time = info->motion? info->motion->getduration() : 0.0f; 1334 info->blend_end_time = info->begin_time; 1335 info->blend_begin_time = info->end_time; 1336 } // 1340 // サンプル動作セットの読み込み 1341 // 1342 Skeleton * LoadSampleMotions( vector< MotionInfo * > & motion_list, Skeleton * body ) 1343 { 1344 // アプリケーションのテストに使用する動作データの定義 (BVH ファイル名 キー時刻 描画色 ) 1345 // 各歩行動作の 右足が地面から離れる 右足が着く 左足が離れる 左足が着く 右足が離れるの 5 つのキー時刻を設定 1346 const int num_motions = 2; 1347 const int num_keytimes = 5; 1348 const char * sample_motions[ num_motions ] = { 1349 "sample_walking1.bvh", 1350 "sample_walking2.bvh" }; 1351 const float sample_keytimes[ num_motions ][ num_keytimes ] = { 1352 { 2.35f, 3.00f, 3.08f, 3.68f, 3.74f }, 1353 { 1.30f, 2.07f, 2.12f, 2.88f, 2.94f } 1354 }; 1355 const Color3f sample_colors[] = { 1356 Color3f( 0.5f, 1.0f, 0.5f ), Color3f( 0.5f, 0.5f, 1.0f ), 1357 }; MotionInfo * info = NULL; // 動作データの読み込み 動作情報の設定 1362 for ( int i=0; i<num_motions; i++ ) 1363 { 1364 // BVH 動作ファイルの読み込み 1365 BVH * new_bvh = new BVH( sample_motions[ i ] ); 1366 if (!new_bvh!new_bvh->isloadsuccess() ) 1367 continue; // 骨格モデル 動作情報の生成 ( 骨格モデルの生成は最初の一度のみ ) 1370 Motion * new_motion = CoustructBVHMotion( new_bvh, body ); 1371 if (!new_motion ) 1372 continue; 1373 if (!body ) 1374 body = new_motion->body; // 動作のメタ情報の設定 1377 info = new MotionInfo(); 1378 InitMotionInfo( info, new_motion ); 1379 for ( int j=0; j<num_keytimes; j++ ) 1380 info->keytimes.push_back( sample_keytimes[ i ][ j ] ); 1381 info->begin_time = info->keytimes[ 0 ]; 1382 info->blend_end_time = info->keytimes[ 1 ]; 1383 info->blend_begin_time = info->keytimes[ info->keytimes.size() - 2 ]; 1384 info->end_time = info->keytimes[ info->keytimes.size() - 1 ]; 1385 info->color = sample_colors[ i ]; // 動作リストに追加 1388 motion_list.push_back( info ); 1389 } return body; 1392 } // 1396 // コンストラクタ 1397 // 1398 MotionTransitionApp::MotionTransitionApp() 1399 { 1400 app_name = "Motion Transition"; body = NULL; 1403 curr_posture = NULL; 1404 curr_motion = NULL; 13
14 1405 on_animation = true; 1406 animation_time = 0.0f; 1407 animation_speed = 1.0f; 1408 frame_no = 0; next_motion_posture = NULL; enable_connection = true; 1413 enable_transition = true; 1414 } // 1418 // デストラクタ 1419 // 1420 MotionTransitionApp::~MotionTransitionApp() 1421 { 1422 for ( int i=0; motion_list.size(); i++ ) 1423 { 1424 delete motion_list[ i ]->motion; 1425 delete motion_list[ i ]; 1426 } 1427 motion_list.clear(); if ( next_motion_posture ) 1430 delete next_motion_posture; 1431 if ( curr_posture ) 1432 delete curr_posture; 1433 if ( body ) 1434 delete body; 1435 } // 1439 // 初期化 1440 // H3 void MotionTransitionApp::Initialize() 1442 { 1443 GLUTBaseApp::Initialize(); // サンプル動作セットの読み込み 1446 if ( motion_list.size() == 0 ) 1447 body = LoadSampleMotions( motion_list ); // 姿勢の初期化 1450 if ( body ) 1451 { 1452 if ( curr_posture ) 1453 delete curr_posture; 1454 if ( next_motion_posture ) 1455 delete next_motion_posture; curr_posture = new Posture( body ); 1458 InitPosture( *curr_posture, body ); 1459 next_motion_posture = new Posture( body ); 1460 } 1461 } // 1465 // 開始 リセット 1466 // H3 void MotionTransitionApp::Start() 1468 { 1469 GLUTBaseApp::Start(); // 動作データが正しく初期化されていなければ終了 1472 if ( motion_list.size() == 0 ) 1473 { 1474 curr_motion = NULL; 1475 curr_motion_no = -1; 1476 return; 1477 } curr_motion_no = 0; 1480 next_motion_no = -1; 1481 waiting_motion_no = -1; 1482 figure_color = motion_list[ curr_motion_no ]->color; Point3f init_pos( 0.0f, 0.0f, 0.0f ); 1485 Matrix3f init_ori; 1486 init_ori.roty( 180.0f * M_PI / 180.0f ); 1487 curr_motion_mat.set( init_ori, init_pos, 1.0f ); if ( motion_list.size() > 0 ) 1490 curr_motion = motion_list[ curr_motion_no ]->motion; 1491 else 1492 { 1493 curr_motion = NULL; 1494 curr_motion_no = -1; 1495 } animation_time = 0.0f; 1498 frame_no = 0; curr_start_frame = animation_time; 1501 on_motion_transition = false; Animation( 0.0f ); 1504 } // 1508 // 画面描画 1509 // H3 void MotionTransitionApp::Display() 1511 { 1512 GLUTBaseApp::Display(); 14
15 // キャラクタを描画 1515 if ( curr_posture ) 1516 { 1517 glcolor3f( figure_color.x, figure_color.y, figure_color.z ); 1518 DrawPosture( *curr_posture ); 1519 DrawPostureShadow( *curr_posture, shadow_dir, shadow_color ); 1520 } // 現在のモード 現在 次の再生動作 時間 フレーム番号を表示 1523 char message[ 64 ]; 1524 DrawTextInformation( 0, "Motion Transition" ); 1525 if ( curr_motion_no!= -1 ) 1526 { 1527 if ( ( next_motion_no!= -1 ) && ( next_motion_no!= curr_motion_no ) ) 1528 sprintf( message, "%s -> %s", motion_list[ curr_motion_no ]->motion->name.c_str(), motion_list[ next_motion_no ]->motion->name. c_str() ); 1529 else 1530 sprintf( message, "%s", motion_list[ curr_motion_no ]->motion->name.c_str() ); 1531 DrawTextInformation( 1, message ); 1532 } 1533 if ( curr_motion ) 1534 sprintf( message, "%.2f (%d)", animation_time, frame_no ); 1535 else 1536 sprintf( message, "Failed to open the sample motions" ); 1537 DrawTextInformation( 2, message ); // 動作接続 遷移の設定を表示 1540 if (!enable_connection!enable_transition ) 1541 { 1542 if (!enable_connection &&!enable_transition ) 1543 sprintf( message, "Connection: Off, Transition: Off" ); 1544 else if (!enable_connection ) 1545 sprintf( message, "Connection: Off" ); 1546 else if (!enable_transition ) 1547 sprintf( message, "Transition: Off" ); 1548 DrawTextInformation( 3, message ); 1549 } 1550 } // 1554 // マウスクリック 1555 // H3 void MotionTransitionApp::MouseClick( int button, int state, int mx, int my ) 1557 { 1558 GLUTBaseApp::MouseClick( button, state, mx, my ); // 左ボタンが押されたら 次の再生動作を変更 1561 if ( ( button == GLUT_LEFT_BUTTON ) && ( state == GLUT_DOWN ) ) 1562 { 1563 SetNextMotion(); 1564 } 1565 } // 1569 // キーボードのキー押下 1570 // H3 void MotionTransitionApp::Keyboard( unsigned char key, int mx, int my ) 1572 { 1573 GLUTBaseApp::Keyboard( key, mx, my ); // s キーでアニメーションの停止 再開 1576 if ( key == 's' ) 1577 on_animation =!on_animation; // w キーでアニメーションの再生速度を変更 1580 if ( key == 'w' ) 1581 animation_speed = ( animation_speed == 1.0f )? 0.1f : 1.0f; // n キーで次のフレーム 1584 if ( ( key == 'n' ) &&!on_animation && curr_motion ) 1585 { 1586 on_animation = true; 1587 Animation( curr_motion->interval ); 1588 on_animation = false; 1589 } // p キーで前のフレーム 1592 if ( ( key == 'p' ) &&!on_animation && curr_motion && ( frame_no > 0 ) ) 1593 { 1594 on_animation = true; 1595 Animation( - curr_motion->interval ); 1596 on_animation = false; 1597 } // d キーで動作接続 遷移の設定を変更 1600 if ( key == 'd' ) 1601 { 1602 if ( enable_connection && enable_transition ) 1603 enable_transition = false; 1604 else if ( enable_connection &&!enable_transition ) 1605 enable_connection = false; 1606 else if (!enable_connection &&!enable_transition ) 1607 { 1608 enable_connection = true; 1609 enable_transition = true; 1610 } if (!enable_transition ) 1613 on_motion_transition = false; 1614 } 1615 } // 1619 // キーボードの特殊キー押下 15
16 1620 // H3 void MotionTransitionApp::KeyboardSpecial( unsigned char key, int mx, int my ) 1622 { 1623 // カーソル上キーが押されたら 次の再生動作を変更 1624 if ( key == GLUT_KEY_UP ) 1625 { 1626 SetNextMotion(); 1627 } 1628 } // 1632 // アニメーション処理 1633 // H3 void MotionTransitionApp::Animation( float delta ) 1635 { 1636 // アニメーション再生中でなければ終了 1637 if (!on_animation ) 1638 return; // 動作再生処理 ( 動作接続を考慮 動作遷移は考慮しない ) 1641 if ( enable_connection &&!enable_transition ) 1642 AnimationWithConnection( delta ); 1643 // 動作再生処理 ( 動作接続 遷移を考慮 ) 1644 else 1645 AnimationWithConnectionTransition( delta ); // 注視点を更新 1648 view_center.set( curr_posture->root_pos.x, 0.0f, curr_posture->root_pos.z ); 1649 } // 1653 // 次の動作を変更 1654 // H3 void MotionTransitionApp::SetNextMotion( int no ) 1656 { 1657 if ( motion_list.size() == 0 ) 1658 return; // 次の動作が指定されなかった場合は 現在の再生動作の次の番号の動作を次の動作とする 1661 if ( no < 0 ) 1662 no = ( curr_motion_no + 1) % motion_list.size(); 1663 else 1664 no = no % motion_list.size(); // 動作遷移中は次の動作の変更はできないため 待ち動作として設定 1667 if ( on_motion_transition ) 1668 { 1669 waiting_motion_no = no; 1670 return; 1671 } // 次の動作を設定 1674 next_motion_no = no; 1675 } // 1679 // 動作再生処理 ( 動作接続を考慮 動作遷移は考慮しない ) 1680 // H3 void MotionTransitionApp::AnimationWithConnection( float delta ) 1682 { 1683 // 時間を進める 1684 animation_time += delta * animation_speed; // 現在の再生動作が設定されていなければ終了 1687 if (!curr_motion ) 1688 { 1689 frame_no = 0; 1690 return; 1691 } // 現在 次の再生動作の情報を取得 1694 Motion * next_motion = NULL; 1695 MotionInfo * curr_motion_info = NULL; 1696 MotionInfo * next_motion_info = NULL; 1697 if ( next_motion_no == -1 ) 1698 next_motion_no = curr_motion_no; 1699 curr_motion_info = motion_list[ curr_motion_no ]; 1700 next_motion_info = motion_list[ next_motion_no ]; 1701 next_motion = next_motion_info->motion; // 現在の動作の開始 終了時刻を取得 ( 動作のローカル時間 ) 1704 float curr_motion_begin_time = curr_motion_info->begin_time; 1705 float curr_motion_end_time = curr_motion_info->end_time; // 次の動作の開始時刻を取得 ( 動作のローカル時間 ) 1708 float next_motion_begin_time = next_motion_info->begin_time; // 現在の動作の開始からの経過時間を計算 1711 float local_time = animation_time - curr_start_frame; // 現在のフレーム番号を計算 ( 表示用 ) 1714 frame_no = local_time / curr_motion->interval; // 現在の動作の終了時刻を超えたら 次の動作へ動作接続 1717 if ( local_time > curr_motion_end_time - curr_motion_begin_time ) 1718 { 1719 // 現在の動作の終了姿勢 位置 向き ( ワールド座標系 ) を取得 1720 Matrix4f curr_end_frame; 1721 curr_motion->getposture( curr_motion_end_time, *curr_posture ); 1722 TransformPosture( curr_motion_mat, *curr_posture ); 1723 curr_end_frame.set( curr_posture->root_ori, curr_posture->root_pos, 1.0f ); // 次の動作の開始姿勢 位置 向き ( 動作データのワールド座標系 ) を取得 1726 Matrix4f next_begin_frame; 1727 next_motion->getposture( next_motion_begin_time, *next_motion_posture ); 16
17 1728 next_begin_frame.set( next_motion_posture->root_ori, next_motion_posture->root_pos, 1.0f ); // 現在の動作の終了姿勢と次の動作の開始姿勢の姿勢の位置 向きを合わせるための変換行列を計算 1731 //(next_begin_frame の位置 向きを curr_end_frame の位置向きに合わせるための変換行列 trans_mat を計算 ) 1732 ComputeConnectionTransformation( curr_end_frame, next_begin_frame, next_motion_mat ); // 現在の動作を次の動作に切り替え 1735 curr_motion = next_motion; 1736 curr_motion_no = next_motion_no; 1737 curr_start_frame = curr_start_frame + curr_motion_end_time - curr_motion_begin_time; 1738 curr_motion_begin_time = next_motion_begin_time; 1739 curr_motion_mat = next_motion_mat; 1740 local_time = animation_time - curr_start_frame; // 次の動作の設定をクリア 1743 next_motion_no = -1; 1744 } // 現在の動作から現在時刻の姿勢を取得 1747 curr_motion->getposture( local_time + curr_motion_begin_time, *curr_posture ); // 変換行列を適用 1750 TransformPosture( curr_motion_mat, *curr_posture ); // 姿勢の描画色を設定 1753 figure_color = curr_motion_info->color; 1754 } // 1758 // 動作再生処理 ( 動作接続 遷移を考慮 ) 1759 // H3 void MotionTransitionApp::AnimationWithConnectionTransition( float delta ) 1761 { 1762 // 時間を進める 1763 animation_time += delta * animation_speed; // 現在の再生動作が設定されていなければ終了 1766 if (!curr_motion ) 1767 { 1768 frame_no = 0; 1769 return; 1770 } // 現在 次の再生動作の情報を取得 1773 Motion * next_motion = NULL; 1774 MotionInfo * curr_motion_info = NULL; 1775 MotionInfo * next_motion_info = NULL; 1776 if ( next_motion_no == -1 ) 1777 next_motion_no = curr_motion_no; 1778 curr_motion_info = motion_list[ curr_motion_no ]; 1779 next_motion_info = motion_list[ next_motion_no ]; 1780 next_motion = next_motion_info->motion; // 現在の動作の開始時刻 終了時刻 ブレンド開始時刻を取得 ( 動作のローカル時間 ) 1783 float curr_motion_begin_time = curr_motion_info->begin_time; 1784 float curr_motion_end_time = curr_motion_info->end_time; 1785 float curr_motion_blend_begin_time = curr_motion_info->blend_begin_time; // 次の動作の開始時刻 ブレンド終了時刻を取得 ( 動作のローカル時間 ) 1788 float next_motion_begin_time = next_motion_info->begin_time; 1789 float next_motion_blend_end_time = next_motion_info->blend_end_time; // 現在の動作の開始からの経過時間を計算 1792 float local_time = animation_time - curr_start_frame; // 現在のフレーム番号を計算 ( 表示用 ) 1795 frame_no = local_time / curr_motion->interval; // 動作接続 遷移の動作ブレンドの開始 1798 if (!on_motion_transition && ( local_time > curr_motion_blend_begin_time - curr_motion_begin_time ) ) 1799 { 1800 // 現在の動作 次の動作の位置 向きを合わせる時刻を決定 ( それぞれの動作のローカル時刻 ) 1801 float curr_motion_time = curr_motion_end_time; 1802 float next_motion_time = next_motion_begin_time; // レポート課題 1805 // curr_motion_time =???; 1806 // next_motion_time =???; // 現在の動作の終了姿勢 位置 向き ( ワールド座標系 ) を取得 1809 Matrix4f curr_end_frame; 1810 curr_motion->getposture( curr_motion_time, *curr_posture ); 1811 TransformPosture( curr_motion_mat, *curr_posture ); 1812 curr_end_frame.set( curr_posture->root_ori, curr_posture->root_pos, 1.0f ); // 次の動作の開始姿勢 位置 向き ( 動作データのワールド座標系 ) を取得 1815 Matrix4f next_begin_frame; 1816 next_motion->getposture( next_motion_time, *next_motion_posture ); 1817 next_begin_frame.set( next_motion_posture->root_ori, next_motion_posture->root_pos, 1.0f ); // 現在の動作の終了姿勢と次の動作の開始姿勢の姿勢の位置 向きを合わせるための変換行列を計算 1820 //(next_begin_frame の位置 向きを curr_end_frame の位置向きに合わせるための変換行列 trans_mat を計算 ) 1821 ComputeConnectionTransformation( curr_end_frame, next_begin_frame, next_motion_mat ); // 動作ブレンドを開始 1824 on_motion_transition = true; 1825 } // 動作接続 遷移の動作ブレンドの完了 1828 if ( local_time - ( curr_motion_end_time - curr_motion_begin_time ) >= next_motion_blend_end_time - next_motion_begin_time ) 1829 { 1830 // 現在の動作を次の動作に切り替え 1831 curr_motion = next_motion; 1832 curr_motion_no = next_motion_no; 1833 curr_motion_info = next_motion_info; 1834 curr_start_frame = curr_start_frame + curr_motion_end_time - curr_motion_begin_time; 1835 curr_motion_begin_time = next_motion_begin_time; 17
18 1836 curr_motion_mat = next_motion_mat; 1837 local_time = animation_time - curr_start_frame; // 次の動作の設定をクリア 1840 next_motion_no = -1; 1841 if ( waiting_motion_no!= -1 ) 1842 { 1843 next_motion_no = waiting_motion_no; 1844 waiting_motion_no = -1; 1845 } // 動作ブレンドを終了 1848 on_motion_transition = false; 1849 } // 現在の動作から現在時刻の姿勢を取得 1852 curr_motion->getposture( local_time + curr_motion_begin_time, *curr_posture ); // 変換行列を適用 1855 TransformPosture( curr_motion_mat, *curr_posture ); // 動作接続 遷移のためのブレンド中は 次の動作の姿勢とブレンド 1858 if ( on_motion_transition && enable_transition ) 1859 { 1860 // 次の動作のローカル時間での時刻を計算 1861 float next_local_time = local_time - ( curr_motion_end_time - curr_motion_begin_time ) + next_motion_begin_time; // 次の動作から現在時刻の姿勢を取得 1864 next_motion->getposture( next_local_time, *next_motion_posture ); // 変換行列を適用 1867 TransformPosture( next_motion_mat, *next_motion_posture ); // ブレンド比率を計算 1870 float blend_ratio = 0.0f; // レポート課題 // 前後の動作の姿勢をブレンド 1876 PostureInterpolation( *curr_posture, *next_motion_posture, blend_ratio, *curr_posture ); // 姿勢の描画色を設定 1879 figure_color.scaleadd( blend_ratio, next_motion_info->color - curr_motion_info->color, curr_motion_info->color ); 1880 } 1881 else 1882 { 1883 // 姿勢の描画色を設定 1884 figure_color = curr_motion_info->color; 1885 } 1886 } // 1890 // 変換行列の水平向き ( 方位角 ) 成分を計算 1891 // 1892 float ComputeOrientation( const Matrix3f & ori ) 1893 { 1894 Vector3f fig_ori; 1895 ori.getcolumn( 2, &fig_ori ); 1896 return atan2( fig_ori.x, fig_ori.z ) * 180.0f / M_PI; 1897 } // 1901 // 2つの姿勢の位置 向きを合わせるための変換行列を計算 1902 // (next_frame の位置 向きを prev_frame の位置向きに合わせるための変換行列 trans_mat を計算 ) 1903 // 1904 void ComputeConnectionTransformation( const Matrix4f & prev_frame, const Matrix4f & next_frame, Matrix4f & trans_mat ) 1905 { 1906 // レポート課題 trans_mat.setidentity(); } // 1914 // 姿勢の位置 向きに変換行列を適用 1915 // 1916 void TransformPosture( const Matrix4f & trans, Posture & posture ) 1917 { 1918 // 変換行列を適用 1919 Matrix3f rot; 1920 trans.get( &rot ); 1921 posture.root_ori.mul( rot, posture.root_ori ); 1922 trans.transform( &posture.root_pos ); 1923 } /////////////////////////////////////////////////////////////////////////////// 1928 // 1929 // 動作補間アプリケーション 1930 // // 1934 // 動作補間アプリケーションクラス 1935 // 1936 class MotionInterpolationApp : public GLUTBaseApp 1937 { 1938 protected: 1939 // キャラクタ情報 // キャラクタの骨格 1942 Skeleton * body;
19 1944 // キャラクタの姿勢 1945 Posture * curr_posture; protected: 1948 // 動作再生のための変数 // アニメーション中かどうかを表すフラグ 1951 bool on_animation; // アニメーションの再生時間 1954 float animation_time; // アニメーションの再生速度 1957 float animation_speed; protected: 1960 // 動作データの情報 // 動作データ情報 ( 動作補間に用いる2つの動作 ) 1963 MotionInfo * motions[ 2 ]; protected: 1966 // 動作補間のための変数 // 動作補間の重み 1969 float weight; // サンプル動作からの取得姿勢 1972 Posture * motion_posture[ 2 ]; // 現在姿勢の描画色 1975 Color3f figure_color; protected: 1978 // 動作接続のための変数 // 繰り返し動作の再生開始時刻 1981 float cycle_start_time; // サンプル動作の位置 向きを合わせるための変換行列 1984 Matrix4f motion_trans_mat[ 2 ]; public: 1987 // コンストラクタ 1988 MotionInterpolationApp(); // デストラクタ 1991 virtual ~MotionInterpolationApp(); public: 1994 // イベント処理 // 初期化 1997 virtual void Initialize(); // 開始 リセット 2000 virtual void Start(); // 画面描画 2003 virtual void Display(); // マウスドラッグ 2006 virtual void MouseDrag( int mx, int my ); // キーボードのキー押下 2009 virtual void Keyboard( unsigned char key, int mx, int my ); // アニメーション処理 2012 virtual void Animation( float delta ); 2013 }; // 補助処理 ( グローバル関数 ) のプロトタイプ宣言 // 2つの姿勢の位置 向きを合わせるための変換行列を計算 2019 //(next_frame の位置 向きを prev_frame の位置向きに合わせるための変換行列 trans_mat を計算 ) 2020 void ComputeConnectionTransformation( const Matrix4f & prev_frame, const Matrix4f & next_frame, Matrix4f & trans_mat ); // 姿勢の位置 向きに変換行列を適用 2023 void TransformPosture( const Matrix4f & trans, Posture & posture ); // 2028 // コンストラクタ 2029 // 2030 MotionInterpolationApp::MotionInterpolationApp() 2031 { 2032 app_name = "Motion Interpolation"; body = NULL; 2035 curr_posture = NULL; 2036 on_animation = true; 2037 animation_time = 0.0f; 2038 animation_speed = 1.0f; motions[ 0 ] = NULL; 2041 motions[ 1 ] = NULL; 2042 weight = 0.0f; 2043 motion_posture[ 0 ] = NULL; 2044 motion_posture[ 1 ] = NULL; 2045 } // 2049 // デストラクタ 2050 // 2051 MotionInterpolationApp::~MotionInterpolationApp() 19
20 2052 { 2053 for ( int i=0; i<2; i++ ) 2054 { 2055 if ( motions[ i ] ) 2056 { 2057 if ( motions[ i ]->motion ) 2058 delete motions[ i ]->motion; 2059 delete motions[ i ]; 2060 } 2061 } if ( curr_posture ) 2064 delete curr_posture; 2065 if ( body ) 2066 delete body; 2067 } // 2071 // 初期化 2072 // H3 void MotionInterpolationApp::Initialize() 2074 { 2075 GLUTBaseApp::Initialize(); // サンプル動作セットの読み込み 2078 if (!motions[ 0 ] ) 2079 { 2080 vector< MotionInfo * > motion_list; 2081 body = LoadSampleMotions( motion_list ); 2082 motions[ 0 ] = motion_list[ 0 ]; 2083 motions[ 1 ] = motion_list[ 1 ]; 2084 } // 姿勢の初期化 2087 if ( body ) 2088 { 2089 if ( curr_posture ) 2090 delete curr_posture; 2091 if ( motion_posture[ 0 ] ) 2092 delete motion_posture[ 0 ]; 2093 if ( motion_posture[ 1 ] ) 2094 delete motion_posture[ 1 ]; curr_posture = new Posture( body ); 2097 InitPosture( *curr_posture, body ); 2098 motion_posture[ 0 ] = new Posture( body ); 2099 motion_posture[ 1 ] = new Posture( body ); 2100 } 2101 } // 2105 // 開始 リセット 2106 // H3 void MotionInterpolationApp::Start() 2108 { 2109 GLUTBaseApp::Start(); weight = 0.0f; on_animation = true; 2114 animation_time = 0.0f; cycle_start_time = 0.0f; // 各サンプル動作の接続のための変換行列を計算 2119 Matrix4f init_frame; 2120 init_frame.setidentity(); 2121 Matrix4f motion_start_frame; 2122 for ( int i=0; i<2; i++ ) 2123 { 2124 // 動作データが読み込まれていなければスキップ 2125 if (!motions[ i ]!motions[ i ]->motion!curr_posture ) 2126 continue; // 動作データから開始姿勢を取得 位置 向きを取得 2129 motions[ i ]->motion->getposture( motions[ i ]->keytimes[ 0 ], *motion_posture[ i ] ); 2130 motion_start_frame.set( motion_posture[ i ]->root_ori, motion_posture[ i ]->root_pos, 1.0f ); // 変換行列を計算 2133 ComputeConnectionTransformation( motion_start_frame, motion_start_frame, motion_trans_mat[ i ] ); 2134 } Animation( 0.0f ); 2137 } // 2141 // 画面描画 2142 // H3 void MotionInterpolationApp::Display() 2144 { 2145 GLUTBaseApp::Display(); // キャラクタを描画 2148 if ( curr_posture ) 2149 { 2150 glcolor3f( figure_color.x, figure_color.y, figure_color.z ); 2151 DrawPosture( *curr_posture ); 2152 DrawPostureShadow( *curr_posture, shadow_dir, shadow_color ); 2153 } // 現在のモード 補間重みを表示 2156 DrawTextInformation( 0, "Motion Interpolation" ); 2157 char message[ 64 ]; 2158 sprintf( message, "%.2f", animation_time ); 2159 DrawTextInformation( 1, message ); 20
コンピュータグラフィックスS 演習資料
コンピュータグラフィックス S 演習資料 第 4 回シェーディング マッピング 九州工業大学情報工学部システム創成情報工学科講義担当 : 尾下真樹 1. 演習準備 今回の演習も 前回までの演習で作成したプログラムに続けて変更を行う まずは シェーディングの演習のため 描画処理で 回転する一つの四角すいを描画するように変更する 画面をクリア ( ピクセルデータと Z バッファの両方をクリア ) glclear(
More informationMicrosoft PowerPoint - 04.pptx
初期化 コールバック関数の登録 glutmainloop() 描画関数 マウス処理関数 キーボード処理関数などの関数ポインタを登録する イベント待ちの無限ループ 再描画? no マウス入力? no キーボード入力? no yes yes yes 描画関数の呼び出し マウス処理関数の呼び出し キーボード処理関数の呼び出し void keyboard(unsigned char key, int x,
More informationスライド 1
グラフィックスの世界第 3 回 サイバーメディアセンター サイバーコミュニティ研究部門安福健祐 Processing によるアニメーション setup と draw void setup() size(400, 400); void draw() ellipse( mousex,mousey,100,100); void とか setup とか draw とかはじめて見る が出てきてややこしい ellipseは円描く関数でした
More informationイントロダクション
プログラミング演習 IV 第 7 回マウス, キーボード, サウンド, 文字 埼玉大学情報システム工学科 小林貴訓 マウス入力 クリックイベントのコールバック関数の登録 glutmousefunc(mouse); クリックイベントのコールバック関数 // マウスクリックコールバック関数の指定 static int MouseLB_ON=0; // 左マウスボタン押下フラグ static int MouseRB_ON=0;
More informationfile:///D|/C言語の擬似クラス.txt
愛知障害者職業能力開発校 システム設計科 修了研究発表会報告書 題名 : C 言語の擬似クラス あらまし : C 言語でクラスを作れるという噂の真偽を確かめるために思考錯誤した まえがき : VC++ や Java その他オブジェクト指向の言語にはクラスが存在して クラスはオブジェクトの設計図である 手法 : C++ のクラスを解析して C++ のクラスを作成して C 言語に翻訳する class struct
More informationMicrosoft PowerPoint - info_eng3_05ppt.pptx
インタラクティブシステム構築法 第 5 回 OpenGL と GLUT の使い方 (3) 埼玉大学情報システム工学科小林貴訓 シェーディング 光源の設定を有効にする glenable(gl_lighting); // 光源の設定を有効にする glenable(gl_light0); //0 番目の光源を有効にする (8 個まで設定可能 ) 光源の位置 GLfloat light0pos[] = {
More information2 : 2008/12/ /01/ G :
2 : 2008/12/08 2008/01/16 075730G : 1 project draw main.cpp 1 draw main.cpp /* * main.cpp * draw * * Created by C-T on 08/12/08. * Copyright 2008 MyCompanyName. All rights reserved. * */ #include
More information#include <stdio.h> 2 #include <stdlib.h> 3 #include <GL/glut.h> 4 Program 1 (OpenGL GameSample001) 5 // 6 static bool KeyUpON = false; // 7 sta
1 1. 1 #include 2 #include 3 #include 4 Program 1 (OpenGL GameSample001) 5 // 6 static bool KeyUpON = false; // 7 static bool KeyDownON = false; // 8 static bool KeyLeftON
More informationProg2_12th
2018 年 12 月 13 日 ( 木 ) 実施クラスの継承オブジェクト指向プログラミングの基本的な属性として, 親クラスのメンバを再利用, 拡張, または変更する子クラスを定義することが出来る メンバの再利用を継承と呼び, 継承元となるクラスを基底クラスと呼ぶ また, 基底クラスのメンバを継承するクラスを, 派生クラスと呼ぶ なお, メンバの中でコンストラクタは継承されない C# 言語では,Java
More informationmemo
数理情報工学演習第一 C プログラミング演習 ( 第 5 回 ) 2015/05/11 DEPARTMENT OF MATHEMATICAL INFORMATICS 1 今日の内容 : プロトタイプ宣言 ヘッダーファイル, プログラムの分割 課題 : 疎行列 2 プロトタイプ宣言 3 C 言語では, 関数や変数は使用する前 ( ソースの上のほう ) に定義されている必要がある. double sub(int
More information演算増幅器
コンピュータグラフィックス 2 前回は GLUT を使った簡単な 2 次元グラフィックスについて習った 今週は以下の項目について 補足していく イベント駆動型プログラムの動作について コンピュータグラフィックスの座標系 イベント駆動型プログラム従来のプログラムとの違いこれまでに学習してきたプログラムは上から下に順次実行され 条件分岐や繰り返し処理によって プログラムの流れ (flow: フロー )
More information謗域・ュ逕ィppt
情報工学 2017 年度後期第 5 回 [11 月 1 日 ] 静岡大学 工学研究科機械工学専攻ロボット 計測情報講座創造科学技術大学院情報科学専攻 三浦憲二郎 講義日程 第 6 回 11 月 8 日画像処理パート第 1 回 第 7 回 11 月 15 日 CGパート第 6 回 第 8 回 11 月 22 日 CGパート第 7 回 第 9 回 11 月 29 日 CGパート試験 講義アウトライン [11
More information解きながら学ぶC++入門編
!... 38!=... 35 "... 112 " "... 311 " "... 4, 264 #... 371 #define... 126, 371 #endif... 369 #if... 369 #ifndef... 369 #include... 3, 311 #undef... 371 %... 17, 18 %=... 85 &... 222 &... 203 &&... 40 &=...
More informationMicrosoft PowerPoint - diip ppt
2006 年度デザイン情報学科情報処理 III 第 12 回マウスによる制御 ブロック崩し の部品 ボール直径 10pixel の円ラケット横 60pixel 縦 10pixel, マウスにより左右に移動ブロック横 50pixel 縦 20pixel,28 個 (7 個 4 段 ) 壁 ( フィールド ) 横 400pixel 縦 600pixel 2006 年度デザイン情報学科情報処理 III 2
More informationPowerPoint Presentation
マイコンシステム 第 12 回 青森大学ソフトウェア情報学部 橋本恭能 haship@aomori-u.ac.jp 目次 講義 内部設計 3 Deviceタブ Actionタブの関数実装 例題 定義した機能を実現する方法を検討する 課題 動作確認 2 講義 内部設計 3 残りの関数を実装 3 組込みシステム開発 週テーマ内容 7 キッチンタイマーの組立キッチンタイマーのハードを製作 確認 8 9 10
More informationPowerPoint プレゼンテーション
プログラマー勉強会 1 回 basic.h 補足 [ 修飾子 ] const 付けた変数は初期化以外で値を設定することができなくなる 定数宣言に使う unsigned 付けた変数は符号がなくなり 正の値しか設定できない [ 条件コンパイル ] #ifdef M ここ以前に M がマクロとして定義されていれば ここ以下をコンパイルする #ifndef M ここ以前に M というマクロが定義されていなければ
More information基礎プログラミング2015
応用プログラミング 第 4 回 ファイル操作 2017 年 10 月 11 日 ( 水 ) 第 6 章 ファイル操作 標準入出力とファイル (P.50) これまでのプログラム 入力 : キーボード 出力 : ディスプレイ Input an integer 1024 1024 標準入出力とファイル (P.50) 今回のプログラム 入力 : ファイル ( の内容 ) 出力 : ファイル Input a
More informationCondition DAQ condition condition 2 3 XML key value
Condition DAQ condition 2009 6 10 2009 7 2 2009 7 3 2010 8 3 1 2 2 condition 2 3 XML key value 3 4 4 4.1............................. 5 4.2...................... 5 5 6 6 Makefile 7 7 9 7.1 Condition.h.............................
More informationMicrosoft Word - no15.docx
7. ファイルいままでは プログラムを実行したとき その結果を画面で確認していました 簡単なものならそれでもいいのですか 複雑な結果は画面で見るだけでなく ファイルに保存できればよいでしょう ここでは このファイルについて説明します 使う関数のプロトタイプは次のとおりです FILE *fopen(const char *filename, const char *mode); ファイルを読み書きできるようにする
More informationJava プログラミング Ⅰ 3 回目変 数 今日の講義講義で学ぶ内容 変数とは 変数の使い方 キーボード入力の仕方 変 数 変 数 一時的に値を記憶させておく機能 変数は 型 ( データ型 ) と識別子をもちます 2 型 ( データ型 ) 変数に記憶する値の種類変数の型は 記憶できる値の種類と範囲
Java プログラミング Ⅰ 3 回目変 数 今日の講義講義で学ぶ内容 変数とは 変数の使い方 キーボード入力の仕方 変 数 変 数 一時的に値を記憶させておく機能 変数は 型 ( データ型 ) と識別子をもちます 2 型 ( データ型 ) 変数に記憶する値の種類変数の型は 記憶できる値の種類と範囲を決定します 次の型が利用でき これらの型は特に基本型とよばれます 基本型 値の種類 値の範囲 boolean
More informationコンピューターグラフィックスS
前回の演習の復習 今日の内容 コンピューターグラフィックス S 第 7 回演習 (2): ポリゴンモデルの描画 システム創成情報工学科尾下真樹 前回の復習 ポリゴンの描画方法 ( 復習 ) 基本オブジェクトの描画 ポリゴンモデルの描画 演習課題 サンプルプログラム 前回の演習の復習 opengl_sample.c 地面と 枚の青い三角形が表示される マウスの右ボタンドラッグで 視点を上下に回転 前回の演習課題.
More information画像ファイルを扱う これまでに学んだ条件分岐, 繰り返し, 配列, ファイル入出力を使って, 画像を扱うプログラムにチャレンジしてみよう
第 14 回 応用 情報処理演習 ( テキスト : 第 10 章 ) 画像ファイルを扱う これまでに学んだ条件分岐, 繰り返し, 配列, ファイル入出力を使って, 画像を扱うプログラムにチャレンジしてみよう 特定色の画素の検出 ( テキスト 134 ページ ) 画像データが保存されているファイルを読み込んで, 特定色の画素の位置を検出するプログラムを作成しなさい 元画像生成画像 ( 結果の画像 )
More informationMicrosoft PowerPoint - kougi11.ppt
C プログラミング演習 中間まとめ 2 1 ソフトウエア開発の流れ 機能設計 外部仕様 ( プログラムの入力と出力の取り決め ) 構成設計 詳細設計 論理試験 内部データ構造や関数呼び出し方法などに関する取り決めソースプログラムの記述正しい入力データから正しい結果が得られるかテスト関数単位からテストをおこなう 耐性試験 異常な入力データに対して, 異常を検出できるかテスト異常終了することはないかテスト
More information< F2D834F838C A815B A CC>
グレゴリー ライプニッツの公式 [Java アプレット ] [Java アプリケーション ] 1. はじめに 次のグレゴリー ライプニッツの公式を用いて π の近似値を求めてみましょう [ グレゴリー ライプニッツの公式 ] π 4 =1-1 3 + 1 5-1 7 + 1 9-1 + 11 シミュレーションソフト グレゴリー ライプニッツの公式による π の近似 を使って π の近似値が求まる様子を観察してみてください
More information演算増幅器
スペースインベーダーもどき 1000 行プログラムの参考として スペースインベーダーもどきのプログラムを配布する いくつか習って いないものもあるので 補足の説明を加えていく 文字列の描画 文字の描画は glutbitmapcharacter() を用いる これは以下のようにして利用する int i; char *str = "Display String"; glcolor3f(0.0, 0.0,
More informationとても使いやすい Boost の serialization
とても使いやすい Boost の serialization Zegrahm シリアライズ ( 直列化 ) シリアライズ ( 直列化 ) とは何か? オブジェクトデータをバイト列や XML フォーマットに変換すること もう少しわかりやすく表現すると オブジェクトの状態を表す変数 ( フィールド ) とオブジェクトの種類を表す何らかの識別子をファイル化出来るようなバイト列 XML フォーマット形式で書き出す事を言う
More information基礎計算機演習 実習課題No6
実習課題 No.6 課題は 3 題ある. 課題 6-1 時間内提出 次の実行例のように, 名簿を出力するプログラムをつくりたい. このプログラムでは, まず人数をたずね, 次にその人数分の名前を入力し, それを再びコンソールに出力する. なお, 空の名前が入力されても終了せずにその欄は空欄で出力するものとする. 注意とヒント この課題では,string 型の配列をまず宣言する. このとき, 配列の要素はちょうど名簿に入力する人数分だけを宣言すること
More information1 1. Program 1 OpenCV (OpenCV Sample001) 1 /* 2 - > - > - >VC++ 3 ( ) 4 C:\opencv\build\include 5 ( ) 6 C:\opencv\build\x86\vc10\lib 7 - > - > - > - >
1 1. Program 1 OpenCV (OpenCV Sample001) 1 /* 2 - > - > - >VC++ 3 ( ) 4 C:\opencv\build\include 5 ( ) 6 C:\opencv\build\x86\vc10\lib 7 - > - > - > - > 8 (240 O p e n C V ) 9 opencv_core240d.lib 10 opencv_imgproc240d.lib
More information< F2D B838A835882CC8CF68EAE2E6A7464>
ウォーリスの公式 [Java アプレット ] [Java アプリケーション ] 1. はじめに 次のウォーリスの公式を用いて π の近似値を求めてみましょう [ ウォーリスの公式 ] π=2{ 2 2 4 4 6 6 1 3 3 5 5 7 シミュレーションソフト ウォーリスの公式による π の近似 を使って π の近似値が求まる様子を観察してみてください 2.Java アプレット (1) Javaプログラムリスト
More informationTestDesign for Web
発行日 2012/6/21 発行元 株式会社アープ 本書は Web でのテスト自動化における Test Design の一連の操作方法まとめたものです Test Design のメニューの説明やより詳細な使い方については ユーザーズガイド を参照してください 目次 1. はじめに... 1 2. 環境構築... 2 2.1. Selenium のサイトについて... 2 2.2. Selenium
More informationdouble float
2015 3 13 1 2 2 3 2.1.......................... 3 2.2............................. 3 3 4 3.1............................... 4 3.2 double float......................... 5 3.3 main.......................
More informationMicrosoft Word - Training10_プリプロセッサ.docx
Training 10 プリプロセッサ 株式会社イーシーエス出版事業推進委員会 1 Lesson1 マクロ置換 Point マクロ置換を理解しよう!! マクロ置換の機能により 文字列の置き換えをすることが出来ます プログラムの可読性と保守性 ( メンテナンス性 ) を高めることができるため よく用いられます マクロ置換で値を定義しておけば マクロの値を変更するだけで 同じマクロを使用したすべての箇所が変更ができるので便利です
More information< F2D B825082CC96E291E82E6A7464>
3x+1 の問題 [Java アプレット ] [Java アプリケーション ] 1. はじめに どんな自然数から始めても良いので その数が偶数ならば2で割り 奇数ならば3 倍して1を加えることを繰り返します そうすると どんな自然数から始めても必ず1になるというのはほんとうなのでしょうか 例えば 11から始めると 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 となります
More information1) OOP 2) ( ) 3.2) printf Number3-2.cpp #include <stdio.h> class Number Number(); // ~Number(); // void setnumber(float n); float getnumber();
: : :0757230G :2008/07/18 2008/08/17 1) OOP 2) ( ) 3.2) printf Number3-2.cpp #include class Number Number(); // ~Number(); // void setnumber(float n); float getnumber(); private: float num; ;
More informationJavaプログラミングⅠ
Java プログラミング Ⅰ 12 回目クラス 今日の講義で学ぶ内容 クラスとは クラスの宣言と利用 クラスの応用 クラス クラスとは 異なる複数の型の変数を内部にもつ型です 直観的に表現すると int 型や double 型は 1 1 つの値を管理できます int 型の変数 配列型は 2 5 8 6 3 7 同じ型の複数の変数を管理できます 配列型の変数 ( 配列変数 ) クラスは double
More informationMicrosoft PowerPoint - CproNt02.ppt [互換モード]
第 2 章 C プログラムの書き方 CPro:02-01 概要 C プログラムの構成要素は関数 ( プログラム = 関数の集まり ) 関数は, ヘッダと本体からなる 使用する関数は, プログラムの先頭 ( 厳密には, 使用場所より前 ) で型宣言 ( プロトタイプ宣言 ) する 関数は仮引数を用いることができる ( なくてもよい ) 関数には戻り値がある ( なくてもよい void 型 ) コメント
More information2016 VOCALOID Group, Yamaha Corporation 2
2016 VOCALOID Group, Yamaha Corporation 2016 VOCALOID Group, Yamaha Corporation 2 2016 VOCALOID Group, Yamaha Corporation 3 #if UNITY_EDITOR_WIN UNITY_STANDALONE_WIN using Yamaha.VOCALOID.Windows; #elif
More informationMicrosoft PowerPoint - kougi9.ppt
C プログラミング演習 第 9 回ポインタとリンクドリストデータ構造 1 今まで説明してきた変数 #include "stdafx.h" #include int _tmain(int argc, _TCHAR* argv[]) { double x; double y; char buf[256]; int i; double start_x; double step_x; FILE*
More information< F2D F B834E2E6A7464>
ランダムウォーク [Java アプレット ] [Java アプレリケーョン ] 1. はじめに 酔っぱらいは前後左右見境なくふらつきます 酔っぱらいは目的地にたどり着こうと歩き回っているうちに何度も同じところに戻って来てしまったりするものです 今 酔っぱらいが数直線上の原点にいるとします 原点を出発して30 回ふらつくとき 30 回目に酔っぱらいがいる位置は 出発点である原点からどれくらい離れてしまっているのでしょうか
More informationProg2_15th
2019 年 7 月 25 日 ( 木 ) 実施メニューメニューバーとコンテクストメニュー Visual C# では, メニューはコントロールの一つとして扱われ, フォームアプリケーションの上部に配置されるメニューバーと, コントロール上でマウスを右クリックすると表示されるコンテクストメニューとに対応している これ等は選択するとメニューアイテムのリストが表示されるプルダウンメニューと呼ばれる形式に従う
More informationしずおかアプリ部 Unity はじめるよ すごいよサウンド機能 実践編 統合開発環境を内蔵したゲームエンジン いろんな職業の が る資料なので説明を簡単にしてある部分があります 正確には本来の意味と違いますが上記理由のためです ご了承ください この
Unity はじめるよ すごいよサウンド機能 実践編 統合開発環境を内蔵したゲームエンジン http://japan.unity3d.com/ いろんな職業の が る資料なので説明を簡単にしてある部分があります 正確には本来の意味と違いますが上記理由のためです ご了承ください この資料内の 部の画像 部の 章は Unity 公式サイトから引 しています AudioMixer のサンプルアプリを作る
More informationコンピューターグラフィックスS
今日の内容 コンピューターグラフィックス S 第 8 回 () システム創成情報工学科尾下真樹 28 年度 Q2 前回の復習 演習 (2): ポリゴンモデルの描画 変換行列 の概要 座標系 視野変換 射影変換 のまとめ 教科書 ( 参考書 ) コンピュータグラフィックス CG-ATS 協会編集 出版 2 章 ビジュアル情報処理 -CG 画像処理入門 - CG-ATS 協会編集 出版 章 (-2~-3
More informationJavaプログラミングⅠ
Java プログラミング Ⅰ 3 回目変数 今日の講義で学ぶ内容 変数とは 変数の使い方 キーボード入力の仕方 変 数 変 数 一時的に値を記憶させておく機能です 変数は 型 ( データ型ともいいます ) と識別子をもちます 2 型 変数に記憶できる値の種類です型は 値の種類に応じて次の 8 種類があり これを基本型といいます 基本型値の種類値の範囲または例 boolean 真偽値 true または
More informationJava講座
~ 第 1 回 ~ 情報科学部コンピュータ科学科 2 年竹中優 プログラムを書く上で Hello world 基礎事項 演算子 構文 2 コメントアウト (//, /* */, /** */) をしよう! インデントをしよう! 変数などにはわかりやすい名前をつけよう! 要するに 他人が見て理解しやすいコードを書こうということです 3 1. Eclipse を起動 2. ファイル 新規 javaプロジェクト
More informationProg1_10th
2012 年 6 月 20 日 ( 木 ) 実施ポインタ変数と文字列前回は, ポインタ演算が用いられる典型的な例として, ポインタ変数が 1 次元配列を指す場合を挙げたが, 特に,char 型の配列に格納された文字列に対し, ポインタ変数に配列の 0 番の要素の先頭アドレスを代入して文字列を指すことで, 配列そのものを操作するよりも便利な利用法が存在する なお, 文字列リテラルは, その文字列が格納されている領域の先頭アドレスを表すので,
More information< F2D82B682E182F182AF82F12E6A7464>
3 人のじゃんけん [Java アプレット ] [Java アプリケーション ] 1. はじめに A 君 B 君 C 君の 3 人でじゃんけんを 1 回するときの勝ち負けを考えてみましょう あいこの場合は A 君 B 君 C 君の順に グー グー グー チョキ チョキ チョキ パー パー パー グー チョキ パー グー パー チョキ チョキ グー パー チョキ パー グー パー グー チョキ パー
More information14.event-handling
14. Event-Handling イベント処理 (Event Handling) 今回は Windows の Form アプリケーションで 様々なイベント を表示する時のプログラムです 題材として 以下のプログラムを使います 何のプログラムか? 見ての通りです 全く同じプログラムで 先頭 の数行を変更するだけでサイズや通路の広さを変えることができます 試してみてください なお 縦 と 横 のサイズは一致させています
More information2 ColorSpace DepthSpace CameraSpace Kinect V2 Kinect V2 BOdyIndex 3. NtKinect Kinect V2 C++ NtKinect [4] NtKinect = Kinect SDK + + STL(C++) + OpenCV +
NtKinect: C++ Class Library for Kinect V2 1,a) Kinect for Windows V2 C++ NtKinect NtKinect DLL Kinect V2 Kinect V2, C++, DLL, Unity NtKinect: C++ Class Library for Kinect V2 Nitta Yoshihisa 1,a) Abstract:
More informationGUIプログラムⅣ
GUI プログラム Ⅳ 画像指定ウィンドウの生成 ファイル名 :awtimage.java import java.awt.*; import java.awt.event.*; public class awtimage extends Frame // コンポーネントクラスの宣言 Button btnbrowse; Label lblcaption7; TextField txtimage; //
More informationMicrosoft PowerPoint ppt
独習 Java ( 第 3 版 ) 6.7 変数の修飾子 6.8 コンストラクタの修飾子 6.9 メソッドの修飾子 6.10 Object クラスと Class クラス 6.7 変数の修飾子 (1/3) 変数宣言の直前に指定できる修飾子 全部で 7 種類ある キーワード final private protected public static transient volatile 意味定数として使える変数同じクラスのコードからしかアクセスできない変数サブクラスまたは同じパッケージ内のコードからしかアクセスできない変数他のクラスからアクセスできる変数インスタンス変数ではない変数クラスの永続的な状態の一部ではない変数不意に値が変更されることがある変数
More informationPowerPoint Presentation
ファイルの入出力 芝浦工業大学情報工学科 青木義満 今回の講義内容 ファイル入出力 ファイルからのデータ読込み ファイルと配列 2 1 ファイルへのデータ書き込み ( 復習 ) ソースファイル名 :fileio1.c データをファイルに書き込み #include int main(void) { ファイルポインタ宣言 int student_id = 100; char name[
More information第33回_プレゼン資料_菅原(~IKを使ってアニメーションをコントロール~)
Unity はじめるよ IK を使って アニメーションをコントロール 統合開発環境を内蔵したゲームエンジン http://japan.unity3d.com/ いろんな職業の が る資料なので説明を簡単にしてある部分があります 正確には本来の意味と違いますが上記理由のためです ご了承ください この資料内の 部の画像 部の 章は Unity 公式サイトから引 しています 体の 部を別アニメーションに
More informationJava プログラミング Ⅰ 3 回目変数 変数 変 数 一時的に値を記憶させておく機能型 ( データ型 ) と識別子をもつ 2 型 ( データ型 ) 変数の種類型に応じて記憶できる値の種類や範囲が決まる 型 値の種類 値の範囲 boolean 真偽値 true / false char 2バイト文
Java プログラミング Ⅰ 3 回目変数 変数 変 数 一時的に値を記憶させておく機能型 ( データ型 ) と識別子をもつ 2 型 ( データ型 ) 変数の種類型に応じて記憶できる値の種類や範囲が決まる 型 値の種類 値の範囲 boolean 真偽値 true / false char 2バイト文字 0x0000 ~ 0xffff byte 1バイト整数 - 2 8 ~ 2 8-1 short 2バイト整数
More informationMicrosoft Word - 第5回 基本データ構造2(連結リスト).doc
第 5 回基本データ構造 2 連結リストとその操作 第 5 回 Page 1 5-1. リスト構造 データ部 と ポインタ部 で構成され ポインタをたどることによりデータを扱うことができる構造 5-2. 単方向リストとその操作 5-2-1. 単方向リスト 次のデータへのポインタを 1 つだけ持っているデータ構造 ( データ部は 複数のデータを持っている場合もある ) データ部 ポインタ部 ノード リストを構成する要素のことを
More informationProg2_10th
2017 年 12 月 7 日 ( 木 ) 実施 効果音の付加 SoundPool とは Android には音を処理するクラスが複数用意されているが, その中で SoundPool は, 予め音のデータをメモリ上に読み込んで再生するため, 長い音楽よりも短い音を扱うのに適している また,SoundPool では遅延が無いので, 効果音を付加したい場面で用いられる 授業の準備 1)Android Studio
More information第32回_プレゼン資料_菅原(Unityはじめるよ~上半身だけ動かす2~)
Unity はじめるよ 上半 だけ動かす 2 統合開発環境を内蔵したゲームエンジン http://japan.unity3d.com/ いろんな職業の が る資料なので説明を簡単にしてある部分があります 正確には本来の意味と違いますが上記理由のためです ご了承ください この資料内の 部の画像 部の 章は Unity 公式サイトから引 しています 上半 だけ動かす 複雑なステートマシンを体の各部分ごとに管理することができます
More informationJava演習(4) -- 変数と型 --
50 20 20 5 (20, 20) O 50 100 150 200 250 300 350 x (reserved 50 100 y 50 20 20 5 (20, 20) (1)(Blocks1.java) import javax.swing.japplet; import java.awt.graphics; (reserved public class Blocks1 extends
More informationdesign_pattern.key
#include void init(int* ary, int size) for (int i = 0; i < size; ++i) ary[i] = i; void mul10(int* ary, int size) for (int i = 0; i < size; ++i) ary[i] *= 10; void dispary(int* ary, int size)
More information< F2D825282CC947B909482CC A815B83682E6A>
3 の倍数のトランプカード 1. はじめに [Java アプレット ] [Java アプリケーション ] ここにトランプが 1 組あります ジョーカー 2 枚を除いて 52 枚を使います 3 の倍数は スペード クローバ ダイヤ ハートに それぞれ 3 と 6 と 9 と 12 の 4 枚ずつあるので 4 4=16 枚あります この 52 枚のトランプから 1 枚引いたとき そのカードが 3 の倍数である確率を考えます
More informationAssignment_.java /////////////////////////////////////////////////////////////////////// // 課題 星の画像がマウスカーソルを追従するコードを作成しなさい 次 ///////////////////
Assignment_.java 0 0 0 0 0 /////////////////////////////////////////////////////////// // 課題 次のようにマウスのカーソルに同期しメッセージを /////////////////////////////////////////////////////////// class Assignment_ extends
More information< F2D82518E9F8AD CC834F CC8CFC82AB82C68D4C>
2 次関数のグラフの向きと広がり [Java アプレット ] [Java アプリケーション ] 1. はじめに 2 2 y=ax のグラフについて x の係数 aが正のときと負のときでは グラフにどのような違いがあるでしょうか 2 2 y=ax のグラフについて x の係数 aが正のとき 係数 aの値が大きくなるにつれて グラフの広がりはどうなるでしょうか 2 2 y=ax のグラフについて x の係数
More informationJavaプログラミングⅠ
Java プログラミング Ⅰ 3 回目変数 今日の講義で学ぶ内容 変数とは 変数の使い方 キーボード入力の仕方 変 数 変 数 一時的に値を記憶させておく機能です 変数は 型 ( データ型ともいいます ) と識別子をもちます 2 型 変数に記憶できる値の種類です型は 値の種類に応じて次の 8 種類があり これを基本型といいます 基本型値の種類値の範囲または例 boolean 真偽値 true または
More informationMicrosoft Word - 92.doc
208 9.2 陰線消去 (1) 考え方 9.2 陰線消去 等高線は,3 次元形状を数値的に正確に表示するという意味では有効ですが, 直感的に図形を把握するのが困難です そこで, 普段, 見慣れた見取り図で表示することを試みましょう 曲線の XYZ 座標を 2 次元に平行投影するのが, 最も簡単に見取り図を表示する方法です 図 9-3 に示す式が平行投影における変換式です z,y X Y j j j
More informationMicrosoft Word - Cプログラミング演習(10)
第 10 回 (6/25) 3. ファイルとその応用 (3) ファイルの更新 シーケンシャルファイルの更新 シーケンシャルファイルでは, 各レコードが可変長で連続して格納されており, その中の特定のレコードを変更することができない そこで一般的には, マスタファイルからデータを取り出し, 更新処理を行ったあとに新マスタファイルに書き込む 注 ) マスタファイル : 主ファイル, 基本ファイルと呼ばれるファイルで内容は比較的固定的であり,
More informationJava プログラミング Ⅰ 7 回目 switch 文と論理演算子 今日の講義講義で学ぶ内容 switch 文 論理演算子 条件演算子 条件判断文 3 switch 文 switch 文 式が case のラベルと一致する場所から直後の break; まで処理しますどれにも一致致しない場合 def
Java プログラミング Ⅰ 7 回目 switch 文と論理演算子 今日の講義講義で学ぶ内容 switch 文 論理演算子 条件演算子 条件判断文 3 switch 文 switch 文 式が case のラベルと一致する場所から直後の まで処理しますどれにも一致致しない場合 default: から直後の まで処理します 式の結果 ラベル 定数 整数または文字 (byte, short, int,
More informationMicrosoft Word - C言語研修 C++編 3.doc
2006/05/10 オブジェクト指向... 3 1 クラスの継承... 3 2 継承の書式... 3 3 protected... 5 4 メンバ関数のオーバーライド... 6 5 クラスの型キャスト... 7 6 仮想関数... 8 2 オブジェクト指向 1 クラスの継承 クラスには 継承 という機能があります 継承とは 既にあるクラスを元に 新しいクラスを作る 機能です 継承元のクラスを 親クラス
More informationスライド 1
C# の基本 ~ ファイル読み込み ~ 今回学ぶ事 今回はファイル読み書きに必要 BinaryReader クラスについて記載する ファイル参照ダイアログである OpenFileDialog クラスについても理解を深める また Bitmap クラスを用いた Bitmap ファイルの読み込み方法についても学ぶ フォーム作り まず label picturebox を配置する ツールボックスより左クリックで選択する
More informationSmartBrowser_document_build30_update.pptx
SmartBrowser Update for ios / Version 1.3.1 build30 2017 年 8 月 株式会社ブルーテック 更新内容 - 概要 ios Version 1.3.1 build28 の更新内容について 1. 設定をQRから読み込み更新する機能 2.URLをQRから読み込み画面遷移する機能 3.WEBページのローカルファイル保存と外部インテントからの起動 4.JQuery-LoadImageライブラリの組み込み
More informationPowerPoint Presentation
知能システム論 1 (9) 2015.6.17 情報システム学研究科情報メディアシステム学専攻知能システム学講座末廣尚士 13. アームモデルの Python による表現 理想ロボット :ArmWithHand 構造は関係なし move: 手先や持った物を動かす ハンド :Hand open, close, width アームのリンクの計算 :Link set_jparam シリアルリンクアーム :LinkedArm
More informationコンピュータグラフィックスS 演習資料
2015/5/26 コンピュータグラフィックスS 演 習 資 料 第 2 回 ポリゴンモデルの 描 画 九 州 工 業 大 学 情 報 工 学 部 システム 創 成 情 報 工 学 科 講 義 担 当 : 尾 下 真 樹 1. 準 備 : 前 回 の 演 習 本 日 の 演 習 は 前 回 の 演 習 で 作 成 したプログラムを 引 き 続 き 修 正 していく もし 前 回 の 演 習 を 行
More informationC のコード例 (Z80 と同機能 ) int main(void) { int i,sum=0; for (i=1; i<=10; i++) sum=sum + i; printf ("sum=%d n",sum); 2
アセンブラ (Z80) の例 ORG 100H LD B,10 SUB A LOOP: ADD A,B DEC B JR NZ,LOOP LD (SUM),A HALT ORG 200H SUM: DEFS 1 END 1 C のコード例 (Z80 と同機能 ) int main(void) { int i,sum=0; for (i=1; i
More information第3章 OpenGL の基礎
3 OpenGL April 11, 2017 1 / 28 3.1 ( ) OpenGL OpenGL 2 / 28 3.2 OpenGL OpenGL OpenGL (Open Graphics Library) Silicon Graphics, Inc. 2 3 API (Application Program Interface) [4] UNIX OS Windows Macintosh
More informationMicrosoft Word - no204.docx
2. ファイル処理 2.1 ファイル処理の基本いままでは プログラムを実行したとき 入力はキーボードから入れていました また その結果を画面で確認していました 簡単なものならそれでもいいのですが 複雑な入力はファイルから読み込んだり 結果は画面で見るだけでなくファイルに保存できればよいでしょう ここでは ファイル処理について説明します 使う関数のプロトタイプは次のとおりです FILE *fopen(const
More information教材ドットコムオリジナル教材 0から始めるiアフ リ リファレンス i アプリ簡易リファレンス ver i アプリ Java 独自のメソッド (1)iアプリの命令を使えるようにする import com.nttdocomo.ui.*; (2) 乱数を使う import java.u
i アプリ簡易リファレンス ver0.1.5.1 1.i アプリ Java 独自のメソッド (1)iアプリの命令を使えるようにする import com.nttdocomo.ui.*; (2) 乱数を使う import java.util.random; int ; Random =new Random(); =Math.abs(.nextInt()% ); 0~ まで乱数を発生させます (3) 機種ごとの縦横幅を調べる
More informationMicrosoft PowerPoint - kougi8.ppt
C プログラミング演習 第 8 回構造体とレコードデータファイル 1 例題 1. バイナリファイル形式のファイル からのデータ読み込み 次のような名簿ファイル ( バイナリファイル形式 ) を読み込んで, 画面に表示するプログラムを作る name Ken Bill Mike age 20 32 35 address NewYork HongKong Paris 名簿ファイル 2 #include "stdafx.h"
More information問 1 図 1 の図形を作るプログラムを作成せよ 但し ウィンドウの大きさは と し 座標の関係は図 2 に示すものとする 図 1 作成する図形 原点 (0,0) (280,0) (80,0) (180,0) (260,0) (380,0) (0,160) 図 2 座標関係 問 2
問 1 図 1 の図形を作るプログラムを作成せよ 但し ウィンドウの大きさは 400 200 と し 座標の関係は図 2 に示すものとする 図 1 作成する図形 原点 (0,0) (280,0) (80,0) (180,0) (260,0) (380,0) (0,160) 図 2 座標関係 問 2 for 文を用いて図 3 の様な図形を描くプログラムを作成せよ 但し ウィンドウのサイズは 300 300
More informationMicrosoft PowerPoint - ruby_instruction.ppt
Ruby 入門 流れ Ruby の文法 画面に出力 キーボードから入力 数値 文字列 変数 配列 ハッシュ 制御構造 ( 分岐 繰り返しなど ) if while case for each 関数 クラス Ruby とは プログラミング言語 インタプリタ言語 オブジェクト指向 国産 ウェブアプリケーションフレームワーク RubyOnRails で注目 弊社での Web アプリケーション開発に利用 画面に出力
More informationPowerPoint プレゼンテーション
1 05 テキストフゔルからの入力 と 別のフォームを開く をいっぺんにやる星座を描く 1 今回作成するゕプリケーションの概要 座標の記入されているテキストフゔイルを読み込んで 表示ただし 表示するのは別のウィンドウ ( フォーム ) 行われる動作 [1] 座標の記入されているテキストフゔルを指定する [2] テキストフゔルで読み込んだ内容をテキストボックスにそのまま表示する [3] Draw ボタンをクリックすると別のウゖンドウが開く
More informationJava言語 第1回
Java 言語 第 8 回ウインドウ部品を用いる (1) 知的情報システム工学科 久保川淳司 kubokawa@me.it-hiroshima.ac.jp 前回の課題 (1) マウスを使って, 前回課題で作成した 6 4 のマスの図形で, \ をマウスクリックによって代わるようにしなさい 前回の課題 (2) import java.applet.applet; import java.awt.*;
More informationAndroid Layout SDK プログラミング マニュアル
プログラミングマニュアル Version 1.3.0 用 更新履歴 年月日 バージョン 履歴 2014.09.08 1.2.0.0 新規 (Layout Utilities ユーザーズ ガイド ) 2016.08.16 1.3.0.0 モバイル端末用レイアウトで直線部品と矩形部品に対応 モバイル端末用レイアウトファイルを CLFX から XML へ変更 Layout Print Engine から
More informationMicrosoft PowerPoint - kougi2.ppt
C プログラミング演習 第 2 回 Microsoft Visual Studio.NET を使ってみよう 説明 例題 1. プログラム実行の体験 コンピュータを役に立つ道具として実感する 次ページのプログラムを使って, Microsoft Visual Studio.NETでの C++ ソースファイル編集, ビルド, テスト実行の一連の過程を体験する 例題 1 のプログラムの機能 計算の繰り返し
More informationProg2_10th
2016 年 12 月 8 日 ( 木 ) 実施 効果音の付加 SoundPool とは Android には音を処理するクラスが複数用意されているが, その中で SoundPool は, 予め音のデータをメモリ上に読み込んで再生するため, 長い音楽よりも短い音を扱うのに適している また,SoundPool では遅延が無いので, 効果音を付加したい場面で用いられる 授業の準備 1)Android Studio
More informationDiMP Users Manual Yuichi Tazaki
DiMP Users Manual Yuichi Tazaki 3 1 5 2 7 2.1............................. 7 2.2........................... 7 3 DiMP 9 3.1............................... 9 3.2........................... 10 3.3...................................
More information< F2D E E6A7464>
ピタゴラス数 [Java アプレット ] [Java アプリケーション ] 1. はじめに 2 2 2 三平方の定理 a +b =c を満たす3つの自然数の組 ( a, b, c) をピタゴラス数と言います ピタゴラス数の最も簡単な例として (3,4,5) がありますね このピタゴラス数を求めるには ピタゴラスの方法とプラトンの方法の2つの方法があります 2 2 ピタゴラス数 (a,b,c) に対して
More information< F2D82518E9F8AD CC95BD8D7388DA93AE2E6A7464>
2 次関数のグラフの平行移動 [Java アプレット ] [Java アプリケーション ] 1. はじめに 2 2 y=ax のグラフとy=a(x-b) +c のグラフは 位置は違うけれど 形も広がりも全く同じです 2 2 y=a(x-b) +c のグラフは y=ax のグラフをx 軸方向に ( 右方向に ) +b y 軸方向に ( 上方向に ) +c だけ平行移動したものです 2 シミュレーションソフト
More informationPowerPoint プレゼンテーション
複雑系科学演習 1 コンピュータグラフィックス 担当畔上秀幸情報科学研究科複雑系科学専攻 今日の話題 STL ファイルを読み込んで表示する. STL データをどのようなデータ構造に格納しているか? 配列を用いる方法 構造体を用いる方法 読み込んだデータをどのように使うか? lesson8_1.c の説明 solid NOTITLE facet normal 00e+00 000e+00 1.000000e+00
More information‚æ4›ñ
( ) ( ) ( ) A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9 (OUS) 9 26 1 / 28 ( ) ( ) ( ) A B C D Z a b c d z 0 1 2 9 (OUS) 9
More informationMicrosoft PowerPoint - 13.ppt [互換モード]
第 13 回構造体 1 今回の目標 構造体を理解する 構造体の定義の仕方を理解する 構造体型を理解する 構造体型の変数 引数 戻り値を理解する 複素数同士を足し算する関数を作成し その関数を利用するプログラムを作成する 2 複素数の足し算 複素数は実部と虚部の2つの実数で 表現される z = a+ bi z = a + bi z = a + b i 2 つの複素数 1 1 1 と 2 2 2 の和
More informationプログラミング基礎
C プログラミング 演習 アルゴリズム基礎論 演習 第 10 回 今後の予定 12/22( 月 ) 期末試験 (60 分間 ) 場所 :A1611 時間 :16:20~17:20 課題の最終提出締切 :12/19( 金 ) これ以降の新規提出は評価されない 12/22までに最終状況を提示するので, 提出したのに や になってる人は自分の提出内容や提出先を再確認した上で12/26までに問い合わせること
More informationField Logic, Inc. 標準モード 3D モデル作成 配置編 Field Logic, Inc. 第 1 版
Field Logic, Inc. 標準モード 3D モデル作成 配置編 Field Logic, Inc. 第 1 版 目次 1. 初めに... 1 本書の概要 ( 学習のポイント )... 1 2. Google SketchUp の起動... 2 3. 単純な形状をした工場の 3D モデルを作成... 3 3D モデルの作成... 3 工場の 3D モデルを STL 形式のファイルとして出力...
More informationA, K, Q, J, 10, 9, 8, 7, 6, 5, 4, 3,
40 2 1. 2 2. 52 3. A, K, Q, J, 10, 9, 8, 7, 6, 5, 4, 3, 2 4. 13 5. 6. 7. 8. 9. 13 10. 11. 12. 1 VC++ VC++ Visual C++ Professional 2010 Visual C++ 2010 express Windows whist 2 OK] 3 Form1 size 800, 500
More informationOpenGL & GLUTの基本関数の説明
コンピュータグラフィックス S 演習資料 OpenGL & GLUT の基本関数の説明 1. OpenGL & GLUT 2. GLUT 2.1. GLUT void glutinit( int argc, char ** argv ); glut void glutinitdysplaymode( unsigned int mode ); mode void glutinitwindowsize(
More information/*p7-1-1*/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 /* e8.c Copyright (c) 2003 by T. HAYASHI and
More information1 C STL(1) C C C libc C C C++ STL(Standard Template Library ) libc libc C++ C STL libc STL iostream Algorithm libc STL string vector l
C/C++ 2007 6 18 1 C STL(1) 2 1.1............................................... 2 1.2 stdio................................................ 3 1.3.......................................... 10 2 11 2.1 sizeof......................................
More informationMicrosoft PowerPoint - 12.ppt [互換モード]
第 12 回構造体 1 今回の目標 構造体を理解する 構造体の定義の仕方を理解する 構造体型を理解する 構造体型の変数 引数 戻り値を理解する 複素数同士を足し算する関数を作成し その関数を利用するプログラムを作成する 2 複素数の足し算 複素数は実部と虚部の2つの実数で 表現される 表現される z = a+ bi 2 つの複素数 z 1 = a 1+ bi 1 と z2 = a2 + b2i の和
More information< F2D82518CC282CC D2E6A7464>
2 個のさいころ 1. はじめに [Java アプレット ] [Java アプリケーション ] 2 個のさいころを同時に投げたときの目の出方を考えてみましょう この 2 個のさいころをそれぞれ さいころ Ⅰ さいころ Ⅱ とすると その目の出方は順に 1 1 2 1 3 1 4 1 5 1 6 1 1 2 2 2 3 2 4 2 5 2 6 2 1 3 2 3 3 3 4 3 5 3 6 3 1 4
More information人工知能入門
藤田悟 黄潤和 探索とは 探索問題 探索解の性質 探索空間の構造 探索木 探索グラフ 探索順序 深さ優先探索 幅優先探索 探索プログラムの作成 バックトラック 深さ優先探索 幅優先探索 n 個の ueen を n n のマスの中に 縦横斜めに重ならないように配置する 簡単化のために 4-ueen を考える 正解 全状態の探索プログラム 全ての最終状態を生成した後に 最終状態が解であるかどうかを判定する
More informationProg1_15th
2012 年 7 月 26 日 ( 木 ) 実施構造体と typedef typedef 宣言によって,struct 構造体タグ名という表記を再定義し, データ型名のように扱うことができる 構文は typedef struct 構造体タグ名 再定義名 ; となり, この場合の構造体変数の宣言は, 再定義名を用いて行うことができる なお, ここでは 構造体タグ名は省略可能である 構造体を指すポインタ
More informationMicrosoft Word - no12.doc
7.5 ポインタと構造体 構造体もメモリのどこかに値が格納されているのですから 構造体へのポインタ も存在します また ポインタも変数ですから 構造体のメンバに含めることができます まずは 構造体へのポインタをあつかってみます ex53.c /* 成績表 */ #define IDLENGTH 7 /* 学籍番号の長さ */ #define MAX 100 /* 最大人数 */ /* 成績管理用の構造体の定義
More information81 /******************************************************************************/ 82 /* スレーブアドレスの設定 */ 83 /*****************************************
1 /******************************************************************************/ 2 /* IIC(Inter IC Bus) の制御 */ 3 /******************************************************************************/ 4 /*
More information