LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); switch (wmId) { case IDM_ABOUT: break; case IDM_EXIT: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_ERASEBKGND: return 1; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); Paint(hWnd, ps.hdc); EndPaint(hWnd, &ps); break; case WM_KEYDOWN: switch (wParam) { case VK_LEFT: { Matrix44 mat; mat.SetRotationZ(0.1f); g_matLocal1 *= mat; } break; case VK_RIGHT: { Matrix44 mat; mat.SetRotationZ(-0.1f); g_matLocal1 *= mat; } break; } break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
void CDlgCalc4x4::OnEnChangeEditAngle2() { UpdateData(); SECOND_VARIABLE second = (SECOND_VARIABLE)m_ComboSecond.GetCurSel(); CommonDataInterface *secondData = dynamic_cast<CommonDataInterface *>(m_Second[ m_ComboSecond.GetCurSel()]); if (!secondData) return; m_Second[ m_ComboSecond.GetCurSel()]->UpdateData(); Matrix44 mat; switch (second) { case VAR2_MAT_ROTATEX: mat.SetRotationX(m_Angle2); break; case VAR2_MAT_ROTATEY: mat.SetRotationY(m_Angle2); break; case VAR2_MAT_ROTATEZ: mat.SetRotationZ(m_Angle2); break; case VAR2_MAT_SCALE: mat.SetScale(Vector3(m_Angle2, m_Angle2, m_Angle2)); break; } secondData->SetMatrix(mat); }
void CDlgCalc4x4::OnEnChangeEditAngle1() { UpdateData(); FIRST_VARIABLE first = (FIRST_VARIABLE)m_ComboFirst.GetCurSel(); CommonDataInterface *firstData = dynamic_cast<CommonDataInterface *>(m_First[ m_ComboFirst.GetCurSel()]); if (!firstData) return; m_First[ m_ComboFirst.GetCurSel()]->UpdateData(); Matrix44 mat; switch (first) { case VAR1_MAT_ROTATEX: mat.SetRotationX(m_Angle1); break; case VAR1_MAT_ROTATEY: mat.SetRotationY(m_Angle1); break; case VAR1_MAT_ROTATEZ: mat.SetRotationZ(m_Angle1); break; case VAR1_MAT_SCALE: mat.SetScale(Vector3(m_Angle1, m_Angle1, m_Angle1)); break; } firstData->SetMatrix(mat); }
//--------------------------- // //--------------------------- Matrix44 Matrix44::GetBillboardZ() const { static Matrix44 matWorld; static Vector3 vDir; vDir.x = _13; vDir.y = _23; vDir.z = _33; if( vDir.x > 0.0F ) { matWorld.SetRotationZ( atanf( vDir.y / vDir.x ) + MATH_PI / 2 ); } else { matWorld.SetRotationZ( atanf( vDir.y / vDir.x ) - MATH_PI / 2 ); } //if..else if..else.. return matWorld; } //Matrix44::GetBillboardZ
void GCL::Node::SetOrientation( Real x,Real y,Real z ) { const WorldPoint4 backupPosition = mTransform[3]; Matrix44 xRot; xRot.SetRotationX(x); Matrix44 yRot; yRot.SetRotationY(y); Matrix44 zRot; zRot.SetRotationZ(z); mTransform = xRot * yRot * zRot; mTransform.SetPosition(backupPosition); }
/** @brief @date 2014-04-17 */ bool cParticle::Move(int elapseTime) { const float dt = (float)elapseTime * 0.001f; m_Velocity += Vector3(0, 3000.f * dt, 0); m_Pos += m_Velocity * dt; m_tm.SetWorld(m_Pos); Matrix44 mat; mat.SetRotationZ(m_Torq * dt); m_localTm *= mat; if (m_Pos.y > 1000.f) return false; return true; }
//------------------------------- // //------------------------------- void Vector3::RotateZ( float fAngle ) { matRot.SetRotationZ( fAngle ); *this *= matRot; } //Vector3::RotateZ