Exemplo n.º 1
0
void PMCone::createPoints( PMPointArray& points, const PMVector& end1,
                               const PMVector& end2, double radius1, double radius2, int steps )
{

   double angle = ( 2.0 * M_PI ) / (double) steps;

   PMVector pointAt = end2 - end1;
   double pl = pointAt.abs( );
   if( approxZero( pl ) )
      pointAt = PMVector( 0.0, 1.0, 0.0 );
   else
      pointAt /= pl;

   PMMatrix rotation = PMMatrix::rotation( pointAt, angle );
   PMVector endPoint1 = pointAt.orthogonal( );
   endPoint1 *= radius1;
   PMVector endPoint2 = pointAt.orthogonal( );
   endPoint2 *= radius2;

   int i;
   for( i = 0; i < steps; i++ )
   {
      points[i] = PMPoint( endPoint1 + end1 );
      points[i + steps] = PMPoint( endPoint2 + end2 );
      endPoint1 = rotation * endPoint1;
      endPoint2 = rotation * endPoint2;
   }
}
Exemplo n.º 2
0
PMDistanceControlPoint::PMDistanceControlPoint( PMControlPoint* base,
        const PMVector& direction, double distance,
        int id, const QString& description,
        bool showExtraLine )
    : PMControlPoint( id, description )
{
    m_distance = distance;
    m_pBasePoint = base;
    m_direction = direction;
    m_directionLength = direction.abs( );
    m_extraLine = showExtraLine;
}
Exemplo n.º 3
0
void PMDistanceControlPoint::setDirection( const PMVector& direction )
{
    m_direction = direction;
    m_directionLength = direction.abs( );
}
Exemplo n.º 4
0
void WindowInterface::UpdateShadow(CursorData& a_data)
{
//     UInt32 num = 0;
// 
//     for (std::map<UInt32, WindowFingerData>::iterator iter = a_data.fingerData.begin();
//         iter != a_data.fingerData.end();
//         ++iter)
//     {
//         WindowFingerData& tmp = iter->second;
// 
//         if (tmp.distance.x < m_width * m_width / 4 &&
//             tmp.distance.y < m_height * m_height / 4 &&
//             tmp.distance.z < NEAR_DISTANCE_SQUARE)
//         {
//             PMVector direction = tmp.oriPos - m_object->GetAbsolutePosition();
//             float x = (m_planeVectorX.Dot(direction) >= 0) ? sqrt(tmp.distance.x) : - sqrt(tmp.distance.x);
//             float y = (m_planeVectorY.Dot(direction) >= 0) ? sqrt(tmp.distance.y) : - sqrt(tmp.distance.y);
// 
//             GameObject* shadow;
// 
//             if (num + 1 < m_shadows.size())
//             {
//                 shadow = m_shadows[num];
//             }
//             else
//             {
//                 shadow = sGameObjectFactory.CreatePlaneShadow();
//                 m_shadows.push_back(shadow);
//             }
// 
//             shadow->SetVisible(true);
// 
//             shadow->SetRotation(m_object->GetAbsoluteRotation());
//             shadow->SetScale((tmp.distance.z < ATTACH_DISTANCE_SQUARE) ? PMVector(5, 0, 5): PMVector(10, 0, 10));
// 
//             if (iter->first == a_data.cursorID)
//             {
//                 a_data.coordinate.x = x;
//                 a_data.coordinate.y = y;
//                 a_data.coordinate.z = (m_normal.Dot(direction) >= 0) ? sqrt(tmp.distance.z) : - sqrt(tmp.distance.z);
//                 shadow->ChangeTexture(TEXTURE_PLANE_CURSOR);
//             }
//             else
//             {
//                 shadow->ChangeTexture(TEXTURE_PLANE_SHADOW);
//             }
// 
//             AvatarObject* avatar = sGameObjectFactory.GetAvatar();
//             PMVector view = avatar->GetHeadAbsolutePosition() - m_object->GetAbsolutePosition();
//             float shadowNormal = (view.Dot(m_normal) > 0) ? 1.0f : -1.0f;
// 
//             PMVector position = m_object->GetAbsolutePosition() + m_planeVectorX * x + m_planeVectorY * y + shadowNormal * m_normal;
// 
//             shadow->SetPosition(position);
// 
//             ++num;
//         }
//     }
    
    
//    UInt32 num = 0;

    std::vector<ShadowData> shadowData;

    for (std::map<UInt32, WindowFingerData>::iterator iter = a_data.fingerData.begin();
        iter != a_data.fingerData.end();
        ++iter)
    {
        WindowFingerData& tmp = iter->second;

        if (tmp.distance.x < m_width * m_width / 4 &&
            tmp.distance.y < m_height * m_height / 4 &&
            tmp.distance.z < NEAR_DISTANCE_SQUARE)
        {
            PMVector direction = tmp.oriPos - m_object->GetAbsolutePosition();
//             float x = (m_planeVectorX.Dot(direction) >= 0) ? sqrt(tmp.distance.x) : - sqrt(tmp.distance.x);
//             float y = (m_planeVectorY.Dot(direction) >= 0) ? sqrt(tmp.distance.y) : - sqrt(tmp.distance.y);
            ShadowData tmpData;
            tmpData.x = (m_planeVectorX.Dot(direction) >= 0) ? sqrt(tmp.distance.x) : - sqrt(tmp.distance.x);
            tmpData.y = (m_planeVectorY.Dot(direction) >= 0) ? sqrt(tmp.distance.y) : - sqrt(tmp.distance.y);

            shadowData.push_back(tmpData);
//             GameObject* shadow;
// 
//             if (num + 1 < m_shadows.size())
//             {
//                 shadow = m_shadows[num];
//             }
//             else
//             {
//                 shadow = sGameObjectFactory.CreatePlaneShadow();
//                 shadow->SetParent(m_object);
//                 m_shadows.push_back(shadow);
//             }
// 
//             shadow->SetVisible(true);
//             
//             PMVector scale = m_object->GetScale();
//             float shadowScale = (scale.x > scale.z) ? scale.x : scale.z; 
//             shadow->SetScale((tmp.distance.z < ATTACH_DISTANCE_SQUARE) ? PMVector(5 / shadowScale, 0, 5 / shadowScale): PMVector(10 / shadowScale, 0, 10 / shadowScale));
// 
//             AvatarObject* avatar = sGameObjectFactory.GetAvatar();
//             PMVector view = avatar->GetHeadAbsolutePosition() - m_object->GetAbsolutePosition();
// 
//             float shadowY = (view.Dot(m_normal) > 0) ? 1.0f / scale.y : -1.0f / scale.y;
//             
//             if (iter->first == a_data.cursorID)
//             {
//                 a_data.coordinate.x = x;
//                 a_data.coordinate.y = y;
//                 a_data.coordinate.z = (m_normal.Dot(direction) >= 0) ? sqrt(tmp.distance.z) : - sqrt(tmp.distance.z);
//                 shadow->ChangeTexture(TEXTURE_PLANE_CURSOR);
//             }
//             else
//             {
//                 shadow->ChangeTexture(TEXTURE_PLANE_SHADOW);
//             }
// 
//             shadow->SetPosition(PMVector(x / scale.x, shadowY, y / scale.z));
// 
//             ++num;
        }
    }

    if (!shadowData.empty())
    {
        AvatarObject* avatar = sGameObjectFactory.GetAvatar();
        PMVector view = avatar->GetHeadAbsolutePosition() - m_object->GetAbsolutePosition();
         
        float shadowY = (view.Dot(m_normal) > 0) ? 1.0f : -1.0f;

        m_shadow->SetVisible(true);
        m_shadow->SetPosition(m_object->GetAbsolutePosition() + shadowY * m_normal);
        m_shadow->SetRotation(m_object->GetAbsoluteRotation());

        sGameObjectFactory.DrawShadow(m_shadow, shadowData);
        //m_shadowDirty = true;
    }
//     else if (m_shadowDirty)
//     {
//         m_shadowDirty = false;
//         m_object->RecoverTexture();
//     }
}