//============================================================================== // Brief : 親のワールド変換行列の取得 // Return : void : なし // Arg : D3DXMATRIX* pOut : 値の格納アドレス //============================================================================== void Object::GetMatrixWolrdParent( D3DXMATRIX* pOut ) { // ワールド変換行列の更新 UpdateMatrixWorld(); // 親のワールド変換行列と合成 if( pParent_ != nullptr ) { D3DXMATRIX matrixWorldParent; // 親のワールド変換行列 pParent_->UpdateMatrixWorld(); pParent_->GetMatrixWolrdParent( &matrixWorldParent ); matrixWorld_ *= matrixWorldParent; } // ワールド変換行列を返す if( pOut != nullptr ) { *pOut = matrixWorld_; } }
//============================================================================== // Brief : 更新処理 // Return : void : なし // Arg : void : なし //============================================================================== void Object::Update( void ) { // ワールドマトリクスの更新 if( needsUpdate_ || pParent_ != nullptr ) { // ワールド変換行列の更新 UpdateMatrixWorld(); // 親の行列と合成 if( pParent_ != nullptr ) { GetMatrixWolrdParent( &matrixWorld_ ); } // 描画情報の更新 if( pGraphic_ != nullptr ) { pGraphic_->SetMatrixWorld( matrixWorld_ ); } } }
GRAPHICS::GRAPHICS(HWND in_hwnd) : hwnd(in_hwnd) { try { d3d = Direct3DCreate9(D3D_SDK_VERSION); if (!d3d) throw 0; try { CreateDirect3DDevice(); try { InitVBCube(); } catch(...) { d3ddev->Release(); throw; } } catch(...) { d3d->Release(); throw; } } catch(...) { throw; } InitLights(); InitMaterials(); strWorld.rotationY = 0.0f; strWorld.rotationZ = 0.0f; strView.camera_pos = D3DXVECTOR3(6.0f, 0.0f, 0.0f); strView.look_at_point = D3DXVECTOR3(0.0f, 0.0f, 0.0f); strView.up_direction = D3DXVECTOR3(0.0f, 0.0f, 1.0f); strProjection.angle = 45; strProjection.plane_near = 1.0f; strProjection.plane_far = 100.0f; UpdateMatrixWorld(); UpdateMatrixView(); UpdateMatrixProjection(); }