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.
Наследование: NewTOAPIA.GL.Mesh3D
Пример #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);
        }
Пример #2
0
 public BlockProcessor(GraphicsInterface gi, int width, int height, int blockSize)
     : base(gi, width, height, UnaryTextureProcessor.FixedFrag)
 {
     fBlockSize = 8;
     fPointMesh = new XYAxesPointMesh(gi, new Vector3D(width, height, 0), new Resolution(width / blockSize, height / blockSize), null);
 }