Ejemplo n.º 1
0
void CTrack::DrawHandles(HDC hDC, bool bOn, CPoint* pCorners)
{
	CPoint ptRotate(0,0);
	CPoint ptCenter(0,0);

	for (int h = 0; h < NUM_HANDLES; h++)
	{
		if (!m_iHandleInUse[h])
			continue;

		switch (h)
		{
			case H_UL:
			case H_UR:
			case H_LR:
			case H_LL:
			{
				int i = h - H_UL;
				m_hHandleRects[h].left = pCorners[i].x;
				m_hHandleRects[h].top  = pCorners[i].y;
				break;
			}
			case H_TOP:
			{
				m_hHandleRects[h].left = (pCorners[0].x + pCorners[1].x)/2;
				m_hHandleRects[h].top  = (pCorners[0].y + pCorners[1].y)/2;
				break;
			}
			case H_RIGHT:
			{
				m_hHandleRects[h].left = (pCorners[1].x + pCorners[2].x)/2;
				m_hHandleRects[h].top  = (pCorners[1].y + pCorners[2].y)/2;
				break;
			}
			case H_BOTTOM:
			{
				m_hHandleRects[h].left = (pCorners[2].x + pCorners[3].x)/2;
				m_hHandleRects[h].top  = (pCorners[2].y + pCorners[3].y)/2;
				break;
			}
			case H_LEFT:
			{
				m_hHandleRects[h].left = (pCorners[3].x + pCorners[0].x)/2;
				m_hHandleRects[h].top  = (pCorners[3].y + pCorners[0].y)/2;
				break;
			}
			case H_ROTATE:
			{
				m_Matrix.Transform(m_ptRotate, m_hHandleRects[h].left, m_hHandleRects[h].top);
				m_ViewToDeviceMatrix.Transform((CPoint&)m_hHandleRects[h].left);
				ptRotate.x = m_hHandleRects[h].left;
				ptRotate.y = m_hHandleRects[h].top;
				break;
			}
			case H_CENTER:
			{
				m_Matrix.Transform(m_ptCenter, m_hHandleRects[h].left, m_hHandleRects[h].top);
				m_ViewToDeviceMatrix.Transform((CPoint&)m_hHandleRects[h].left);
				ptCenter.x = m_hHandleRects[h].left;
				ptCenter.y = m_hHandleRects[h].top;
				break;
			}
			case H_CORNER_UL:
			case H_CORNER_UR:
			case H_CORNER_LR:
			case H_CORNER_LL:
			{
				int i = h - H_CORNER_UL;
				m_Matrix.Transform(m_Distort.p[i], m_hHandleRects[h].left, m_hHandleRects[h].top);
				m_ViewToDeviceMatrix.Transform((CPoint&)m_hHandleRects[h].left);
				break;
			}
			default:
				break;
		}

		m_hHandleRects[h].left -= (H_SIZE/2);
		m_hHandleRects[h].top  -= (H_SIZE/2);
		m_hHandleRects[h].right  = m_hHandleRects[h].left + H_SIZE;
		m_hHandleRects[h].bottom = m_hHandleRects[h].top + H_SIZE;
		DrawHandle(hDC, &m_hHandleRects[h], h >= H_CENTER, bOn);
	}

	if (ptRotate.x || ptRotate.y || ptCenter.x || ptCenter.y)
		DrawLine(hDC, ptCenter.x, ptCenter.y, ptRotate.x, ptRotate.y, bOn);
}
void VisitorLandsideBehavior::setDestination( const ARCVector3& p ,MobDir emWalk )
{
	//destination is equal to current location
	ASSERT(m_pPerson->getType().GetTypeIndex() != 0);
	
	//carrion that defines relative position should use own relative position
	PaxOnboardBaseBehavior* spCarrionBehavior = m_pPerson->getOnboardBehavior();
	//ASSERT(spCarrionBehavior);
	if (!m_pPerson->m_pGroupInfo->IsFollower())
	{
		PaxVisitor* pVisitor = (PaxVisitor*)m_pPerson;
		Passenger* pOwner = pVisitor->GetOwner();
		if (pOwner && pOwner->GetVisitorItemByType(pVisitor->getType().GetTypeIndex()))//does not separate with passenger
		{
			CGroupLeaderInfo* pGroupLeader = (CGroupLeaderInfo*)(m_pPerson->m_pGroupInfo);
			if (pGroupLeader->isInGroup())//separate with group
			{
				LandsideBaseBehavior* spOwnerBehavior = pOwner->getLandsideBehavior();
				ASSERT(spOwnerBehavior);
				ARCVector3 _OwnerPreLocation = spOwnerBehavior->location;
				ARCVector3 OwnerLocation = spOwnerBehavior->m_ptDestination;

				if (_OwnerPreLocation == OwnerLocation && spOwnerBehavior->getState() != EntryLandside)//can not calculate direction of passenger and current location
				{
					m_ptDestination = p;
					SetFollowerDestination(location,m_ptDestination,Person::m_pRotation);
					return;
				}

				ARCVector3 paxDirection(_OwnerPreLocation, OwnerLocation);
				ARCVector3 paxLogPoint = _OwnerPreLocation;

				Point ptDir(paxDirection[VX],paxDirection[VY],paxDirection[VZ]);
				Point ptCenter(paxLogPoint.n[VX],paxLogPoint.n[VY],paxLogPoint.n[VZ]);

				CNonPaxRelativePosSpec* pNonPaxRelPosSpec = pVisitor->GetTerminal()->GetNonPaxRelativePosSpec();
				ASSERT(pNonPaxRelPosSpec);
				CPoint2008 ptRelatePos;
				ARCVector4 rotation;
				bool bRes = pNonPaxRelPosSpec->GetNonPaxRelatePosition(ptRelatePos, rotation, pVisitor->getType().GetTypeIndex());
				if (bRes)
				{
					Point vectorLat( ptRelatePos.getX(),ptRelatePos.getY(), 0.0);
					double dAngle = GetRotateAngle(emWalk);
					Point dir(paxDirection.n[VX],paxDirection.n[VY],paxDirection.n[VZ]);
					Point ptRotate(paxLogPoint.n[VX],paxLogPoint.n[VY],paxLogPoint.n[VZ]);
					dir.rotate(dAngle);
					dir.Normalize();
					vectorLat.rotate(dir, ptRotate);
					ARCVector3 vectorPt;
					vectorPt.n[VX] = vectorLat.getX();
					vectorPt.n[VY] = vectorLat.getY();
					vectorPt.n[VZ] = paxLogPoint.n[VZ];
					setLocation(vectorPt);

					SetRelativePosition(ptDir,ptCenter,emWalk);
					return;
				}
			}	
		}
		m_ptDestination = p;
		SetFollowerDestination(location,m_ptDestination,Person::m_pRotation);
	}

	//separate with passenger or not in group
	m_ptDestination = p;
	
}