/// <summary> /// Render propeller in modern opengl. /// </summary> /// <returns></returns> public static OutlineCubeNode 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 OutlineCubeNode(new TexturedCubeModel(), TexturedCubeModel.strPosition, builder); node.texture = texture; node.Initialize(); return(node); }
private SceneNodeBase GetRootElement() { // demo 1: //return StencilTestNode.Create(); // demo 2: //var quaterNode = QuaterNode.Create(); //var bottleNode = KleinBottleNode.Create(new KleinBottleModel()); //bottleNode.Scale = new vec3(1, 1, 1) * 0.1f; //var group = new HowStencilTestWorkNode(); //group.Children.Add(quaterNode); //group.Children.Add(bottleNode); //return group; // demo 3: var clearStencilNode = ClearStencilNode.Create(); // this helps clear stencil buffer because glClear(GL_STENCIL_BUFFER_BIT); doesn't work. 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(clearStencilNode); for (int x = 0; x < 3; x++) { for (int z = 0; z < 3; z++) { var outlineCubeNode = OutlineCubeNode.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); }
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, true, true, false); var lastNode = this.lastPickedNode as OutlineCubeNode; this.lastPickedNode = null;// we will pick again. OutlineCubeNode currentNode = null; if (pickedGeometry != null) { currentNode = pickedGeometry.FromRenderer as OutlineCubeNode; } if (lastNode != currentNode) { if (lastNode != null) { lastNode.DisplayOutline = false; } if (currentNode != null) { currentNode.DisplayOutline = true; } } this.lastPickedNode = currentNode; this.lblState.Text = string.Format("picked: {0}", this.lastPickedNode); }