コード例 #1
0
ファイル: IndicatorSet.cs プロジェクト: xiaodelea/frame3Sharp
        public IndicatorSet(FScene scene)
        {
            Scene = scene;

            preRender = new PreRenderHelper("indicators_helper")
            {
                PreRenderF = () => { this.PreRender(); }
            };
            scene.AddUIElement(preRender);
        }
コード例 #2
0
        public void AddGizmo(List <TransformableSO> targets)
        {
            ITransformGizmoBuilder useBuilder = activeBuilder;

            if (sOverrideGizmoType != null && sOverrideGizmoType != "")
            {
                useBuilder = GizmoTypes[sOverrideGizmoType];
            }

            List <TransformableSO> useTargets = new List <TransformableSO>(targets);

            if (useTargets.Count > 0 && useBuilder.SupportsMultipleObjects == false)
            {
                useTargets.RemoveRange(1, useTargets.Count - 1);
            }

            FScene scene = Context.Scene;

            // remove existing active gizmo
            // [TODO] support multiple gizmos?
            if (activeGizmo != null)
            {
                if (unordered_lists_equal(activeGizmo.Targets, useTargets))
                {
                    return;     // same targets
                }
                DismissActiveGizmo();
            }

            if (targets != null)
            {
                activeGizmo = useBuilder.Build(scene, useTargets);

                if (activeGizmo == null)
                {
                    return;
                }

                // set frame type. behavior here is a bit tricky...we have a default frame type
                // and then a cached type for each object. However if we only cache type on explicit
                // user changes, then if user changes default, all other gizmos inherit this default.
                // This is currently a problem because we are also using default frame type to
                // control things like snapping behavior (local=translate+rotate, world=translate-only).
                // So then if we change that, we can change default, which then changes object gizmo
                // behavior in unexpected ways. So right now we are initializing cache with a per-type
                // default (always Local right now), which user can then change. This "feels" right-est...
                if (activeGizmo.SupportsFrameMode)
                {
                    if (targets.Count == 1)
                    {
                        if (lastFrameTypeCache.ContainsKey(useTargets[0]) == false)
                        {
                            lastFrameTypeCache[useTargets[0]] = initial_frame_type(useTargets[0]);
                        }
                        activeGizmo.CurrentFrameMode = lastFrameTypeCache[useTargets[0]];
                    }
                    else
                    {
                        activeGizmo.CurrentFrameMode = defaultFrameType;
                    }
                }

                scene.AddUIElement(activeGizmo);
                SendOnActiveGizmoModified();
            }
        }