Exemplo n.º 1
0
        public virtual void Update(float dt)
        {
            _location = _location + _linearVelocity * dt;
            kQuat operationalAngularVelocity = new kQuat(_angularVelocity);

            operationalAngularVelocity.scl = operationalAngularVelocity.scl * dt;
            if (_angularVelocity.scl == 0.0f || _angularVelocity.scl == 2.0 * Math.PI)
            {
                // No angular velocity; keep old orientation
            }
            else if (_orientation.scl == 0.0f || _orientation.scl == 2.0 * Math.PI)
            {
                // Frame has not yet rotated; apply one step of velocity
                _orientation = operationalAngularVelocity;
            }
            else
            {
                // Convert both quaternions to operational; combine; revert to valued
                operationalAngularVelocity.convertValuedToOperational();
                _orientation.convertValuedToOperational();
                _orientation = operationalAngularVelocity * _orientation;
                _orientation.convertOperationalToValued();
            }

            while (_orientation.scl > 2.0 * Math.PI)
            {
                _orientation.scl = _orientation.scl - 2.0f * (float)Math.PI;
            }
            while (_orientation.scl < 0.0)
            {
                _orientation.scl = _orientation.scl + 2.0f * (float)Math.PI;
            }
            _orientation.normalize();
        }
Exemplo n.º 2
0
 public kQuat(kQuat o1)
 {
     scl = o1.scl;
     i   = o1.i;
     j   = o1.j;
     k   = o1.k;
 }
Exemplo n.º 3
0
        public static kQuat operator *(kQuat o1, kQuat o2)
        {
            kQuat toReturn = new kQuat();

            toReturn.scl = o1.scl * o2.scl - o1.i * o2.i - o1.j * o2.j - o1.k * o2.k;
            toReturn.i   = o1.scl * o2.i + o1.i * o2.scl + o1.j * o2.k - o1.k * o2.j;
            toReturn.j   = o1.scl * o2.j - o1.i * o2.k + o1.j * o2.scl + o1.k * o2.i;
            toReturn.k   = o1.scl * o2.k + o1.i * o2.j - o1.j * o2.i + o1.k * o2.scl;
            return(toReturn);
        }
Exemplo n.º 4
0
 public aObject()
 {
     Mesh = new aMesh();
     Mesh.loadCube(1.0f);
     _location        = new aVertex();
     _orientation     = new kQuat();
     _color           = new aColor();
     _linearVelocity  = new aVertex();
     _angularVelocity = new kQuat();
 }