예제 #1
0
	//----------------------------------------------------------------------------
	// Quaternion
	Quaternion StringConv::quaternionFromString(const String& _str, size_t _start, size_t& _readcount)
	{
		Vector3 vec = fromString<Vector3>(_str, _start, _readcount);
		if(!_readcount)
			return Quaternion::ZERO;

		Radian xAngle(Degree(vec.x));
		Radian yAngle(Degree(vec.y));
		Radian zAngle(Degree(vec.z));
		Matrix3 mat;
		mat.FromEulerAnglesXYZ(xAngle, yAngle, zAngle);
		Quaternion q(mat);
		return q;
	}
예제 #2
0
파일: Element.cpp 프로젝트: chnlkw/16thAI9
void Element::go(float delta)
{
    if (gif)
    {
        tex = TEX[gif_count];
        gif_count = (gif_count + 1) % TEX.size();
    }

    if (!speed) return;

    if (moveto == 0)
    {
        pos += v * delta;
    }

    if (moveto == 1)
    {
        float len = length(Goal - pos);
        float vlen = length(v * delta);
        if (vlen >= len)
        {
            pos = Goal;
            speed = false;
        }
        else
        {
            pos += v * delta;
        }
    }

    if (moveto == 2)
    {
        t = t + 0.015;
        v = Start*2*(t-1) + Control*2*(1-2*t) + Goal*2*t;
        A = xAngle(v)/PI*180;
        if (t >= 1)
        {
            pos = Goal;
            speed = false;
        }
        else
        {
            pos = Start * (1-t)*(1-t) + Control*2*t*(1-t) + Goal*t*t;
        }
    }
}