public XMU555(float[] array, bool w) { XMVector v = XMVector.LoadFloat3(new XMFloat3(array)); v.W = w ? 1.0f : 0.0f; this = v; }
public override void FrameMove(double fElapsedTime) { if (IsKeyDown(m_aKeys[(int)SdkCameraKey.Reset])) { Reset(); } // If no dragged has happend since last time FrameMove is called, // and no camera key is held down, then no need to handle again. if (!m_bDragSinceLastUpdate && m_cKeysDown == 0) { return; } m_bDragSinceLastUpdate = false; //// If no mouse button is held down, //// Get the mouse movement (if any) if the mouse button are down //if( m_nCurrentButtonMask != 0 ) // UpdateMouseDelta( fElapsedTime ); GetInput(m_bEnablePositionMovement, m_nCurrentButtonMask != 0); // Get amount of velocity based on the keyboard input and drag (if any) UpdateVelocity(fElapsedTime); // Simple euler method to calculate position delta XMVector vPosDelta = XMVector.LoadFloat3(m_vVelocity) * (float)fElapsedTime; // Change the radius from the camera to the model based on wheel scrolling if (m_nMouseWheelDelta != 0 && m_nZoomButtonMask == SdkCameraMouseKeys.Wheel) { m_fRadius -= m_nMouseWheelDelta * m_fRadius * 0.1f / 120.0f; } m_fRadius = Math.Min(m_fMaxRadius, m_fRadius); m_fRadius = Math.Max(m_fMinRadius, m_fRadius); m_nMouseWheelDelta = 0; // Get the inverse of the arcball's rotation matrix XMMatrix mCameraRot = m_ViewArcBall.GetRotationMatrix().Inverse(); // Transform vectors based on camera's rotation matrix XMVector vWorldUp = XMVector3.TransformCoord(XMVector.FromFloat(0.0f, 1.0f, 0.0f, 0.0f), mCameraRot); XMVector vWorldAhead = XMVector3.TransformCoord(XMVector.FromFloat(0.0f, 0.0f, 1.0f, 0.0f), mCameraRot); // Transform the position delta by the camera's rotation XMVector vPosDeltaWorld = XMVector3.TransformCoord(vPosDelta, mCameraRot); // Move the lookAt position XMVector vLookAt = m_vLookAt; vLookAt += vPosDeltaWorld; if (m_bClipToBoundary) { vLookAt = ConstrainToBoundary(vLookAt); } m_vLookAt = vLookAt; // Update the eye point based on a radius away from the lookAt position XMVector vEye = vLookAt - vWorldAhead * m_fRadius; m_vEye = vEye; // Update the view matrix XMMatrix mView = XMMatrix.LookAtLH(vEye, vLookAt, vWorldUp); m_mView = mView; XMMatrix mInvView = mView.Inverse(); mInvView.M41 = 0.0f; mInvView.M42 = 0.0f; mInvView.M43 = 0.0f; XMMatrix mModelLastRot = m_mModelLastRot; XMMatrix mModelLastRotInv = mModelLastRot.Inverse(); // Accumulate the delta of the arcball's rotation in view space. // Note that per-frame delta rotations could be problematic over long periods of time. XMMatrix mModelRot0 = m_WorldArcBall.GetRotationMatrix(); XMMatrix mModelRot = m_mModelRot; mModelRot *= mView * mModelLastRotInv * mModelRot0 * mInvView; if (m_ViewArcBall.IsBeingDragged() && m_bAttachCameraToModel && !IsKeyDown(m_aKeys[(int)SdkCameraKey.ControlDown])) { // Attach camera to model by inverse of the model rotation XMMatrix mCameraRotLast = m_mCameraRotLast; XMMatrix mCameraLastRotInv = mCameraRotLast.Inverse(); XMMatrix mCameraRotDelta = mCameraLastRotInv * mCameraRot; // local to world matrix mModelRot *= mCameraRotDelta; } m_mModelLastRot = mModelRot0; m_mCameraRotLast = mCameraRot; // Since we're accumulating delta rotations, we need to orthonormalize // the matrix to prevent eventual matrix skew XMVector xBasis = XMVector3.Normalize(XMVector.FromFloat(mModelRot.M11, mModelRot.M12, mModelRot.M13, mModelRot.M14)); XMVector yBasis = XMVector3.Cross(XMVector.FromFloat(mModelRot.M31, mModelRot.M32, mModelRot.M33, mModelRot.M34), xBasis); yBasis = XMVector3.Normalize(yBasis); XMVector zBasis = XMVector3.Cross(xBasis, yBasis); mModelRot.M11 = xBasis.X; mModelRot.M12 = xBasis.Y; mModelRot.M13 = xBasis.Z; mModelRot.M21 = yBasis.X; mModelRot.M22 = yBasis.Y; mModelRot.M23 = yBasis.Z; mModelRot.M31 = zBasis.X; mModelRot.M32 = zBasis.Y; mModelRot.M33 = zBasis.Z; // Translate the rotation matrix to the same position as the lookAt position mModelRot.M41 = vLookAt.X; mModelRot.M42 = vLookAt.Y; mModelRot.M43 = vLookAt.Z; m_mModelRot = mModelRot; // Translate world matrix so its at the center of the model XMMatrix mTrans = XMMatrix.Translation(-m_vModelCenter.X, -m_vModelCenter.Y, -m_vModelCenter.Z); XMMatrix mWorld = mTrans * mModelRot; m_mWorld = mWorld; }
public XMFloat3SharedExponent(float[] array) { this = XMVector.LoadFloat3(new XMFloat3(array)); }
public XMFloat3Packed(float[] array) { this = XMVector.LoadFloat3(new XMFloat3(array)); }
public XMU565(float[] array) { this = XMVector.LoadFloat3(new XMFloat3(array)); }