Esempio n. 1
0
 private static VAO CreateMesh(Shader shader)
 {
     Mesh mesh = Obj2Mesh.FromObj(Resourcen.suzanne);
     var vao = new VAO();
     vao.SetAttribute(shader.GetAttributeLocation("position"), mesh.positions.ToArray(), VertexAttribPointerType.Float, 3);
     vao.SetAttribute(shader.GetAttributeLocation("normal"), mesh.normals.ToArray(), VertexAttribPointerType.Float, 3);
     vao.SetID(mesh.ids.ToArray(), PrimitiveType.Triangles);
     return vao;
 }
Esempio n. 2
0
 private static VAO CreateMesh(Shader shader)
 {
     Mesh mesh = Meshes.CreateSphere(0.03f, 2);
     var vao = new VAO();
     vao.SetAttribute(shader.GetAttributeLocation("position"), mesh.positions.ToArray(), VertexAttribPointerType.Float, 3);
     vao.SetAttribute(shader.GetAttributeLocation("normal"), mesh.normals.ToArray(), VertexAttribPointerType.Float, 3);
     vao.SetID(mesh.ids.ToArray(), PrimitiveType.Triangles);
     return vao;
 }
Esempio n. 3
0
        public MainVisual()
        {
            var sVertex = Encoding.UTF8.GetString(Resourcen.vertex);
            var sFragment = Encoding.UTF8.GetString(Resourcen.fragment);
            shader = ShaderLoader.FromStrings(sVertex, sFragment);

            //load geometry
            Mesh mesh = Obj2Mesh.FromObj(Resourcen.suzanne);
            geometry.SetAttribute(shader.GetAttributeLocation("position"), mesh.positions.ToArray(), VertexAttribPointerType.Float, 3);
            geometry.SetAttribute(shader.GetAttributeLocation("normal"), mesh.normals.ToArray(), VertexAttribPointerType.Float, 3);
            //geometry.SetAttribute(shader.GetAttributeLocation("uv"), mesh.uvs.ToArray(), VertexAttribPointerType.Float, 2);
            geometry.SetID(mesh.ids.ToArray(), PrimitiveType.Triangles);

            GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line); //draw wireframe

            //GL.Enable(EnableCap.DepthTest);
            //texDiffuse = TextureLoader.FromFile(pathMedia + "capsule0.jpg");
        }
Esempio n. 4
0
 public VisualPlane()
 {
     var sVertex = Encoding.UTF8.GetString(Resourcen.plane_vert);
     var sFragment = Encoding.UTF8.GetString(Resourcen.plane_frag);
     shdPlane = ShaderLoader.FromStrings(sVertex, sFragment);
     var mesh = Meshes.CreatePlane(2, 2, 1, 1);
     plane.SetAttribute(shdPlane.GetAttributeLocation("position"), mesh.positions.ToArray(), VertexAttribPointerType.Float, 3);
     plane.SetID(mesh.ids.ToArray(), PrimitiveType.Triangles);
 }
Esempio n. 5
0
        private static void CreatePerInstanceAttributes(VAO vao, Shader shader)
        {
            //per instance attributes
            var rnd = new Random(12);
            Func<float> Rnd01 = () => (float)rnd.NextDouble();
            Func<float> RndCoord = () => (Rnd01() - 0.5f) * 2.0f;
            var instancePositions = new Vector3[particelCount];
            for (int i = 0; i < particelCount; ++i)
            {
                instancePositions[i] = new Vector3(RndCoord(), RndCoord(), RndCoord());
            }
            vao.SetAttribute(shader.GetAttributeLocation("instancePosition"), instancePositions, VertexAttribPointerType.Float, 3, true);

            //todo: students: add per instance attribute speed here
            //var locInstSpeed = shader.GetAttributeLocation("instanceSpeed");
        }