示例#1
0
        public override void Start()
        {
            Context.Input.SetMouseVisible(true);

            SetupResourcePaths();
            Selection = new Engn_Selection();
            SetupScene();
            SubscribeEvents();

            InitializeTcpConnection();

            DebugHud debugHud = Engine.CreateDebugHud();

            debugHud.Mode = DebugHudMode.DebughudShowAll;
            RunOnce();
        }
示例#2
0
        public override void Start()
        {
            UI.Input.SetMouseVisible(true);

            //SetupResources Location
            string ResDir = @"./Resources/3D";

            Cache.AddResourceDir(ResDir);
            Cache.AddResourceDir(@"c:\windows\fonts");
            this.UI.Cursor = new Urho3DNet.Cursor(Context);

            // Scene
            scene = new Scene(Context);
            scene.CreateComponent <Octree>();

            Selection = new Engn_Selection();

            //Camera-Viewport
            cam = new Engn_Camera(scene);
            cam.CameraNode.Position = (new Vector3(0, 2, -20));
            cam.LookAt(Vector3.Zero);
            viewport        = new Viewport(Context);
            viewport.Scene  = scene;
            viewport.Camera = cam.camera;
            Engine.Renderer.SetViewport(0, viewport);


            // Background
            Engine.Renderer.DefaultZone.FogColor = (new Color(0.5f, 0.5f, 0.7f));

            //Plan
            //we don't to set wireplan to rootnode, as we need it for any root node that can be created later
            new Engn_WirePlane(scene);

            //Add Zone
            new Engn_Zone_Test(scene);

            //AddPlan
            new Engn_Plan(scene);

            // Light
            light = scene.CreateChild("Light");
            var l = light.CreateComponent <Light>();

            light.Position = (new Vector3(0, 50, -1));
            l.Range        = 100f;
            light.LookAt(Vector3.Zero);
            l.LightType   = LightType.LightPoint;
            l.CastShadows = true;
            l.ShadowBias  = new BiasParameters(0.00025f, 0.5f);
            // Set cascade splits at 10, 50 and 200 world units, fade shadows out at 80% of maximum shadow distance
            l.ShadowCascade = new CascadeParameters(10.0f, 50.0f, 200.0f, 0.0f, 0.8f);


            //Create Root Components for all models
            RootNode = scene.CreateChild("RootNode");

            //setup Menu
            uiMenu = new UIMenu(RootNode, Selection);

            //create RandomBoxes
            new Rbfx_RandomBoxes(RootNode);
            //info window shows name by hovered
            SetupInfoWindow();


            //create customshape
            CreateCustomShape();

            //drawModelform Scratch
            CreateModelfromScratch();

            bool setup = false;

            SubscribeToEvent(E.Update, args =>
            {
                uiMenu.SetupMenu();
                //what to do if selection is nothing
                onUnSelect();

                //camera movement
                cam.FirstPersonCamera(this, this.Time.TimeStep, 10, Selection?.SelectedModel?.Node);

                //CheckSelection
                var hoverselected = Selection.SelectGeometry(this, scene, cam);
                uiMenu.Selection  = Selection;
                uiMenu.RootNode   = RootNode;

                if (scene.Input.GetMouseButtonPress(Urho3DNet.MouseButton.MousebLeft))
                {
                    touraroundboxes(Selection.SelectedModel);

                    var node = RootNode.GetChild("Building");
                    if (node != null)
                    {
                        objname = objname == "door" ? "wall" : "door";
                        DisplaceAll(node, objname);
                    }
                }

                //invoke any actions in the list
                if (Actions.Count > 0)
                {
                    var runningactions = Actions.ToList();
                    Actions.Clear();
                    for (int i = 0; i < runningactions.Count; i++)
                    {
                        runningactions[i].Invoke();
                    }
                }

                if (scene.Input.GetMouseButtonClick(Urho3DNet.MouseButton.MousebRight))
                {
                    if (Selection.SelectedModel != null)
                    {
                        uiMenu.ActionMenu = menuaction.ObjectContext;
                    }
                }

                DisplayInfoText(hoverselected);
            });
        }