コード例 #1
0
        void Update()
        {
            Vector3 axis         = Vector3.down;
            float   angularSpeed = 1.0f;
            float   dt           = m_timeScale * Time.fixedDeltaTime;

            // render
            Quaternion baseRot = Quaternion.FromToRotation(Vector3.one, Vector3.up);

            DebugUtil.DrawBox(Vector3.zero, m_quatClosedForm * baseRot, Vector3.one, m_closedColor, true, DebugUtil.Style.FlatShaded);
            DebugUtil.DrawBox(Vector3.zero, m_quatPower * baseRot, 1.05f * Vector3.one, m_powerColor, true, DebugUtil.Style.Wireframe);
            DebugUtil.DrawBox(Vector3.zero, m_quatDerivative * baseRot, 1.1f * Vector3.one, m_derivativeColor, true, DebugUtil.Style.Wireframe);

            // integrate
            Quaternion v = QuaternionUtil.AxisAngle(axis, angularSpeed);
            Vector3    o = angularSpeed * axis;

            m_quatClosedForm = QuaternionUtil.Normalize(QuaternionUtil.AxisAngle(axis, (m_angle += angularSpeed * dt)));
            m_quatPower      = QuaternionUtil.Normalize(QuaternionUtil.Integrate(m_quatPower, v, dt));
            m_quatDerivative = QuaternionUtil.Normalize(QuaternionUtil.Integrate(m_quatDerivative, o, dt));

            if (Input.GetKey(KeyCode.Space))
            {
                Reset();
            }
        }
コード例 #2
0
    private void DrawBoxDimensions(Vector3 center)
    {
        Vector3 dimensions = new Vector3
                             (
            1.0f + 0.2f * Mathf.Sin(m_phase),
            1.0f + 0.2f * Mathf.Sin(m_phase + 0.6f * Mathf.PI),
            1.0f + 0.2f * Mathf.Sin(m_phase + 1.2f * Mathf.PI)
                             );

        DebugUtil.DrawBox(center + m_basePos, m_baseRotQuat, dimensions, Color.white);
    }
コード例 #3
0
    private void DrawBoxDimensions(Vector3 center)
    {
        Vector3 dimensions = new Vector3
                             (
            1.0f + 0.2f * Mathf.Sin(m_phase),
            1.0f + 0.2f * Mathf.Sin(m_phase + 0.6f * Mathf.PI),
            1.0f + 0.2f * Mathf.Sin(m_phase + 1.2f * Mathf.PI)
                             );

        Color color = (m_style == DebugUtil.Style.Wireframe ? m_wireframeColor : new Color(0.7f, 0.2f, 0.2f));

        DebugUtil.DrawBox(center + m_basePos, m_baseRotQuat, dimensions, color, true, m_style);
    }