Ejemplo n.º 1
0
 public void RegisterGizmoType(string sType, ITransformGizmoBuilder builder)
 {
     if (GizmoTypes.ContainsKey(sType))
     {
         throw new ArgumentException("TransformManager.RegisterGizmoType : type " + sType + " already registered!");
     }
     GizmoTypes[sType] = builder;
 }
Ejemplo n.º 2
0
        public TransformManager(ITransformGizmoBuilder defaultBuilder)
        {
            activeBuilder = defaultBuilder;
            activeGizmo   = null;

            GizmoTypes = new Dictionary <string, ITransformGizmoBuilder>();
            RegisterGizmoType(NoGizmoType, new NoGizmoBuilder());
            RegisterGizmoType(DefaultGizmoType, activeBuilder);
            sActiveGizmoType = DefaultGizmoType;

            defaultFrameType   = FrameType.LocalFrame;
            lastFrameTypeCache = new Dictionary <SceneObject, FrameType>();

            sOverrideGizmoType = "";
        }
Ejemplo n.º 3
0
        public void SetActiveGizmoType(string sType)
        {
            if (sActiveGizmoType == sType)
            {
                return;
            }
            if (GizmoTypes.ContainsKey(sType) == false)
            {
                throw new ArgumentException("TransformManager.SetActiveGizmoType : type " + sType + " is not registered!");
            }

            activeBuilder    = GizmoTypes[sType];
            sActiveGizmoType = sType;

            update_gizmo();
        }
Ejemplo n.º 4
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();
            }
        }