Beispiel #1
0
IZ_BOOL StateMoveToItem::Enter(
    izanagi::IMemoryAllocator* allocator,
    izanagi::graph::CGraphicsDevice* device,
    izanagi::CValue& arg)
{
    PhotoItem* hitItem = (PhotoItem*)arg.GetValueAsPtr();
    IZ_ASSERT(hitItem != IZ_NULL);

    // Keep camera matrix.
    izanagi::math::SMatrix44::Copy(m_CamMtx, GetCamera().GetTransform());

    const izanagi::math::SMatrix44& globalRotMtx = PhotoItemManager::Instance().GetRotationMtx();

    // Compute target matrix.
    {
        izanagi::math::SVector4 pos;
        hitItem->GetCenterPosition(pos);
        izanagi::math::SMatrix44::Apply(pos, pos, globalRotMtx);

        izanagi::math::SVector4 nml;
        hitItem->GetNormal(nml);
        izanagi::math::SMatrix44::ApplyXYZ(nml, nml, globalRotMtx);

        izanagi::math::CVector4 targetPos(
            pos.x + nml.x * Configure::CameraDistanceFromItem,
            pos.y + nml.y * Configure::CameraDistanceFromItem,
            pos.z + nml.z * Configure::CameraDistanceFromItem);
    
        izanagi::math::CVector4 targetAt(pos);

        izanagi::CVectorCamera tmpCam;
        tmpCam.Init(
            targetPos,
            targetAt,
            1.0f,
            500.0f,
            izanagi::math::CMath::Deg2Rad(60.0f),
            1.0f);
        tmpCam.Update();

        izanagi::math::SMatrix44::Copy(m_TargetMtx, tmpCam.GetTransform());
    }

    m_State = State_Move;

    m_Timeline.Reset();
    m_Timeline.Start();

    return IZ_TRUE;
}
Beispiel #2
0
/**
 * Returns a const target of a code vector given its position
 * Parameter: _pos  The position of the code vector
 */
const Label& FuzzyMap::targetAtPos(const SomPos& _pos) const
{
    if (!calibrated())
    {
        std::ostringstream msg;
        msg << "The S.O.M. is not calibrated. No target at position ("
            << _pos.first << ", " << _pos.second << ")";
        throw std::out_of_range(msg.str());
    }
    if (_pos.first >= (signed)somWidth || _pos.second >= (signed)somHeight)
    {
        std::ostringstream msg;
        msg << "Out of range. No target at position (" << _pos.first << ", "
            << _pos.second << ")";
        throw std::out_of_range(msg.str());
    }

    return targetAt((somWidth * _pos.second) + _pos.first);
}