Example #1
0
        public View(IContentLoader contentLoader, IRenderContext renderContext)
        {
            renderContext.RenderState.Set(new DepthTest(true));
            //renderContext.RenderState.Set(new FaceCullingModeState(FaceCullingMode.BACK_SIDE));
            shader = contentLoader.Load <IShaderProgram>("shader.*");

            var fileName = @"D:\Daten\downloads\gits\glTF-Sample-Models\2.0\Cameras\glTF-Embedded\Cameras.gltf";

            fileName = @"D:\Daten\downloads\gits\glTF-Sample-Models\2.0\BrainStem\glTF\BrainStem.gltf";
            //fileName = @"D:\Daten\downloads\gits\glTF-Sample-Models\2.0\BoxAnimated\glTF\BoxAnimated.gltf";
            //fileName = @"D:\Daten\downloads\gits\glTF-Sample-Models\2.0\RiggedSimple\glTF\RiggedSimple.gltf";
            //fileName = @"D:\Daten\downloads\gits\glTF-Sample-Models\2.0\RiggedFigure\glTF\RiggedFigure.gltf";
            //fileName = @"D:\Daten\downloads\gits\glTF-Sample-Models\2.0\Monster\glTF\Monster.gltf";
            //fileName = @"D:\Daten\downloads\gits\glTF-Sample-Models\2.0\CesiumMan\glTF\CesiumMan.gltf";
            //fileName = @"D:\Daten\downloads\gits\glTF-Sample-Models\2.0\2CylinderEngine\glTF\2CylinderEngine.gltf";
            //fileName = @"D:\Daten\downloads\gits\glTF-Sample-Models\2.0\OrientationTest\glTF-Embedded\OrientationTest.gltf";
            //fileName = @"D:\Daten\downloads\_cg\gltf models\ferris_wheel_animated\scene.gltf";
            //fileName = @"D:\Daten\downloads\_cg\gltf models\izzy_-_animated_female_character_free_download\scene.gltf";
            //fileName = @"D:\Daten\downloads\_cg\gltf models\littlest_tokyo\scene.gltf";
            var directory = Path.GetDirectoryName(fileName);

            //using (var stream = contentLoader.Load<Stream>("AnimatedTriangle.gltf"))
            //using (var stream = contentLoader.Load<Stream>("Box.gltf"))
            using (var stream = File.OpenRead(fileName))
            {
                byte[] LoadFile(string externalFile) => File.ReadAllBytes(Path.Combine(directory, externalFile));
                int UniformLoc(string name) => shader.GetResourceLocation(ShaderResourceType.Uniform, name);

                int AttributeLoc(string name)
                {
                    var attributeName = name.ToLowerInvariant();
                    var location      = shader.GetResourceLocation(ShaderResourceType.Attribute, attributeName);

                    return(location);
                }

                model = new GltfModelRendererGL(stream, LoadFile, UniformLoc, AttributeLoc);
            }
            locJoints = shader.GetResourceLocation(ShaderResourceType.Uniform, "u_jointMat");
            Cameras   = model.Cameras;
            time      = new Stopwatch();
            time.Start();
        }