예제 #1
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var position = new vec3(-0.2f, 0, 1) * 14;
            var center   = new vec3(0, 0, 0);
            var up       = new vec3(0, 1, 0);
            var camera   = new Camera(position, center, up, CameraType.Perspecitive, this.winGLCanvas1.Width, this.winGLCanvas1.Height);

            this.scene = new Scene(camera, this.winGLCanvas1);

            {
                var   node = NormalMappingNode.Create();
                float max  = node.ModelSize.max();
                node.Scale            *= 16.0f / max;
                this.rootNode          = node;
                this.scene.RootElement = node;
            }

            var list            = new ActionList();
            var transformAction = new TransformAction(scene);

            list.Add(transformAction);
            var renderAction = new RenderAction(scene);

            list.Add(renderAction);
            this.actionList = list;

            var manipulater = new FirstPerspectiveManipulater();

            manipulater.Bind(camera, this.winGLCanvas1);
        }
예제 #2
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var position = new vec3(-0.2f, 0, 1) * 14;
            var center   = new vec3(0, 0, 0);
            var up       = new vec3(0, 1, 0);
            var camera   = new Camera(position, center, up, CameraType.Perspective, this.winGLCanvas1.Width, this.winGLCanvas1.Height);

            this.scene = new Scene(camera);

            {
                var sphere   = new Sphere(1, 40, 80);
                var filename = Path.Combine(System.Windows.Forms.Application.StartupPath, "sphere.obj_");
                sphere.DumpObjFile(filename, "sphere");
                var          parser = new ObjVNFParser(false);
                ObjVNFResult result = parser.Parse(filename);
                if (result.Error != null)
                {
                    Console.WriteLine("Error: {0}", result.Error);
                }
                else
                {
                    ObjVNFMesh mesh  = result.Mesh;
                    var        model = new ObjVNF(mesh);
                    var        node  = NormalMappingNode.Create(model, model.GetSize(),
                                                                ObjVNF.strPosition,
                                                                ObjVNF.strTexCoord,
                                                                ObjVNF.strNormal,
                                                                ObjVNF.strTangent);
                    float max = node.ModelSize.max();
                    node.Scale         *= 16.0f / max;
                    this.rootNode       = node;
                    this.scene.RootNode = node;
                    (new FormPropertyGrid(node)).Show();
                }
            }

            var list            = new ActionList();
            var transformAction = new TransformAction(scene);

            list.Add(transformAction);
            var renderAction = new RenderAction(scene);

            list.Add(renderAction);
            this.actionList = list;

            var manipulater = new FirstPerspectiveManipulater();

            manipulater.Bind(camera, this.winGLCanvas1);
        }
예제 #3
0
        public static NormalMappingNode Create()
        {
            var model = new NormalMappingModel();
            var vs    = new VertexShader(vertexCode);
            var fs    = new FragmentShader(fragmentCode);
            var array = new ShaderArray(vs, fs);
            var map   = new AttributeMap();

            map.Add("inPosition", NormalMappingModel.strPosition);
            map.Add("inTexCoord", NormalMappingModel.strTexCoord);
            map.Add("inNormal", NormalMappingModel.strNormal);
            map.Add("inTangent", NormalMappingModel.strTangent);
            var builder = new RenderMethodBuilder(array, map);
            var node    = new NormalMappingNode(model, builder);

            node.ModelSize = new vec3(2, 2, 0.1f);
            node.Initialize();

            return(node);
        }
예제 #4
0
        public static NormalMappingNode Create(IBufferSource model, vec3 size, string position, string texCoord, string normal, string tangent)
        {
            //var model = new NormalMappingModel();
            var vs    = new VertexShader(vertexCode);
            var fs    = new FragmentShader(fragmentCode);
            var array = new ShaderArray(vs, fs);
            var map   = new AttributeMap();

            //map.Add("inPosition", NormalMappingModel.strPosition);
            //map.Add("inTexCoord", NormalMappingModel.strTexCoord);
            //map.Add("inNormal", NormalMappingModel.strNormal);
            //map.Add("inTangent", NormalMappingModel.strTangent);
            map.Add("inPosition", position);
            map.Add("inTexCoord", texCoord);
            map.Add("inNormal", normal);
            map.Add("inTangent", tangent);
            var builder = new RenderMethodBuilder(array, map);
            var node    = new NormalMappingNode(model, builder);

            node.ModelSize = size;
            node.Initialize();

            return(node);
        }