Esempio n. 1
0
//------------------------------------------------------------------------------
// setComputematrix4 () - for Angle types
//------------------------------------------------------------------------------
bool Transform::setComputematrix4(const Angle* const sc4obj)
{
    bool ok = true;
    if (nv == 0 && isClassType(typeid(Rotation))) {
        Radians rad;
        v[nv++] = static_cast<LCreal>(rad.convert(*sc4obj));
        computeMatrix();
    }
    else {
        std::cerr << "Transform::setComputematrix4:  Invalid Angle type or input" << std::endl;
        ok = false;
    }
    return ok;
}
Esempio n. 2
0
    void Camera::rotate(Radians angle)
    {
        Quat rot = glm::angleAxis(angle.value(), mUpReal);

        mFront = Vec3(rot * mFront).normalized();
        mRight = Vec3(rot * mRight).normalized();

        mMatrixUpdateFlags |= MatrixRotationUpdated;
        updateAngles();
    }
Esempio n. 3
0
    void Camera::mouseLook(Radians dtX, Radians dtY)
    {
        float angleXZ = getHorizontalAngle().value();
        float angleY = getVerticalAngle().value();

        angleXZ -= dtX.value(); // -? lol
        angleY -= dtY.value();  // same
        angleY = glm::clamp(angleY, -PI_2, PI_2);

        float len = Vec3(mAt - mEye).length();
        Vec3 at = mEye + Vec3(len * sinf(angleXZ) * cosf(angleY),
                              len * sinf(angleY),
                              len * cosf(angleXZ) * cosf(angleY));

        //gLog.trace("%f, %f, len %f\n", angleXZ, angleY, len);
        //gLog.trace("eye: %s\n", utils::toString(mEye).c_str());
        //gLog.trace("at: %s\n", utils::toString(mAt).c_str());
        //gLog.trace("at - eye: %s\n", utils::toString(Vec3(mAt - mEye)).c_str());
        //gLog.trace("new at = %s\n", utils::toString(Vec3(len * sinf(angleXZ) * cosf(angleY),
                                                     //len * sinf(angleY),
                                                     //len * cosf(angleXZ) * cosf(angleY))).c_str());

        lookAt(mEye, at, mUp);
    }
Esempio n. 4
0
	float sin(const Radians &rad)
	{
		return sinf(rad.value());
	}
Esempio n. 5
0
	float atan(const Radians &rad)
	{
		return atanf(rad.value());
	}
Esempio n. 6
0
	float acos(const Radians &rad)
	{
		return acosf(rad.value());
	}
Esempio n. 7
0
//------------------------------------------------------------------------------
// convert() -- converts from radians/sec to desired angle/time ratio:
//    NOTE: This ignores values of input - only the object type is used
//------------------------------------------------------------------------------
LCreal AngularVelocity::convert(Angle* newAngleUnit, Time* newTimeUnit)
{

    //Init a num to -1 as a check:
    LCreal desiredAngle = -1.0f;
    LCreal desiredTime = -1.0f;
    LCreal desiredResult = -1.0f;

    //Set input opject's internal value to 1 as a precaution:
    newAngleUnit->setValue(1);
    newTimeUnit->setValue(1);

    //Take the internal unit and create an object of Angle to convert angles:
    Radians* internalRadians = new Radians(static_cast<LCreal>(angle));

    //Find out what units the angle is in:
    if (dynamic_cast<Degrees*>(newAngleUnit) != nullptr)
    {
        //New angle is in degrees:
        Degrees* degrees = new Degrees;
        desiredAngle = static_cast<LCreal>(degrees->convert(*internalRadians));
        degrees->unref();
    }
    else if (dynamic_cast<Radians*>(newAngleUnit) != nullptr)
    {
        //New angle is in radians:
        desiredAngle = angle;
    }
    else if (dynamic_cast<Semicircles*>(newAngleUnit) != nullptr)
    {
        //New angle is in semicircles:
        Semicircles* semicircles = new Semicircles;
        desiredAngle = static_cast<LCreal>(semicircles->convert(*internalRadians));
        semicircles->unref();
    }
    else
    {
        //Give Error - Not sure what type it is:
        std::cerr << "Angle Conversion Type Not Found." << std::endl;
    }
    internalRadians->unref();

    //Find out what units the time input is in - do not use built in convert - very easy to do by hand:
    Seconds* q = dynamic_cast<Seconds*>(newTimeUnit);
    if(q != nullptr)
    {
        desiredTime = time;
    }
    else if(dynamic_cast<MilliSeconds*>(newTimeUnit) != nullptr)
    {
        //Time in milliseconds:
        desiredTime = time*1000;
    }
    else if(dynamic_cast<Minutes*>(newTimeUnit) != nullptr)
    {
        //Time in minutes:
        desiredTime = time/60;
    }
    else if(dynamic_cast<Hours*>(newTimeUnit) != nullptr)
    {
        //Time in hours:
        desiredTime = time/3600;
    }
    else if(dynamic_cast<Days*>(newTimeUnit) != nullptr)
    {
        //Time in days:
        desiredTime = time/86400;
    }
    else
    {
        //Give Error - Not sure what type it is:
        std::cerr << "Time Conversion Type Not Found." << std::endl;
    };

    desiredResult = desiredAngle/desiredTime;

    return desiredResult;

}
Esempio n. 8
0
 void Camera::rotateAround(Radians angle)
 {
     Quat rot = glm::angleAxis(angle.value(), mUpReal);
     lookAt(mAt + (rot * (mEye - mAt)), mAt, mUp);
 }
Esempio n. 9
0
 void Camera::rotate(const Vec3& axis, Radians angle)
 {
     Quat rot = glm::angleAxis(angle.value(), axis.normalized());
     lookAt(mEye, mEye + (rot * (mAt - mEye)), mUp);
 }
Esempio n. 10
0
 Degrees::Degrees(const Radians &r) : m_value(double(r.toDegrees()))
 {
 }