void PositionJavaPinButtonExample::Project (const Eegeo::Space::LatLongAltitude& location, Eegeo::v3& screenPosition)
{
	//project a 3D Ecef location to the screen
	Eegeo::m44 finalMatrix;

	Eegeo::Camera::RenderCamera renderCamera(GetGlobeCameraController().GetRenderCamera());

	Eegeo::m44::Mul (finalMatrix,
	                 renderCamera.GetProjectionMatrix(),
	                 renderCamera.GetViewMatrix());

	Eegeo::v3 local = (location.ToECEF() - renderCamera.GetEcefLocation()).ToSingle();
	Eegeo::v4 inVector(local, 1.0f);

	// get clip space coords
	Eegeo::v4 outVector = Eegeo::v4::Mul(inVector, finalMatrix);

	// divide through by w to get normalized device space coords -- range [-1, 1]
	screenPosition.SetX((outVector.GetX()/outVector.GetW()));
	screenPosition.SetY((outVector.GetY()/outVector.GetW()));
	screenPosition.SetZ((outVector.GetZ()/outVector.GetW()));

	// transform from [-1, 1] to [0, 1]
	screenPosition.SetX((screenPosition.GetX() + 1.0f) * 0.5f);
	screenPosition.SetY(1.0f - ((screenPosition.GetY() + 1.0f) * 0.5f));

	float viewport[] = {0, 0, renderCamera.GetViewportWidth(), renderCamera.GetViewportHeight()};

	// transform from [0, 1] to screen coords.
	screenPosition.SetX((screenPosition.GetX()*(viewport[2]-viewport[0])) + viewport[0]);
	screenPosition.SetY((screenPosition.GetY()*(viewport[3]-viewport[1])) + viewport[1]);
}
void DynamicText3DExample::EnqueueRenderables(const Eegeo::Rendering::RenderContext& renderContext, Eegeo::Rendering::RenderQueue& renderQueue)
{
    Eegeo::Camera::RenderCamera renderCamera(GetGlobeCameraController().GetRenderCamera());
	const dv3& ecefCameraPosition = renderCamera.GetEcefLocation();
	v3 camSurfaceNormal = ecefCameraPosition.Norm().ToSingle();
	float environmentScale = m_environmentFlatteningService.GetCurrentScale();
    
	for(std::vector<PlaceNameView*>::const_iterator it = m_views.begin(); it != m_views.end(); ++it)
	{
		PlaceNameView& view = **it;
        
		view.UpdateTransformsAndVisibility(renderCamera, camSurfaceNormal, 4.0, environmentScale);
        
		if(view.IsInFrustum() && !view.IsCompletelyTransparent())
		{
			typedef std::vector<PlaceNameRenderable*> TRenderables;
			const TRenderables& renderables = view.GetRenderables();
            
			for(TRenderables::const_iterator it = renderables.begin(); it != renderables.end(); ++it)
			{
				const Rendering::RenderableBase* pRenderable = *it;;
                
                renderQueue.EnqueueRenderable(pRenderable);
			}
		}
	}
}
void PinOverModelExample::Update(float dt)
{
    // Update the PinsModule to query terrain heights and update screen space coordinats for the Pins.
    Eegeo::Camera::RenderCamera renderCamera(GetGlobeCameraController().GetRenderCamera());
	m_pPinsModule->Update(dt, renderCamera);
    
	m_pModel->UpdateAnimator(1.0f/30.0f);
    m_pMyModelRenderable->UpdateObserverLocation(renderCamera.GetEcefLocation());
}
Beispiel #4
0
Eegeo::Camera::CameraState RouteSimulationExample::GetCurrentCameraState() const
{
    if(m_usingFollowCamera)
    {
        return m_pRouteSessionFollowCameraController->GetCameraState();
    }
    else
    {
        return GetGlobeCameraController().GetCameraState();
    }
}
void CameraTransitionExample::EarlyUpdate(float dt)
{
	if (!m_transitioner.IsTransitioning())
	{
        // Do not update touch events or the globe controller if the transition controller is working
        GetGlobeCameraController().Update(dt);
        
		Transition();
	}
	m_transitioner.Update(dt);
}
void PinsExample::Update(float dt)
{
	m_addRemoveTimer += dt;
	if(m_addRemoveTimer > 3.0f)
	{
		AddRemovePin0();
		m_addRemoveTimer = 0.0f;
	}

    // Update the PinsModule to query terrain heights and update screen space coordinats for the Pins.
    Eegeo::Camera::RenderCamera renderCamera(GetGlobeCameraController().GetRenderCamera());
	m_pPinsModule->Update(dt, renderCamera);
}
Beispiel #7
0
void RouteSimulationExample::Update(float dt)
{
    //Defer initialisation until the loading state is over.
    if(!m_initialised)
    {
        return;
    }

    Eegeo::Camera::RenderCamera renderCamera(m_usingFollowCamera
            ? m_pRouteSessionFollowCameraController->GetRenderCamera()
            : GetGlobeCameraController().GetRenderCamera());

    m_pViewBindingForCycleSession->Update();
    m_pViewBindingForOscillatingSession->Update();
    m_pViewBindingForCameraSession->Update();

    //The route session for which we want to project a position to (in this case, the ecef interest
    //point) should be updated giving it the latest position.
    Eegeo::Camera::CameraState cameraState(GetCurrentCameraState());
    const Eegeo::dv3& ecefPositionToProjectToRoute = cameraState.InterestPointEcef();
    m_pSessionCamera->SetCurrentPositionSnappedToRoute(ecefPositionToProjectToRoute);

    //For the session which should just cycle the route forever, when it has completed simply end
    //the session and restart playback from the beginning.
    if(m_pSessionCycle->IsRouteCompleted())
    {
        m_pSessionCycle->EndPlayback();
        m_pSessionCycle->StartPlaybackFromBeginning();
    }

    //For the session which should oscillate, when the route is finished we change the playback direction
    //and unpause the session (such that it restarts from where it left off), and also demonstrate that
    //we can change playback speed by selecting a random speed multiplier. This multiplier applies to the
    //link speed (such that it is like a 'fast-forward' function). If we wanted to, we could also override
    //the playback speed such that the link speed is ignored by calling the UseCustomSpeedValue method.
    if(m_pSessionAlternatingSpeedChanger->IsRouteCompleted())
    {
        m_pSessionAlternatingSpeedChanger->TogglePlaybackDirection();
        m_pSessionAlternatingSpeedChanger->Unpause();

        m_linkSpeedMultiplier = 0.5f + ((rand() % 200)/100.f);
        m_pSessionAlternatingSpeedChanger->UseLinkSpeedValueWithMultiplier(m_linkSpeedMultiplier);
    }

    EXAMPLE_LOG("%f metres from start of route. %f percent.\n", m_pSessionAlternatingSpeedChanger->GetDistanceFromStartInMetres(),(m_pSessionAlternatingSpeedChanger->GetDistanceFromStartInMetres() / m_pRoute->GetLength())*100.0f) ;
}
void RoutingServiceExample::Update(float dt)
{
	//Defer creating the routes until the loading state is over.
	if(m_world.Initialising())
	{
		return;
	}
    
    if (!m_enteredInterior)
    {
        Eegeo::Resources::Interiors::InteriorId interiorId("westport_house");
        EnterInterior(interiorId);
        CreateAndBindUI();
    }
    
    // Update the altitude based scaler with the current camera's altitude.
    float altitude = GetGlobeCameraController().GetRenderCamera().GetAltitude();
    m_routeThicknessPolicy.SetAltitude(altitude);
}
void PODAnimationExample::Start()
{
    
    // Load the model
    m_pModel = m_sceneModelLoader.LoadPOD("pod_animation_example/Test_ROBOT_ARM.pod");
    
    Eegeo::Space::EcefTangentBasis cameraInterestBasis = Eegeo::Rendering::SceneModels::SceneModelTransformHelpers::PositionOnEarthSurface(*m_pModel,
                                                                                      Eegeo::Space::LatLongAltitude::FromDegrees(37.780642, -122.385876, 16.472872f).ToECEF(),
                                                                                      0.f);

    // Set correct layer for shadowing.
    m_pModel->SetLayer(Eegeo::Rendering::LayerIds::BeforeWorldTranslucency);
    
    // Set camera to look at location
    GetGlobeCameraController().SetView(cameraInterestBasis, 1209.007812f);
    
    // Create an animator to animate the model
    const u32 fps = 30;
    m_pModelAnimator = new Eegeo::Rendering::SceneModels::SceneModelAnimator(*m_pModel, fps);
    m_pModelAnimator->Play();
    
    // Add the model to the renderable filter so it will be queued and drawn by the SDK's rendering system.
    m_renderableFilter.AddSceneModel(*m_pModel);
}
Beispiel #10
0
void RouteSimulationExample::NotifyScreenPropertiesChanged(const Eegeo::Rendering::ScreenProperties& screenProperties)
{
    m_pRouteSessionFollowCameraController->UpdateScreenProperties(screenProperties);
    GetGlobeCameraController().UpdateScreenProperties(screenProperties);
}
void RouteThicknessPolicyExample::Update(float dt)
{
	//Defer creating the routes until the loading state is over.
	if(m_world.Initialising())
	{
		return;
	}

	//Just create the routes once.
	if(!m_createdRoutes)
	{
		//Some route data...
		const float halfWidth = 5.f;
		const float routeSpeedMetersPerSecond = 40.f;
		const Eegeo::v4 routeColor(1, 0, 1, 0.6f);
		const float altitudeMeters = 3.f;

		RouteBuilder builder;

		//// Demonstrate a custom route scaling policy on a route around the transamerica pyramid.
		//// This route animates to thicken and thin.
		std::vector<Eegeo::Routes::RouteVertex> transamericaPyramidRoutePoints = builder.Start(routeColor, halfWidth, routeSpeedMetersPerSecond, Routes::Road)
		        .AddPoint(37.795729,-122.401698, altitudeMeters)
		        .AddPoint(37.794873,-122.401516, altitudeMeters)
		        .AddPoint(37.794728,-122.403179, altitudeMeters)
		        .AddPoint(37.794483,-122.404863, altitudeMeters)
		        .AddPoint(37.793618,-122.404670, altitudeMeters)
		        .AddPoint(37.793813,-122.403007, altitudeMeters)
		        .AddPoint(37.792940,-122.402825, altitudeMeters)
		        .AddPoint(37.793109,-122.401108, altitudeMeters)
		        .AddPoint(37.792143,-122.400990, altitudeMeters)
		        .AddPoint(37.790303,-122.400603, altitudeMeters)
		        .AddPoint(37.790324,-122.400126, altitudeMeters)
		        .AddPoint(37.794449,-122.394906, altitudeMeters)
		        .AddPoint(37.793253,-122.393238, altitudeMeters)
		        .AddPoint(37.793707,-122.392578, altitudeMeters)
		        .FinishRoute();

		Eegeo::Routes::Style::RouteStyle transamericaPyramidStyle(&m_myScalingRouteThicknessPolicy, Eegeo::Routes::Style::RouteStyle::DebugStyleNone);
		Route* transamericaPyramidRoute = m_routeService.CreateRoute(transamericaPyramidRoutePoints, transamericaPyramidStyle, false);
		m_routes.push_back(transamericaPyramidRoute);

		//// Demonstrate the built-in altitude based route scaling policy on a route at north treasure isle. This route thickens as the camera
		//// altitude increases.
		std::vector<Eegeo::Routes::RouteVertex> northTreasureIsleRoutePoints = builder.Start(routeColor, halfWidth, routeSpeedMetersPerSecond, Routes::Road)
		        .AddPoint(37.827209,-122.377746,altitudeMeters)
		        .AddPoint(37.826057,-122.37663,altitudeMeters)
		        .AddPoint(37.825802,-122.374223,altitudeMeters)
		        .AddPoint(37.825921,-122.372035,altitudeMeters)
		        .AddPoint(37.826802,-122.369674,altitudeMeters)
		        .AddPoint(37.828667,-122.369159,altitudeMeters)
		        .AddPoint(37.830209,-122.369824,altitudeMeters)
		        .AddPoint(37.830328,-122.373172,altitudeMeters)
		        .FinishRoute();

		Eegeo::Routes::Style::RouteStyle northTreasureIsleStyle(&m_linearAltitudeBasedRouteThicknessPolicy, Eegeo::Routes::Style::RouteStyle::DebugStyleNone);
		Route* northTreasureIsleRoute = m_routeService.CreateRoute(northTreasureIsleRoutePoints, northTreasureIsleStyle, false);
		m_routes.push_back(northTreasureIsleRoute);

		//// Demonstrate the built-in identity route scaling policy on a route at south treasure isle. This route remains
		//// the same thickness.
		std::vector<Eegeo::Routes::RouteVertex> southTreasureIsleRoutePoints = builder.Start(routeColor, halfWidth, routeSpeedMetersPerSecond, Routes::Road)
		        .AddPoint(37.818226,-122.370339,altitudeMeters)
		        .AddPoint(37.820294,-122.371713,altitudeMeters)
		        .AddPoint(37.821599,-122.370940,altitudeMeters)
		        .AddPoint(37.822701,-122.368279,altitudeMeters)
		        .AddPoint(37.822260,-122.366735,altitudeMeters)
		        .AddPoint(37.820277,-122.365361,altitudeMeters)
		        .FinishRoute();

		Eegeo::Routes::Style::RouteStyle southTreasureIsleStyle(&m_identityRouteThicknessPolicy, Eegeo::Routes::Style::RouteStyle::DebugStyleNone);
		Route* southTreasureIsleRoute = m_routeService.CreateRoute(southTreasureIsleRoutePoints, southTreasureIsleStyle, false);
		m_routes.push_back(southTreasureIsleRoute);


		//We have created the routes so don't need to do so again.
		m_createdRoutes = true;
	}

	//Update our custom thickness policy to make it animate.
	m_myScalingRouteThicknessPolicy.UpdateScale();
    
    // Update the altitude based scaler with the current camera's altitude.
    float altitude = GetGlobeCameraController().GetRenderCamera().GetAltitude();
    m_linearAltitudeBasedRouteThicknessPolicy.SetAltitude(altitude);
}