Ejemplo n.º 1
0
        public void Connect(
            BrushManager brushManager,
            MaterialManager materialManager,
            OperationStack operationStack,
            SceneManager sceneManager,
            SelectionManager selectionManager,
            Sounds sounds,
            UserInterfaceManager userInterfaceManager
            )
        {
            this.brushManager         = brushManager;
            this.materialManager      = materialManager;
            this.operationStack       = operationStack;
            this.sceneManager         = sceneManager;
            this.selectionManager     = selectionManager;
            this.sounds               = sounds;
            this.userInterfaceManager = userInterfaceManager;

            InitializationDependsOn(brushManager);
            InitializationDependsOn(materialManager);
            InitializationDependsOn(operationStack);
            InitializationDependsOn(sceneManager);
            InitializationDependsOn(selectionManager);
            InitializationDependsOn(sounds);
            InitializationDependsOn(userInterfaceManager);
        }
Ejemplo n.º 2
0
    //===================================================
    void Start()
    {
        // Allocate space for strokes list
        strokes = new List <Stroke> ();
        // Allocaate space for options dictionary
        options = new Dictionary <BrushType, Dictionary <string, object> > ();

        //Debug.Log (BrushManager.AvailableBrushes.Count);

        // Load all default options for all available brushes
        foreach (var type in BrushManager.AvailableBrushes)
        {
            Dictionary <string, object> defaultOpt = BrushManager.GetDefaultOptions(type);
            // TODO: catch exception
            Dictionary <string, object> opt = new Dictionary <string, object> ();
            // loop through default options for specific brush type and add to temp opt
            foreach (var item in defaultOpt)
            {
                opt.Add(item.Key, item.Value);
            }

            options.Add(type, opt);
        }

        // Initialize selected brush with line brush
        SelectedBrush = BrushType.LineBrush;

        // Initialize curStroke with empty
        CurStroke = null;
        Debug.Log("CurStroke initialize: " + CurStroke);
        curStrokeIndex = 0;
        Debug.Log("CurStrokeIndex initialize: " + curStrokeIndex);
    }
Ejemplo n.º 3
0
        public void Paint(GraphPath figure, Graphics g, int time)
        {
            Brush brush1 = null;

            brush1 = BrushManager.GetGDIBrushFromPatten(this.pattern, figure.GetBounds());

            g.FillPath(brush1, figure.GPath);
        }
Ejemplo n.º 4
0
        protected Brush(BrushManager manager, SceneNode node)
        {
            if (manager == null) throw new ArgumentNullException("manager");
            if (node == null) throw new ArgumentNullException("node");

            Manager = manager;
            Node = node;
        }
Ejemplo n.º 5
0
        public BrushCommandFactory(BrushManager brushManager)
        {
            if (brushManager == null) throw new ArgumentNullException("brushManager");

            this.brushManager = brushManager;

            pool.Register(typeof(PickBlockCommand), () => { return new PickBlockCommand(); });
            pool.Register(typeof(SetBrushCommand), () => { return new SetBrushCommand(); });
        }
Ejemplo n.º 6
0
        protected override void LoadContent()
        {
            logger.Info("LoadContent");

            //----------------------------------------------------------------
            // ストレージ マネージャ

            StorageManager.SelectStorageContainer("Blocks.Demo.MainGame");

            //----------------------------------------------------------------
            // リソース ローダ

            ResourceLoader.Register(ContentResourceLoader.Instance);
            ResourceLoader.Register(TitleResourceLoader.Instance);
            ResourceLoader.Register(StorageResourceLoader.Instance);
            ResourceLoader.Register(FileResourceLoader.Instance);

            //----------------------------------------------------------------
            // ビュー コントローラ

            var viewport = GraphicsDevice.Viewport;

            viewInput.InitialMousePositionX = viewport.Width / 2;
            viewInput.InitialMousePositionY = viewport.Height / 2;
            viewInput.MoveVelocity          = moveVelocity;
            viewInput.DashFactor            = dashFactor;
            viewInput.Yaw(MathHelper.Pi);

            //----------------------------------------------------------------
            // ワールド マネージャ

            worldManager = new WorldManager(Services, GraphicsDevice);
            worldManager.Initialize();

            //----------------------------------------------------------------
            // リージョン

            // TODO
            region = worldManager.Load("dummy");

            //----------------------------------------------------------------
            // ブラシ マネージャ

            brushManager = new BrushManager(Services, GraphicsDevice, worldManager, commandManager);

            //----------------------------------------------------------------
            // その他

            spriteBatch         = new SpriteBatch(GraphicsDevice);
            font                = Content.Load <SpriteFont>("Fonts/Debug");
            fillTexture         = Texture2DHelper.CreateFillTexture(GraphicsDevice);
            helpMessageFontSize = font.MeasureString(helpMessage);

            BuildInfoMessage();
            informationTextFontSize = font.MeasureString(stringBuilder);
        }
Ejemplo n.º 7
0
        public BrushSidebarPanel()
        {
            InitializeComponent();

            BrushManager.Init();
            BrushManager.SetBrushControl(this);
            Mediator.Subscribe(EditorMediator.ResetSelectedBrushType, this);

            RoundCreatedVerticesCheckbox.Checked = BrushManager.RoundCreatedVertices;
        }
Ejemplo n.º 8
0
        public void Paint(GraphicsPath path, Graphics g, int time, float opacity)
        {
            Brush brush1 = null;

            this.pattern.Opacity = opacity;

            brush1 = BrushManager.GetGDIBrushFromPatten(this.pattern, path.GetBounds());

            g.FillPath(brush1, path);
        }
Ejemplo n.º 9
0
 public void StartNewStroke()
 {
     if (CurrentStroke == null)
     {
         CurrentStroke = new Stroke();
         strokes.Add(CurrentStroke);
         curIndex            = strokes.Count - 1;
         CurrentStroke.Brush = BrushManager.CreateBrush(CurrentStroke, SelectedBrush, null);
         CurrentStroke.Brush.SetOptions(options[CurrentStroke.Brush.BrushName]);
     }
 }
Ejemplo n.º 10
0
        public IBrushInstance MakeInstance([NotNull] Player player, [NotNull] Command cmd, [NotNull] DrawOperation op)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (cmd == null)
            {
                throw new ArgumentNullException("cmd");
            }
            if (op == null)
            {
                throw new ArgumentNullException("op");
            }

            if (cmd.HasNext)
            {
                Block block = cmd.NextBlock(player);
                if (block == Block.Undefined)
                {
                    return(null);
                }

                string brushName = cmd.Next();
                if (brushName == null || !CommandManager.IsValidCommandName(brushName))
                {
                    player.Message("ReplaceBrush usage: &H/Brush rb <Block> <BrushName>");
                    return(null);
                }
                IBrushFactory brushFactory = BrushManager.GetBrushFactory(brushName);

                if (brushFactory == null)
                {
                    player.Message("Unrecognized brush \"{0}\"", brushName);
                    return(null);
                }

                IBrush replacement = brushFactory.MakeBrush(player, cmd);
                if (replacement == null)
                {
                    return(null);
                }
                Block       = block;
                Replacement = replacement;
            }

            ReplacementInstance = Replacement.MakeInstance(player, cmd, op);
            if (ReplacementInstance == null)
            {
                return(null);
            }

            return(new ReplaceBrushBrush(this));
        }
Ejemplo n.º 11
0
        public FreeBrush(BrushManager manager, SceneNode node)
            : base(manager, node)
        {
            var mesh = manager.LoadAsset<Mesh>("title:Resources/Meshes/Cube.json");

            brushMesh = new BrushMesh("BrushMesh", manager.GraphicsDevice, mesh);
            brushMesh.Color = new Vector3(1, 0, 0);
            brushMesh.Alpha = 0.5f;
            Node.Objects.Add(brushMesh);

            // 常にペイント可能。
            CanPaint = true;
        }
Ejemplo n.º 12
0
        public StickyBrush(BrushManager manager, SceneNode node)
            : base(manager, node)
        {
            var mesh = manager.LoadAsset<Mesh>("title:Resources/Meshes/Cube.json");

            brushMesh = new BrushMesh("BrushMesh", manager.GraphicsDevice, mesh);
            brushMesh.Color = new Vector3(1, 0, 0);
            brushMesh.Alpha = 0.5f;
            Node.Objects.Add(brushMesh);

            triangleInfos = new TriangleInfo[2 * 6];

            // 原点中心の立方体をブロックのグリッドへ移動させるための行列。
            var transform = Matrix.CreateTranslation(new Vector3(0.5f));

            int i = 0;
            for (int j = 0; j < Side.Count; j++)
            {
                var side = Side.Items[j];

                var normal = side.Direction.ToVector3();

                var side1 = new Vector3(normal.Y, normal.Z, normal.X);
                var side2 = Vector3.Cross(normal, side1);

                // (0,0,0) を原点に頂点を算出。
                var v0 = (normal - side1 - side2) * 0.5f;
                var v1 = (normal - side1 + side2) * 0.5f;
                var v2 = (normal + side1 + side2) * 0.5f;
                var v3 = (normal + side1 - side2) * 0.5f;

                // ブロックのグリッドに移動。
                Vector3.Transform(ref v0, ref transform, out v0);
                Vector3.Transform(ref v1, ref transform, out v1);
                Vector3.Transform(ref v2, ref transform, out v2);
                Vector3.Transform(ref v3, ref transform, out v3);

                triangleInfos[i] = new TriangleInfo(side)
                {
                    Triangle = new Triangle(v0, v1, v2)
                };

                triangleInfos[i + 1] = new TriangleInfo(side)
                {
                    Triangle = new Triangle(v0, v2, v3)
                };

                i += 2;
            }
        }
Ejemplo n.º 13
0
        /// <summary>Draws a hatch component on the specified path.</summary>
        /// <param name="graphics">The specified graphics to draw on.</param>
        /// <param name="hatch">The hatch type.</param>
        /// <param name="hatchPath">The hatch path to fill.</param>
        public static void RenderHatch(Graphics graphics, Hatch hatch, GraphicsPath hatchPath)
        {
            if (!hatch.Visible)
            {
                return;
            }

            HatchBrush hatchBrush = new HatchBrush(hatch.Style, hatch.ForeColor, hatch.BackColor);

            using (TextureBrush textureBrush = BrushManager.HatchTextureBrush(hatchBrush))
            {
                textureBrush.ScaleTransform(hatch.Size.Width, hatch.Size.Height);
                graphics.FillPath(textureBrush, hatchPath);
            }
        }
Ejemplo n.º 14
0
        public IBrush MakeBrush([NotNull] Player player, [NotNull] Command cmd)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (cmd == null)
            {
                throw new ArgumentNullException("cmd");
            }

            if (!cmd.HasNext)
            {
                player.Message("ReplaceBrush usage: &H/Brush rb <Block> <BrushName>");
                return(null);
            }

            Block block = cmd.NextBlock(player);

            if (block == Block.Undefined)
            {
                return(null);
            }

            string brushName = cmd.Next();

            if (brushName == null || !CommandManager.IsValidCommandName(brushName))
            {
                player.Message("ReplaceBrush usage: &H/Brush rb <Block> <BrushName>");
                return(null);
            }
            IBrushFactory brushFactory = BrushManager.GetBrushFactory(brushName);

            if (brushFactory == null)
            {
                player.Message("Unrecognized brush \"{0}\"", brushName);
                return(null);
            }

            IBrush newBrush = brushFactory.MakeBrush(player, cmd);

            if (newBrush == null)
            {
                return(null);
            }

            return(new ReplaceBrushBrush(block, newBrush));
        }
Ejemplo n.º 15
0
    // Use this for initialization
    void Start()
    {
        strokes = new List <Stroke>();

        options = new Dictionary <string, Dictionary <string, object> >();

        foreach (string name in BrushManager.AvailableBrushes)
        {
            Dictionary <string, object> defaultOpt = BrushManager.GetDefaultOptions(name);
            Dictionary <string, object> opt        = new Dictionary <string, object>();
            foreach (KeyValuePair <string, object> pair in defaultOpt)
            {
                opt.Add(pair.Key, pair.Value);
            }
            options.Add(name, opt);
        }
    }
Ejemplo n.º 16
0
    /// <summary>
    /// Starts the new stroke.
    /// </summary>
    public void startNewStroke(GameObject painting, GameObject brushCursor)
    {
        if (CurStroke == null)
        {
            // ################# using prefab to create stroke game object #################

            // Make sure current stroke is empty and Create a new stroke according to selected brush type
            // GameObject.Instantiate(Object original, Vector3 position, Quaternion rotation);
            // original: An existing object that you want to make a copy of.
            // position: Position for the new object (default Vector3.zero).
            // rotation: Orientation of the new object (default Quaternion.identity).
            GameObject newStroke = (GameObject)Instantiate(BrushManager.getPrefab(SelectedBrush), brushCursor.transform.position, brushCursor.transform.rotation);

            // #############################################################################
            // Rename new stroke gameobject in the scene
            string name = "Stroke_" + strokes.Count.ToString();
            newStroke.name = name;

            // Make new stroke be a child of painting object
            newStroke.transform.SetParent(painting.transform, false);

            // Scale new stroke size according whole project scale
            // TODO: whole project scale needed to be redesigned
            newStroke.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f);


            // get newStroke's stroke object from script component
            CurStroke = newStroke.GetComponent <Stroke> ();
            CurStroke.Initialize();

            // Add newStroke to stroke list
            strokes.Add(CurStroke);
            curStrokeIndex = strokes.Count - 1;

            // Create brush scriptableobject related to current stroke
            CurStroke.Brush = BrushManager.CreateBrush(CurStroke, SelectedBrush, options [SelectedBrush]);

            // because in above line, brush of curStroke haven't been created, so pass null, to CreateBrush
            // Set options after CurStroke.Brush been created
            CurStroke.Brush.SetOptions(options [CurStroke.Brush.BrushName]);
        }
        // TODO: if the CurStroke is not empty
    }
Ejemplo n.º 17
0
        public void Connect(
            AmbientOcclusionManager aoManager,
            BrushManager brushManager,
            CurveTool.CurveTool curveTool,
            HighLevelRenderer highLevelRenderer,
            MaterialManager materialManager,
            Operations operations,
            OperationStack operationStack,
            IRenderer renderer,
            SceneManager sceneManager,
            SelectionManager selectionManager,
            ShadowRenderer shadowRenderer,
            Sounds sounds,
            Statistics statistics,
            TextRenderer textRenderer,
            OpenTK.GameWindow window
            )
        {
            this.aoManager         = aoManager;
            this.brushManager      = brushManager;
            this.curveTool         = curveTool;
            this.highLevelRenderer = highLevelRenderer;
            this.materialManager   = materialManager;
            this.operations        = operations;
            this.operationStack    = operationStack;
            this.renderer          = renderer;
            this.sceneManager      = sceneManager;
            this.selectionManager  = selectionManager;
            this.shadowRenderer    = shadowRenderer;
            this.sounds            = sounds;
            this.statistics        = statistics;
            this.textRenderer      = textRenderer;
            this.window            = window;

            InitializationDependsOn(brushManager, materialManager, renderer, sceneManager, selectionManager, textRenderer);
            InitializationDependsOn(curveTool);

            initializeInMainThread = true;
        }
Ejemplo n.º 18
0
        static void Main()
        {
            // factory
            var factories = new ShopFactory[2];

            factories[0] = new CanvasFactory("cloth", 14, 12, 100);
            factories[1] = new DrawingPaperFactory("Cardboard", 30, 30, 15);

            foreach (ShopFactory factory in factories)
            {
                Console.WriteLine(factory.GetType().Name);
            }
            Console.WriteLine("\n\n");
            // Builder
            var pencil = new SupplieCreator(new Pencil("red", 12, 2, 1));

            pencil.CreateSupplie();
            pencil.GetSupplie();

            var pastel = new SupplieCreator(new Pastel("black", 2, 4, 2));

            pastel.CreateSupplie();
            pastel.GetSupplie();

            //abstract factory
            IBrush       standartBrush = new AngleBrush();
            BrushManager standartManag = new BrushManager(standartBrush);

            Console.WriteLine(standartManag.GetAngleBrushDelails());
            Console.WriteLine(standartManag.GetFlatBrushDetails());

            IBrush       acrylicBrush = new FlatBrush();
            BrushManager acrylicManag = new BrushManager(acrylicBrush);

            Console.WriteLine(acrylicManag.GetAngleBrushDelails());
            Console.WriteLine(acrylicManag.GetFlatBrushDetails());

            Console.ReadLine();
        }
Ejemplo n.º 19
0
        public void Connect(
            BrushManager brushManager,
            MaterialManager materialManager,
            IRenderer renderer,
            SelectionManager selectionManager,
            Sounds sounds,
            TextRenderer textRenderer,
            UserInterfaceManager userInterfaceManager,
            OpenTK.GameWindow window
            )
        {
            this.brushManager         = brushManager;
            this.materialManager      = materialManager;
            this.renderer             = renderer;
            this.selectionManager     = selectionManager;
            this.sounds               = sounds;
            this.textRenderer         = textRenderer;
            this.userInterfaceManager = userInterfaceManager;
            this.window               = window;

            InitializationDependsOn(brushManager, materialManager, renderer);

            //debugLineRenderer.Initialize();
        }
Ejemplo n.º 20
0
        public static Stroke GetStroke(IGraphPath path)
        {
            Pen       pen1   = null;
            string    text1  = AttributeFunc.ParseAttribute("stroke", (SvgElement)path, false).ToString();
            Color     color1 = Color.Empty;
            ISvgBrush brush1 = new SolidColor(Color.Empty);

            if ((text1 != null) || (text1 != string.Empty))
            {
                brush1 = BrushManager.Parsing(text1, ((SvgElement)path).OwnerDocument);
            }
            text1 = AttributeFunc.ParseAttribute("stroke-opacity", (SvgElement)path, false).ToString();
            float single1 = 1f;

            if ((text1 != string.Empty) && (text1 != null))
            {
                single1 = Math.Max((float)0f, Math.Min((float)255f, ItopVector.Core.Func.Number.ParseFloatStr(text1)));
            }
            if (single1 > 1f)
            {
                single1 /= 255f;
            }
            single1 = Math.Min(path.Opacity, path.StrokeOpacity);
            float  single2 = 1f;
            object obj1    = AttributeFunc.ParseAttribute("stroke-width", (SvgElement)path, false);

            if (obj1 is float)
            {
                single2 = (float)obj1;
            }
            pen1           = new Pen(Color.Empty, single2);
            pen1.Alignment = PenAlignment.Outset;
            string text2 = AttributeFunc.FindAttribute("stroke-linecap", (SvgElement)path).ToString();

            if (text2 == "round")
            {
                LineCap cap1;
                pen1.EndCap   = cap1 = LineCap.Round;
                pen1.StartCap = cap1;
            }
            else if (text2 == "square")
            {
                LineCap cap2;
                pen1.EndCap   = cap2 = LineCap.Square;
                pen1.StartCap = cap2;
            }
            else
            {
                LineCap cap3;
                pen1.EndCap   = cap3 = LineCap.Flat;
                pen1.StartCap = cap3;
            }
            string text3 = AttributeFunc.FindAttribute("stroke-linejoin", (SvgElement)path).ToString();

            if (text3 == "round")
            {
                pen1.LineJoin = LineJoin.Round;
            }
            else if (text3 == "bevel")
            {
                pen1.LineJoin = LineJoin.Bevel;
            }
            else
            {
                pen1.LineJoin = LineJoin.Miter;
            }
            string text4 = AttributeFunc.FindAttribute("stroke-miterlimit", (SvgElement)path).ToString();

            if (text4 == "")
            {
                text4 = "4";
            }
            float single3 = ItopVector.Core.Func.Number.parseToFloat(text4, (SvgElement)path, SvgLengthDirection.Horizontal);

            if (single3 < 1f)
            {
                throw new Exception("stroke-miterlimit " + ItopVector.Core.Config.Config.GetLabelForName("notlowerstr") + " 1:" + text4);
            }
            pen1.MiterLimit = single3;
            string text5 = AttributeFunc.FindAttribute("stroke-dasharray", (SvgElement)path).ToString();

            if ((text5 != "") && (text5 != "none"))
            {
                Regex regex1 = new Regex(@"[\s\,]+");
                text5 = regex1.Replace(text5, ",");
                char[] chArray1 = new char[1] {
                    ','
                };
                string[] textArray1   = text5.Split(chArray1);
                float[]  singleArray1 = new float[textArray1.GetLength(0)];
                for (int num1 = 0; num1 < textArray1.GetLength(0); num1++)
                {
                    singleArray1[num1] = ItopVector.Core.Func.Number.ParseFloatStr(textArray1[num1]) / pen1.Width;
                }
                if ((singleArray1.GetLength(0) % 2) == 1)
                {
                    float[] singleArray2 = new float[singleArray1.GetLength(0) * 2];
                    singleArray1.CopyTo(singleArray2, 0);
                    singleArray1.CopyTo(singleArray2, singleArray1.GetLength(0));
                    singleArray1 = singleArray2;
                }
                pen1.DashPattern = singleArray1;
            }
            string text6   = AttributeFunc.FindAttribute("stroke-dashoffset", (SvgElement)path).ToString();
            float  single4 = 0f;

            if (text6 != "")
            {
                single4 = ItopVector.Core.Func.Number.parseToFloat(text6, (SvgElement)path, SvgLengthDirection.Horizontal);
            }
            float single5 = Math.Abs((float)AnimFunc.GetAnimateValue((SvgElement)path, "stroke-dashoffset", DomType.SvgNumber, single4)) / pen1.Width;

            pen1.DashOffset = single5 / single2;
            if (brush1 != null)
            {
                brush1.Pen = pen1;
            }
            Stroke stroke1 = new Stroke(brush1);

            stroke1.Opacity = single1;
            return(stroke1);
        }
Ejemplo n.º 21
0
        private void EditorLoad(object sender, EventArgs e)
        {
            FileTypeRegistration.RegisterFileTypes();

            SettingsManager.Read();

            if (TaskbarManager.IsPlatformSupported)
            {
                TaskbarManager.Instance.ApplicationId = FileTypeRegistration.ProgramId;

                _jumpList = JumpList.CreateJumpList();
                _jumpList.KnownCategoryToDisplay = JumpListKnownCategoryType.Recent;
                _jumpList.Refresh();
            }

            UpdateDocumentTabs();
            UpdateRecentFiles();

            DockBottom.Hidden = DockLeft.Hidden = DockRight.Hidden = true;

            MenuManager.Init(mnuMain, tscToolStrip);
            MenuManager.Rebuild();

            BrushManager.Init();
            SidebarManager.Init(RightSidebar);

            ViewportManager.Init(TableSplitView);
            ToolManager.Init();

            foreach (var tool in ToolManager.Tools)
            {
                var tl     = tool;
                var hotkey = CBRE.Settings.Hotkeys.GetHotkeyForMessage(HotkeysMediator.SwitchTool, tool.GetHotkeyToolType());
                tspTools.Items.Add(new ToolStripButton(
                                       "",
                                       tl.GetIcon(),
                                       (s, ea) => Mediator.Publish(HotkeysMediator.SwitchTool, tl.GetHotkeyToolType()),
                                       tl.GetName())
                {
                    Checked      = (tl == ToolManager.ActiveTool),
                    ToolTipText  = tl.GetName() + (hotkey != null ? " (" + hotkey.Hotkey + ")" : ""),
                    DisplayStyle = ToolStripItemDisplayStyle.Image,
                    ImageScaling = ToolStripItemImageScaling.None,
                    AutoSize     = false,
                    Width        = 36,
                    Height       = 36
                }
                                   );
            }

            TextureProvider.SetCachePath(SettingsManager.GetTextureCachePath());
            MapProvider.Register(new RmfProvider());
            MapProvider.Register(new MapFormatProvider());
            MapProvider.Register(new VmfProvider());
            MapProvider.Register(new L3DWProvider());
            GameDataProvider.Register(new FgdProvider());
            TextureProvider.Register(new SprProvider());
            TextureProvider.Register(new MiscTexProvider());
            ModelProvider.Register(new AssimpProvider());

            TextureHelper.EnableTransparency       = !CBRE.Settings.View.GloballyDisableTransparency;
            TextureHelper.DisableTextureFiltering  = CBRE.Settings.View.DisableTextureFiltering;
            TextureHelper.ForceNonPowerOfTwoResize = CBRE.Settings.View.ForcePowerOfTwoTextureResizing;

            Subscribe();

            Mediator.MediatorException += (mthd, ex) => Logging.Logger.ShowException(ex.Exception, "Mediator Error: " + ex.Message);

            if (string.IsNullOrEmpty(Directories.TextureDir))
            {
                OpenSettings(4);
            }

            if (CBRE.Settings.View.LoadSession)
            {
                foreach (var session in SettingsManager.LoadSession())
                {
                    LoadFileGame(session, SettingsManager.Game);
                }
            }

            ProcessArguments(System.Environment.GetCommandLineArgs());

            ViewportManager.RefreshClearColour(DocumentTabs.TabPages.Count == 0);
        }
Ejemplo n.º 22
0
        public void Insert()
        {
            SelectionManager selectionManager = RenderStack.Services.BaseServices.Get <SelectionManager>();
            BrushManager     brushManager     = RenderStack.Services.BaseServices.Get <BrushManager>();

            if (
                (selectionManager == null) ||  
                    (brushManager == null) ||
                (selectionManager.HoverModel == null) ||
                (selectionManager.HoverPolygon == null)
                )
            {
                return;
            }

            GeometryMesh mesh = selectionManager.HoverModel.Batch.MeshSource as GeometryMesh;

            if (mesh == null)
            {
                return;
            }

            int   cornerCount = selectionManager.HoverPolygon.Corners.Count;
            Brush brush       = brushManager.CurrentBrush;

            if (
                (brush == null) ||
                (brush.PolygonDictionary.ContainsKey(cornerCount) == false)
                )
            {
                Dictionary <int, Brush> dictionary = brushManager.Dictionary(userInterfaceManager.CurrentPalette);
                if (dictionary == null)
                {
                    return;
                }

                if (dictionary.ContainsKey(cornerCount))
                {
                    brush = dictionary[cornerCount];
                }
                else
                {
                    return;
                }
            }

            GeometryMesh brushPolyMesh = brush.Model.Batch.MeshSource as GeometryMesh;

            Polygon        brushPolygon = brush.PolygonDictionary[cornerCount];
            ReferenceFrame hoverFrame   = Operations.MakePolygonReference(mesh.Geometry, selectionManager.HoverPolygon);
            ReferenceFrame brushFrame   = Operations.MakePolygonReference(brushPolyMesh.Geometry, brushPolygon);

            float scale = hoverFrame.Scale / brushFrame.Scale;

            if (scale != 1.0f)
            {
                //Geometry newGeometry = new CloneGeometryOperation(brushPolyMesh.Geometry, null).Destination;
                Matrix4 scaleTransform;
                Matrix4.CreateScale(scale, out scaleTransform);
                //newGeometry.Transform(scaleTransform);
                //newGeometry.ComputePolygonCentroids();
                //newGeometry.ComputePolygonNormals();
                ////newGeometry.ComputeCornerNormals(0.0f);
                //newGeometry.SmoothNormalize("corner_normals", "polygon_normals", (0.0f * (float)Math.PI));
                //newGeometry.BuildEdges();

                brushFrame.Transform(scaleTransform);

                brushPolyMesh = brush.ScaledMesh(scale); //new GeometryMesh(newGeometry, NormalStyle.PolygonNormals);
            }

            //  Flip target normal..
            hoverFrame.Normal *= -1.0f;

            Matrix4 hoverTransform = hoverFrame.GetTransform();
            Matrix4 brushTransform = brushFrame.GetTransform();
            Matrix4 inverseBrush   = Matrix4.Invert(brushTransform);
            Matrix4 align          = hoverTransform * inverseBrush;

            Material material = materialManager[userInterfaceManager.CurrentMaterial];

            Model newModel = new Model(
                brush.Model.Name,
                brushPolyMesh,
                material,
                align
                );

            if (Configuration.physics)
            {
                newModel.PhysicsShape = brush.ScaledShape(scale);
            }

            newModel.Frame.Updated = false;
            newModel.Frame.Parent  = selectionManager.HoverModel.Frame;
            newModel.Frame.UpdateHierarchicalNoCache();
            sceneManager.UnparentModel(newModel);
            //newModel.Frame.Updated = true;

            //  Added objects are not static in physics sence
            newModel.Static = !userInterfaceManager.AddWithPhysics;

            Insert op = new Insert(newModel);

            operationStack.Do(op);

#if false
            newModel.Frame.Debug(0);

            newModel.Selected = true;
            selectionManager.Models.Add(newModel);
            selectionManager.HoverModel.Selected = true;
            selectionManager.Models.Add(selectionManager.HoverModel);
#endif
        }
Ejemplo n.º 23
0
        protected override void OnLoad(EventArgs e)
        {
            string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            Title = String.Format("StoneVox 3D - version {0}", version);

            GL.Viewport(0, 0, Width, Height);
            Qfont_1280 = new QFont("data\\fonts\\Bigfish.ttf", 11.2f, new QFontBuilderConfiguration(true, false));
            Qfont_1400 = new QFont("data\\fonts\\Bigfish.ttf", 12f, new QFontBuilderConfiguration(true, false));
            Qfont_1920 = new QFont("data\\fonts\\Bigfish.ttf", 15, new QFontBuilderConfiguration(true, false));
            if (Width <= 1280)
            {
                Qfont = Qfont_1280;
            }
            else if (Width < 1400)
            {
                Qfont = Qfont_1400;
            }
            else
            {
                Qfont = Qfont_1920;
            }

            this.Qfont.Options.Colour = Color.White;
            //this.Qfont.Options.TransformToViewport = new TransformViewport(-1,-1,2,2);

            Scale.SetHScaling(0, Width);
            Scale.SetVScaling(0, Height);

            ShaderUtil.CreateShader("quad_interpolation", "./data/shaders/QuadInterpolation.vs", "./data/shaders/QuadInterpolation.fs");

            broadcaster = new Broadcaster();
            manager = new QbManager(broadcaster);
            input = new Input(this);
            camera = new Camera(this, input, manager);
            brushes = new BrushManager(this, input);
            floor = new Floor(camera, broadcaster);
            gui = new GUI(this, manager, input);
            selection = new Selection(this,brushes, input, manager, floor, gui);
            renderer = new Wireframe(camera, selection, floor, input);
            undoredo = new UndoRedo(input);

            selection.GenerateVertexArray();

            if(!manager.HasModel)
                manager.AddEmpty();
            camera.LookAtModel(true);

            backcolor = new Color4(0, 0, 0, 0);

            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            GL.Enable(EnableCap.CullFace);
            GL.CullFace(CullFaceMode.Back);

            int ole_hresult = OleInitialize(IntPtr.Zero);
            IntPtr handle = FindWindowByCaption(IntPtr.Zero, Title);
            dnd = new DragDropTarget();
            int dnd_hresult = RegisterDragDrop(handle, dnd);

            raycaster = new Raycaster(this, camera, selection, floor, input, manager, gui);
            selection.raycaster = raycaster;

            Client.Initialized = true;
            base.OnLoad(e);
            SetForegroundWindow(WindowInfo.Handle);
        }
Ejemplo n.º 24
0
        protected override void LoadContent()
        {
            logger.Info("LoadContent");

            //----------------------------------------------------------------
            // �X�g���[�W �}�l�[�W��

            StorageManager.SelectStorageContainer("Blocks.Demo.MainGame");

            //----------------------------------------------------------------
            // ���\�[�X ���[�_

            ResourceLoader.Register(ContentResourceLoader.Instance);
            ResourceLoader.Register(TitleResourceLoader.Instance);
            ResourceLoader.Register(StorageResourceLoader.Instance);
            ResourceLoader.Register(FileResourceLoader.Instance);

            //----------------------------------------------------------------
            // �r���[ �R���g���[��

            var viewport = GraphicsDevice.Viewport;
            viewInput.InitialMousePositionX = viewport.Width / 2;
            viewInput.InitialMousePositionY = viewport.Height / 2;
            viewInput.MoveVelocity = moveVelocity;
            viewInput.DashFactor = dashFactor;
            viewInput.Yaw(MathHelper.Pi);

            //----------------------------------------------------------------
            // ���[���h �}�l�[�W��

            worldManager = new WorldManager(Services, GraphicsDevice);
            worldManager.Initialize();

            //----------------------------------------------------------------
            // ���[�W����

            // TODO
            region = worldManager.Load("dummy");

            //----------------------------------------------------------------
            // �u���V �}�l�[�W��

            brushManager = new BrushManager(Services, GraphicsDevice, worldManager, commandManager);

            //----------------------------------------------------------------
            // ���̑�

            spriteBatch = new SpriteBatch(GraphicsDevice);
            font = Content.Load<SpriteFont>("Fonts/Debug");
            fillTexture = Texture2DHelper.CreateFillTexture(GraphicsDevice);
            helpMessageFontSize = font.MeasureString(helpMessage);

            BuildInfoMessage();
            informationTextFontSize = font.MeasureString(stringBuilder);
        }