public override bool AddDirectionalLight(DirectionalLightComponent directionalLight) { if (this.directionalLight != null) { return(false); } if (directionalLight == null) { return(false); } this.directionalLight = directionalLight; return(true); }
public override bool RemoveDirectionalLight(DirectionalLightComponent directionalLight) { if (directionalLight == null) { return(false); } if (this.directionalLight != directionalLight) { return(false); } this.directionalLight = null; lightSources[0] = Vector4.Zero; return(true); }
public abstract bool AddDirectionalLight(DirectionalLightComponent directionalLight);
public abstract bool RemoveDirectionalLight(DirectionalLightComponent directionalLight);
static void Main(string[] args) { var gameWidth = 800; var gameHeight = 600; var solarSystemGame = Game.CreateGame("Space", gameWidth, gameHeight, true); var testModel = MeshImporter.ImportModelFromFile("Models/Earth/Earth.obj"); var planet = testModel[0]; var tableMesh = MeshImporter.ImportModelFromFile("Models/Table/table.obj")[0]; solarSystemGame.CurrentWorld = new World("Solar System"); SetupInput(solarSystemGame.InputManager); var center = new WorldObject(objectName: "System center") { WorldLocation = Vector3.Up * 400 }; var CameraLocation = new Vector3(0, 1000, 2000); var camera = new SimpleControllableCamera(objectName: "Camera") { ForwardAxis = "Forward", RightAxis = "Right", UpAxis = "Up", TurnRightAxis = "Turn Right", TurnUpAxis = "Turn Up", WorldLocation = CameraLocation, WorldRotation = Quaternion.Invert(Quaternion.LookAtRH(CameraLocation, center.WorldLocation, Vector3.Up)), }; var table = new WorldObject(objectName: "Table mesh"); var tableComponent = new StaticMeshComponent(table) { Mesh = tableMesh, DefaultShader = new PhongVertexColorShader() { AmbientReflection = .23125f, DiffuseReflection = 0.2775f, SpecularReflection = .1f, Shininess = 6.0f, }, }; var sun = new Planet(0, planet, center, "Sun") { PlanetSize = 100, RotationAngularSpeed = 0.0f, TurningAngularSpeed = 1.0f, }; var mercury = new Planet(400, planet, center, "Mercury") { PlanetSize = 9, RotationAngularSpeed = 5.0f, TurningAngularSpeed = 2.0f, }; var venus = new Planet(700, planet, center, "Venus") { PlanetSize = 27, RotationAngularSpeed = 3.0f, TurningAngularSpeed = -1.0f, }; var earth = new Planet(1000, planet, center, "Earth") { PlanetSize = 30, RotationAngularSpeed = 1.0f, TurningAngularSpeed = 1.0f, }; var moon = new Planet(6, planet, earth.PlanetCenter, "Moon") { PlanetSize = 6, RotationAngularSpeed = 2.0f, TurningAngularSpeed = 1.0f, }; var mars = new Planet(1500, planet, center, "Mars") { PlanetSize = 15, RotationAngularSpeed = 1.0f, TurningAngularSpeed = 0.8f, }; var directionalLight = new DirectionalLightComponent(center) { Direction = Vector3.Normalize(Vector3.Down + Vector3.Right), Intensity = 3, }; var moonPointLight = new PointLightComponent(moon.PlanetCenter) { Intensity = 2 }; var sunPointLight = new PointLightComponent(sun) { Intensity = 10, }; solarSystemGame.GameRenderer.LightingModel.AddDirectionalLight(directionalLight); solarSystemGame.GameRenderer.LightingModel.AddPointLight(sunPointLight); solarSystemGame.GameRenderer.LightingModel.AddPointLight(moonPointLight); solarSystemGame.StartGame(); solarSystemGame.Dispose(); Console.WriteLine(); Console.WriteLine("Game finished. Press Enter."); Console.ReadLine(); }