Write to face of Box object

Mar 6, 2011 at 9:23 AM

Hi.

I am using Balder to represent the pages returned by Google in response to a query.

Each page is represented by a cube, the top surface of each cube should show the page.  I can capture the page abd transfer its bitmap to a memory stream. I am, however, in some difficulty as to how to transfer the stream to a face of the cube , probably as a texture.

Could you help with a code snippet?

Paul Mariotti

Mar 6, 2011 at 9:59 AM

Hi,

If you have the image as a WriteableBitmap convert it to a Balder.Imaging,Image

	  var bimage = new Balder.Imaging.Image();

            var imageFormat = new ImageFormat
                                  {
                                      Depth = 32,
                                      PixelFormat = PixelFormat.RGBAlpha
                                  };

            bimage.Width = sidetexture.PixelWidth;
            bimage.Height = sidetexture.PixelHeight;
            bimage.ImageContext.SetFrame(imageFormat, sidetexture.ToByteArray());
You then need to create a new  Balder material using the new image:
		    var mside = new Material()
                        {
                            DiffuseMap = new ImageMap(bimage),
                            Shade = MaterialShade.Gouraud,
                            DoubleSided = false,
                        };
Once you have this done you can then assign the new material as a submaterial of your
cubes material.
		myCubeBaseMaterial.SubMaterials.Add(0,mside);
and then repeat for all 6 sides (0,1,2,3,4,5)
Is that what you need ?
Stuart