示例#1
0
        public void LoadScene()
        {
            IEnumerable <IEntity> renderableEntities = _entityManager.GetEntitiesWithComponents <RenderableComponent>();

            renderableEntities.ForEach(SetupRenderableEntity);

            IEnumerable <IEntity> cameraEntities = _entityManager.GetEntitiesWithComponents <CameraComponent>();

            cameraEntities.ForEach(SetupCamera);

            _entityManager.GetEntities().ForEach(entity =>
            {
                entity.GetComponents().ForEach(component =>
                {
                    component.OnLoaded();
                });
            });

            if (!_context.IsEditor)
            {
                // Set the current Active Camera
                _entityManager.GetEntitiesWithComponents <CameraComponent>().ForEach(entity =>
                {
                    CameraComponent cameraComponent = entity.GetComponent <CameraComponent>();
                    if (cameraComponent.ActiveCamera)
                    {
                        var vp = _context.GetRenderWindow().addViewport(cameraComponent.Camera);
                        vp.setBackgroundColour(new ColourValue(.1f, .3f, .3f));
                    }
                });
            }

            MeshPtr meshPtr  = MeshManager.getSingleton().createPlane("background", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, new Plane(VectorUtils.Vector3.UNIT_Y, 0f), 800, 600, 4, 4, true, 1, 4, 4, VectorUtils.Vector3.UNIT_Z);
            var     floorEnt = _sceneManager.createEntity("background", "background");

            floorEnt.setMaterial(MaterialManager.getSingleton().getByName("Color_009"));

            var floorNode = _sceneManager.getRootSceneNode().createChildSceneNode();

            floorNode.setPosition(new Vector3(0f, -3f, 0f));
            floorNode.attachObject(floorEnt);

            meshPtr.Dispose();
        }