void FPSCamera::LookAt(float3 posCamera, float3 posTarget) { m_pos = posCamera; setTranslation(&m_viewToWorld, m_pos); // Calculate angles to look at posTarget float3 vecToTarget = posTarget - posCamera; ASSERT_WARN(!all(isnear(vecToTarget, 0.0f))); vecToTarget = normalize(vecToTarget); m_yaw = atan2f(-vecToTarget.z, vecToTarget.x); m_pitch = asinf(vecToTarget.y); // Update matrices UpdateOrientation(); UpdateWorldToClip(); }
void MayaCamera::LookAt(float3 posCamera, float3 posTarget) { m_posTarget = posTarget; m_pos = posCamera; // Calculate angles to look at posTarget float3 vecToTarget = posTarget - posCamera; ASSERT_WARN(!all(isnear(vecToTarget, 0.0f))); m_radius = length(vecToTarget); vecToTarget /= m_radius; m_yaw = atan2f(-vecToTarget.z, vecToTarget.x); m_pitch = asinf(vecToTarget.y); // Update matrices UpdateOrientation(); m_pos = m_posTarget + m_radius * m_viewToWorld[2].xyz; setTranslation(&m_viewToWorld, m_pos); UpdateWorldToClip(); }
void QGraphicsItemResizable::mousePressEvent(QGraphicsSceneMouseEvent *event) { ispressed = true; if (select) select = false; else select = true; if (select) grabKeyboard(); else ungrabKeyboard(); first = event->scenePos();// prendo la posizione isResize = isnear(first);// vedo se è in basso a destra if (isResize) QApplication::setOverrideCursor(QCursor(Qt::SizeFDiagCursor));// setto il cursore di resize else QApplication::setOverrideCursor(QCursor(Qt::DragMoveCursor));// setto il cursore di spostamento prepareGeometryChange(); update(boundingRect()); }