예제 #1
0
        public void DrawBg(GraphicsDevice gd, WorldState state, BoundingBox[] skyBounds)
        {
            var frustrum = new BoundingFrustum(state.Camera.View * state.Camera.Projection);

            //frustrum.Contains(skyBounds)
            if ((state.Camera as WorldCamera3D)?.FromIntensity > 0 || skyBounds?.Any(x => x.Intersects(frustrum)) != false)
            {
                if (Dome == null)
                {
                    Dome = new SkyDomeComponent(gd);
                }
                Dome.Draw(gd, state);

                Surroundings?.DrawSurrounding(gd, state.Camera, Dome.FogColor, (Blueprint.SubWorlds.Count > 0)?1:0);
            }
            gd.Clear(ClearOptions.DepthBuffer, Color.White, 1, 0);

            foreach (var surround in Blueprint.SubWorlds)
            {
                var bounds = ((SubWorldComponentRC)surround).Bounds;
                if (bounds.Intersects(frustrum))
                {
                    surround.DrawArch(gd, state);
                }
            }

            gd.BlendState = BlendState.NonPremultiplied;
            if (Blueprint.Terrain != null)
            {
                Blueprint.Terrain.DepthMode = state._2D.OutputDepth;
                Blueprint.Terrain._3D       = true;
                Blueprint.Terrain.Draw(gd, state);
            }
        }
예제 #2
0
        public void DrawBg(GraphicsDevice gd, WorldState state, BoundingBox[] skyBounds, bool forceSurround)
        {
            state.PrepareCamera();
            if (forceSurround || (state.CameraMode == CameraRenderMode._3D && state.Cameras.ExternalTransitionActive()) || skyBounds?.Any(x => x.Intersects(state.Frustum)) != false)
            {
                if (Dome == null)
                {
                    Dome = new SkyDomeComponent(gd, Bp);
                }
                Dome.BP = Bp;
                Dome.Draw(gd, state);

                World.Surroundings?.DrawSurrounding(gd, state.Camera, Bp.Weather.FogColor, (Bp.SubWorlds.Count > 0) ? 1 : 0);
            }
            gd.Clear(ClearOptions.DepthBuffer, Color.White, 1, 0);

            //if (((WorldCamera3D)state.Camera).FromIntensity > 0) state.CenterTile = state.CenterTile;
        }
예제 #3
0
        static public BaseComponent LoadComponent(BaseEntity parent, ComponentType type, ContentManager contentManager, string XMLDefinitionPath)
        {
            // This is a factory for creating any component based on a ComponentType
            switch (type)
            {
            case ComponentType.RenderComponent:
            {
                BaseComponent newComponent = RenderComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.CameraComponent:
            {
                BaseComponent newComponent = CameraComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.ConstantMovementComponent:
            {
                BaseComponent newComponent = ConstantMovementComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.ConstantRotationComponent:
            {
                BaseComponent newComponent = ConstantRotationComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.FreeCameraInputComponent:
            {
                BaseComponent newComponent = FreeCameraInputComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.LightEmitterComponent:
            {
                BaseComponent newComponent = LightEmitterComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.PhysicsComponent:
            {
                BaseComponent newComponent = PhysicsComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.PhantomPhysicsComponent:
            {
                BaseComponent newComponent = PhantomPhysicsComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.CharacterPhysicsComponent:
            {
                BaseComponent newComponent = CharacterPhysicsComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.CharacterInputComponent:
            {
                BaseComponent newComponent = CharacterInputComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.WaterComponent:
            {
                BaseComponent newComponent = WaterComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.ArcBallCameraInputComponent:
            {
                BaseComponent newComponent = ArcBallCameraInputComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.ParticleEmitterComponent:
            {
                BaseComponent newComponent = ParticleEmitterComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.SkyDomeComponent:
            {
                BaseComponent newComponent = SkyDomeComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.CollisionTriggerComponent:
            {
                BaseComponent newComponent = CollisionTriggerComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.TerrainComponent:
            {
                BaseComponent newComponent = TerrainComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.TerrainPhysicsComponent:
            {
                BaseComponent newComponent = TerrainPhysicsComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.WaterVolumePhysicsComponent:
            {
                BaseComponent newComponent = WaterVolumePhysicsComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.Invalid:
            {
                throw new ArgumentException(String.Format("Invalid component type passed, type {0} is not valid", type));
            }

            default:
            {
                throw new ArgumentException(String.Format("Invalid component type passed, type {0} is not valid", type));
            }
            }
        }