void PinOverModelExample::Start()
{
    pModel = Eegeo::Model::CreateFromPODFile("Test_ROBOT_ARM.pod", fileIO, renderContext.GetGLState(), &textureRequestor, "");
    Eegeo_ASSERT(pModel->GetRootNode());

    m_pMyModelRenderable = Eegeo_NEW (MyModelRenderable)(*pModel, renderContext, globalFogging, nullMat);
    m_pMyRenderableFilter = Eegeo_NEW (MyRenderableFilter)(*m_pMyModelRenderable);
    renderableFilters.AddRenderableFilter(m_pMyRenderableFilter);
}
 void InteriorWorldPinController::HandleMarkerRemoved(const Eegeo::Resources::Interiors::Markers::InteriorMarkerModel &markerModel)
 {
     Eegeo_ASSERT(m_interiorIdToWorldPinMap.find(markerModel.GetInteriorId().Value()) != m_interiorIdToWorldPinMap.end(),
                  "InteriorWorldPinController does not have a pin with that Id");
     
     WorldPins::SdkModel::WorldPinItemModel* pPinModel = m_interiorIdToWorldPinMap[markerModel.GetInteriorId().Value()];
     
     m_deferedRemovalMap[markerModel.GetInteriorId().Value()] = pPinModel;
 }
 void WorldMenuController::OnWorldMenuItemRemoved(WorldMenuItem& worldMenuItem)
 {
     Eegeo_ASSERT(HasViewForModel(worldMenuItem), "Attempt to remove unknown model from WorldMenuController.");
     WorldMenuItemView* pView = GetViewForModel(worldMenuItem);
     
     m_viewsByModel.erase(&worldMenuItem);
     m_uiInteractionObservable.UnRegisterInteractableItem(pView);
     
 }
            bool WorldPinsService::HandleTouchTap(const Eegeo::v2& screenTapPoint)
            {
                std::vector<Eegeo::Pins::Pin*> intersectingPinsClosestToCameraFirst;

                if(m_pinController.TryGetPinsIntersectingScreenPoint(screenTapPoint, intersectingPinsClosestToCameraFirst))
                {
                    Eegeo_ASSERT(intersectingPinsClosestToCameraFirst.size() > 0);
                    Eegeo::Pins::Pin* pSelectedPin = intersectingPinsClosestToCameraFirst[0];
                    Eegeo_ASSERT(pSelectedPin != NULL);
                    TPinToSelectionHandlerMapIt pinToSelectionHandlerMapIt = m_pinsToSelectionHandlers.find(pSelectedPin->GetId());
                    Eegeo_ASSERT(pinToSelectionHandlerMapIt != m_pinsToSelectionHandlers.end(),
                                 "Selected pin with unknown ID %d.\n", pSelectedPin->GetId());
                    IWorldPinSelectionHandler& selectionHandler = *pinToSelectionHandlerMapIt->second;
                    selectionHandler.SelectPin();
                    return true;
                }

                return false;
            }
 void WorldMenuController::OnWorldMenuItemAdded(WorldMenuItem& worldMenuItem)
 {
     Eegeo_ASSERT(!HasViewForModel(worldMenuItem), "Attempt to add duplicate model to WorldMenuController.");
     
     WorldMenuItemView* pView = m_viewFactory.CreateViewForWorldMenuItem(worldMenuItem);
     m_viewsByModel[&worldMenuItem] = pView;
     
     m_uiInteractionObservable.RegisterInteractableItem(pView);
     m_isMenuShown = false;
 }
 void JumpPointController::OnJumpPointRemoved(JumpPoint& jumpPoint)
 {
     Eegeo_ASSERT(HasViewForModel(jumpPoint), "Attempt to remove unknown model from JumpPointController.");
     JumpPointView* pView = GetViewForModel(jumpPoint);
     
     m_viewsByModel.erase(&jumpPoint);
     m_uiInteractionObservable.UnRegisterInteractableItem(pView);
     
     Eegeo_DELETE(pView);
 }
 void TwitterFeedService::HandleTimeLineResponse(Eegeo::Web::IWebResponse& webResponse)
 {
     m_pCurrentTimeLineRequest = NULL;
     
     if(webResponse.GetHttpStatusCode() != 200)
     {
         m_currentServiceState = OFFLINE;
         
         ClearAccountNameQueue();
         
         return;
     }
     
     size_t resultSize = webResponse.GetBodyData().size();
     std::string serialized(reinterpret_cast<char const*>(&(webResponse.GetBodyData().front())), resultSize);
     
     rapidjson::Document document;
     
     document.Parse<0>(serialized.c_str());
     
     Eegeo_ASSERT(!document.HasParseError(), "Error parsing timeline request response")
     Eegeo_ASSERT(document.IsArray(), "Timeline request response unrecognised: %s", serialized.c_str());
     
     std::map<std::string, TweetRepository*>::iterator repositoryIt = m_repositoryMap.find(m_accountNameQueue.front());
     
     if(repositoryIt == m_repositoryMap.end())
     {
         repositoryIt = m_repositoryMap.insert(std::pair<std::string, TweetRepository*>(m_accountNameQueue.front(), Eegeo_NEW(TweetRepository)())).first;
     }
     
     TweetRepository* currentRepository = (*repositoryIt).second;
     
     for(rapidjson::SizeType i = 0; i < document.Size(); ++i)
     {
         currentRepository->AddItem(TweetModel::GetNewTweetModelFromJsonDocument(document, i));
     }
     
     m_feedLoadedCallbacks.ExecuteCallbacks(m_accountNameQueue.front(), *currentRepository);
     
     m_accountNameQueue.pop();
     
     LoadNextTimeLine();
 }
void PinOverModelExample::Start()
{
	m_pModel = Eegeo::Model::CreateFromPODFile("pin_over_model_example/Test_ROBOT_ARM.pod", m_fileIO, &m_textureRequestor, "pin_over_model_example/");
	Eegeo_ASSERT(m_pModel->GetRootNode());

    m_pNullMaterial = m_nullMaterialFactory.Create("PinOverModelExampleNullMaterial");
    
	m_pMyModelRenderable = Eegeo_NEW (MyModelRenderable)(*m_pModel, m_globalFogging, *m_pNullMaterial);
	m_pMyRenderableFilter = Eegeo_NEW (MyRenderableFilter)(*m_pMyModelRenderable);
	m_renderableFilters.AddRenderableFilter(*m_pMyRenderableFilter);
}
            void VRDistortionRenderable::Render(Eegeo::Rendering::GLState& glState) const
            {
                m_material->SetStatePerRenderable(this, glState);
                m_pMesh->BindVertexBuffers(GetVertexBinding(), glState);
                const u32 indexCount = m_pMesh->GetNumOfIndices();

                Eegeo_ASSERT(indexCount != 0);
                Eegeo_GL(glDrawElements(GL_TRIANGLES, indexCount, GL_UNSIGNED_SHORT, (void*)(0)));
                m_pMesh->UnbindVertexBuffers(glState);
                
            }
 void SearchRefreshService::HandleSearchResultsResponseReceived(const SearchQuery& query,
         const std::vector<SearchResultModel>& results)
 {
     if (!m_searchResultsCleared)
     {
         m_searchResultsExist = true;
     }
     m_previousQueryLocationEcef = query.Location().ToECEF();
     -- m_queriesPending;
     Eegeo_ASSERT(m_queriesPending >= 0);
 }
PinOverModelExample::PinOverModelExample(
    Eegeo::Modules::Core::RenderingModule& renderingModule,
    Eegeo::Modules::IPlatformAbstractionModule& platformAbstractionModule,
    Eegeo::Modules::Map::MapModule& mapModule,
    Eegeo::Rendering::AsyncTexturing::IAsyncTextureRequestor& textureRequestor,
    Eegeo::Lighting::GlobalFogging& fogging,
    Eegeo::Rendering::Materials::NullMaterialFactory& nullMaterialFactory,
    Eegeo::Camera::GlobeCamera::GlobeCameraController* pCameraController,
    Eegeo::Camera::GlobeCamera::GlobeCameraTouchController& cameraTouchController,
    const Eegeo::Rendering::ScreenProperties& initialScreenProperties
)
	: GlobeCameraExampleBase(pCameraController, cameraTouchController)
    , m_pin0UserData("Pin Zero(0) User Data")
	,m_pPin0(NULL)
	,m_fileIO(platformAbstractionModule.GetFileIO())
	,m_textureRequestor(textureRequestor)
	,m_pModel(NULL)
	,m_globalFogging(fogging)
	,m_renderableFilters(renderingModule.GetRenderableFilters())
	,m_nullMaterialFactory(nullMaterialFactory)
    ,m_pNullMaterial(NULL)
{
    Eegeo::Helpers::ITextureFileLoader& textureLoader = platformAbstractionModule.GetTextureFileLoader();

	textureLoader.LoadTexture(m_pinIconsTexture, "pin_over_model_example/PinIconTexturePage.png", true);
	Eegeo_ASSERT(m_pinIconsTexture.textureId != 0);

	// This example uses a texture page containing 2 x 2 icons.
	// Increase the following number to use a texture page containing more icons
	// (e.g. 3 for a page containing 3 x 3 icons)
	int numberOfTilesAlongEachAxisOfTexturePage = 2;
	m_pPinIconsTexturePageLayout = Eegeo_NEW(Eegeo::Rendering::RegularTexturePageLayout)(numberOfTilesAlongEachAxisOfTexturePage);

	// The following values specify the size and shape of the Pins within the 3D world.
	int spriteWidthInMetres = 64;
	int spriteHeightInMetres = 64;

	// N.B. The implementation for PinModule is given in PinModule.h as a guide for Apps that
	// require an alternate configuration of the various Pin related components.
    m_pPinsModule = Eegeo::Pins::PinsModule::Create(
                                    renderingModule,
                                    platformAbstractionModule,
                                    mapModule,
                                    m_pinIconsTexture.textureId,
                                    *m_pPinIconsTexturePageLayout,
                                    Eegeo::Rendering::LayerIds::PlaceNames,
                                    spriteWidthInMetres,
                                    spriteHeightInMetres,
                                    initialScreenProperties,
                                    false);

	CreateExamplePins();
}
Ejemplo n.º 12
0
void RouteSimulationExample::ToggleRotateToFollow()
{
    Eegeo_ASSERT(m_usingFollowCamera);

    if(m_pRouteSessionFollowCameraController->GetOrientationMode() == RouteSimulationGlobeCameraController::UnlockedOrientation)
    {
        m_pRouteSessionFollowCameraController->LockFollowHeadingToCurrentLinkDirection();
    }
    else
    {
        m_pRouteSessionFollowCameraController->UnlockFollowHeading();
    }
}
    void PinsWithAttachedJavaUIExample::Draw()
    {
    	//lazily create the pin button when we start drawing so it is not displayed on top of the loading screen
		if(m_world.Initialising()) {
			return;
		}
		else if(m_buttonID == 0) {
			CreateJavaUIButton();
		}

		AndroidSafeNativeThreadAttachment attached(m_nativeState);
		JNIEnv* env = attached.envForThread;

		Eegeo_ASSERT(m_buttonID != 0);

		// Get the pin position on the screen
		Eegeo::Pins::PinRepository& pinRepo = m_pPinsModule->GetRepository();
		Eegeo::Pins::Pin* pPin = pinRepo.GetPinAtIndex(0);
		Eegeo_ASSERT(pPin != NULL);

		Eegeo::Pins::PinController& pinController = m_pPinsModule->GetController();
		Eegeo::Geometry::Bounds2D pinScreenBounds = Eegeo::Geometry::Bounds2D::Empty();
		pinController.GetScreenBoundsForPin(*pPin, pinScreenBounds);
		Eegeo::v2 screenPosition = pinScreenBounds.center();

		// now update the java ui to be in sync with the pin, positioned above it on screen.
		// the pixel nudging is hard-coded for simplicity; you should probably do something more sophisticated
		// (based on the size of your pin & java ui assets)
		const int buttonOffsetPixelsX = 40;
		const int buttonOffsetPixelsY = 110;

		env->CallVoidMethod(
			m_hudPinController,
			m_updateLocationMethodId,
			m_buttonID,
			screenPosition.GetX() - buttonOffsetPixelsX,
			screenPosition.GetY() - buttonOffsetPixelsY
		);
    }
 void HeatmapExample::Start()
 {
     bool heatmapResult = m_textureLoader.LoadTexture(m_heatmapTexture, "heatmap_example/sf-heatmap.png", true);
     Eegeo_ASSERT(heatmapResult, "Unable to load heatmap_example/sf-heatmap.png");
     
     bool gradientResult = m_textureLoader.LoadTexture(m_gradientTexture, "heatmap_example/gradient.png", true);
     Eegeo_ASSERT(gradientResult, "Unable to load heatmap_example/gradient.png");
     
     m_pSfCrimeHeatmap = Eegeo::Data::Heatmaps::HeatmapModel::HeatmapBuilder(
                                                                      "example_heatmap",
                                                                      m_heatmapTexture.textureId,
                                                                      m_gradientTexture.textureId,
                                                                      Eegeo::Space::LatLong::FromDegrees(37.8137250395396194, -122.5163426427749869),
                                                                      Eegeo::Space::LatLong::FromDegrees(37.7018266572250056,-122.3670702007672872)
                                                                      )
                                                                 .Alpha(0.5)
                                                                 .MaxValue(24)
                                                                 .Layer(Eegeo::Rendering::StencilMapLayerMask::Buildings)
                                                                 .Build();
     
     m_heatmapController.Add(*m_pSfCrimeHeatmap);
 }
    void MobileExampleApp::InitialiseApplicationViewState()
    {
        Eegeo_ASSERT(m_initialisedApplicationViewState == false, "Can only initialise application state once!\n");

        m_initialisedApplicationViewState = true;

        m_pSecondaryMenuModule->GetSecondaryMenuViewModel().AddToScreen();
        m_pSearchResultMenuModule->GetMenuViewModel().AddToScreen();
        m_pFlattenButtonModule->GetScreenControlViewModel().AddToScreen();
        m_pCompassModule->GetScreenControlViewModel().AddToScreen();
        m_pMyPinCreationModule->GetInitiationScreenControlViewModel().AddToScreen();
        m_pWatermarkModule->GetWatermarkViewModel().AddToScreen();
    }
            WeatherMenuModule::WeatherMenuModule(Eegeo::Helpers::IFileIO& fileIO,
                                                 Eegeo::Resources::CityThemes::ICityThemesService& themesService,
                                                 Eegeo::Resources::CityThemes::ICityThemesUpdater& themesUpdater,
                                                 ExampleAppMessaging::TMessageBus& messageBus,
                                                 Metrics::IMetricsService& metricsService)
            {
                m_pMenuModel = Eegeo_NEW(Menu::View::MenuModel)();
                m_pMenuOptionsModel = Eegeo_NEW(Menu::View::MenuOptionsModel)(*m_pMenuModel);

                std::fstream stream;
                size_t size;

                if(!fileIO.OpenFile(stream, size, "weatherstates.json"))
                {
                    Eegeo_ASSERT(false, "Failed to load weatherstates.json definitions file.");
                }

                std::string json((std::istreambuf_iterator<char>(stream)),
                                 (std::istreambuf_iterator<char>()));

                std::vector<WeatherMenuStateModel> weatherStates;
                if(!WeatherMenuDataParser::ParseWeatherStates(json, weatherStates))
                {
                    Eegeo_ASSERT(false, "Failed to parse weatherstates.json definitions file.");
                }

                m_pWeatherController = Eegeo_NEW(WeatherController)(themesService, themesUpdater);

                for(std::vector<WeatherMenuStateModel>::iterator it = weatherStates.begin(); it != weatherStates.end(); it++)
                {
                    WeatherMenuStateModel& weatherState = *it;
                    m_pMenuOptionsModel->AddItem(weatherState.GetName(),
                                                 weatherState.GetName(), "", weatherState.GetIcon(),
                                                 Eegeo_NEW(View::WeatherMenuStateOption)(weatherState, messageBus, metricsService));
                }

                m_pWeatherSelectedMessageHandler = Eegeo_NEW(WeatherSelectedMessageHandler)(*m_pWeatherController, messageBus);
            }
            void WorldPinsService::GetPinEcefAndScreenLocations(const WorldPinItemModel& pinItemModel,
                    Eegeo::dv3& ecefLocation,
                    Eegeo::v2& screenLocation) const
            {
                Eegeo::Pins::Pin* pPin = m_pinRepository.GetPinById(pinItemModel.Id());
                Eegeo_ASSERT(pPin != NULL);

                ecefLocation = m_environmentFlatteningService.GetScaledPointEcef(pPin->GetEcefPosition(),
                               m_environmentFlatteningService.GetCurrentScale());

                Eegeo::Geometry::Bounds2D outScreenBounds = Eegeo::Geometry::Bounds2D::Empty();
                m_pinController.GetScreenBoundsForPin(*pPin, outScreenBounds);
                screenLocation = outScreenBounds.center();
            }
 void TourService::SetActiveTourState(int activeStateIndex)
 {
     Eegeo_ASSERT(m_hasActiveTour);
     Eegeo_ASSERT(activeStateIndex < m_activeTourModel.StateCount());
     
     EXAMPLE_LOG("SDK: Active tour state index: %d, name: %s\n",
                 activeStateIndex,
                 m_activeTourModel.States()[activeStateIndex].Headline().c_str());
     
     if(m_activeTourState != activeStateIndex)
     {
         std::stringstream ss;
         ss << m_activeTourState;
         m_metricsService.SetEvent(TourMetricsPrefix + m_activeTourModel.Name(), TourCardExitedKey, ss.str());
         
         m_activeTourState = activeStateIndex;
         m_pActiveTourStateMachine->ChangeToState(activeStateIndex);
         
         ss.clear();
         ss << m_activeTourState;
         m_metricsService.SetEvent(TourMetricsPrefix + m_activeTourModel.Name(), TourCardEnteredKey, ss.str());
     }
 }
            void MenuController::OnViewClosed()
            {
                Eegeo_ASSERT(!m_dragInProgress, "identity %d\n", Identity());

                if(!m_viewModel.IsFullyClosed())
                {
                    m_viewModel.Close();
                }

                if(m_viewModel.HasReactorControl())
                {
                    m_viewModel.ReleaseReactorControl();
                }
            }
                bool PoiRingTouchController::PerformRayPick(const Eegeo::dv3 &rayOrigin,
                                                            Eegeo::dv3 &rayDirection,
                                                            Eegeo::dv3 &out_rayIntersectionPoint,
                                                            double &out_intersectionParam,
                                                            float &out_terrainHeight,
                                                            float &out_heightAboveTerrain)
                {
                    bool rayPick = false;

                    if(m_appModeModel.GetAppMode() == AppModes::SdkModel::InteriorMode && m_interiorTransitionModel.InteriorIsVisible())
                    {
                        const Eegeo::Resources::Interiors::InteriorsModel* interiorsModel = m_interiorInteractionModel.GetInteriorModel();
                        
                        Eegeo_ASSERT(interiorsModel, "Couldn't get current interiorsModel");
                        
                        const Eegeo::dv3 originNormal = interiorsModel->GetTangentBasis().GetUp();
                        
                        const int selectedFloorIndex = m_interiorInteractionModel.GetSelectedFloorIndex();

                        float floorHeightAboveSeaLevel = Helpers::InteriorHeightHelpers::GetFloorHeightAboveSeaLevel(*interiorsModel, selectedFloorIndex);
                        
                        const Eegeo::dv3 point = originNormal * (floorHeightAboveSeaLevel + Eegeo::Space::EarthConstants::Radius);
                        
                        out_terrainHeight = interiorsModel->GetTangentSpaceBounds().GetMin().y;
                        out_heightAboveTerrain = floorHeightAboveSeaLevel - out_terrainHeight;
                        rayPick = Eegeo::Geometry::IntersectionTests::RayIntersectsWithPlane(rayOrigin, rayDirection, originNormal, point, out_intersectionParam, out_rayIntersectionPoint);
                    }
                    else
                    {
                        rayPick = m_rayPicker.TryGetRayIntersection(rayOrigin, rayDirection, out_rayIntersectionPoint, out_intersectionParam);
                        if(rayPick)
                        {
                            out_terrainHeight = static_cast<float>(out_rayIntersectionPoint.Length() - Eegeo::Space::EarthConstants::Radius);
                            out_heightAboveTerrain = 0.0f;
                        }
                    }
                    if(!rayPick)
                    {
                        rayPick = Eegeo::Geometry::IntersectionTests::GetRayEarthSphereIntersection(rayOrigin, rayDirection, out_rayIntersectionPoint, Eegeo::Space::EarthConstants::RadiusSquared);
                        if(rayPick)
                        {
                            out_terrainHeight = 0.0f;
                            out_heightAboveTerrain = 0.0f;
                            out_intersectionParam = (out_rayIntersectionPoint - rayOrigin).Length();
                        }
                    }

                    return rayPick;
                }
	PinsWithAttachedJavaUIExample::PinsWithAttachedJavaUIExample(
							Eegeo::EegeoWorld& world,
							AndroidNativeState& nativeState,
							Eegeo::Rendering::RenderContext& renderContext,
                            Eegeo::Helpers::ITextureFileLoader& textureLoader,
                            Eegeo::Rendering::GlBufferPool& glBufferPool,
                            Eegeo::Rendering::Shaders::ShaderIdGenerator& shaderIdGenerator,
                            Eegeo::Rendering::Materials::MaterialIdGenerator& materialIdGenerator,
                            Eegeo::Rendering::VertexLayouts::VertexBindingPool& vertexBindingPool,
                            Eegeo::Rendering::VertexLayouts::VertexLayoutPool& vertexLayoutPool,
                            Eegeo::Rendering::RenderableFilters& renderableFilters,
                            const Eegeo::Camera::ICameraProvider& cameraProvider,
                            Eegeo::Resources::Terrain::Heights::TerrainHeightProvider& terrainHeightProvider,
                            Eegeo::Rendering::EnvironmentFlatteningService& environmentFlatteningService
                            )
	: m_nativeState(nativeState)
	, m_renderContext(renderContext)
	, m_world(world)
    , m_pinUserData("Pin User Data")
    {
        textureLoader.LoadTexture(m_pinIconsTexture, "PinIconTexturePage.png", true);
        Eegeo_ASSERT(m_pinIconsTexture.textureId != 0);

        int numberOfTilesAlongEachAxisOfTexturePage = 2;
        m_pPinIconsTexturePageLayout = Eegeo_NEW(Eegeo::Rendering::RegularTexturePageLayout)(
        		numberOfTilesAlongEachAxisOfTexturePage);

        // The following values specify the size and shape of the Pins within the 3D world.
        int spriteWidthInMetres = 100;
        int spriteHeightInMetres = 100;

        m_pPinsModule = Eegeo_NEW(Eegeo::Pins::PinsModule)(
        		m_pinIconsTexture.textureId,
        		*m_pPinIconsTexturePageLayout,
        		glBufferPool,
				shaderIdGenerator,
				materialIdGenerator,
				vertexBindingPool,
				vertexLayoutPool,
				renderableFilters,
				cameraProvider,
				terrainHeightProvider,
				spriteWidthInMetres,
				spriteHeightInMetres,
				Eegeo::Rendering::LayerIds::PlaceNames,
				environmentFlatteningService);

        CreateExamplePins();
    }
            void TourService::StartCurrentActiveTour(const TourModel& tourModel, const int atCard)
            {
                Eegeo_ASSERT(!m_hasActiveTour);
                Eegeo_ASSERT(m_pTourToStateMachineMapping.find(tourModel.Name()) != m_pTourToStateMachineMapping.end());

                m_activeTourModel = tourModel;
                Eegeo_ASSERT(atCard >= 0 && atCard < m_activeTourModel.StateCount(),
                             "Invalid 'atCard' parameter. Must be within range. Was: %d, Max: %d", atCard, m_activeTourModel.StateCount());
                
                m_cameraTransitionController.ResetControllerState();
                
                m_pActiveTourStateMachine = m_pTourToStateMachineMapping[tourModel.Name()];
                m_pActiveTourStateMachine->StartTour(atCard);
                
                m_hasActiveTour = true;
                m_activeTourState = atCard;
                
                m_metricsService.BeginTimedEvent(TourMetricsPrefix + m_activeTourModel.Name());

                std::stringstream ss;
                ss << atCard;
                m_metricsService.SetEvent(TourMetricsPrefix + m_activeTourModel.Name(), TourCardEnteredKey, ss.str());
                
                m_searchRefreshService.SetEnabled(false);
                m_pActiveTourStateMachine = m_pTourToStateMachineMapping[tourModel.Name()];
                m_pActiveTourStateMachine->StartTour(atCard);

                bool showBackButton = !m_previousActiveToursStack.empty();
                
                m_messageBus.Publish(TourOnMapSelectedMessage(m_activeTourModel, atCard, showBackButton));
                m_sdkDomainEventBus.Publish(WorldPins::WorldPinsVisibilityMessage(WorldPins::SdkModel::WorldPinVisibility::TourPin));
                if(m_previousActiveToursStack.size() == 0)
                {
                    m_tourStartedCallbacks.ExecuteCallbacks();
                }
            }
            ApplicationConfiguration ApplicationConfigurationJsonParser::ParseConfiguration(const std::string& serialized)
            {
                rapidjson::Document document;
                
                const bool hasParseError(document.Parse<0>(serialized.c_str()).HasParseError());
                Eegeo_ASSERT(!hasParseError);
                
                Eegeo_ASSERT(document.HasMember("Name"));
                m_builder.SetApplicationName(document["Name"].GetString());
                
                Eegeo_ASSERT(document.HasMember("StartLocationLatitude"));
                Eegeo_ASSERT(document.HasMember("StartLocationLongitude"));
                Eegeo_ASSERT(document.HasMember("StartLocationAltitude"));
                m_builder.SetStartInterestPointLocation(Eegeo::Space::LatLongAltitude::FromDegrees(document["StartLocationLatitude"].GetDouble(),
                                                                                                   document["StartLocationLongitude"].GetDouble(),
                                                                                                   document["StartLocationAltitude"].GetDouble()));
                
                Eegeo_ASSERT(document.HasMember("StartLocationDistance"));
                m_builder.SetStartDistanceFromInterestPoint(static_cast<float>(document["StartLocationDistance"].GetDouble()));
                
                Eegeo_ASSERT(document.HasMember("StartLocationOrientationDegrees"));
                m_builder.SetStartOrientationAboutInterestPoint(static_cast<float>(document["StartLocationOrientationDegrees"].GetDouble()));
                
                Eegeo_ASSERT(document.HasMember("TryStartAtGpsLocation"));
                m_builder.SetTryStartAtGpsLocation(document["TryStartAtGpsLocation"].GetBool());
                
                Eegeo_ASSERT(document.HasMember("GoogleAnalyticsReferrerToken"));
                m_builder.SetGoogleAnalyticsReferrerToken(document["GoogleAnalyticsReferrerToken"].GetString());

                if (document.HasMember("CoverageTreeManifestURL"))
                {
                    m_builder.SetCoverageTreeManifestURL(document["CoverageTreeManifestURL"].GetString());
                }
                
                if (document.HasMember("ThemeManifestURL"))
                {
                    m_builder.SetThemeManifestURL(document["ThemeManifestURL"].GetString());
                }
                
                return m_builder.Build();
            }
Ejemplo n.º 24
0
PinsExample::PinsExample(
    Eegeo::Modules::Core::RenderingModule& renderingModule,
    Eegeo::Modules::IPlatformAbstractionModule& platformAbstractionModule,
    Eegeo::Modules::Map::MapModule& mapModule,
    Eegeo::Rendering::EnvironmentFlatteningService& environmentFlatteningService,
    Eegeo::Camera::GlobeCamera::GlobeCameraController* pCameraController,
    Eegeo::Camera::GlobeCamera::GlobeCameraTouchController& cameraTouchController,
    const Eegeo::Rendering::ScreenProperties& initialScreenProperties
)
	: GlobeCameraExampleBase(pCameraController, cameraTouchController)
    , m_pin0UserData("Pin Zero(0) User Data")
	, m_pin1UserData("Pin One(1) User Data")
	, m_pin2UserData("Pin Two(2) User Data")
	, m_pin3UserData("Pin Three(3) User Data")
	, m_addRemoveTimer(0.0f)
	, m_pPin0(NULL)
{
    Eegeo::Helpers::ITextureFileLoader& textureLoader = platformAbstractionModule.GetTextureFileLoader();
    
	textureLoader.LoadTexture(m_pinIconsTexture, "pins_example/PinIconTexturePage.png", true);
	Eegeo_ASSERT(m_pinIconsTexture.textureId != 0);

	// This example uses a texture page containing 2 x 2 icons.
	// Increase the following number to use a texture page containing more icons
	// (e.g. 3 for a page containing 3 x 3 icons)
	int numberOfTilesAlongEachAxisOfTexturePage = 2;
	m_pPinIconsTexturePageLayout = Eegeo_NEW(Eegeo::Rendering::RegularTexturePageLayout)(numberOfTilesAlongEachAxisOfTexturePage);

	// The following values specify the size and shape of the Pins within the 3D world.
	int spriteWidthInMetres = 64;
	int spriteHeightInMetres = 64;

	// N.B. The implementation for PinModule is given in PinModule.h as a guide for Apps that
	// require an alternate configuration of the various Pin related components.
    m_pPinsModule = Eegeo::Pins::PinsModule::Create(
        renderingModule,
        platformAbstractionModule,
        mapModule,
        m_pinIconsTexture.textureId,
        *m_pPinIconsTexturePageLayout,
        Eegeo::Rendering::LayerIds::PlaceNames,
        spriteWidthInMetres,
        spriteHeightInMetres,
        initialScreenProperties,
        false);

	CreateExamplePins();
}
            void InitialExperienceModuleBase::InitialiseWithApplicationModels(WorldAreaLoader::SdkModel::IWorldAreaLoaderModel &worldAreaLoaderModel,
                                                                              Menu::View::IMenuViewModel& searchMenuViewModelControl,
                                                                              SearchResultMenu::View::ISearchResultMenuViewModel& searchResultMenuViewModel)
            {
                Eegeo_ASSERT(m_pInitialExperienceModel == NULL, "Cannot call InitialExperienceModule::InitialiseWithApplicationModels twice.\n");

                std::vector<IInitialExperienceStep*> steps = CreateSteps(worldAreaLoaderModel,
                                                                         searchMenuViewModelControl,
                                                                         searchResultMenuViewModel);

                const int lastCameraLockedStep = 1;
                
                m_pInitialExperienceModel = Eegeo_NEW(InitialExperienceModel)(steps, lastCameraLockedStep);

                m_pInitialExperienceController = Eegeo_NEW(InitialExperienceController)(*m_pInitialExperienceModel);
            }
 void TransitionToInteriorPointStage::Start()
 {
     Eegeo_ASSERT(m_interiorInteractionModel.HasInteriorModel(), "Must be inside interior to start this transition");
     m_startCameraInterestAltitude = m_cameraController.GetFloorOffsetHeight();
     m_endCameraInterestAltitude = m_startCameraInterestAltitude;
     m_interiorSelectionModel.ClearSelection();
     m_interiorSelectionModel.SelectInteriorId(m_interiorId);
     m_interiorsExplorerModel.HideInteriorExplorer();
     m_transitionTime = 0.0f;
     m_startInterestPoint = m_cameraController.GetInterestLocation();
     m_startDistanceToInterest = m_cameraController.GetDistanceToInterest();
     m_cameraController.SetApplyRestrictions(false);
     m_cameraController.SetApplyFloorOffset(false);
     m_initialisedNextInterior = false;
     m_cameraInterestAltitudeStartTime = 0.0f;
 }
 void CameraTransitionController::StartTransitionTo(const Eegeo::dv3& newInterestPoint,
                                                    float distanceFromInterest,
                                                    float newHeadingRadians,
                                                    const Eegeo::Resources::Interiors::InteriorId& interiorId,
                                                    int targetFloorIndex,
                                                    bool jumpIfFar)
 {
     if(IsTransitioning())
     {
         StopCurrentTransition();
     }
     
     m_navigationService.SetGpsMode(Eegeo::Location::NavigationService::GpsModeOff);
     
     if(m_appModeModel.GetAppMode() == ExampleApp::AppModes::SdkModel::InteriorMode)
     {
         const double exitInteriorDistanceSquared = 100*100;
         double interestDifferenceSquared = (m_interiorsCameraController.GetInterestLocation() - newInterestPoint).LengthSq();
         if(m_interiorSelectionModel.GetSelectedInteriorId() == interiorId)
         {
             Eegeo_ASSERT(interiorId != Eegeo::Resources::Interiors::InteriorId::NullId(), "Invalid state. Have selected null Interior while in Interior mode");
             EnqueueTransitionToInteriorStage(newInterestPoint, distanceFromInterest, interiorId, targetFloorIndex);
             StartQueuedTransition();
             return;
         }
         else if(interiorId != Eegeo::Resources::Interiors::InteriorId::NullId() && interestDifferenceSquared < exitInteriorDistanceSquared)
         {
             EnqueueTransitionToInteriorPointStage(newInterestPoint, distanceFromInterest, newHeadingRadians, interiorId, targetFloorIndex, jumpIfFar);
             StartQueuedTransition();
             return;
         }
         else
         {
             EnqueueExitInteriorStage();
         }
     }
     
     EnqueueTransitionToPointStage(newInterestPoint, distanceFromInterest, newHeadingRadians, jumpIfFar);
     
     if(interiorId != m_interiorSelectionModel.GetSelectedInteriorId() && interiorId != Eegeo::Resources::Interiors::InteriorId::NullId())
     {
         EnqueueTransitionToInteriorStage(newInterestPoint, distanceFromInterest, interiorId, targetFloorIndex);
     }
     
     StartQueuedTransition();
 }
    void MobileExampleApp::InitialisePinsModules(Eegeo::Modules::Map::MapModule& mapModule, Eegeo::EegeoWorld& world)
    {
        m_platformAbstractions.GetTextureFileLoader().LoadTexture(m_pinIconsTexture,
                                                                  Helpers::ImageHelpers::GetImageNameForDevice("SearchResultOnMap/PinIconTexturePage", ".png"),
                                                                  false);
        Eegeo_ASSERT(m_pinIconsTexture.textureId != 0);

        int numberOfTilesAlongEachAxisOfTexturePage = 4;
        m_pPinIconsTexturePageLayout = Eegeo_NEW(Eegeo::Rendering::RegularTexturePageLayout)(numberOfTilesAlongEachAxisOfTexturePage);

        float spriteWidth = m_pinDiameter;
        float spriteHeight = m_pinDiameter;

        Eegeo::Modules::Core::RenderingModule& renderingModule = world.GetRenderingModule();
        Eegeo::Modules::Map::Layers::TerrainModelModule& terrainModelModule = world.GetTerrainModelModule();

        m_pPinsModule = Eegeo_NEW(Eegeo::Pins::PinsModule)(
                            m_pinIconsTexture.textureId,
                            *m_pPinIconsTexturePageLayout,
                            renderingModule.GetGlBufferPool(),
                            renderingModule.GetShaderIdGenerator(),
                            renderingModule.GetMaterialIdGenerator(),
                            renderingModule.GetVertexBindingPool(),
                            renderingModule.GetVertexLayoutPool(),
                            renderingModule.GetRenderableFilters(),
                            terrainModelModule.GetTerrainHeightProvider(),
                            spriteWidth,
                            spriteHeight,
                            Eegeo::Rendering::LayerIds::InteriorEntities,
                            mapModule.GetEnvironmentFlatteningService(),
                            m_screenProperties,
                            false
                        );

        Eegeo::Modules::Map::Layers::InteriorsPresentationModule& interiorsPresentationModule = mapModule.GetInteriorsPresentationModule();
        
        m_pWorldPinsModule = Eegeo_NEW(ExampleApp::WorldPins::SdkModel::WorldPinsModule)(
                                 m_pPinsModule->GetRepository(),
                                 m_pPinsModule->GetController(),
                                 mapModule.GetEnvironmentFlatteningService(),
                                 m_identityProvider,
                                 m_messageBus,
                                 interiorsPresentationModule.GetInteriorsController());
    }
            void MyPinsFileIO::SavePinModelToDisk(const MyPinModel& pinModel)
            {
                std::fstream stream;
                size_t size;

                if (m_fileIO.OpenFile(stream, size, MyPinsDataFilename))
                {
                    std::string json((std::istreambuf_iterator<char>(stream)),
                                     (std::istreambuf_iterator<char>()));

                    rapidjson::Document jsonDoc;
                    if (jsonDoc.Parse<0>(json.c_str()).HasParseError())
                    {
                        Eegeo_TTY("Parse error in MyPins JSON.\n");
                        return;
                    }

                    Eegeo_ASSERT(jsonDoc.IsObject(), "JSON document is not of object type");

                    rapidjson::Document::AllocatorType& allocator = jsonDoc.GetAllocator();
                    rapidjson::Value& myPinsArray = jsonDoc[MyPinsJsonArrayName.c_str()];

                    rapidjson::Value pinModelJson;
                    MyPinModelToJson(pinModel, allocator, m_myPinBoundObjectRepository, pinModelJson);
                    
                    myPinsArray.PushBack(pinModelJson, allocator);

                    rapidjson::StringBuffer strbuf;
                    rapidjson::Writer<rapidjson::StringBuffer> writer(strbuf);
                    jsonDoc.Accept(writer);
                    std::string jsonString = strbuf.GetString();

                    if (WriteJsonToDisk(jsonString))
                    {
                        m_persistentSettings.SetValue(MyPins_LastMyPinModelIdKey, pinModel.Identifier());
                    }
                }
                else
                {
                    Eegeo_TTY("Couldn't open file:%s\n", MyPinsDataFilename.c_str());
                }
            }
 std::string GetFormattedAvailabilityString(const std::string& availabilityString)
 {
     if(availabilityString == Search::Lax::SearchConstants::MEETING_ROOM_AVAILABLE)
     {
         return "Available";
     }
     else if(availabilityString == Search::Lax::SearchConstants::MEETING_ROOM_AVAILABLE_SOON)
     {
         return "Available Soon";
     }
     else if(availabilityString == Search::Lax::SearchConstants::MEETING_ROOM_OCCUPIED)
     {
         return "Occupied";
     }
     else
     {
         Eegeo_ASSERT(false, "Unrecognised meeting room availabity string");
         return "Unknown";
     }
 }