/// <summary> /// 开始显示图像 /// </summary> public void Start() { if (bWorkStart) { return; } bWorkStart = true; byte[] lpszName = new byte[100]; hWndC = CameraApi.capCreateCaptureWindowA(lpszName, WS_CHILD | WS_VISIBLE, mLeft, mTop, mWidth, mHeight, mControlPtr, 0); if (hWndC.ToInt32() != 0) { CameraApi.SendMessage(hWndC, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0); CameraApi.SendMessage(hWndC, WM_CAP_SET_CALLBACK_ERROR, 0, 0); CameraApi.SendMessage(hWndC, WM_CAP_SET_CALLBACK_STATUSA, 0, 0); CameraApi.SendMessage(hWndC, WM_CAP_DRIVER_CONNECT, 0, 0); CameraApi.SendMessage(hWndC, WM_CAP_SET_SCALE, 1, 0); CameraApi.SendMessage(hWndC, WM_CAP_SET_PREVIEWRATE, 66, 0); CameraApi.SendMessage(hWndC, WM_CAP_SET_OVERLAY, 1, 0); CameraApi.SendMessage(hWndC, WM_CAP_SET_PREVIEW, 1, 0); } return; }
void Start() { camapi = Api.Instance.CameraApi; cam = transform.GetComponentInChildren <Camera>(); float latitude = PlayerPrefs.GetFloat("latitude"); float longitude = PlayerPrefs.GetFloat("longitude"); GameObject.Find("WrldMap").GetComponentInChildren <WrldMap>().m_latitudeDegrees = latitude; GameObject.Find("WrldMap").GetComponentInChildren <WrldMap>().m_longitudeDegrees = longitude; Api.Instance.SetOriginPoint(LatLongAltitude.FromDegrees(latitude, longitude, 500)); cam.farClipPlane = cam.farClipPlane * 2 / 5; Input.simulateMouseWithTouches = false; spawn(); }
public ApiImplementation(string apiKey, CoordinateSystem coordinateSystem, Transform parentTransformForStreamedObjects, ConfigParams configParams) { m_nativePluginRunner = new NativePluginRunner(apiKey, parentTransformForStreamedObjects, 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); }
public void Start(int i)///这是我新添的一个方法,想用来调用另外一个摄像头, { //if (bWorkStart_1) // return; bWorkStart_1 = true; byte[] lpszName_1 = new byte[100]; hWndC_1 = CameraApi.capCreateCaptureWindowB(lpszName_1, WS_CHILD | WS_VISIBLE, mLeft, mTop, mWidth, mHeight, mControlPtr_1, 0); if (hWndC_1.ToInt32() != 0) { CameraApi.SendMessage(hWndC_1, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 1); CameraApi.SendMessage(hWndC_1, WM_CAP_SET_CALLBACK_ERROR, 0, 0); CameraApi.SendMessage(hWndC_1, WM_CAP_SET_CALLBACK_STATUSA, 0, 0); CameraApi.SendMessage(hWndC_1, WM_CAP_DRIVER_CONNECT, 1, 0); CameraApi.SendMessage(hWndC_1, WM_CAP_SET_SCALE, 1, 0); CameraApi.SendMessage(hWndC_1, WM_CAP_SET_PREVIEWRATE, 66, 0); CameraApi.SendMessage(hWndC_1, WM_CAP_SET_OVERLAY, 1, 0); CameraApi.SendMessage(hWndC_1, WM_CAP_SET_PREVIEW, 1, 0); } return; }
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 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()); } }
/// <summary> /// 停止显示 /// </summary> public void Stop() { CameraApi.SendMessage(hWndC, WM_CAP_DRIVER_DISCONNECT, 0, 0); bWorkStart = false; }