Ejemplo n.º 1
0
        public override void PreRender()
        {
            Vector3f pos = PositionF();

            sphereGO.SetPosition(pos);
            sphereGO.SetLocalScale(2 * Radius.WorldValuef);
        }
Ejemplo n.º 2
0
        void update_indicator(CreateDropPrimitiveButton button, FScene scene)
        {
            if (button == null || buttonTypes.ContainsKey(button) == false)
            {
                return;
            }
            SOType t = buttonTypes[button];

            if (t.hasTag(SOType.TagPrimitive) == false)
            {
                return;
            }

            scene.DefaultPrimitiveType = t;

            if (indicatorButton != null)
            {
                indicatorButton.RemoveGO(indicatorGO);
            }
            indicatorButton = button;

            indicatorGO.SetPosition(Vector3f.Zero);
            indicatorGO.SetRotation(Quaternionf.Identity);
            indicatorGO.SetLocalScale(fIndicatorSize * Vector3f.One);
            indicatorGO.SetLocalPosition(
                indicatorGO.GetLocalPosition() + fIndicatorShift * (Vector3f.AxisY - 1 * Vector3f.AxisZ + Vector3f.AxisX));

            indicatorButton.AppendNewGO(indicatorGO, indicatorButton.RootGameObject, false);
            indicatorGO.Show();
        }
Ejemplo n.º 3
0
        void UpdateTracking(bool bSetInitial)
        {
            if (bSetInitial || PositionMode == MovementMode.Static)
            {
                // [TODO] should damp out jitter while allowing larger moves
                if (bStaticUpdated == false)
                {
                    RootGameObject.SetPosition(ActiveCamera.GetPosition());
                    RootGameObject.SetRotation(Quaternionf.Identity);
                    bStaticUpdated = true;
                }
            }
            else if (PositionMode == MovementMode.TrackOrientation)
            {
                RootGameObject.SetPosition(ActiveCamera.GetPosition());
                RootGameObject.SetRotation(ActiveCamera.GetRotation());
            }
            else if (PositionMode == MovementMode.CustomTracking && CustomTracker != null)
            {
                CustomTracker.UpdateTracking(this, ActiveCamera);
            }
            else
            {
                // MovemementMode.TrackPosition
                RootGameObject.SetPosition(ActiveCamera.GetPosition());
                RootGameObject.SetRotation(Quaternionf.Identity);
            }

            // apply post-rotations
            Frame3f     frame    = RootGameObject.GetWorldFrame();
            Quaternionf rotateLR = Quaternionf.AxisAngleD(frame.Y, ShiftAngle);
            Quaternionf rotateUp = Quaternionf.AxisAngleD(rotateLR * frame.X, TiltAngle);

            RootGameObject.SetRotation(rotateLR * rotateUp * RootGameObject.GetRotation());


            // camera-tracking GO always tracks camera
            onCameraGO.SetPosition(ActiveCamera.GetPosition());
            onCameraGO.SetRotation(ActiveCamera.GetRotation());
        }
Ejemplo n.º 4
0
        DropMaterialButton add_material_button(Cockpit cockpit, string sName,
                                               float fHUDRadius, float dx, float dy,
                                               float fButtonRadius,
                                               Material bgMaterial, SOMaterial material)
        {
            DropMaterialButton button = new DropMaterialButton()
            {
                TargetScene = cockpit.Scene,
                Material    = material
            };

            button.Create(fButtonRadius, bgMaterial);
            HUDUtil.PlaceInSphere(button, fHUDRadius, dx, dy);
            button.Name = sName;

            button.OnClicked += (s, e) => {
                cockpit.Scene.DefaultSOMaterial = material;
                if (indicatorButton != null)
                {
                    indicatorButton.RemoveGO(indicatorGO);
                }
                indicatorButton = button;

                indicatorGO.SetPosition(Vector3f.Zero);
                indicatorGO.SetRotation(Quaternionf.Identity);
                indicatorGO.SetLocalScale(fIndicatorSize * Vector3f.One);
                indicatorGO.SetLocalPosition(
                    indicatorGO.GetLocalPosition() + fIndicatorShift * (Vector3f.AxisY - 4 * Vector3f.AxisZ + Vector3f.AxisX));
                indicatorButton.AppendNewGO(indicatorGO, indicatorButton.RootGameObject, false);
            };

            button.OnDoubleClicked += (s, e) => {
                if (cockpit.Scene.Selected.Count > 0)
                {
                    button.DoSetMaterial(cockpit.Scene.Selected, button.Material);
                }
            };
            return(button);
        }
Ejemplo n.º 5
0
        IEnumerator Teleport_Level_Helper(Vector3f vMoveToLocation, Vector3f vNewTargetLocation, Vector3f vPivotAround, float fLevelRotateAngle, float duration)
        {
            yield return(null);

            Sequence mySequence = DOTween.Sequence();

            mySequence.Append(
                ((Material)fadeObject.GetMaterial()).DOFade(1.0f, duration / 3.0f).OnComplete(() => {
                fGameObject sceneGO = UseScene.RootGameObject;

                // set target to new target location explicitly, then reset orbit altitude.
                // now we are level with ground but not at location
                CameraTarget = vPivotAround;
                UseCamera.Manipulator().ResetSceneOrbit(UseScene, false, true, true);

                // add planar rotation if we need it
                if (fLevelRotateAngle != 0)
                {
                    UseCamera.Manipulator().SceneOrbit(UseScene, UseCamera, fLevelRotateAngle, 0.0f);
                }

                // figure out the pan that we would apply to camera, opposite is pan to scene
                Vector3f delta = UseCamera.GetPosition() - vMoveToLocation;
                sceneGO.SetPosition(sceneGO.GetPosition() + delta);
                // also have to shift scene target pos
                CameraTarget = vNewTargetLocation + delta;

                UseCamera.SetTargetVisible(true);
            }));
            mySequence.AppendInterval(duration / 3.0f);
            mySequence.Append(
                ((Material)fadeObject.GetMaterial()).DOFade(0.0f, duration / 3.0f));

            // add a delay before we hide target
            mySequence.AppendInterval(1.0f);
            mySequence.OnComplete(() => {
                UseCamera.SetTargetVisible(false);
            });
        }