public void CreateDisplayLists(bool texenabled, CombinerTypes combinertype) { Program.Status.Message = string.Format("Rendering room '{0}'...", (this.Parent as HeaderCommands.Rooms.RoomInfoClass).Description); CachedWithTextures = texenabled; CachedWithCombinerType = combinertype; /* Execute DLs once before creating GL lists, to cache textures & fragment programs beforehand */ foreach (uint dl in DLAddresses) { this.ROM.Renderer.Render(dl); } /* Copy most recently rendered triangles - this mesh header's DL's - to triangle list */ TriangleList = new List <SimpleF3DEX2.SimpleTriangle>(); foreach (SimpleF3DEX2.SimpleTriangle st in this.ROM.Renderer.LastTriList) { TriangleList.Add(st); } /* Now execute DLs again, with stuff already cached, which speeds everything up! */ DLs = new List <OpenGLHelpers.DisplayListEx>(); foreach (uint dl in DLAddresses) { OpenGLHelpers.DisplayListEx newdlex = new OpenGLHelpers.DisplayListEx(ListMode.Compile); this.ROM.Renderer.Render(dl, gldl: newdlex); newdlex.End(); DLs.Add(newdlex); } /* Clear the renderer's triangle list */ this.ROM.Renderer.LastTriList.Clear(); /* Finally, from the triangle list compiled before, create a simple display list for picking purposes */ PickGLID = GL.GenLists(1); GL.NewList(PickGLID, ListMode.Compile); GL.Disable(EnableCap.Lighting); GL.Disable(EnableCap.Texture2D); if (OpenGLHelpers.Initialization.SupportsFunction("glGenProgramsARB")) { GL.Disable((EnableCap)All.FragmentProgram); } GL.Begin(PrimitiveType.Triangles); foreach (SimpleF3DEX2.SimpleTriangle st in TriangleList) { GL.Vertex3(st.Vertices[0]); GL.Vertex3(st.Vertices[1]); GL.Vertex3(st.Vertices[2]); } GL.End(); GL.EndList(); }
public Combiner(CombinerTypes type, ModuleBase source1, ModuleBase source2) { _type = type; Source = source1; _source2 = source2; }
public Combiner(CombinerTypes type, ModuleBase source1, ModuleBase source2) { this.Type = type; this.Source = source1; this.Source2 = source2; }
public void CreateDisplayLists(bool texenabled, CombinerTypes combinertype) { Program.Status.Message = string.Format("Rendering room '{0}'...", (this.Parent as HeaderCommands.Rooms.RoomInfoClass).Description); CachedWithTextures = texenabled; CachedWithCombinerType = combinertype; /* Execute DLs once before creating GL lists, to cache textures & fragment programs beforehand */ foreach (uint dl in DLAddresses) this.ROM.Renderer.Render(dl); /* Copy most recently rendered triangles - this mesh header's DL's - to triangle list */ TriangleList = new List<SimpleF3DEX2.SimpleTriangle>(); foreach (SimpleF3DEX2.SimpleTriangle st in this.ROM.Renderer.LastTriList) TriangleList.Add(st); /* Now execute DLs again, with stuff already cached, which speeds everything up! */ DLs = new List<OpenGLHelpers.DisplayListEx>(); foreach (uint dl in DLAddresses) { OpenGLHelpers.DisplayListEx newdlex = new OpenGLHelpers.DisplayListEx(ListMode.Compile); this.ROM.Renderer.Render(dl, gldl: newdlex); newdlex.End(); DLs.Add(newdlex); } /* Clear the renderer's triangle list */ this.ROM.Renderer.LastTriList.Clear(); /* Finally, from the triangle list compiled before, create a simple display list for picking purposes */ PickGLID = GL.GenLists(1); GL.NewList(PickGLID, ListMode.Compile); GL.Disable(EnableCap.Lighting); GL.Disable(EnableCap.Texture2D); if (OpenGLHelpers.Initialization.SupportsFunction("glGenProgramsARB")) GL.Disable((EnableCap)All.FragmentProgram); GL.Begin(PrimitiveType.Triangles); foreach (SimpleF3DEX2.SimpleTriangle st in TriangleList) { GL.Vertex3(st.Vertices[0]); GL.Vertex3(st.Vertices[1]); GL.Vertex3(st.Vertices[2]); } GL.End(); GL.EndList(); }
public Combiner(CombinerTypes type, ModuleBase source1, ModuleBase source2) { this.Type = type; this.Source = source1; this.Source2 = source2; }
public Combiner(CombinerTypes type, ModuleBase source1, ModuleBase source2) { _type = type; Source = source1; _source2 = source2; }
private unsafe void BtnGenerateLabyrinthClick(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; FractalType type = (FractalType)cbLabyrinthType.SelectedItem; BasisTypes basis = (BasisTypes)cbLabyrinthBasis.SelectedItem; InterpTypes interp = (InterpTypes)cbLabyrinthInterp.SelectedItem; int? octaves = !string.IsNullOrEmpty(tbLabyrinthOctaves.Text) ? int.Parse(tbLabyrinthOctaves.Text) : (int?)null; double?frequency = !string.IsNullOrEmpty(tbLabyrinthFrequency.Text) ? double.Parse(tbLabyrinthFrequency.Text) : (double?)null; double?angle = !string.IsNullOrEmpty(tbLabyrinthAngle.Text) ? double.Parse(tbLabyrinthAngle.Text) : (double?)null; double?lacunarity = !string.IsNullOrEmpty(tbLabyrinthLacunarity.Text) ? double.Parse(tbLabyrinthLacunarity.Text) : (double?)null; _labOldSeed = cbLabyrinthRnd.Checked ? (uint?)Environment.TickCount : _labOldSeed; ModuleBase moduleBase = new Fractal(type, basis, interp, octaves, frequency, _labOldSeed, angle, lacunarity); if (chkLabyrinthAC.Checked) { double acLow = double.Parse(tbLabyrinthACLow.Text); double acHigh = double.Parse(tbLabyrinthACHigh.Text); CombinerTypes combType = (CombinerTypes)cbLabyrinthACCombine.SelectedItem; AutoCorrect correct = new AutoCorrect(moduleBase, acLow, acHigh); moduleBase = new Combiner(combType, correct, moduleBase); } // Bias bias = new Bias(moduleBase, 0.01); // Gradient gradient = new Gradient(0, 0, 50, 100); // moduleBase = new TranslatedDomain(moduleBase, gradient, bias); if (chkLabyrinthSel.Checked) { double selLow = double.Parse(tbLabyrinthSelLow.Text); double selHigh = double.Parse(tbLabyrinthSelHigh.Text); double selThreshold = double.Parse(tbLabyrinthSelThreshold.Text); double?selFalloff = !string.IsNullOrEmpty(tbLabyrinthSelFalloff.Text) ? double.Parse(tbLabyrinthSelFalloff.Text) : (double?)null; moduleBase = new Select(moduleBase, selLow, selHigh, selThreshold, selFalloff); } if (pbLabyrinth.Image != null) { pbLabyrinth.Image.Dispose(); } ushort width = 500, height = 500; Bitmap bitmap = new Bitmap(width, height, PixelFormat.Format32bppRgb); BitmapData data = bitmap.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadWrite, bitmap.PixelFormat); byte *pRoughMap = (byte *)Memory.HeapAlloc(width * height); Parallel.For(0, height, y => { int *row = (int *)data.Scan0 + (y * data.Stride) / 4; Parallel.For(0, width, x => { double p = (double)x / width; double q = (double)y / height; double val = moduleBase.Get(p, q); pRoughMap[y * width + x] = (byte)Math.Abs(val - 1); Color color = Color.Black.Lerp(Color.White, val); row[x] = color.ToArgb(); }); }); using (ServerMap map = new ServerMap(width, height, 0, pRoughMap)) { map.SaveToFile("RK.save"); } Memory.HeapFree(pRoughMap); bitmap.UnlockBits(data); pbLabyrinth.Image = bitmap; Cursor = DefaultCursor; }