public SphereScene(GraphicsDevice device, SkyboxSceneService skybox, GeneratedAssets generatedAssets, GeometryFactory geometry, LightFactory lights) { this.Device = device; this.Skybox = skybox; this.GeneratedAssets = generatedAssets; this.Geometry = geometry; this.Lights = lights; }
private void SetupLightFactory(bool deviceConnected) { var mockDeviceController = new Mock <IDeviceController>(MockBehavior.Strict); mockDeviceController.Setup(x => x.OpenDevice()).Returns(deviceConnected); _factoryToTest = new LightFactory(mockDeviceController.Object); }
public void Light_OK() { //Act ILight light = LightFactory.Create(new Vector3(0, 1, 0), new Color4(250, 248, 248, 1), new Color4(250, 246, 247, 1), new Color4(0, 1, 0, 1), OpenTK.Graphics.OpenGL.LightName.Light0); //Assert Assert.AreEqual(new Vector3(0, 1, 0), light.LightPosition, "LightPosition"); Assert.AreEqual(new Color4(250, 248, 248, 1), light.AmbientColor, "AmbientColor"); Assert.AreEqual(new Color4(250, 246, 247, 1), light.DiffuseColor, "DiffuseColor"); Assert.AreEqual(new Color4(0, 1, 0, 1), light.SpecularColor, "SpecularColor"); }
static void Main(string[] args) { Console.WriteLine("Hello World!"); var trafficLight = new TrafficLight(); var factory = new LightFactory(); trafficLight.SetState(factory.GetNextState("red")); while (true) { Console.WriteLine($"CurrentState: {trafficLight.GetState().ToString()}"); Console.WriteLine($"Can Proceed: {trafficLight.GetState().CanProceed()}"); Console.WriteLine("===================================================="); } }
internal void InjectDependencies(FearResourceManager resMan, Input fearInput, GameObjectFactory gameObjFactory, UpdateableFactory updateableFac, SceneFactory sceneFac, LightFactory lightFac, CameraFactory cameraFac) { resourceManager = resMan; input = fearInput; gameObjectFactory = gameObjFactory; updateableFactory = updateableFac; sceneFactory = sceneFac; lightFactory = lightFac; cameraFactory = cameraFac; }
/// <summary/> public static Light MakeLight(Variation v) { Light light = null; if (v["Light"] != null) { v.AssertAbsenceOf("LightType", "LightColor", "LightPosition", "LightDirection", "LightRange", "LightConstantAttenuation", "LightLinearAttenuation", "LightQuadraticAttenuation", "LightInnerConeAngle", "LightOuterConeAngle"); light = LightFactory.MakeLight(v["Light"]); } else { v.AssertExistenceOf("LightType", "LightColor"); switch (v["LightType"]) { case "Ambient": light = new AmbientLight(); break; case "Directional": v.AssertExistenceOf("LightDirection"); light = new DirectionalLight(); ((DirectionalLight)light).Direction = StringConverter.ToVector3D(v["LightDirection"]); break; case "Point": v.AssertExistenceOf("LightPosition", "LightRange", "LightConstantAttenuation", "LightLinearAttenuation", "LightQuadraticAttenuation"); light = new PointLight(); SetLocalLightParameters((PointLight)light, v); break; case "Spot": v.AssertExistenceOf("LightPosition", "LightDirection", "LightRange", "LightConstantAttenuation", "LightLinearAttenuation", "LightQuadraticAttenuation", "LightInnerConeAngle", "LightOuterConeAngle"); light = new SpotLight(); SetLocalLightParameters((SpotLight)light, v); ((SpotLight)light).Direction = StringConverter.ToVector3D(v["LightDirection"]); ((SpotLight)light).InnerConeAngle = StringConverter.ToDouble(v["LightInnerConeAngle"]); ((SpotLight)light).OuterConeAngle = StringConverter.ToDouble(v["LightOuterConeAngle"]); break; default: throw new ApplicationException("Invalid light type: " + v["LightType"]); } light.Color = StringConverter.ToColor(v["LightColor"]); } return(light); }
private static void RunTeamCityMonitor(Options options) { var buildLight = new LightFactory().CreateLight(options.Device); var config = new Config { ServerUrl = options.Url, Username = options.Username, Password = options.Password, Interval = TimeSpan.FromSeconds(options.IntervalInSeconds), TimeSpan = TimeSpan.FromDays(options.Timespan), BuildTypeIds = string.Join(",", options.BuildTypeIds), RunOnce = options.RunOnce, GuestAccess = options.GuestAccess, IncludeAllBranches = options.IncludeAllBranches, IncludeFailedToStart = options.IncludeFailedToStart }; Logger.VerboseEnabled = options.Verbose; new TeamCityMonitor(config, buildLight).Start().Wait(); }
protected override Task Handle(RenderSceneCommand request, CancellationToken cancellationToken) { var shapes = new List <IBasicShape>(); shapes.AddRange(request.Scene.Shapes.Select(ShapeFactory.MapApiToDomain)); var world = new World(shapes, LightFactory.MapApiToDomain(request.Scene.LightSource)); var camera = CameraFactory.MapApiToDomain(request.Scene.Camera); // Render image using var canvas = new System.Drawing.Bitmap(camera.HorizontalSize, camera.VerticalSize); for (int y = 0; y < camera.VerticalSize - 1; y++) { if (cancellationToken.IsCancellationRequested) { break; } for (int x = 0; x < camera.HorizontalSize - 1; x++) { if (cancellationToken.IsCancellationRequested) { break; } var ray = camera.GetRay(x, y); Color color = Lighting.CalculateColorWithPhongReflection(world, ray); canvas.SetPixel(x, y, color.Simplify(255)); } } if (!cancellationToken.IsCancellationRequested) { canvas.Save(request.FilePath); } return(cancellationToken.IsCancellationRequested ? Task.FromCanceled(cancellationToken) : Task.CompletedTask); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(LightFactory obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
public SceneConfiguration ExportConfiguration(FrameDescription frame) { var result = new SceneConfiguration(); result["frame", "global", "name"] = FrameName; result["frame", "global", "width"] = width; result["frame", "global", "height"] = height; result["frame", "global", "directory"] = Directory.GetCurrentDirectory(); result.SetFrame("samplesperpixel", QualitySettings.SamplesPerPixel); result.SetFrame("supersampling", QualitySettings.SuperSamplingSize); result.SetFrame("maxpathdepth", Scene.MaxPathDepth); result.SetFrame("lightgain", this.Scene.DefaultLightGain); result.SetFrame("rrimportancecap", this.Scene.RussianRuletteImportanceCap); result.SetFrame("shadowraysperlight", this.Scene.ShadowRayCount); result.SetFrame("texturesampling", (int)this.QualitySettings.TextureSamplingQuality); result.SetFrame("pathbuffersize", this.Scene.MaxPaths); result.SetFrame("arealightasmesh", this.AreaLightAsMeshLight); /* foreach (var frameElement in frame.Elements.Where(frameElement => frameParsers.ContainsKey(frameElement.GetType()))) { frameParsers[frameElement.GetType()](frameElement); }*/ if ((Scene.Camera is FiniteAppertureCamera)) { result.FiniteAppertureCameras.AddItem("camera1", new CameraFactory().Serialize(Scene.Camera), "."); } else { result.PinholeCameras.AddItem("camera1", new CameraFactory().Serialize(Scene.Camera), "."); } var objTag = frame.Elements.OfType<FrameObjFileReference>().FirstOrDefault(); result.SetMesh("objfilename", objTag.ObjFilePath); result.SetMesh("mtlfilename", objTag.MtlFilePath); result.SetMesh("invertnormals", objTag.InvertNormals); var serializer = new LightFactory(); foreach (var light in Scene.Lights) { EntityCollection lightCollection = null; if (light is PointLight) { lightCollection = result.PointLights; } else if (light is MeshLight) { lightCollection = result.AreaLights; } else if (light is BaseInfiniteLight) { lightCollection = result.InfiniteLights; } if (lightCollection != null) lightCollection.AddItem(light.Name, serializer.Serialize(light), "."); } /* var matSer = new MaterialFactory(); foreach (var material in Scene.MatLib) { EntityCollection mats = null; switch (material.Class) { case BrdfClass.Alloy: mats = result.AlloyMaterials; break; case BrdfClass.DiffuseLambert: mats = result.MatteMaterials; break; } if (mats != null) { var mat = matSer.Serialize(material); mats.AddItem(mat.Name, mat,"."); } } */ return result; }
static void Main(string[] args) { var gameWindow = new GameWindow(WindowWidth, WindowHeight, new GraphicsMode(32, 24, 0, 8), "Ocean sim (Grestner waves) and terrain", GameWindowFlags.Default, DisplayDevice.AvailableDisplays.Last()); gameWindow.MakeCurrent(); gameWindow.Context.LoadAll(); Utils.Utils.GLRenderProperties(WindowWidth, WindowHeight); _camera = Factory <Camera.Camera> .Create(_cameraPosition0, LookAt0, new Vector3(0, 1, 0)); _light = LightFactory.Create(new Vector3(-350.0f, 300.0f, 0.0f), new Color4(255, 255, 255, 1), new Color4(255, 255, 255, 1), new Color4(252, 252, 252, 1), LightName.Light0); _light.Load(); _terrain = Terrainfactory.Create(Utils.Utils.GetImageResource <ITerrain>("Landscape.Terrains.TOPOMAP1.GIF"), Utils.Utils.GetImageResource <ITerrain>("Landscape.Terrains.Dirt.jpg"), Utils.Utils.GetImageResource <ITerrain>("Landscape.Terrains.sand.jpg"), Utils.Utils.GetImageResource <ITerrain>("Landscape.Terrains.Grass.png"), Utils.Utils.GetImageResource <ITerrain>("Landscape.Terrains.Rock.png")); _terrain.Load(); _cubeMap = CubeMapFactory.Create(2500, false, new Vector3(256, 0, 256), Utils.Utils.GetImageResource <ICubeMap>("EnvironmentMap.Textures.Desert.Desert_front.jpg"), Utils.Utils.GetImageResource <ICubeMap>("EnvironmentMap.Textures.Desert.Desert_back.jpg"), Utils.Utils.GetImageResource <ICubeMap>("EnvironmentMap.Textures.Desert.Desert_front.jpg"), Utils.Utils.GetImageResource <ICubeMap>("EnvironmentMap.Textures.Desert.Desert_top.jpg"), Utils.Utils.GetImageResource <ICubeMap>("EnvironmentMap.Textures.Desert.Desert_left.jpg"), Utils.Utils.GetImageResource <ICubeMap>("EnvironmentMap.Textures.Desert.Desert_right.jpg") ); _cubeMap.Load(); _woodenChest = CubeMapFactory.Create(100, true, new Vector3(256, 150, 256), Utils.Utils.GetImageResource <ICubeMap>("EnvironmentMap.Textures.plank.jpg")); _woodenChest.Load(); _water = new Water(WaterWidth, WaterHeight); _water.Load(); _seaBed = PlaneFactory.Create(true, new Vbo() { Position = new Vector3(0, -70, 0), Normal = new Vector3(0, 1, 0), TexCoord = new Vector2(0, 0) }, new Vbo() { Position = new Vector3(0, -70, WaterHeight), Normal = new Vector3(0, 1, 0), TexCoord = new Vector2(0, 1) }, new Vbo() { Position = new Vector3(WaterWidth, -70, WaterHeight), Normal = new Vector3(0, 1, 0), TexCoord = new Vector2(1, 1) }, new Vbo() { Position = new Vector3(WaterWidth, -70, 0), Normal = new Vector3(0, 1, 0), TexCoord = new Vector2(1, 0) }, Utils.Utils.GetImageResource <ITerrain>("Landscape.Terrains.seabed.jpg"), TextureWrapMode.ClampToEdge); _seaBed.Load(); _birdTexture = FramBufferOBjectFactory.Create(512, 512); _birdTexture.Load(); gameWindow.RenderFrame += gameWindow_RenderFrame; gameWindow.UpdateFrame += gameWindow_UpdateFrame; gameWindow.Keyboard.KeyDown += Keyboard_KeyDown; gameWindow.Run(60.0, 30.0); }