Пример #1
0
void MainWindow::mouseMovedOnScene()
{
    int x = scene.x;
    int y = scene.y;
    if(x > datawidth-1 || x < 0 || y > dataheight || y < 0)
	inimage = false;
    else
	inimage = true;

    if(inimage)
    {
	setCursor(Qt::CrossCursor);
    if(( (YCheckBox->isChecked()||beamCheckBox->isChecked()) && x <= Y2SpinBox->value()+2/pow(2,zoom/2) && x >= Y2SpinBox->value()-2/pow(2,zoom/2)) || y2drag)
	    setCursor(Qt::SplitHCursor);
    if(( (YCheckBox->isChecked()||beamCheckBox->isChecked()) && x <= Y1SpinBox->value()+2/pow(2,zoom/2) && x >= Y1SpinBox->value()-2/pow(2,zoom/2)) || y1drag)
	    setCursor(Qt::SplitHCursor);
    if(( (XCheckBox->isChecked()||beamCheckBox->isChecked()) && y <= X2SpinBox->value()+2/pow(2,zoom/2) && y >= X2SpinBox->value()-2/pow(2,zoom/2)) || x2drag)
	    setCursor(Qt::SplitVCursor);
    if(( (XCheckBox->isChecked()||beamCheckBox->isChecked()) && y <= X1SpinBox->value()+2/pow(2,zoom/2) && y >= X1SpinBox->value()-2/pow(2,zoom/2)) || x1drag)
	    setCursor(Qt::SplitVCursor);
    }
    else
	setCursor(Qt::ArrowCursor);

    if(x > datawidth-1)
        x = datawidth-1;
    if(x < 0)
        x = 0;
    if(y > dataheight-1)
        y = dataheight-1;
    if(y < 0)
        y = 0;

    if(x1drag){
        x1line->setLine(0.5, y+0.5, datawidth-0.5, y+0.5);
        UpdateScene();
    }
    if(x2drag){
        x2line->setLine(0.5, y+0.5, datawidth-0.5, y+0.5);
        UpdateScene();
    }
    if(y1drag){
        y1line->setLine(x+0.5, 0.5, x+0.5, dataheight-0.5);
        UpdateScene();
    }
    if(y2drag){
        y2line->setLine(x+0.5, 0.5, x+0.5, dataheight-0.5);
        UpdateScene();
    }

    UpdateStatus();
}
Пример #2
0
VOID COGLAppBase::Run()
{
    MSG msg;
    ZeroMemory( &msg, sizeof(msg) );

	LARGE_INTEGER timeStart;
	LARGE_INTEGER timeEnd;
	LARGE_INTEGER timerFrequency;
	QueryPerformanceFrequency(&timerFrequency);
	double fi = 1000.0/(double)timerFrequency.QuadPart;

    while( msg.message!=WM_QUIT )
    {
        if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
        {
            TranslateMessage( &msg );
            DispatchMessage( &msg );
        }
        else
		{
			QueryPerformanceCounter(&timeStart);

			UpdateScene();
			DrawBase();
			HandleInput();

			QueryPerformanceCounter(&timeEnd);

			// the time elapsed since the last frame is stored in m_timeElapsed
			m_timeElapsed = (float)((timeEnd.QuadPart - timeStart.QuadPart)*fi);
		}
    }

	Cleanup();
}
Пример #3
0
int D3DApplication::Run()
{
	MSG message = {0};

	m_GameTimer.Reset();

	while (message.message != WM_QUIT)
	{
		// If there are Window messages then process them.
		if (PeekMessage(&message, nullptr, 0, 0, PM_REMOVE))
		{
			TranslateMessage(&message);
			DispatchMessage(&message);
		}
		// Otherwise, do animation/game stuff.
		else
		{
			m_GameTimer.Tick();

			if(!m_IsPaused)
			{
				UpdateScene(m_GameTimer.GetDeltaTime());	
			}
			else
			{
				Sleep(50);
			}

			DrawScene();
		}
	}

	return int(message.wParam);
}
Пример #4
0
void tSonar3D::SetVesselMode(bool enabled)
{
    if (m_VesselMode != enabled)
    {
        m_VesselMode = enabled;

        if (m_VesselMode)
        {
            tVector3d cameraPosition = m_SceneSettings.camera.Position();

            if (m_PreviewMode)
            {
            	m_Target = GetHeadSequencePosition();
            }
            else
            {
                m_Target = CalculateVesselModeTarget();
            }

            tVector3d lookAtTarget = m_Target - cameraPosition;
            m_CameraDistanceMeters = lookAtTarget.Length();

            m_TrackBallInteractor.SetTarget(m_Target);

            m_pCameraInteractor = &m_TrackBallInteractor;
        }
        else
        {
            m_pCameraInteractor = &m_FPSInteractor;
        }

        UpdateScene();
    }
}
Пример #5
0
void Idle()
{
	static double lastDeltas[3] = { 0.0, 0.0, 0.0 };
	static const double REFRESH_TIME = 1.0/60.0;	// monitor with 60 Hz
	
	// in milisec
	int t = glutGet(GLUT_ELAPSED_TIME);
	double newTime = (double)t*0.001;

	double deltaTime = newTime - g_appTime;
	if (deltaTime > REFRESH_TIME) deltaTime = REFRESH_TIME;

	// average:
	deltaTime = (deltaTime + lastDeltas[0] + lastDeltas[1] + lastDeltas[2]) * 0.25;

	g_appTime = g_appTime+deltaTime;

	// call Update:
	UpdateScene(deltaTime);

	// render frame:
	RenderScene();

	// save delta:
	lastDeltas[0] = lastDeltas[1];
	lastDeltas[1] = lastDeltas[2];
	lastDeltas[2] = deltaTime;
}
Пример #6
0
		int messageloop(){
			// Struktur um die message zu speichern
			MSG msg;
			ZeroMemory(&msg, sizeof(MSG));
		
		
			while (true)
			{
				//Schau nach ob es eine Nachricht gibt
				if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
				{
					if (msg.message == WM_QUIT)
						break;
					// Bearbeite die message
					TranslateMessage(&msg);
					DispatchMessage(&msg);
				}
				// Wenn nicht :
				else
				{
					UpdateScene();
					DrawScene();
		
				}
			}
			return msg.wParam;
		}
int messageloop(){
	MSG msg;
	ZeroMemory(&msg, sizeof(MSG));
	while(true)
	{
		BOOL PeekMessageL( 
			LPMSG lpMsg,
			HWND hWnd,
			UINT wMsgFilterMin,
			UINT wMsgFilterMax,
			UINT wRemoveMsg
			);

		if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			if (msg.message == WM_QUIT)
				break;
			TranslateMessage(&msg);	
			DispatchMessage(&msg);
		}
		else{
			// run game code            
			UpdateScene();
			DrawScene();
		}
	}
	return msg.wParam;
}
Пример #8
0
void tSonar3D::ZoomOut()
{
    double zoomDistance = m_ZoomStepMeters;

    if (m_VesselMode == true)
    {
        if ((m_CameraDistanceMeters + m_ZoomStepMeters) > m_CameraDistanceMax)
        {
            zoomDistance = m_CameraDistanceMax - m_CameraDistanceMeters;
        }
    }

    m_CameraDistanceMeters += zoomDistance;

    if (m_FollowVessel == true)
    {
        m_TrackBallInteractor.SetDistance(m_CameraDistanceMeters);
    }

    else
    {
        m_SceneSettings.camera.MoveBackward(zoomDistance);
    }

    UpdateScene();
}
Пример #9
0
int DemoBase::RunDemo()
{
	MSG msg = { 0 };

	mTimer.Reset();

	while (msg.message != WM_QUIT)
	{
		if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
		else
		{
			mTimer.Tick();

			if (!mAppPaused)
			{
				CalculateFrameStats();
				UpdateScene(mTimer.DeltaTime());
				DrawScene();
			}
			else
			{
				Sleep(100);
			}
		}
	}

	return (int)msg.wParam;
}
Пример #10
0
/*!****************************************************************************
 @Function		RenderScene
 @Return		bool		true if no error occured
 @Description	Main rendering loop function of the program. The shell will
				call this function every frame.
				eglSwapBuffers() will be performed by PVRShell automatically.
				PVRShell will also manage important OS events.
				Will also manage relevent OS events. The user has access to
				these events through an abstraction layer provided by PVRShell.
******************************************************************************/
bool OGLES2Glass::RenderScene()
{
	if (PVRShellIsKeyPressed(PVRShellKeyNameLEFT))	m_iEffect -= 1;
	if (PVRShellIsKeyPressed(PVRShellKeyNameRIGHT))	m_iEffect += 1;
	m_iEffect = (m_iEffect + g_iNumEffects) % g_iNumEffects;

	UpdateScene();

	DrawIntoParaboloids(PVRTVec3(0, 0, 0));

	// Clear the color and depth buffer
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// Draw the ball
	DrawBall();

	// Draw the balloons
	DrawBalloons(&m_DefaultProgram, m_mProjection, m_mView, m_mModels, 2);

	// Draw the skybox
	DrawSkybox();

	// Displays the demo name using the tools. For a detailed explanation, see the training course IntroducingPVRTools
	m_Print3D.DisplayDefaultTitle("Glass", g_aszEffectNames[m_iEffect], ePVRTPrint3DSDKLogo);
	m_Print3D.Flush();

	return true;
}
Пример #11
0
void RenderSystem::v_Render()
{
	BeginScene();

	UpdateScene();
	XMMATRIX Model = XMMatrixIdentity();
	XMStoreFloat4x4(&m_Matrix.model, XMMatrixTranspose(Model));

    m_Matrix.view = m_Camera.GetViewMatrix();
	m_Cube.Render(m_pD3D11DeviceContext.Get(), m_Matrix.model, m_Matrix.view, m_Matrix.proj);

	XMFLOAT3 camPos = m_Camera.GetPos();
	XMFLOAT3 modelPos;
	modelPos.x = 0.0f;
	modelPos.y = 1.5f;
	modelPos.z = 0.0f;
	// Calculate the rotation that needs to be applied to the billboard model to face the current camera position using the arc tangent function.
	float angle = atan2(modelPos.x - camPos.x, modelPos.z - camPos.z) * (180.0 / XM_PI);
	// Convert rotation into radians.
	float rotation = (float)angle * 0.0174532925f;
	// Setup the rotation the billboard at the origin using the world matrix.
	XMMATRIX world = XMMatrixRotationY(rotation);
	// Setup the translation matrix from the billboard model.
	XMMATRIX trans = XMMatrixTranslation(modelPos.x, modelPos.y, modelPos.z);
	world *= trans;
	XMStoreFloat4x4(&m_Matrix.model, XMMatrixTranspose(world));

	m_Square.Render(m_pD3D11DeviceContext.Get(), m_Matrix.model, m_Matrix.view, m_Matrix.proj);

	DrawInfo();

	EndScene();
}
Пример #12
0
int D3DApp::Run()
{
	MSG msg = {0};
 
	mTimer.Reset();

	while(msg.message != WM_QUIT)
	{
		// If there are Window messages then process them.
		if(PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
		{
            TranslateMessage( &msg );
            DispatchMessage( &msg );
		}
		// Otherwise, do animation/game stuff.
		else
        {	
			mTimer.Tick();

			if( !mAppPaused )
			{
				CalculateFrameStats();
				UpdateScene(mTimer.DeltaTime());	
				DrawScene();
			}
			else
			{
				Sleep(100);
			}
        }
    }

	return (int)msg.wParam;
}
Пример #13
0
void tSonar3D::ZoomIn()
{
    double zoomDistance = m_ZoomStepMeters;

    if (m_VesselMode == true)
    {
        if ((m_CameraDistanceMeters - m_ZoomStepMeters) < m_CameraDistanceMin)
        {
            zoomDistance = m_CameraDistanceMeters - m_CameraDistanceMin;
        }
    }

    if (zoomDistance > 0.01)
    {
        m_CameraDistanceMeters -= zoomDistance;

        if (m_FollowVessel == true)
        {        
            m_TrackBallInteractor.SetDistance(m_CameraDistanceMeters);
        }

        else
        {        
            m_SceneSettings.camera.MoveForward(zoomDistance);
        }

        UpdateScene();
    }
}
Пример #14
0
// D3D ½ÇÇà (¸Þ¼¼Áö ·çÇÁ)
int cInitD3D::Run()
{
	MSG msg = { 0 };
	mTimer.Reset();

	// ¸Þ¼¼Áö ·çÇÁ
	while (msg.message != WM_QUIT)
	{
		// À©µµ¿ì ¸Þ¼¼Áö°¡ µé¾î¿Ô´Â°¡?
		if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
		// ¾Æ´Ï¶ó¸é, ·»´õ¸µ
		else
		{
			// ŸÀ̸Ó
			mTimer.Tick();

			if (!mAppPaused)
			{
				CalculateFrameStats();
				UpdateScene(mTimer.DeltaTime());
				DrawScene();
			}
			else
			{
				// ÇÁ·¹ÀÓ Àç°è»êÇÏ´Â ½Ã°£
				Sleep(100);
			}
		}
	}
	return (int)msg.wParam;
}
Пример #15
0
void tSonar3D::SetCameraView(eCameraView view)
{
    Assert( view < eCameraView_End );

    m_CameraView = view;

    UpdateScene();
}
Пример #16
0
void Idle(void)
{

	//Do the physical calculation for one step:
	if (!g_bPaused) UpdateScene(0.05);
	//render the scene:
	Display();
}
Пример #17
0
void tSonar3D::mouseMoveEvent(QMouseEvent* pEvent)
{
    if (m_pCameraInteractor != 0)
    {
    	m_pCameraInteractor->HandleMouseMove(pEvent);
    }
    UpdateScene();
}
Пример #18
0
void tSonar3D::mousePressEvent(QMouseEvent* pEvent)
{
    m_CameraRotating = true;
    if (m_pCameraInteractor != 0)
    {
    	m_pCameraInteractor->HandleMousePress(pEvent);
    }
    UpdateScene();
}
Пример #19
0
void tSonar3D::SetWireframeMode(bool enabled)
{
    if (m_SceneSettings.wireframe != enabled)
    {
        m_SceneSettings.wireframe = enabled;

        UpdateScene();
    }
}
Пример #20
0
void tSonar3D::SetNightMode(bool enabled)
{
    if(m_NightMode != enabled)
    {
        m_NightMode = enabled;

        m_SceneSettings.nightModeEnabled = enabled;
        UpdateScene();
    }
    
    m_xSonar3DRenderer->OnNightModeChanged();
}
Пример #21
0
bool D3DApp::Run() {
	if (!m_timerStop) m_timer.Signal();

	if (!m_appPaused) {
		ShowFPS();
		UpdateScene(m_timer.Delta());
		DrawScene();
	} else {
		Sleep(100);
	}

	return true;
}
Пример #22
0
void tSonar3D::resizeEvent(QResizeEvent* pEvent)
{    
    m_SceneSettings.camera.SetProjection(width() / static_cast<float>(height()), DegreesToRadians(cDefaultFOV), cDefaultNearZ, cDefaultFarZ);
    m_SceneSettings.screenWidth = pEvent->size().width();

    if (m_VesselMode == true)
    {
        m_TrackBallInteractor.SetScreenSize(m_pNativeWindow->width(), m_pNativeWindow->height());
    }

    // Make sure these camera updates take effect
    UpdateScene();
}
Пример #23
0
void tSonar3D::mouseReleaseEvent(QMouseEvent* pEvent)
{
    if (m_pCameraInteractor != 0)
    {
    	m_pCameraInteractor->HandleMouseRelease(pEvent);
    }
    m_CameraRotating = false;

    float lastHeadingCartesianDegrees = HeadingToCartesianAngle(m_LastHeading);
    double azimuthDegrees = RadiansToDegrees(m_SceneSettings.camera.Azimuth(false));
    m_CameraRelativeAngleDegrees = tMathUtil::Normalize(azimuthDegrees - lastHeadingCartesianDegrees, -180.0, 180.0);

    UpdateScene();
}
Пример #24
0
bool Engine::Update()
{ BROFILER_FRAME("MainThread")
	UpdateInput();

	UpdateMessages();

	UpdateLogic();

	UpdateScene();

	UpdatePhysics();

	Draw();

	return true;
}
bool MinimumVolumeSphere3DWindow::OnCharPress(unsigned char key, int x, int y)
{
    switch (key)
    {
    case 'n':
    case 'N':
        if (mNumActive < NUM_POINTS)
        {
            mMVS3(++mNumActive, &mVertices[0], mMinimalSphere);
            UpdateScene();
        }
        return true;
    }

    return Window::OnCharPress(key, x, y);
}
MinimumVolumeSphere3DWindow::MinimumVolumeSphere3DWindow(Parameters& parameters)
    :
    Window3(parameters),
    mNumActive(2),
    mVertices(NUM_POINTS)
{
    mNoCullWireState = std::make_shared<RasterizerState>();
    mNoCullWireState->cullMode = RasterizerState::CULL_NONE;
    mNoCullWireState->fillMode = RasterizerState::FILL_WIREFRAME;
    mEngine->SetRasterizerState(mNoCullWireState);

    CreateScene();
    InitializeCamera();

    mMVS3(mNumActive, &mVertices[0], mMinimalSphere);
    UpdateScene();
}
Пример #27
0
// The actual game loop, which processes the windows message queue
// and calls our Update & Draw methods
int DirectXGame::Run()
{
	MSG msg = { 0 };
	timer.Reset();

	// Loop until we get a quit message from windows
	while (msg.message != WM_QUIT)
	{
		// Peek at the next message (and remove it from the queue)
		if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
		{
			// Handle this message
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
		else
		{
			// No message, so continue the game loop
			timer.Tick();

			if (gamePaused)
			{
				Sleep(100);
			}
			else
			{
				//Wait for vertical sync
				//float dt = 0.0f;
				//do
				//{
				//	dt += timer.DeltaTime();
				//	timer.Reset();
				//	Sleep(1);
				//} while (dt < 0.016f);
				// Standard game loop type stuff
				float dt = timer.DeltaTime();
				CalculateFrameStats();
				UpdateScene(dt);
				DrawScene();
			}
		}
	}

	return (int)msg.wParam;
}
Пример #28
0
int D3DApp::messageloop(){	//The message loop

	MSG msg;	//Create a new message structure
	ZeroMemory(&msg, sizeof(MSG));	//clear message structure to NULL

	while (true)	//while there is a message
	{
		//if there was a windows message
		if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			if (msg.message == WM_QUIT)	//if the message was WM_QUIT
				break;	//Exit the message loop

			TranslateMessage(&msg);	//Translate the message

			//Send the message to default windows procedure
			DispatchMessage(&msg);
		}

		else{
			// run game code    
			frameCount++;
			if (GetTime() > 1.0f)
			{
				fps = frameCount;
				frameCount = 0;
				StartTimer();
			}

			frameTime = GetFrameTime();

			DetectInput(frameTime);
			UpdateScene(frameTime);
			DrawScene();
		}


	}

	return (int)msg.wParam;		//return the message

}
Пример #29
0
void RenderSystem::v_Render()
{
	BeginScene();

	UpdateScene();
	m_Matrix.view = m_Camera.GetViewMatrix();

	XMMATRIX Model     = XMMatrixTranslation(-1.5f, 0.0f, 0.0f);
	XMStoreFloat4x4(&m_Matrix.model, XMMatrixTranspose(Model));

	m_LightShader.Render(m_pD3D11DeviceContext.Get(), m_Matrix);
	m_Cube.Render(m_pD3D11DeviceContext.Get());

	Model     = XMMatrixTranslation(1.5f, 0.0f, 0.0f);
	XMStoreFloat4x4(&m_Matrix.model, XMMatrixTranspose(Model));
	m_AlphaShader.Render(m_pD3D11DeviceContext.Get(), m_Matrix);
	m_Cube.Render(m_pD3D11DeviceContext.Get());

	EndScene();
}
Пример #30
0
U32 Application::Run()
{
	m_timer.Reset();
	
	auto hwnd = m_pWindow->GetHandle();
	auto bWindowActive = true;
	while (!m_pWindow->ShouldClose())
	{
		auto activeWindow = GetForegroundWindow();
		if (activeWindow != hwnd)
		{
			g_inputManager.EnableCursor();
			g_inputManager.SetRMBUp();
			g_inputManager.SetLMBUp();
			m_pWindow->Unclip();
			bWindowActive = false;
		}
		else
		{
			if (!bWindowActive)
			{
				g_inputManager.EnableCursor();
				bWindowActive = true;
			}
		}

		g_inputManager.Reset();

		m_pWindow->RunMessageLoop();
		
		m_timer.Update();
		g_eventManager.PostEvent(CreateTickEvent(m_timer.GetElapsed()));
		g_eventManager.DispatchEvents();
		UpdateScene(m_timer.GetElapsed());

		CopyRenderData();
		m_pRenderer->Render();
	}

	return 0;
}