This object uses a set of quads to represent a mesh that is in the XY plane. A size parameter sets the model coordinate boundaries of the mesh The Resolution determines how many quads are constructed along each axis. This class clearly separates the creation of vertices, indices, and texture coodinates for the sake of clarity. It may not be the most efficient manner, but is probably the easiest to understand, modiy, extend, and maintain. This is not the most optimal representation of a mesh of quads. First, the individual vertices are duplicated rather than shared. This is to allow setting of individual normal vectors, and texture coordinates per vertex. Also, instead of using quad strips, each individual quad is drawn as a separate object. Again, this is for full control of drawing. One scenario might be that each individual quad is drawn and some shader parameters are set before the drawing occurs. This might allow a shader to convey information to the quad such as which position it is in relative to the resolution of the entire mesh.
Inheritance: Mesh3D
Example #1
0
        /// <summary>
        /// Once we have a context, we are able to peform various setup routines
        /// that require us to connect to OpenGL.
        /// </summary>
        protected override void OnSetContext()
        {
            //fCamera1 = VideoTexture.CreateFromDeviceIndex(GI, 0, 640, 480);
            fCamera1 = VideoTexture.CreateFromDeviceIndex(GI, 0, true);
        
            // Turn off features that we don't need, and they 
            // just slow down video processing
            GI.Features.AlphaTest.Disable();
            GI.Features.Blend.Disable();
            GI.Features.DepthTest.Disable();
            GI.Features.Dither.Disable();
            GI.Features.Fog.Disable();
            GI.Features.Lighting.Disable();

            // Create the FaceMesh that will receive the gray texture so we 
            // can break it up into 8x8 squares
            fFaceSize = new Vector3D(fCamera1.Width, fCamera1.Height, 0);

            fBackgroundCreator = new RGBToGray(GI, fCamera1.Width, fCamera1.Height);
            fBackgroundCopier = new UnaryTextureProcessor(GI, fCamera1.Width, fCamera1.Height);
            fBackgroundPixellator = new Pixellate(GI, fCamera1.Width, fCamera1.Height, 8);
            
            fImageOperator = new UnaryTextureProcessor(GI, fCamera1.Width, fCamera1.Height);
            fGrayConverter = new RGBToGray(GI, fCamera1.Width, fCamera1.Height);
            fGammaCorrection = new PowerLawTransform(GI, fCamera1.Width, fCamera1.Height, 1.0f);
            fLuminanceThreshold = new LuminanceThreshold(GI, fCamera1.Width, fCamera1.Height, 0f);
            fLuminanceBinarizer = new LuminanceBinarizer(GI, fCamera1.Width, fCamera1.Height, 0.3f);
            fLuminanceBinarizer.OverColor = ColorRGBA.Black;
            fLuminanceBinarizer.UnderColor = ColorRGBA.White;
            fPixellate = new Pixellate(GI, fCamera1.Width, fCamera1.Height,8);
            fBlocker = new BlockProcessor(GI, fCamera1.Width, fCamera1.Height, 2);
            fAverager = new AverageProcessor(GI, fCamera1.Width, fCamera1.Height);
            fMorpher = new Morph(GI, fCamera1.Width, fCamera1.Height);

            fEdgeEnhance = new ConvolutionProcessor(GI, fCamera1.Width, fCamera1.Height, ConvolutionKernel.EdgeEnhance);
            fEdgeEnhance.Distance = 4;
            fEmboss = new ConvolutionProcessor(GI, fCamera1.Width, fCamera1.Height, ConvolutionKernel.Emboss);
            fSoften = new ConvolutionProcessor(GI, fCamera1.Width, fCamera1.Height, ConvolutionKernel.GaussianBlur);
            fSoften.Distance = 4;
            fSobell = new ConvolutionProcessor(GI, fCamera1.Width, fCamera1.Height, ConvolutionKernel.Sobell);
            fLaplacian = new ConvolutionProcessor(GI, fCamera1.Width, fCamera1.Height, ConvolutionKernel.Laplacian);

            fDifference = new DifferenceProcessor(GI, fCamera1.Width, fCamera1.Height);



            // We want replace mode because we don't care about
            // the values that are currently in place, we just want
            // to replace them.
            GI.TexEnv(TextureEnvModeParam.Replace);

            fGrayMesh = new XYAxesMesh(GI, new Vector3D(fCamera1.Width, fCamera1.Height, 0), new Resolution(2, 2), null);
            fPointMesh = new XYAxesPointMesh(GI, new Vector3D(fCamera1.Width, fCamera1.Height, 0), new Resolution(fCamera1.Width/4, fCamera1.Height/4), null);
        }
Example #2
0
        protected override void DrawBegin()
        {
            // Start with viewport covering whole window
            GI.Viewport(0, 0, fViewWidth, fViewHeight);

            // Create an orthographic view so we can draw
            // using 2D coordinates and not really worry about the
            // camera position
            GI.MatrixMode(MatrixMode.Projection);
            GI.LoadIdentity();

            GI.Ortho(0, fViewWidth, 0, fViewHeight, -1.0, 1.0);

            // Clear the color buffer to an unlikely color so
            // that we can see where the drawing is NOT occuring
            GI.Buffers.ColorBuffer.Color = new ColorRGBA(1, 0, 0, 1); ;
            GI.Buffers.ColorBuffer.Clear();

            // If the resolution of the mesh changed since the last time we were
            // drawing, recreate the mesh using the newest dimensions.
            if (fResolutionChanged)
            {
                Console.WriteLine("Block Size: {0}", fBlockSize);
                fResolutionChanged = false;
                fResolution = new Resolution(fVideoTexture.Width / fBlockSize, fVideoTexture.Height / fBlockSize);
                fFaceMesh = new XYAxesMesh(fFaceSize, fResolution, fYTexture);
            }
        }