Applying a Sticker-like texture

By default, Eyeshot repeats a material with texture when it is applied on an entity:

Capture.PNG

If you don't want to repeat it, but instead you want to apply it like a sticker, as in the following picture, you can use the approach described in this document.

 Capture2.PNG

 

Create a bitmap to use as the texture that has a 1 pixel border of the color that you want on your Eyeshot entity, then create a Material from that bitmap with the RepeatX and RepeatY properties set to false and assign it to the entity:

 

 	    Mesh plate = Mesh.CreatePlanar(new LinearPath(20, 30), 0.1, meshNatureType.Plain); 

            Size origSize = Properties.Resources.Smiley.Size; 

            // Create a new bitmap from the original one that has 1-pixel border of the appropriate color 
            Bitmap myBmp = new Bitmap(origSize.Width + 2, origSize.Height + 2); 

            using (Graphics gBmp = Graphics.FromImage(myBmp)) 
            { 
                SolidBrush brush = new SolidBrush(Color.Red); 
                gBmp.FillRectangle(brush, new Rectangle(0, 0, myBmp.Width, myBmp.Height)); 
                gBmp.DrawImage(Properties.Resources.Smiley, 1, 1, origSize.Width, origSize.Height); 
            } 

            Material mat = new Material(myBmp); 
            mat.RepeatX = false;
            mat.RepeatY = false;
            viewportLayout.Materials.Add("mat", mat); 

            // Apply the texture mapping and assign the material to the entity 
            plate.ApplyTextureMapping(textureMappingType.Plate, 0.5, 0.5); 
            plate.MaterialName = "mat"; 
            plate.ColorMethod = colorMethodType.byEntity; 

            viewportLayout.Entities.Add(plate);

 

Note:

With OpenGL Renderer this feature works only with hardware acceleration and from build 8.0.385.

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.