Route* RouteSimulationAnimationExample::BuildRoute()
{
    const float halfWidth = 5.f;
    
    // 0.00185 is a factor that works well for the animation
    // speed of this model
    const float routeSpeedMetersPerSecond = 30.f;
    m_modelAnimationSpeed = routeSpeedMetersPerSecond * 0.00185;
    
    const Eegeo::v4 routeColor(1, 0, 1, 0.6f);
    const float altitudeMeters = 3.f;
    
    RouteBuilder builder;
    
    std::vector<RouteVertex> points = 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();
    
    const Eegeo::Routes::Style::RouteStyle style(Eegeo::Routes::Style::RouteStyle::JoinStyleArc, m_routeThicknessPolicy);
    return m_routeService.CreateRoute(points, style, false);
}
コード例 #2
0
Route* RouteSimulationExample::BuildRoute() const
{
    const float halfWidth = 5.f;
    const float routeSpeedMetersPerSecond = 20.f;
    const Eegeo::v4 routeColor(1, 0, 1, 0.6f);
    const float altitudeMeters = 3.f;

    RouteBuilder builder;

    std::vector<RouteVertex> points = 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();

    const Eegeo::Routes::Style::RouteStyle routeStyle(&m_routeThicknessPolicy, Eegeo::Routes::Style::RouteStyle::DebugStyleNone);
    return m_routeService.CreateRoute(points, routeStyle, false);
}
コード例 #3
0
void RouteMatchingExample::CreateRoutes(bool shouldMatchToNavigationGraph)
{
	// This function generates some routes, potentially matching them to the navigation graph based on the
	// value of the shouldMatchToNavigationGraph parameter. The API used here to build and submit the routes
	// is not explained as has been covered in RouteDrawingExample.cpp - please refer to this example for more
	// information about these API points at http://www.eegeo.com/developers/documentation/routes

	const float halfWidth = 5.f;
	const float routeSpeedMetersPerSecond = 40.f;
	const Eegeo::v4 routeRed(1, 0, 0, 0.6f);
	const Eegeo::v4 routeGreen(0, 1, 0, 0.6f);
	const Eegeo::v4 routeBlue(0, 0, 1, 0.6f);
	const float altitudeMeters = 3.f;
	Eegeo::Routes::Style::RouteStyle routeStyle(&m_routeThicknessPolicy, Eegeo::Routes::Style::RouteStyle::DebugStyleNone);

	RouteBuilder builder;

	// Create a route on roads at the north coast of San Francisco at Fishermans wharf. This route
	// demonstrates fitting to the road graph
	//
	std::vector<RouteVertex> fishermansWharfPoints = builder.Start(routeRed, halfWidth, routeSpeedMetersPerSecond, Routes::Road)
	        .AddPoint(37.807173,-122.408929, altitudeMeters)
	        .AddPoint(37.806982,-122.410527, altitudeMeters)
	        .ChangeColor(routeGreen)
	        .AddPoint(37.806059,-122.41035, altitudeMeters)
	        .AddPoint(37.805847,-122.411986, altitudeMeters)
	        .ChangeColor(routeRed)
	        .AddPoint(37.805385,-122.411916, altitudeMeters)
	        .AddPoint(37.805177,-122.413537, altitudeMeters)
	        .ChangeColor(routeBlue)
	        .AddPoint(37.805635,-122.413633, altitudeMeters)
	        .AddPoint(37.80658,-122.413816, altitudeMeters)
	        .FinishRoute();

	Route* route = m_routeService.CreateRoute(fishermansWharfPoints, routeStyle, shouldMatchToNavigationGraph);
	m_routes.push_back(route);

	// Create a route at Buena Vista park in San Francisco - the park is on a hill, this example demonstrates
	// fitting to the road graph on elevated terrain.
	//
	std::vector<RouteVertex> buenaVistaPoints = builder.Start(routeBlue, halfWidth/2.f, routeSpeedMetersPerSecond, Routes::Road)
	        .AddPoint(37.766088,-122.442888,altitudeMeters)
	        .AddPoint(37.76597,-122.442698,altitudeMeters)
	        .AddPoint(37.766037,-122.442576,altitudeMeters)
	        .AddPoint(37.766129,-122.442381,altitudeMeters)
	        .AddPoint(37.766171,-122.442263,altitudeMeters)
	        .AddPoint(37.766307,-122.442053,altitudeMeters)
	        .AddPoint(37.766667,-122.44175,altitudeMeters)
	        .AddPoint(37.766945,-122.441635,altitudeMeters)
	        .AddPoint(37.767274,-122.441549,altitudeMeters)
	        .AddPoint(37.767683,-122.441276,altitudeMeters)
	        .FinishRoute();

	m_routes.push_back(m_routeService.CreateRoute(buenaVistaPoints, routeStyle, shouldMatchToNavigationGraph));

	// Create a route on Treasure Island in San Francisco. This route starts on the road network, but includes a
	// pedestrian section. The road vertices are colored red and the pedestrian section is colored blue. The
	// pedestrian section is not matched to any navigation graphs, while the road section is (if the value of
	// shouldMatchToNavigationGraph is true).
	//
	std::vector<RouteVertex> islandPoints = builder.Start(routeRed, halfWidth, routeSpeedMetersPerSecond, Routes::Road)
	                                        .AddPoint(37.817416,-122.3681912, altitudeMeters)
	                                        .AddPoint(37.818747,-122.369023, altitudeMeters)
	                                        .AddPoint(37.818243,-122.370348, altitudeMeters)
	                                        .AddPoint(37.820277,-122.3717, altitudeMeters)
	                                        .AddPoint(37.820768,-122.370456, altitudeMeters)
	                                        .AddPoint(37.822794,-122.371775, altitudeMeters)
	                                        .ChangeClassification(Routes::Pedestrian)
	                                        .ChangeColor(routeBlue)
	                                        .AddPoint(37.822887,-122.371207, altitudeMeters)
	                                        .AddPoint(37.822396,-122.370273, altitudeMeters)
	                                        .AddPoint(37.824709,-122.370316, altitudeMeters)
	                                        .FinishRoute();

	m_routes.push_back(m_routeService.CreateRoute(islandPoints, routeStyle, shouldMatchToNavigationGraph));

	//We have created the routes so don't need to do so again.
	m_createdRoutes = true;
}
コード例 #4
0
void RouteDrawingExample::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)
    {
        //An arbitrarily selected default half-width for the route line segments.
        const float halfWidth = 5.f;
        const float routeSpeedMetersPerSecond = 40.f;

        //The color format is (Red, Green, Blue, Transparency - 0.0 is fully transparent and 1.0 is fully opaque).
        const Eegeo::v4 routeRed(1, 0, 0, 0.6f);
        const Eegeo::v4 routeGreen(0, 1, 0, 0.6f);
        const Eegeo::v4 routeBlue(0, 0, 1, 0.6f);
        
        //An arbitrarily selected altitude for the route visualisation.
        const float altitudeMeters = 3.f;
        
        //The route builder helper object provides a fluent interface to make building a route simpler.
        RouteBuilder builder;
        
        //We want the set of route vertices, and we get it by starting with an initial color and width and
        //adding points. This route starts near the Transamerica Pyramid.
        //
        //We can add points by (latDegrees, longDegrees, altitudeMeters) tuples or by a LatLongAltitide object..
        //
        //The color can be changed arbitrarily along the route.
        //
        std::vector<RouteVertex> points = builder.Start(routeRed, halfWidth, routeSpeedMetersPerSecond, Routes::Road)
        .AddPoint(37.795729,-122.401698, altitudeMeters)
        .AddPoint(37.794873,-122.401516, altitudeMeters)
        .AddPoint(37.794728,-122.403179, altitudeMeters)
        .ChangeColor(routeGreen)
        .AddPoint(37.794483,-122.404863, altitudeMeters)
        .AddPoint(37.793618,-122.404670, altitudeMeters)
        .AddPoint(37.793813,-122.403007, altitudeMeters)
        .ChangeColor(routeRed)
        .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)
        .ChangeColor(routeBlue)
        .AddPoint(37.793253,-122.393238, altitudeMeters)
        .ChangeColor(routeRed)
        .AddPoint(37.793707,-122.392578, altitudeMeters)
        .FinishRoute(); //Calling FinishRoute returns to us the set of points...
        
        // Select a Style for the route, use the JoinStyleArc to give a curved arc join; JoinStyleHard can be used to give
        // hard angular joins if preferred.
        //
        // A route thickness scaling policy should be provided; this informs the route how it should modify its thickness
        // (for example, based on camera altitude, or to play a "pulse" animation). Two implementations are provided; the
        // IdentityRouteThicknessPolicy and the LinearAltitudeScaleBasedRouteThicknessPolicy. For this example we use the
        // identity policy which will not modify the thickness of the route. The style accepts a const reference, so it
        // does not take ownership over the thickness policy.
        Eegeo::Routes::Style::RouteStyle hardJoinStyle(Eegeo::Routes::Style::RouteStyle::JoinStyleHard, m_routeThicknessPolicy);
        
        //We can now create a route from this set of points.
        //
        //The route can be created using the CreateRoute method on the RouteService, which must
        //be destroyed through the complementary DestroyRoute method on RouteService.
        Route* route = m_routeService.CreateRoute(points, hardJoinStyle, false);
        
        //Keep a reference to the route so we can Destroy it later.
        m_routes.push_back(route);
        
        //Create a separate route to demonstrate multiple routes drawing at once...
        //
        //This route surrounds AT & T Park. This route has some nasty data; the route
        //doubles back on itself (to produce exactly opposing poly-line segments)
        //and has a duplicated point, but still renders.
        std::vector<RouteVertex> otherPoints = builder.Start(routeBlue, halfWidth/2.f, routeSpeedMetersPerSecond, Routes::Road)
        .AddPoint(37.779483,-122.388609,altitudeMeters)
        .AddPoint(37.779916,-122.389317,altitudeMeters)
        .ChangeColor(routeGreen)
        //a nasty bit with a duplicated point and a parallel line
        .AddPoint(37.777957,-122.391785,altitudeMeters)
        .AddPoint(37.779916,-122.389317,altitudeMeters)
        .AddPoint(37.777957,-122.391785,altitudeMeters)
        .AddPoint(37.777957,-122.391785,altitudeMeters)
        .ChangeColor(routeRed)
        .AddPoint(37.777126,-122.390551,altitudeMeters)
        .AddPoint(37.776134,-122.389972,altitudeMeters)
        .ChangeColor(routeBlue)
        .AddPoint(37.776397,-122.387922,altitudeMeters)
        .FinishRoute();
        
        Eegeo::Routes::Style::RouteStyle arcJoinStyle(Eegeo::Routes::Style::RouteStyle::JoinStyleArc, m_routeThicknessPolicy);
        m_routes.push_back(m_routeService.CreateRoute(otherPoints, arcJoinStyle, false));
        
        //this route curves around entirely on itself, and traces the bounds of treasure island
        std::vector<RouteVertex> islandCircuitPoints = builder.Start(routeGreen, halfWidth, routeSpeedMetersPerSecond, Routes::Road)
        .AddPoint(37.826701,-122.379162, altitudeMeters)
        .AddPoint(37.830429,-122.377531, altitudeMeters)
        .AddPoint(37.832328,-122.373368, altitudeMeters)
        .AddPoint(37.831209,-122.368605, altitudeMeters)
        .AddPoint(37.822633,-122.362983, altitudeMeters)
        .AddPoint(37.818768,-122.364313, altitudeMeters)
        .AddPoint(37.816158,-122.371480, altitudeMeters)
        .AddPoint(37.818294,-122.373368, altitudeMeters)
        .AddPoint(37.816938,-122.375128, altitudeMeters)
        .AddPoint(37.820226,-122.374742, altitudeMeters)
        .AddPoint(37.824158,-122.377574, altitudeMeters)
        .FinishRoute();
        
        m_routes.push_back(m_routeService.CreateRoute(islandCircuitPoints, arcJoinStyle, false));
        
        //We have created the routes so don't need to do so again.
        m_createdRoutes = true;
    }
}
コード例 #5
0
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);
}