예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static ClippedCubeNode Create(Texture texture)
        {
            var vs    = new VertexShader(vertexCode);
            var fs    = new FragmentShader(fragmentCode);
            var array = new ShaderArray(vs, fs);
            var map   = new AttributeMap();

            map.Add("inPosition", TexturedCubeModel.strPosition);
            map.Add("inUV", TexturedCubeModel.strUV);
            var builder = new RenderMethodBuilder(array, map);
            var model   = new TexturedCubeModel();
            var node    = new ClippedCubeNode(model, builder);

            node.texture = texture;
            node.Initialize();
            node.ModelSize = model.ModelSize;

            return(node);
        }
예제 #2
0
        private SceneNodeBase GetRootElement()
        {
            string folder = System.Windows.Forms.Application.StartupPath;
            var bmp = new Bitmap(System.IO.Path.Combine(folder, @"Crate.bmp"));
            TexStorageBase storage = new TexImageBitmap(bmp);
            var texture = new Texture(storage);
            texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureWrapS, (int)GL.GL_CLAMP_TO_EDGE));
            texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureWrapT, (int)GL.GL_CLAMP_TO_EDGE));
            texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureWrapR, (int)GL.GL_CLAMP_TO_EDGE));
            texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureMinFilter, (int)GL.GL_LINEAR));
            texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureMagFilter, (int)GL.GL_LINEAR));
            texture.Initialize();
            texture.TextureUnitIndex = 0;
            bmp.Dispose();

            this.clippedCube = ClippedCubeNode.Create(texture);
            this.transparentPlane = TransparentPlaneNode.Create();
            transparentPlane.Scale = new vec3(1, 1, 1);
            var group = new GroupNode(clippedCube, transparentPlane);

            return group;
        }