void RecordedCamera::initializeViewUp() { if(m_translationPositions.isSet() && m_translationPositions.getValue().size() > 1) { Vec3 zAxis = m_translationPositions.getValue()[1] - m_translationPositions.getValue()[0]; zAxis.normalize(); Vec3 xRef(1,0,0); // Initialize the view-up vector with the reference vector the "most perpendicular" to zAxis. m_cameraUp.setValue(xRef); double normCrossProduct = cross(zAxis,xRef).norm(); for(int i = 1; i<3; ++ i) { Vec3 vecRef(0,0,0); vecRef[i] = 1; if(cross(zAxis,vecRef).norm() >= normCrossProduct ) { normCrossProduct = cross(zAxis,vecRef).norm(); m_cameraUp.setValue(vecRef); } } } }
// 初期化 IZ_BOOL CMyAppl::Init( HINSTANCE hInst, HWND hDeviceWindow, HWND hFocusWindow) { static const IZ_UINT MEM_SIZE = 16 * 1024 * 1024; // 16MB static IZ_UINT8 MEM_BUF[MEM_SIZE]; // システム初期化 IZ_BOOL ret = CMySystem::GetInstance().Init(MEM_SIZE, MEM_BUF); VRETURN(ret); // グラフィックスデバイス設定 izanagi::SGraphicsDeviceInitParams sParams; { sParams.hFocusWindow = hFocusWindow; sParams.hDeviceWindow = hDeviceWindow; sParams.Windowed = IZ_TRUE; // 画面モード(ウインドウモード) sParams.BackBufferWidth = SCREEN_WIDTH; // バックバッファの幅 sParams.BackBufferHeight = SCREEN_HEIGHT; // バックバッファの高さ sParams.MultiSampleType = D3DMULTISAMPLE_NONE; // マルチ・サンプリングの種類 sParams.Adapter = D3DADAPTER_DEFAULT; sParams.DeviceType = D3DDEVTYPE_HAL; sParams.BehaviorFlags = D3DCREATE_HARDWARE_VERTEXPROCESSING; sParams.DepthStencilFormat = D3DFMT_D24S8; sParams.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; } // デバイスリセット ret = CMySystem::GetInstance().GetGraphicsDevice()->Reset(sParams); VRETURN(ret); // デバッグフォント初期化 ret = CMySystem::GetInstance().InitDebugFont(); VRETURN(ret); // リセット用コールバックセット //CMySystem::GetInstance().GetGraphicsDevice()->SetResetCallBack(_ResetResource); // ステート初期化 ret = CStateManager::GetInstance().Init(); VRETURN(ret); // カメラ初期化 { izanagi::math::CVector vecPos(0.0f, 0.0f, 20.0f, 1.0f); izanagi::math::CVector vecRef(0.0f, 0.0f, 0.0f, 1.0f); izanagi::math::CVector vecUp(0.0f, 1.0f, 0.0f, 1.0f); CMyCamera::GetInstance().Init( vecPos, vecRef, vecUp, 1.0f, 1000.0f, izanagi::math::CMath::Deg2Rad(90.0f), (IZ_FLOAT)SCREEN_WIDTH / SCREEN_HEIGHT); } #if 1 // パッド初期化 { D_INPUT* pInput = NULL; HRESULT hr = DirectInput8Create( hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&pInput, NULL); IZ_ASSERT(SUCCEEDED(hr)); ret = CMySystem::GetInstance().InitKeyboard(); if (ret) { izanagi::SInputDeviceInitParam sInitParam(pInput, hDeviceWindow); CMySystem::GetInstance().GetKeyboard()->Init(&sInitParam); } pInput->Release(); //VRETURN(ret); } #endif return IZ_TRUE; }