public SkeletonRenderer (ref Skeleton Skele) { skele = Skele; Allocate (); }
public void newinit(ref Skeleton skele) { GL.Enable(EnableCap.DepthTest); List<Vector4> vertices=new List<Vector4>(); List<Matrix4> matriceses=new List<Matrix4>(); List<ushort> bvhindices=new List<ushort>(); bvh_to_vertices(skele.bones[0],ref vertices,ref bvhindices,ref matriceses); var bvh_elements = bvhindices.Count; GL.GenBuffers(1,out skele.VBOV); GL.BindBuffer(BufferTarget.ArrayBuffer, skele.VBOV); GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(Marshal.SizeOf<Vector4>() * vertices.Count), vertices.ToArray(), BufferUsageHint.DynamicDraw); GL.BindBuffer(BufferTarget.ArrayBuffer, 0); GL.GenBuffers(1,out skele.VBOI); GL.BindBuffer(BufferTarget.ElementArrayBuffer, skele.VBOI); GL.BufferData(BufferTarget.ElementArrayBuffer,(IntPtr)( Marshal.SizeOf<ushort>() * bvhindices.Count), bvhindices.ToArray(), BufferUsageHint.StaticDraw); GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0); //int sLocPosition = shader1.attribute("position"); GL.GenVertexArrays(1,out skele.VAO); GL.BindVertexArray(skele.VAO); GL.BindBuffer(BufferTarget.ArrayBuffer, skele.VBOV); GL.EnableVertexAttribArray(0); GL.VertexAttribPointer(0, 4, VertexAttribPointerType.Float,false, 0, 0); GL.BindBuffer(BufferTarget.ArrayBuffer, 0); GL.BindBuffer(BufferTarget.ElementArrayBuffer, skele.VBOI); GL.BindVertexArray(0); }
public void display(ref Skeleton skele) { //GL.ClearColor(0.5f, 0.5f, 0.5f, 1.0f); //GL.ClearDepth(1.0); //GL.Clear(ClearBufferMask.ColorBufferBit | Clea); //shader1.use(); List<Vector4> vertices=new List<Vector4>(); List<Matrix4> matrices=new List<Matrix4>(); List<ushort> bvhindices=new List<ushort>(); bvh_to_vertices(skele.bones[0],ref vertices,ref bvhindices,ref matrices); var bvh_elements = bvhindices.Count; var mats = matrices.ToArray (); //GL.Enable (EnableCap.Light0); //GL.light //GL.LoadMatrix(ref skele.MVP); //GL.ShadeModel (ShadingModel.Flat); GL.LoadMatrix(ref skele.MVP); //foreach (var childBone in skele.bones[0].Children) DisplayOcta (skele.bones[0]); GL.UseProgram(Shader.shaders["SkeletonShader"].Program); GL.UniformMatrix4(GL.GetUniformLocation(Shader.shaders["SkeletonShader"].Program,"mvp_matrix"), false,ref skele.MVP); update(ref skele); GL.BindVertexArray(skele.VAO); GL.PointSize(5); GL.DrawElements(PrimitiveType.Lines, bvh_elements,DrawElementsType.UnsignedShort , (IntPtr)0); GL.LineWidth(3); GL.DrawElements(PrimitiveType.Points, bvh_elements, DrawElementsType.UnsignedShort, (IntPtr)0); GL.PointSize(1); GL.LineWidth(1); GL.BindVertexArray(0); }
public void update(ref Skeleton skele) { List<Vector4> vertices=new List<Vector4>(); List<ushort> bvhindices=new List<ushort>(); List<Matrix4> matrices=new List<Matrix4>(); bvh_to_vertices(skele.bones[0],ref vertices,ref bvhindices,ref matrices); GL.BindBuffer(BufferTarget.ArrayBuffer, skele.VBOV); GL.BufferData(BufferTarget.ArrayBuffer,(IntPtr)( Marshal.SizeOf<Vector4>() * vertices.Count),vertices.ToArray(),BufferUsageHint.DynamicDraw); GL.BindBuffer(BufferTarget.ArrayBuffer, 0); }