int test(int argc, char ** argv) { NUKLEI_TRACE_BEGIN(); /* Parse command line arguments */ TCLAP::CmdLine cmd(INFOSTRING + "Test App." ); /* Standard arguments */ TCLAP::ValueArg<int> niceArg ("", "nice", "Proccess priority.", false, NICEINC, "int", cmd); /* Custom arguments */ TCLAP::UnlabeledValueArg<std::string> fileArg ("file", "Nuklei file.", false, "", "filename", cmd); cmd.parse( argc, argv ); NUKLEI_ASSERT(setpriority(PRIO_PROCESS, 0, niceArg.getValue()) == 0); Quaternion q(1, 0, 0, 0); { Quaternion r; r.FromAxisAngle(Vector3::UNIT_Z, M_PI/2); q = r * q; std::cout << la::normalized(q) << std::endl; } { Quaternion r; r.FromAxisAngle(Vector3::UNIT_Z, M_PI); std::cout << la::normalized(r*q) << std::endl; } { Quaternion r; r.FromAxisAngle(Vector3::UNIT_Y, 90. / 180*M_PI); std::cout << la::normalized(r*q) << std::endl; } { Quaternion r; r.FromAxisAngle(Vector3::UNIT_Y, -90. / 180*M_PI); std::cout << la::normalized(r*q) << std::endl; } return 0; NUKLEI_TRACE_END(); }
void Entity::Rotate(const Vector3F &pAxis, f32 angle){ Matrix4 rotation; Quaternion quat; quat.FromAxisAngle(pAxis, angle); rotation.SetOrientation(quat); mModelMatrix = rotation * mModelMatrix; }
void ArcBallCameraController::RotateTargetRight(float angle_) { m_bRecomputeViewMatrix = true; Quaternion rot; rot.FromAxisAngle(Up(), -angle_); Vector3F dir = Direction() * m_fDistance; Vector3F vec; rot.Transform(dir, vec); //Vector3F::Transform(dir, rot, vec); m_Target += vec - dir; OrbitRight(-angle_); }
void ThirdPersonCamera::UpdateOrientation(real dt) { m_pitchDegrees *= dt; m_headingDegrees *= dt; m_rollDregrees *= dt; Quaternion rot; if (m_headingDegrees != real(0)) { rot.FromAxisAngle(m_targetYAxis, m_headingDegrees); m_orientation = m_orientation * rot; } if (m_pitchDegrees != real(0)) { rot.FromAxisAngle(WORLD_XAXIS, m_pitchDegrees); m_orientation = m_orientation * rot; } if(m_rollDregrees != real(0)) { rot.FromAxisAngle(WORLD_ZAXIS, m_rollDregrees); m_orientation = m_orientation * rot; } }
void DrawAxis(bgfx::VertexBufferHandle vertexHandle_, bgfx::ProgramHandle programhandle_) { CameraComponent *pCamera = GameInfo::Instance().GetActiveCamera(); Viewport &viewport = pCamera->GetViewport(); Matrix4 matProj, matWorld; //matWorld.CreateRotationZ(0.5f * MATH_PI); //matWorld.CreateTranslation(0.0f, 0.0f, -1.0f); //matWorld.CreateScale(1.0f / (float)CA_DEFAULT_WIDTH, 1.0f / (float)CA_DEFAULT_HEIGHT, 1.0f); //matWorld.CreateScale(0.989f, 1.0f, 1.0f); Vector3F scale(0.989f, 1.0f, 1.0f); Quaternion rot; rot.FromAxisAngle(Vector3F::UnitZ(), 0.5f * MATH_PI); matWorld.Transformation( nullptr, nullptr, &scale, nullptr, &rot, //rotation nullptr); matProj.OrthoOffCenter( static_cast<float>(viewport.X() * CA_DEFAULT_WIDTH), // TODO get screen size static_cast<float>(viewport.Y() * CA_DEFAULT_HEIGHT), static_cast<float>(viewport.Width() * CA_DEFAULT_WIDTH), static_cast<float>(viewport.Height() * CA_DEFAULT_HEIGHT), 0.0f, 1000.0f); bgfx::setViewTransform(1, NULL, matProj); //bgfx::setViewTransform(1, pCamera->GetViewMatrix(), pCamera->GetProjectionMatrix()); bgfx::setViewRect(1, 0, 0, Game::Instance()->GetWindow()->getSize().x, Game::Instance()->GetWindow()->getSize().y); bgfx::setTransform(matWorld); bgfx::setVertexBuffer(vertexHandle_); bgfx::setState(BGFX_STATE_RGB_WRITE | BGFX_STATE_MSAA | BGFX_STATE_PT_LINES); bgfx::submit(1, programhandle_); }
/** \param axis Axis. Should be normalized. \param angleDeg Angle in degrees. */ static Quaternion CreateFromAxisAngle( const Vec3& axis, float angleDeg ) { Quaternion q; q.FromAxisAngle( axis, angleDeg ); return q; }