Пример #1
0
void Test::PrepareCameraAnimation()
{
    Rect rect = rectSequence.front();
    curCameraPosition = GetRealPoint(rect.GetCenter());

    Camera* cam = GetCamera();
    cam->SetPosition(curCameraPosition);
    cam->SetDirection(DEF_CAMERA_DIRECTION);

    nextRectNum = 0;

    curCameraAngle = 0.f;
    float32 maxRotateAngle = 360.f;
    float32 timeToRotate = maxRotateAngle / SettingsManager::Instance()->GetCameraRotationSpeed();
    camRotateAnimation = new LinearAnimation<float32>(this, &curCameraAngle, maxRotateAngle, timeToRotate, Interpolation::LINEAR);
    camRotateAnimation->SetRepeatCount(-1);
}
Пример #2
0
void Test::MoveToNextPoint()
{
    ++nextRectNum;

    if(nextRectNum < rectSequence.size())
    {
        Rect nextRect = rectSequence[nextRectNum];

        Vector3 endPoint = GetRealPoint(nextRect.GetCenter());

        float32 pathSegmentLength = (endPoint - curCameraPosition).Length();
        float32 timeToMove = pathSegmentLength / SettingsManager::Instance()->GetCameraMovementSpeed();
        
        camMoveAnimation = new LinearAnimation<Vector3>(this, &curCameraPosition, endPoint, timeToMove, Interpolation::LINEAR);
        camMoveAnimation->AddEvent(Animation::EVENT_ANIMATION_END, Message(this, &Test::AnimationFinished));
		if(!skipFrames)
        	camMoveAnimation->Start(CAMERA_ANIMATION_MOVE);
    }
    else
    {
		SaveFpsStat();
        isFinished = true;
    }
}
Пример #3
0
int CPROC EditMouseCallback( uintptr_t dwUser, int32_t x, int32_t y, uint32_t b )
{
	static int _x, _y, _right, _left;
	int right, left;
	PEDITOR pe = (PEDITOR)dwUser;
	Image surface = GetDisplayImage( pe->hVideo );
	right = b & MK_RBUTTON;
	left = b & MK_LBUTTON;

	//if( pe->bLocked )
	//{/
	//}
	pe->ptMouseDel[0] = x - pe->ptMouse[0];
	pe->ptMouseDel[1] = y - pe->ptMouse[1];
	pe->ptMouse[0] = x;
	pe->ptMouse[1] = y;

	if( !(left + right + _left + _right) ) // just moving mouse..
	{
		if( pe->bLocked )
		{
			if( pe->ptMouseDel[0] > MOUSE_LOCK || pe->ptMouseDel[0] < -MOUSE_LOCK ||
				 pe->ptMouseDel[1] > MOUSE_LOCK || pe->ptMouseDel[1] < -MOUSE_LOCK )
			{
				pe->bLocked = FALSE;
				SetMousePosition( pe->hVideo, pe->ptMouse[0], pe->ptMouse[1] );
				return 1; // done....
			}
		}
		else
		{
			if( ( abs( pe->ptO[0] - x ) < MOUSE_LOCK ) &&
				 ( abs( pe->ptO[1] - y ) < MOUSE_LOCK ) )
			{
				pe->bLocked = TRUE;
				pe->ptMouseDel[0] = 0;
				pe->ptMouseDel[1] = 0;
				pe->ptMouse[0] = pe->ptO[0];
				pe->ptMouse[1] = pe->ptO[1];
			}
			else
			if( ( abs( pe->ptN[0] - x) < MOUSE_LOCK ) &&
				 ( abs( pe->ptN[1] - y ) < MOUSE_LOCK ) )
			{
				pe->bLocked = TRUE;
				pe->ptMouseDel[0] = 0;
				pe->ptMouseDel[1] = 0;
				pe->ptMouse[0] = pe->ptN[0];
				pe->ptMouse[1] = pe->ptN[1];
			}
		}

		if( pe->bLocked ) // only reset mouse if not dragging??
		{
			pe->ptMouse[0] -= pe->ptMouseDel[0];
			pe->ptMouse[1] -= pe->ptMouseDel[1];
			SetMousePosition( pe->hVideo, pe->ptMouse[0],
											 pe->ptMouse[1] );
		}

	}

	if( pe->bLocked )
	{
		x = pe->ptMouse[0] - pe->ptMouseDel[0];
		y = pe->ptMouse[1] - pe->ptMouseDel[0];
	}

	if( !right && _right )
	{
#ifdef __WINDOWS__
		IMAGE_POINT p;
		int nCmd;
		GetCursorPos( (POINT*)&p );
		nCmd = TrackPopup( pe->hMenu
								//, TPM_CENTERALIGN
								//| TPM_TOPALIGN
								//| TPM_RIGHTBUTTON
								//| TPM_RETURNCMD
								//| TPM_NONOTIFY
								//,p[0]
								//,p[1]
								,0
							  // ,NULL // pe->hVideo->hWndOutput
							  //,NULL
							  );
		switch( nCmd )
		{
		case MNU_ADDLINE:
			break;
		}
#endif
	}

	if( left && !_left ) // left click select...
	{
		if( x == pe->ptO[0] && y == pe->ptO[1] )
		{
			pe->bDragOrigin = TRUE;
		} 
		else if( x == pe->ptN[0] && y == pe->ptN[1] )
		{
			pe->bDragNormal = TRUE;
		}
		else
		{
			pe->bDragWorld = TRUE;
		}	
	}
	else if( !left && _left ) // end click...
	{
		pe->bDragOrigin = FALSE; // cancel all operations...
		pe->bDragNormal = FALSE;
		pe->bDragWorld = FALSE;
	}
	else if( left && _left ) // probably dont want to do this if !left && !_left
	{
		if( pe->bDragOrigin )
		{
			VECTOR vo;
			if( pe->ptMouseDel[0] || pe->ptMouseDel[1] )
			{
				GetOriginV( pe->TView, vo );
				Invert( vo );
				GetRealPoint(surface, (PVECTOR)vo, pe->ptMouse );
				Apply( (PCTRANSFORM)pe->TView, pe->pCurrentLine->r.o, vo ); // apply inverse -> Apply...
				// update Intersecting lines......
				/*
				{
					PLINESEG pl;
					PLINESEGPSET plps;
					int l;
					plps = pe->pCurrentFacet->pLineSet;
					pl = pe->pCurrentLine->pTo;
					
					for( l = 0; l < plps->nUsedLines; l++ )
					{
						pl = plps->pLines[l];
						if( pl == pe->pCurrentLine )
							continue;

					}

				}
				*/
				EditResizeCallback( (uintptr_t)pe ); // update screen...
			}
		} 
		else if( pe->bDragNormal )
		{
			VECTOR vn;
			if( pe->ptMouseDel[0] || pe->ptMouseDel[1] )
			{
				GetOriginV( pe->TView, vn );
				Invert( vn );
				GetRealPoint(surface, (PVECTOR)vn, pe->ptMouse );
				sub( vn, vn, pe->pCurrentLine->r.o );
				Apply( (PCTRANSFORM)pe->TView, pe->pCurrentLine->r.n, vn ); // apply inverse -> Apply...
				// update Intersecting lines......
				EditResizeCallback( (uintptr_t)pe ); // update screen...
			}
		}
		else if( pe->bDragWorld )
		{
			VECTOR v1, v2;
			if( pe->ptMouseDel[0] || pe->ptMouseDel[1] )
			{
				GetOriginV( pe->TView, v1 );
				Invert( v1 );
				v2[vForward] = v1[vForward];
				pe->ptMouseDel[0] = pe->ptMouse[0] - pe->ptMouseDel[0];
				pe->ptMouseDel[1] = pe->ptMouse[1] - pe->ptMouseDel[1];

				GetRealPoint(surface, (PVECTOR)v1, pe->ptMouse );
				GetRealPoint(surface, (PVECTOR)v2, pe->ptMouseDel );
				sub( v1, v2, v1 );
				v1[vForward] = 0; 
				TranslateRelV( pe->TView, v1 );
				EditResizeCallback( (uintptr_t)pe ); // update screen...
			}
		}

	}

	_x = x;
	_y = y;
	_right = right;
	_left  = left;
	return 1;
}