public virtual void Awake()
        {
            if (objects.Count == 0)
            {
                var markers = FindObjectsOfType <LevelGeneratorMarker>();
                if (markers != null)
                {
                    for (int i = 0; i < markers.Length; i++)
                    {
                        objects.Add(markers[i].gameObject);
                    }
                }
            }

            if (bounds == Vector2.zero)
            {
                bounds.x = CameraHelpers.OrthographicBounds(Camera.main).extents.x;
                bounds.y = CameraHelpers.OrthographicBounds(Camera.main).extents.y;
            }

            if (pixelMode && resolution.x > 0 && resolution.y > 0)
            {
                bounds.x = resolution.x / 100 / 2;
                bounds.y = resolution.y / 100 / 2;
            }
        }
        /// <summary>
        /// Creates a building highlight and adds it to the WrldMap.
        /// </summary>
        /// <param name="buildingHighlightOptions">The BuildingHighlightOptions object specifying how to create the BuildingHighlight object.</param>
        /// <returns>The new BuildingHighlight object</returns>
        public BuildingHighlight CreateHighlight(BuildingHighlightOptions buildingHighlightOptions)
        {
            var createParamsInterop = new BuildingHighlightCreateParamsInterop
            {
                SelectionMode    = buildingHighlightOptions.GetSelectionMode(),
                Location         = buildingHighlightOptions.GetSelectionLocation().ToLatLongInterop(),
                ScreenPoint      = CameraHelpers.ScreenPointOriginTopLeft(buildingHighlightOptions.GetSelectionScreenPoint()),
                HighlightColor   = buildingHighlightOptions.GetColor().ToColorInterop(),
                ShouldCreateView = !buildingHighlightOptions.IsInformationOnly()
            };

            var highlightId = NativeBuildingsApi_CreateHighlight(NativePluginRunner.API, ref createParamsInterop);

            m_materialRepository.CreateAndAddHighlightMaterial(MakeMaterialId(highlightId), buildingHighlightOptions.GetColor());
            var buildingHighlight = new BuildingHighlight(
                this,
                highlightId,
                buildingHighlightOptions.GetColor(),
                buildingHighlightOptions.IsInformationOnly(),
                buildingHighlightOptions.GetBuildingInformationReceivedHandler());

            m_buildingHighlightIdToObject.Add(highlightId, buildingHighlight);

            var buildingInformation = TryFetchBuildingInformationForHighlight(buildingHighlight.Id);

            if (buildingInformation != null)
            {
                buildingHighlight.SetBuildingInformation(buildingInformation);
            }

            return(buildingHighlight);
        }
Exemple #3
0
        private void comboBoxResolutionList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this._Camera == null)
            {
                return;
            }

            int comboBoxResolutionIndex = comboBoxResolutionList.SelectedIndex;

            if (comboBoxResolutionIndex < 0)
            {
                return;
            }
            ResolutionList resolutions = CameraHelpers.GetResolutionList(this._Camera.Moniker);

            if (resolutions == null)
            {
                return;
            }

            if (comboBoxResolutionIndex >= resolutions.Count)
            {
                return; // throw
            }
            if (0 == resolutions[comboBoxResolutionIndex].CompareTo(this._Camera.Resolution))
            {
                // this resolution is already selected
                return;
            }

            // Recreate camera
            this.SetCamera(this._Camera.Moniker, resolutions[comboBoxResolutionIndex]);
        }
Exemple #4
0
        public void SurfaceChanged(ISurfaceHolder holder, [GeneratedEnum] Format format, int width, int height)
        {
            if (surfaceHolder.Surface == null)
            {
                return;
            }
            try
            {
                cameraInstance.StopPreview();
                cameraInstance.SetPreviewDisplay(surfaceHolder);

                Android.Hardware.Camera.Parameters parameters  = cameraInstance.GetParameters();
                Android.Hardware.Camera.Size       optimalSize = CameraHelpers.GetOptimalPreviewSize(context, cameraInstance, width, height);
                parameters.SetPreviewSize(optimalSize.Width, optimalSize.Height);
                parameters.SetPictureSize(optimalSize.Width, optimalSize.Height);
                parameters.FocusMode = Android.Hardware.Camera.Parameters.FocusModeContinuousPicture;
                cameraInstance.SetParameters(parameters);
                cameraInstance.SetDisplayOrientation(CameraHelpers.GetCameraOrientation(context));
                cameraInstance.StartPreview();
            }
            catch (Exception e)
            {
                Log.Debug("Camera activity", "Error starting camera preview: " + e.Message);
            }
        }
            public void Update(PlayerControls playerControls)
            {
                if (Input.GetMouseButton(0) && PlayersGroup.selectedPlayer == playerControls.gameObject)
                {
                    var mousePosition = CameraHelpers.GetMousePosition();

                    if (_previous == Vector3.zero)
                    {
                        _previous = mousePosition;
                    }

                    velocity += (mousePosition - _previous) * speed * playerControls.speed * Time.deltaTime;

                    _previous = mousePosition;
                }
                else if (Input.GetMouseButtonDown(0) && PlayersGroup.selectedPlayer != playerControls)
                {
                    var mousePosition = CameraHelpers.GetMousePosition();

                    if (Math2DHelpers.PointInsideRect(mousePosition.x, mousePosition.y, playerControls.gameObject.transform.position.x, playerControls.gameObject.transform.position.y, playerControls.additionalSettings.size.x, playerControls.additionalSettings.size.y))
                    {
                        PlayersGroup.selectedPlayer = playerControls.gameObject;
                    }
                }
                else
                {
                    _previous = Vector3.zero;
                }

                float angle = Mathf.Atan2(velocity.y, velocity.x) * Mathf.Rad2Deg;

                if (rotation)
                {
                    var targetRotation = Quaternion.AngleAxis(angle, Vector3.forward);

                    playerControls.gameObject.transform.rotation = Quaternion.RotateTowards(playerControls.gameObject.transform.rotation, targetRotation, rotationSpeed * Time.deltaTime);
                }

                if (horizontal == false)
                {
                    velocity.x = 0;
                }
                if (vertical == false)
                {
                    velocity.y = 0;
                }

                playerControls.gameObject.transform.position += velocity * Time.deltaTime;

                if (boundaries && playerControls.additionalSettings.bounds != Vector2.zero)
                {
                    _Bounds(playerControls);
                }

                if (friction != 0)
                {
                    velocity *= 1 / (1 + (Time.deltaTime * friction));
                }
            }
Exemple #6
0
        private void buttonCameraSettings_Click(object sender, EventArgs e)
        {
            if (this._Camera == null)
            {
                return;
            }

            CameraHelpers.DisplayPropertyPage_Device(this._Camera.Moniker, this.Handle);
        }
 public void Get(GameObject obj)
 {
     if (camera == null)
     {
         camera = Camera.main;
     }
     if (camera)
     {
         screenBounds = CameraHelpers.OrthographicBounds(camera);
     }
 }
Exemple #8
0
        void Awake()
        {
            bulletProperties.glowColor    = bulletProperties.glow.color;
            bulletProperties.glow.enabled = false;

            screenBounds = CameraHelpers.OrthographicBounds(Camera.main);

            if (Find("Turret") != null)
            {
                turretFrames = Find("Turret").sprites.Length;
            }
        }
        public bool TryFetchScreenPointForPositioner(Positioner positioner, out Vector3 screenPoint)
        {
            screenPoint = Vector3.zero;

            if (NativePositionerApi_TryFetchScreenPointForPositioner(NativePluginRunner.API, positioner.Id, out screenPoint))
            {
                screenPoint = CameraHelpers.ScreenPointOriginTopLeft(screenPoint);
                return(true);
            }

            return(false);
        }
Exemple #10
0
    void Update()
    {
        // refactor -- shouldn't need this check every frame
        if (!msgListenersSetup)
        {
            //CommunicationManager.Instance.AddEventListener(SFSEvent.OBJECT_MESSAGE, OnObjectMessage);
            msgListenersSetup = true;
        }

        if (angleDirty)
        {
            ISFSObject wallAngleObj = new SFSObject();
            wallAngleObj.PutFloat("wa", wallAngle);
            CommunicationManager.SendObjectMsg(wallAngleObj); // Room Variable instead, so new users get it?
        }

#if UNITY_STANDALONE_OSX
        if ((Input.GetKeyUp(KeyCode.LeftArrow) || Input.GetKeyUp(KeyCode.RightArrow)) && (Input.GetKey(KeyCode.RightCommand) || Input.GetKey(KeyCode.LeftCommand)) && browserPlanes.First != null)
#else
        if ((Input.GetKeyUp(KeyCode.LeftArrow) || Input.GetKeyUp(KeyCode.RightArrow)) && (Input.GetKey(KeyCode.RightControl) || Input.GetKey(KeyCode.LeftControl)) && browserPlanes.First != null)
#endif
        {
            if (Input.GetKeyUp(KeyCode.LeftArrow))
            {
                if (focusedPlane == null)
                {
                    focusedPlane = browserPlanes.First;
                }
                else if (focusedPlane.Previous != null)
                {
                    focusedPlane = focusedPlane.Previous;
                }
            }
            else // Input.GetKeyUp(KeyCode.RightArrow)
            {
                if (focusedPlane == null)
                {
                    focusedPlane = browserPlanes.Last;
                }
                else if (focusedPlane.Next != null)
                {
                    focusedPlane = focusedPlane.Next;
                }
            }

            float offsetBuffer = 4;
            float camPosOffset = CameraHelpers.GetCameraDistFromPlane(focusedPlane.Value, Camera.main) + offsetBuffer;
            Camera.main.transform.position = focusedPlane.Value.GetCenter() + camPosOffset * focusedPlane.Value.go.transform.forward;
            Camera.main.transform.forward  = -focusedPlane.Value.go.transform.forward;
        }
    }
Exemple #11
0
 public void Get(GameObject obj)
 {
     if (camera == null)
     {
         camera = Camera.main;
     }
     if (camera)
     {
         screenBounds = CameraHelpers.OrthographicBounds(camera);
     }
     if (spriteRenderer == null)
     {
         spriteRenderer = obj.GetComponent <SpriteRenderer>();
     }
 }
 public void Get(GameObject obj)
 {
     if (Camera.main.orthographic && bounds == Vector2.zero)
     {
         bounds = CameraHelpers.OrthographicBounds(Camera.main).extents;
     }
     if (spriteRenderer == null)
     {
         spriteRenderer = obj.GetComponent <SpriteRenderer>();
     }
     if (spriteRenderer && size == Vector2.zero)
     {
         size = spriteRenderer.bounds.size;
     }
 }
Exemple #13
0
    public void SnapCameraToSeeAllBizSim()
    {
        if (displayBounds.size.sqrMagnitude <= 0.001f)
        {
            return;
        }

        float worldWidth  = displayBounds.size.x;
        float worldHeight = displayBounds.size.y;

        float camPosOffset = CameraHelpers.GetCamDistToFitPlane(worldWidth, worldHeight, Camera.main.fieldOfView);

        Camera.main.transform.position = 0.5f * worldHeight * Vector3.up + camPosOffset * Vector3.forward;
        Camera.main.transform.forward  = -Vector3.forward;
    }
Exemple #14
0
        void Awake()
        {
            if (additionalSettings.camera == null)
            {
                additionalSettings.camera = GetComponent <Camera>();
            }
            if (additionalSettings.camera == null)
            {
                additionalSettings.camera = Camera.main;
            }
            if (additionalSettings.camera == null)
            {
                return;
            }

            CameraHelpers.SetOrthographic(resolution.x, resolution.y, additionalSettings.camera);
        }
Exemple #15
0
        internal void CalculateCameraParameters(NativeCameraState nativeCameraState, out DoubleVector3 cameraPositionECEF, out DoubleVector3 interestPointECEF, out Vector3 cameraUpECEF)
        {
            var scaledInterestPoint = ScaleInterestPointWithEnvironmentFlattening(nativeCameraState.interestPointECEF);

            Vector3       forward, up;
            DoubleVector3 positionECEF;

            CameraHelpers.CalculateLookAt(
                scaledInterestPoint,
                nativeCameraState.interestBasisForwardECEF,
                nativeCameraState.pitchDegrees * Mathf.Deg2Rad,
                nativeCameraState.distanceToInterestPoint,
                out positionECEF, out forward, out up);

            interestPointECEF  = scaledInterestPoint;
            cameraPositionECEF = positionECEF;
            cameraUpECEF       = up;
        }
        protected override void OnOrientationChanged(OrientationChangedEventArgs e)
        {
            if (cam != null)
            {
                viewfinderBrush.RelativeTransform = CameraHelpers.GetCameraTransformByOrientation(cam.CameraType, Orientation);
            }
            if (Orientation == PageOrientation.LandscapeRight || Orientation == PageOrientation.LandscapeLeft)
            {
                var ratio = _cameraHeight / _cameraWidth;
                cameraGrid.Width  = ratio * _phoneHeight;
                cameraGrid.Height = _phoneWidth;
            }
            else if (Orientation == PageOrientation.PortraitUp)
            {
                var ratio = _cameraHeight / _cameraWidth;
                cameraGrid.Width  = _phoneWidth;
                cameraGrid.Height = ratio * _phoneHeight;
            }

            base.OnOrientationChanged(e);
        }
    private void ExploreMap(bool onOff)
    {
        //MapData currentMap = MapLoaderController.mapLoaderInScene.currentMap;
        if ((bool)MapData.loadedMap?.IsBuilt)
        {
            UserViewController viewingCamera = SettingsController.settingsInScene.viewingCamera;
            SettingsController.settingsInScene.SetViewingCamera(onOff);

            //GameObject mapObj = MapData.loadedMap.GetGameObject();
            //mapObj.SetActive(onOff);

            if (onOff)
            {
                Bounds mapBounds    = MapData.loadedMap.GetBounds();
                Rect   cameraRect   = CameraHelpers.Aspectify(mapBounds.min.xz(), mapBounds.max.xz(), viewingCamera.viewingCamera.aspect);
                float  cameraHeight = Camera.main.PerspectiveDistanceFromWidth(cameraRect.width);
                viewingCamera.transform.position = new Vector3(0, cameraHeight * 0.1f, 0);
                viewingCamera.transform.rotation = Quaternion.LookRotation(Vector3.down);
            }
        }
    }
Exemple #18
0
        private void FillResolutionList()
        {
            comboBoxResolutionList.Items.Clear();
            this.comboBoxResolutionList.Enabled = false;

            if (this._Camera == null)
            {
                return;
            }
            if (this._Camera.Resolution == null)
            {
                return;
            }

            ResolutionList resolutions = CameraHelpers.GetResolutionList(this._Camera.Moniker);

            if (resolutions == null)
            {
                return;
            }

            int index_to_select = -1;

            for (int index = 0; index < resolutions.Count; index++)
            {
                comboBoxResolutionList.Items.Add(resolutions[index].ToString());

                if (resolutions[index].CompareTo(this._Camera.Resolution) == 0)
                {
                    index_to_select = index;
                }
            }

            // select current resolution
            if (index_to_select >= 0)
            {
                this.comboBoxResolutionList.SelectedIndex = index_to_select;
                this.comboBoxResolutionList.Enabled       = true;
            }
        }
Exemple #19
0
 public void Get(GameObject obj)
 {
     if (camera == null)
     {
         camera = Camera.main;
     }
     if (camera)
     {
         screenBounds = CameraHelpers.OrthographicBounds(camera);
     }
     if (spriteRenderer == null)
     {
         spriteRenderer = obj.GetComponent <SpriteRenderer>();
     }
     if (spriteRenderer && size == Vector2.zero)
     {
         size = spriteRenderer.bounds.size;
     }
     if (animator == null)
     {
         animator = obj.GetComponent <Animator>();
     }
 }
Exemple #20
0
    public void ToggleSnapCameraToObject()
    {
        if (MainCameraController.Inst.cameraType != CameraType.SNAPCAM)
        {
            float   offsetBuffer = 4;
            float   camPosOffset = CameraHelpers.GetCameraDistFromPlaneHeight(transform.lossyScale.y, Camera.main.fieldOfView) + offsetBuffer;
            Vector3 pos          = transform.position + camPosOffset * transform.forward;
            // only way I know to get a unique copy of a transform (create another game object.

            /*
             * if (toggleSnapCamHelperGO == null)
             *  toggleSnapCamHelperGO = new GameObject("ToggleSnapCamHelper");
             * toggleSnapCamHelperGO.transform.rotation = Camera.main.transform.rotation;
             * toggleSnapCamHelperGO.transform.forward = -transform.forward;
             */
            MainCameraController.Inst.SnapCamera(pos, Quaternion.LookRotation(-transform.forward), 0.12f);
            snapCamOnMe = true;
        }
        else
        {
            MainCameraController.Inst.cameraType = MainCameraController.Inst.LastCameraType;
            snapCamOnMe = false;
        }
    }
Exemple #21
0
        /// <summary>
        /// Обработка запуска превью камеры
        /// </summary>
        private void StartCamera()
        {
            if (camera != null)
            {
                try
                {
                    camera.StartPreview();
                    return;
                }
                catch (Java.Lang.Exception e)
                {
                }
            }

            try
            {
                camera = CameraHelpers.GetCameraInstance();
                flashCurrent--;
                ToggleFlash();

                if (camera == null)
                {
                    //Log.Debug("Can not connect to camera.");
                }
                else
                {
                    preview = new CameraPreview(this, camera);
                    cameraPreview.RemoveAllViews();
                    cameraPreview.AddView(preview);
                }
            }
            catch (Exception e)
            {
                Log.Debug("Camera activity", e.StackTrace);
            }
        }
Exemple #22
0
        internal void ApplyNativeCameraState(NativeCameraState nativeCameraState, UnityEngine.Camera controlledCamera)
        {
            controlledCamera.fieldOfView   = nativeCameraState.fieldOfViewDegrees;
            controlledCamera.nearClipPlane = nativeCameraState.nearClipPlaneDistance;
            controlledCamera.farClipPlane  = nativeCameraState.farClipPlaneDistance;

            var interestBasis = new EcefTangentBasis(
                nativeCameraState.interestPointECEF,
                nativeCameraState.interestBasisRightECEF,
                nativeCameraState.interestBasisUpECEF,
                nativeCameraState.interestBasisForwardECEF);

            Vector3       forward, up;
            DoubleVector3 positionECEF;

            CameraHelpers.CalculateLookAt(
                interestBasis.PointEcef,
                interestBasis.Forward,
                nativeCameraState.pitchDegrees * Mathf.Deg2Rad,
                nativeCameraState.distanceToInterestPoint,
                out positionECEF, out forward, out up);

            m_interestPointProvider.UpdateFromNative(nativeCameraState.interestPointECEF);

            if (m_coordinateSystem == CoordinateSystem.ECEF)
            {
                var position = (positionECEF - m_originECEF).ToSingleVector();
                controlledCamera.transform.position = position;
                controlledCamera.transform.LookAt((interestBasis.PointEcef - m_originECEF).ToSingleVector(), up);
            }
            else // if (m_coordinateSystem == CoordinateSystem.UnityWorld)
            {
                controlledCamera.transform.position = m_frame.ECEFToLocalSpace(positionECEF);
                controlledCamera.transform.LookAt(m_frame.ECEFToLocalSpace(interestBasis.PointEcef), m_frame.ECEFToLocalRotation * up);
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // disable default ActionBar view and set custom view
            ActionBar.SetCustomView(Resource.Layout.action_bar);
            ActionBar.SetDisplayShowCustomEnabled(true);

            LinearLayout history = (LinearLayout)FindViewById(Resource.Id.historyMenu);

            history.Click += LoadHistory;

            SetContentView(Resource.Layout.Home);

            // get access token
            accessToken = Intent.GetStringExtra("access_token");

            userName = Intent.GetStringExtra("user_name");

            //Parse the connection string and return a reference to the storage account.
            storageAccount = StorageHelpers.StorageAccount(accessToken);

            //Create the blob client object.
            blobClient = storageAccount.CreateCloudBlobClient();

            //Get a reference to a container to use for the sample code, and create it if it does not exist.
            container = blobClient.GetContainerReference(Constant.IMAGE_STORAGE_CONTAINER_NAME);

            // Use the shared access signature (SAS) to perform container operations
            sas = StorageHelpers.GetContainerSasUri(container);

            var updateMenu = FindViewById <LinearLayout>(Resource.Id.updateMenu);

            updateMenu.Selected = true;

            CheckBox checkBox = FindViewById <CheckBox>(Resource.Id.checkBox1);

            checkBox.CheckedChange += CheckBox_CheckedChange;

            CameraHelpers.CreateDirectoryForPictures();

            Button btnOpenCamera = FindViewById <Button>(Resource.Id.btnOpenCamera);

            btnOpenCamera.Click += TakeAPicture;

            Button btnRefresh = (Button)FindViewById(Resource.Id.btnRefresh);

            btnRefresh.Click += UpdateLastKitchenInfo;

            Button btnHistory = FindViewById <Button>(Resource.Id.btnHistory);

            btnHistory.Click += LoadHistory;

            EditText siteName = FindViewById <EditText>(Resource.Id.site);

            siteName.TextChanged += (sender, e) => TryToEnableCameraButton(sender, e);

            EditText plotNumber = FindViewById <EditText>(Resource.Id.plot);

            plotNumber.TextChanged += (sender, e) => TryToEnableCameraButton(sender, e);

            // Set spinners for Sites
            IList sitesList = GetSiteList();

            Spinner      siteSpinner = FindViewById <Spinner>(Resource.Id.siteSpinner);
            ArrayAdapter siteAdapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, sitesList);

            siteAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            siteSpinner.Adapter = siteAdapter;
            siteSpinner.Tag     = "siteSpinner";

            siteSpinner.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(SpinnerItemSelected);

            // Set spinner for kitchen models

            Spinner      kitchenSpinner = FindViewById <Spinner>(Resource.Id.kitchenSpinner);
            ArrayAdapter adapter        = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, Constant.KITCHEN_MODELS);

            adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            kitchenSpinner.Adapter = adapter;
            kitchenSpinner.Tag     = "kitchenSpinner";

            kitchenModelName             = Constant.KITCHEN_MODELS[0];
            kitchenSpinner.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(SpinnerItemSelected);


            // Table

            table = this.FindViewById <TableLayout>(Resource.Id.tableLayout1);

            // TODO: Add last day uploads review
            AddLastKitchenInformation(userName);
        }