Esempio n. 1
0
        private SceneNodeBase GetRootElement()
        {
            string folder = System.Windows.Forms.Application.StartupPath;
            var    bitmap = new Bitmap(System.IO.Path.Combine(folder, @"Lenna.png"));

            bitmap.RotateFlip(RotateFlipType.Rotate180FlipX);
            var texture = new Texture(new TexImageBitmap(bitmap));

            texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureWrapS, (int)GL.GL_REPEAT));
            texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureWrapT, (int)GL.GL_REPEAT));
            texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureWrapR, (int)GL.GL_REPEAT));
            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();
            bitmap.Dispose();

            var group = new GroupNode();

            for (int x = 0; x < 3; x++)
            {
                for (int z = 0; z < 3; z++)
                {
                    var outlineCubeNode = LogicOperationNode.Create(texture);
                    outlineCubeNode.Scale         = new vec3(1, 1, 1) * 0.6f;
                    outlineCubeNode.WorldPosition = new vec3(x - 1, 0, z - 1);
                    group.Children.Add(outlineCubeNode);
                }
            }
            return(group);
        }
Esempio n. 2
0
        /// <summary>
        /// Render propeller in modern opengl.
        /// </summary>
        /// <returns></returns>
        public static LogicOperationNode Create(Texture texture)
        {
            var vs       = new VertexShader(vertexCode);
            var fs       = new FragmentShader(fragmentCode);
            var provider = new ShaderArray(vs, fs);
            var map      = new AttributeMap();

            map.Add(inPosition, TexturedCubeModel.strPosition);
            map.Add(inUV, TexturedCubeModel.strUV);
            var builder = new RenderMethodBuilder(provider, map);
            var node    = new LogicOperationNode(new TexturedCubeModel(), TexturedCubeModel.strPosition, builder);

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

            return(node);
        }
Esempio n. 3
0
        void winGLCanvas1_MouseMove(object sender, MouseEventArgs e)
        {
            int x = e.X;
            int y = this.winGLCanvas1.Height - e.Y - 1;

            if (x < 0 || this.winGLCanvas1.Width <= x)
            {
                return;
            }
            if (y < 0 || this.winGLCanvas1.Height <= y)
            {
                return;
            }

            var pickedGeometry = this.pickingAction.Pick(x, y, PickingGeometryTypes.Triangle | PickingGeometryTypes.Quad, this.winGLCanvas1.Width, this.winGLCanvas1.Height);

            var lastNode = this.lastPickedNode as LogicOperationNode;

            this.lastPickedNode = null;// we will pick again.

            LogicOperationNode currentNode = null;

            if (pickedGeometry != null)
            {
                currentNode = pickedGeometry.FromObject as LogicOperationNode;
            }

            if (lastNode != currentNode)
            {
                if (lastNode != null)
                {
                    lastNode.LogicOp = false;
                }

                if (currentNode != null)
                {
                    currentNode.LogicOp = true;
                }
            }

            this.lastPickedNode = currentNode;
            this.lblState.Text  = string.Format("picked: {0}", this.lastPickedNode);
        }