public void Load(VertexPosition[] vertices, short[] elements) { this.vertices = vertices; this.elements = elements; throw new ApplicationException("not created class"); //vbo = VBOHelper.LoadStaticVBO(vertices, elements); }
public virtual void GenerateThread() { System.DateTime renderbegin = System.DateTime.Now; vertices = new VertexPosition[ triangles.Length * 3 ]; elements = new short[ triangles.Length * 3 ]; for( int i = 0; i < ( triangles.Length * 3 ); ) { short c = ( short ) ( i / 3 ); vertices[i] = new VertexPosition(triangles[c][0]); i++; vertices[i] = new VertexPosition(triangles[c][1]); i++; vertices[i] = new VertexPosition(triangles[c][2]); i++; } for( short a = 0; a < triangles.Length * 3; a++ ) { elements[ a ] = ( short ) a; } TimeSpan delta = System.DateTime.Now - renderbegin; Console.WriteLine( "Mesh generation time: " + delta.Milliseconds ); }
public void BufferVertices(ref VertexPosition[] vertices) { Vector2[] value = new Vector2[vertices.Length]; for(int i = 0; i<value.Length;i++) { value[i] = new Vector2(vertices[i].Position.X,vertices[i].Position.Y); } ConcaveTriangulator.Triangulate(value, new int[] { value.Length }, ref log); this.vertices = vertices; this.indices = ConcaveTriangulator.Indices.ToArray(); }
public void DoCircleClipping(Vector2 pos, float radius) { ClippingPolygons subj = new ClippingPolygons(1); subj.Add(new ClippingPolygon(shape.Length)); foreach(VertexPosition point in shape){ subj[0].Add(new IntPoint((int)((point.Position.X) * accuracy), (int)((point.Position.Y) * accuracy))); } ClippingPolygons clip = new ClippingPolygons(1); clip.Add(new ClippingPolygon()); for (int alpha = 0; alpha < 360; alpha += 10) { clip[0].Add(new IntPoint((int)(((Math.Sin((alpha) * Math.PI / 180.0) * radius)+pos.X) * accuracy), (int)(((Math.Cos((alpha) * Math.PI / 180.0) * radius)+pos.Y) * accuracy))); //log.Log(pos.ToString()); } ClippingPolygons solution = new ClippingPolygons(); Clipper c = new Clipper(); c.AddPolygons(subj, PolyType.ptSubject); c.AddPolygons(clip, PolyType.ptClip); if (c.Execute(ClipType.ctDifference, solution, PolyFillType.pftEvenOdd, PolyFillType.pftEvenOdd)) { for (int f = 0; f < solution.Count; f++) { if (f == 0) { shape = new VertexPosition[solution[f].Count]; for (int i = 0; i < solution[f].Count; i++) { shape[i] = new VertexPosition(solution[f][i].X / accuracy, solution[f][i].Y / accuracy, 0); } } } } BufferVertices(ref shape); }
public void OnLoad() { GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest); GL.GenTextures(1, out texture); GL.BindTexture(TextureTarget.Texture2D, texture); BitmapData data = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, data.Width, data.Height, 0, OpenTK.Graphics.PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0); bitmap.UnlockBits(data); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); shape.Add(new VertexPosition[4]); shape[0][0] = new VertexPosition(3 + ChunkPosition.X, 3 + ChunkPosition.Y, 0); shape[0][1] = new VertexPosition(3 + ChunkPosition.X, 0 + ChunkPosition.Y, 0); shape[0][2] = new VertexPosition(0 + ChunkPosition.X, 0 + ChunkPosition.Y, 0); shape[0][3] = new VertexPosition(0 + ChunkPosition.X, 3 + ChunkPosition.Y, 0); drawer[0].BufferVertices(shape[0]); }
public void BufferVertices(VertexPosition[] vertices) { BufferVertices(ref vertices); }