public void LoadGallery() { string currDirectory = System.AppDomain.CurrentDomain.BaseDirectory; #if FINAL string fullPath = currDirectory + "\\galleries\\lights\\"; #else string fullPath = Path.Combine(currDirectory, "..\\..\\galleries\\lights\\"); #endif string[] paths = Directory.GetFiles(fullPath); // TODO poprawić ścieżkę w finalnej wersji foreach (string path in paths) { string file = Path.GetFileNameWithoutExtension(path); List <Light_> lgt = Light_.LoadLights(path); //Material_ material = mat != null ? mat[0] : null; if (lgt != null) { //bezier.Name = file; #if FINAL string ImageUri = currDirectory + "\\galleries\\lights\\" + lgt[0].name + ".png"; #else string ImageUri = AppDomain.CurrentDomain.BaseDirectory + "..\\..\\galleries\\lights\\" + lgt[0].name + ".png"; #endif Add(new LightObj(lgt[0], ImageUri)); // TODO poprawić ścieżkę w finalnej wersji } } }
private void lightPreview_Drop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent("Object") || e.Data.GetDataPresent("Light")) { if (e.Data.GetData("Light") is Light_) { Light_ lightData = (Light_)e.Data.GetData("Light"); Light_ lightPrevious = (Light_)e.Data.GetData("LightPrevious"); e.Data.SetData("Object", e.Data.GetData("Light")); lightData.position = lightPrevious.position; lightData.direction = lightPrevious.direction; } object data = e.Data.GetData("Object"); Console.WriteLine(data.GetType()); if (data is Modeler.Data.Light.LightObj) { light = new Light_(((Modeler.Data.Light.LightObj)data).Light); //material.colorR = material.colorR * 255; //material.colorG = material.colorG * 255; //material.colorB = material.colorB * 255; SetLight(light); //SetSliders(); //name_box.Text = material.name; } else if (data is Light_) { light = new Light_(((Light_)data)); SetLight(light); //SetSliders(); //name_box.Text = material.name; } } }
public void SaveGallery() { List <Light_> lights = new List <Light_>(); foreach (LightObj light in Items) { lights.Add(light.Light); // TODO zapisać ikonę } Light_.SaveLights(lights, "../../galleries/LightsGallery.txt"); // TODO poprawić ścieżkę w finalnej wersji }
public void LoadGallery() { List <Light_> lights = Light_.LoadLights("../../galleries/LightsGallery.txt"); // TODO poprawić ścieżkę w finalnej wersji if (lights == null) { SaveGallery(); } else { foreach (Light_ light in lights) { Add(new LightObj(light, "Ikony/Swiatla/" + light.name + ".png")); } } }
public void SetLight(Light_ lgt) { light = lgt; goniometry.SetGoniometry(light.goniometric); colorRed_slider.Value = light.colorR; colorGreen_slider.Value = light.colorG; colorBlue_slider.Value = light.colorB; flux_slider.Value = light.power; innerAngle_slider.Value = light.innerAngle; outerAngle_slider.Value = light.outerAngle; UpdateElements(); RenderLight(); }
public static Bitmap Render(Light_ lgt) { light = lgt; Vector3D direction = new Vector3D(); Color color; for (int i = 0; i < xResolution; i++) { for (int j = 0; j < yResolution; j++) { direction = vectorU * (i / (float)(xResolution - 1)) + vectorV * (j / (float)(yResolution - 1)); direction += topLeft; direction -= observer; direction.Normalize(); color = CalculateColor(observer, direction, 0); image.SetPixel(i, j, color); } } return(image); }
public void SetLight(Light_ lgt) { light = lgt; goniometry.Goniometry = light.goniometric; colorRed_slider.Value = light.colorR; colorGreen_slider.Value = light.colorG; colorBlue_slider.Value = light.colorB; flux_slider.Value = light.power; innerAngle_slider.Value = light.innerAngle; outerAngle_slider.Value = light.outerAngle; name_box.Text = light.name; lgt.position.X = 0; lgt.position.Y = 0; lgt.position.Z = 0; UpdateElements(); RenderLight(); }
public LightObj SaveLightToGallery(Light_ light) { string currDirectory = System.AppDomain.CurrentDomain.BaseDirectory; #if FINAL LightObj lgtObj = new LightObj(light, currDirectory + "\\galleries\\lights\\" + light.name + ".png"); #else LightObj lgtObj = new LightObj(light, AppDomain.CurrentDomain.BaseDirectory + "..\\..\\galleries\\lights\\" + light.name + ".png"); #endif List <Light_> lgt = new List <Light_>() { light }; #if FINAL Light_.SaveLights(lgt, currDirectory + "\\galleries\\lights\\" + light.name + ".lgt"); #else Light_.SaveLights(lgt, "../../galleries/lights/" + light.name + ".lgt"); #endif Modeler.Graphics.LightRaytracer.SaveImage(light.name, lgtObj.ImageUri); return(lgtObj); }
public LightObj(Light_ lgt, string imgUri) { Light = lgt; ImageUri = imgUri; }
public static void SelectElems(Scene scene, ViewportType viewportType, Point pos, Point size, Vector2 orthoSize, Vector3 orthoPos, Vector3 orthoLookAt) { Vector3 outCamPos = new Vector3(), outSurfPos = new Vector3(); switch (viewportType) { case ViewportType.Perspective: CalcPerspCoords(pos, size, scene.cams.ElementAt(scene.activeCamera).fovAngle, scene.cams.ElementAt(scene.activeCamera).rotateAngle, scene.cams.ElementAt(scene.activeCamera).position, scene.cams.ElementAt(scene.activeCamera).lookAt, out outCamPos, out outSurfPos); break; case ViewportType.Orto: CalcOrthoCoords(pos, size, orthoSize, orthoPos, orthoLookAt, out outCamPos, out outSurfPos); break; } List <Triang> triangs = new List <Triang>(); for (int i = 0; i < scene.triangles.Count; ++i) { Triangle triangle = scene.triangles.ElementAt(i); triangs.Add(new Triang(scene.points.ElementAt((int)triangle.p1), scene.points.ElementAt((int)triangle.p2), scene.points.ElementAt((int)triangle.p3))); } const float lightDiameter = 1; const float cameraDiameter = 1; Vector3 rayDir = Vector3.Normalize(outSurfPos - outCamPos); SlimDX.Ray ray = new SlimDX.Ray(outCamPos + 0.01f * rayDir, rayDir); float[] triangleDist = new float[triangs.Count]; for (int i = 0; i < triangs.Count; ++i) { float dist; if (SlimDX.Ray.Intersects(ray, triangs[i].p1, triangs[i].p2, triangs[i].p3, out dist)) { triangleDist[i] = dist; } else { triangleDist[i] = -1; } } float minDist = float.PositiveInfinity; int minIndex = -1; for (int i = 0; i < triangleDist.Length; ++i) { if (triangleDist[i] >= 0 && triangleDist[i] < minDist) { minIndex = i; minDist = triangleDist[i]; } } int foundTriangle = minIndex; Light_ foundLight = null; // TODO wyliczyć Camera foundCamera = null; // TODO wyliczyć if (foundTriangle >= 0) { HierarchyMesh mesh = GetSelectedMesh(scene.hierarchy.objects, foundTriangle); if (scene.selTriangles.Contains(mesh) == false) { scene.selTriangles.Add(mesh); } } else if (foundLight != null) { } else if (foundCamera != null) { } else { scene.selTriangles.Clear(); scene.selLights.Clear(); scene.selCams.Clear(); } }