public NativePluginRunner(string apiKey, Transform parentForStreamedObjects, ConfigParams config)
        {
            m_textureLoadHandler = new TextureLoadHandler();
            m_materialRepository = new MaterialRepository(config.MaterialsDirectory, config.OverrideLandmarkMaterial, m_textureLoadHandler);
            m_mapGameObjectScene = new MapGameObjectScene(m_materialRepository, parentForStreamedObjects, config.Collisions);
            m_streamingUpdater   = new StreamingUpdater();

            var nativeConfig = config.GetNativeConfig();
            var pathString   = GetStreamingAssetsDir();

            Initialize(Screen.width, Screen.height, Screen.dpi,
                       apiKey,
                       pathString,
                       ref nativeConfig,
                       new MeshUploader.AllocateUnpackedMeshCallback(MeshUploader.AllocateUnpackedMesh),
                       new MeshUploader.UploadUnpackedMeshCallback(MeshUploader.UploadUnpackedMesh),
                       new MapGameObjectScene.AddMeshCallback(MapGameObjectScene.AddMesh),
                       new MapGameObjectScene.DeleteMeshCallback(MapGameObjectScene.DeleteMesh),
                       new MapGameObjectScene.VisibilityCallback(MapGameObjectScene.SetVisible),
                       new CameraApi.CameraEventCallback(CameraApi.OnCameraEvent),
                       new AssertHandler.HandleAssertCallback(AssertHandler.HandleAssert),
                       new TextureLoadHandler.AllocateTextureBufferCallback(TextureLoadHandler.AllocateTextureBuffer),
                       new TextureLoadHandler.BeginUploadTextureBufferCallback(TextureLoadHandler.BeginUploadTextureBuffer),
                       new TextureLoadHandler.ReleaseTextureCallback(TextureLoadHandler.ReleaseTexture),
                       config.CoverageTreeManifestUrl,
                       config.ThemeManifestUrl
                       );

            API = GetAppInterface();
            Debug.Assert(API != IntPtr.Zero);

            m_isRunning = true;
        }
Example #2
0
 public ModelLoader(Device device, TextureLoadHandler textureLoadHandler)
 {
     _device = device;
     _textureLoadHandler = textureLoadHandler;
     _importer = new AssimpImporter();
     _importer.SetConfig(new NormalSmoothingAngleConfig(66.0f));
 }
Example #3
0
 public ModelLoader(Device device, TextureLoadHandler textureLoadHandler)
 {
     _device             = device;
     _textureLoadHandler = textureLoadHandler;
     _importer           = new AssimpImporter();
     _importer.SetConfig(new NormalSmoothingAngleConfig(66.0f));
 }
        internal NativePluginRunner(
            string apiKey,
            TextureLoadHandler textureLoadHandler,
            MaterialRepository materialRepository,
            MapGameObjectScene mapGameObjectScene,
            ConfigParams config,
            IndoorMapScene indoorMapScene,
            IndoorMapsApiInternal indoorMapsApiInternal,
            IndoorMapMaterialService indoorMapMaterialService,
            LabelServiceInternal labelServiceInternal,
            PositionerApiInternal positionerApiInternal,
            CameraApiInternal cameraApiInternal,
            BuildingsApiInternal buildingsApiInternal,
            PrecacheApiInternal precacheApiInternal)
        {
            m_threadService      = new ThreadService();
            m_textureLoadHandler = textureLoadHandler;
            m_materialRepository = materialRepository;
            m_mapGameObjectScene = mapGameObjectScene;
            m_streamingUpdater   = new StreamingUpdater();

            var nativeConfig = config.GetNativeConfig();
            var pathString   = GetStreamingAssetsDir();
            var pathBytes    = GetNullTerminatedUTF8Bytes(pathString);

            var indoorMapsApiHandle            = indoorMapsApiInternal.GetHandle();
            var indoorMapMaterialServiceHandle = indoorMapMaterialService.GetHandle();

            var apiCallbacks = new ApiCallbacks(
                indoorMapsApiHandle,
                indoorMapMaterialServiceHandle,
                indoorMapScene.GetHandle(),
                cameraApiInternal.GetHandle(),
                buildingsApiInternal.GetHandle(),
                m_threadService.GetHandle(),
                textureLoadHandler.GetHandle(),
                mapGameObjectScene.GetHandle(),
                labelServiceInternal.GetHandle(),
                positionerApiInternal.GetHandle(),
                precacheApiInternal.GetHandle());

            Initialize(Screen.width, Screen.height, Screen.dpi,
                       apiKey,
                       pathBytes,
                       ref nativeConfig,
                       ref apiCallbacks,
                       config.CoverageTreeManifestUrl,
                       config.ThemeManifestUrl
                       );

            API = GetAppInterface();
            Debug.Assert(API != IntPtr.Zero);

            m_isRunning = true;
        }
        public NativePluginRunner(string apiKey, TextureLoadHandler textureLoadHandler, MaterialRepository materialRepository, MapGameObjectScene mapGameObjectScene, ConfigParams config)
        {
            // Initialize singleton - this is creepy and should be scheduled as debt
            // Deliberately not assigning it to keep warnings out of the Unity console
            new ThreadService();

            m_textureLoadHandler = textureLoadHandler;
            m_materialRepository = materialRepository;
            m_mapGameObjectScene = mapGameObjectScene;
            m_streamingUpdater   = new StreamingUpdater();

            var nativeConfig = config.GetNativeConfig();
            var pathString   = GetStreamingAssetsDir();

            Initialize(Screen.width, Screen.height, Screen.dpi,
                       apiKey,
                       pathString,
                       ref nativeConfig,
                       new MeshUploader.AllocateUnpackedMeshCallback(MeshUploader.AllocateUnpackedMesh),
                       new MeshUploader.UploadUnpackedMeshCallback(MeshUploader.UploadUnpackedMesh),
                       new MapGameObjectScene.AddMeshCallback(MapGameObjectScene.AddMesh),
                       new MapGameObjectScene.DeleteMeshCallback(MapGameObjectScene.DeleteMesh),
                       new MapGameObjectScene.VisibilityCallback(MapGameObjectScene.SetVisible),
                       new CameraApi.CameraEventCallback(CameraApi.OnCameraEvent),
                       new AssertHandler.HandleAssertCallback(AssertHandler.HandleAssert),
                       new TextureLoadHandler.AllocateTextureBufferCallback(TextureLoadHandler.AllocateTextureBuffer),
                       new TextureLoadHandler.BeginUploadTextureBufferCallback(TextureLoadHandler.BeginUploadTextureBuffer),
                       new TextureLoadHandler.ReleaseTextureCallback(TextureLoadHandler.ReleaseTexture),
                       new ThreadService.CreateThreadDelegate(ThreadService.CreateThread),
                       new ThreadService.JoinThreadDelegate(ThreadService.JoinThread),
                       config.CoverageTreeManifestUrl,
                       config.ThemeManifestUrl
                       );

            API = GetAppInterface();
            Debug.Assert(API != IntPtr.Zero);

            m_isRunning = true;
        }
Example #6
0
        public ApiImplementation(string apiKey, CoordinateSystem coordinateSystem, Transform parentTransformForStreamedObjects, ConfigParams configParams)
        {
            var textureLoadHandler = new TextureLoadHandler();
            var materialRepository = new MaterialRepository(configParams.MaterialsDirectory, configParams.OverrideLandmarkMaterial, textureLoadHandler);

            var terrainCollision  = (configParams.Collisions.TerrainCollision) ? CollisionStreamingType.SingleSidedCollision : CollisionStreamingType.NoCollision;
            var roadCollision     = (configParams.Collisions.RoadCollision) ? CollisionStreamingType.DoubleSidedCollision : CollisionStreamingType.NoCollision;
            var buildingCollision = (configParams.Collisions.BuildingCollision) ? CollisionStreamingType.SingleSidedCollision : CollisionStreamingType.NoCollision;

            m_terrainStreamer   = new GameObjectStreamer("Terrain", materialRepository, parentTransformForStreamedObjects, terrainCollision);
            m_roadStreamer      = new GameObjectStreamer("Roads", materialRepository, parentTransformForStreamedObjects, roadCollision);
            m_buildingStreamer  = new GameObjectStreamer("Buildings", materialRepository, parentTransformForStreamedObjects, buildingCollision);
            m_highlightStreamer = new GameObjectStreamer("Highlights", materialRepository, parentTransformForStreamedObjects, CollisionStreamingType.NoCollision);

            m_mapGameObjectScene = new MapGameObjectScene(m_terrainStreamer, m_roadStreamer, m_buildingStreamer, m_highlightStreamer);

            m_nativePluginRunner = new NativePluginRunner(apiKey, textureLoadHandler, materialRepository, m_mapGameObjectScene, configParams);
            m_coordinateSystem   = coordinateSystem;
            var defaultStartingLocation = LatLongAltitude.FromDegrees(
                configParams.LatitudeDegrees,
                configParams.LongitudeDegrees,
                coordinateSystem == CoordinateSystem.ECEF ? configParams.DistanceToInterest : 0.0);

            if (coordinateSystem == CoordinateSystem.ECEF)
            {
                m_originECEF = defaultStartingLocation.ToECEF();
            }
            else
            {
                m_frame = new UnityWorldSpaceCoordinateFrame(defaultStartingLocation);
            }

            m_cameraController = new CameraApi(this);
            m_buildingsApi     = new BuildingsApi(m_highlightStreamer);
            m_geographicApi    = new GeographicApi();
        }
        public LabelServiceInternal(GameObject unityCanvas, bool enabled, TextureLoadHandler textureLoadHandler)
        {
            if (unityCanvas == null)
            {
                if (enabled)
                {
                    var newUnityCanvas = GameObject.Instantiate(UnityEngine.Resources.Load <GameObject>(CanvasPath));
                    newUnityCanvas.name = CanvasName;
                    newUnityCanvas.transform.SetAsFirstSibling();
                    m_unityCanvas   = newUnityCanvas.GetComponent <Canvas>();
                    m_spawnedCanvas = true;

                    ValidateFont();
                }
            }
            else
            {
                m_unityCanvas = unityCanvas.GetComponent <Canvas>();
            }

            m_handleToSelf       = NativeInteropHelpers.AllocateNativeHandleForObject(this);
            m_enableLabels       = enabled && m_unityCanvas != null;
            m_textureLoadHandler = textureLoadHandler;
        }
Example #8
0
        public ApiImplementation(string apiKey, CoordinateSystem coordinateSystem, Transform parentTransformForStreamedObjects, ConfigParams configParams)
        {
            var textureLoadHandler = new TextureLoadHandler();
            var materialRepository = new MaterialRepository(configParams.MaterialsDirectory, configParams.OverrideLandmarkMaterial, textureLoadHandler);

            var terrainCollision  = (configParams.Collisions.TerrainCollision) ? CollisionStreamingType.SingleSidedCollision : CollisionStreamingType.NoCollision;
            var roadCollision     = (configParams.Collisions.RoadCollision) ? CollisionStreamingType.DoubleSidedCollision : CollisionStreamingType.NoCollision;
            var buildingCollision = (configParams.Collisions.BuildingCollision) ? CollisionStreamingType.SingleSidedCollision : CollisionStreamingType.NoCollision;

            m_root = CreateRootObject(parentTransformForStreamedObjects);

            m_interestPointProvider = new InterestPointProvider(m_root.transform);

            m_terrainStreamer   = new GameObjectStreamer("Terrain", materialRepository, m_root.transform, terrainCollision, true);
            m_roadStreamer      = new GameObjectStreamer("Roads", materialRepository, m_root.transform, roadCollision, true);
            m_buildingStreamer  = new GameObjectStreamer("Buildings", materialRepository, m_root.transform, buildingCollision, true);
            m_highlightStreamer = new GameObjectStreamer("Highlights", materialRepository, m_root.transform, CollisionStreamingType.NoCollision, false);
            m_indoorMapStreamer = new GameObjectStreamer("IndoorMaps", materialRepository, m_root.transform, CollisionStreamingType.NoCollision, false);

            var indoorMapMaterialRepository = new IndoorMapMaterialRepository();

            var indoorMapStreamedTextureObserver = new IndoorMapStreamedTextureObserver(indoorMapMaterialRepository);
            var indoorMapTextureStreamingService = new IndoorMapTextureStreamingService(textureLoadHandler, indoorMapStreamedTextureObserver);

            m_indoorMapsApiInternal = new IndoorMapsApiInternal(indoorMapTextureStreamingService);
            var indoorMapMaterialService = new IndoorMapMaterialService(indoorMapMaterialRepository, m_indoorMapsApiInternal);

            m_indoorMapsApi = new IndoorMapsApi(m_indoorMapsApiInternal);

            var meshUploader   = new MeshUploader();
            var indoorMapScene = new IndoorMapScene(m_indoorMapStreamer, meshUploader, indoorMapMaterialService, m_indoorMapsApiInternal);

            m_mapGameObjectScene   = new MapGameObjectScene(m_terrainStreamer, m_roadStreamer, m_buildingStreamer, m_highlightStreamer, m_indoorMapStreamer, meshUploader, indoorMapScene);
            m_labelServiceInternal = new LabelServiceInternal(UnityEngine.GameObject.Find("Canvas"), configParams.EnableLabels);

            m_positionerApiInternal = new PositionerApiInternal();
            m_positionerApi         = new PositionerApi(m_positionerApiInternal);

            m_cameraApiInternal = new CameraApiInternal();

            m_buildingsApiInternal = new BuildingsApiInternal(materialRepository);
            m_buildingsApi         = new BuildingsApi(m_buildingsApiInternal);

            m_precacheApiInternal = new PrecacheApiInternal();
            m_precacheApi         = new PrecacheApi(m_precacheApiInternal);

            m_nativePluginRunner = new NativePluginRunner(
                apiKey,
                textureLoadHandler,
                materialRepository,
                m_mapGameObjectScene,
                configParams,
                indoorMapScene,
                m_indoorMapsApiInternal,
                indoorMapMaterialService,
                m_labelServiceInternal,
                m_positionerApiInternal,
                m_cameraApiInternal,
                m_buildingsApiInternal,
                m_precacheApiInternal
                );

            m_cameraController = new CameraApi(this, m_cameraApiInternal);

            m_coordinateSystem = coordinateSystem;
            var defaultStartingLocation = LatLongAltitude.FromDegrees(
                configParams.LatitudeDegrees,
                configParams.LongitudeDegrees,
                coordinateSystem == CoordinateSystem.ECEF ? configParams.DistanceToInterest : 0.0);

            m_originECEF = defaultStartingLocation.ToECEF();

            if (coordinateSystem == CoordinateSystem.UnityWorld)
            {
                m_frame = new UnityWorldSpaceCoordinateFrame(defaultStartingLocation);
            }

            m_geographicApi = new GeographicApi(m_root.transform);

            m_environmentFlatteningApiInternal = new EnvironmentFlatteningApiInternal();
            m_environmentFlatteningApi         = new EnvironmentFlatteningApi(m_environmentFlatteningApiInternal);

            m_spacesApi = new SpacesApi(this);

            if (m_coordinateSystem == CoordinateSystem.UnityWorld)
            {
                m_transformUpdateStrategy = new UnityWorldSpaceTransformUpdateStrategy(m_frame, m_environmentFlatteningApi.GetCurrentScale());
            }
            else
            {
                var cameraPosition = m_originECEF;
                m_transformUpdateStrategy = new ECEFTransformUpdateStrategy(
                    cameraPosition,
                    cameraPosition.normalized.ToSingleVector(),
                    m_environmentFlatteningApi.GetCurrentScale());
            }
        }
Example #9
0
 public IndoorMapTextureStreamingService(TextureLoadHandler textureLoadHandler, IIndoorMapStreamedTextureObserver textureObserver)
 {
     m_textureLoadHandler = textureLoadHandler;
     m_textureObserver    = textureObserver;
 }
Example #10
0
 public static void SetTextureLoadHandler(TextureLoadHandler h)
 {
     m_textureLoadHandler = h;
 }
Example #11
0
	public static void SetTextureLoadHandler(TextureLoadHandler h)
	{
		m_textureLoadHandler = h;
	}