Пример #1
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();
        }
Пример #2
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());
        }
Пример #3
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);
        }