Programatically create textures ??

Jul 6, 2010 at 8:52 PM
Is there a way to create a texture from a WriteableBitmap ?

Its a lot cheaper to generate some of my textures in the client compared to downloading a 16k png file :)
Coordinator
Jul 7, 2010 at 6:41 AM

Hi,

the Image support is a bit limiting today in Balder, something I want to clean up and make a lot more extensible. 
But, there is a way of doing this.

You can programatically create it.

- First create an instance of Image by calling the Runtimes ContentManager and initialize the Width and Height :

var image = Runtime.Instance.ContentManager.CreateAssetPart<Image>();
image.Width = 320;
image.Height = 240;

 Then you can use the ImageContext on the Frame to set the actual pixels:

image.ImageContext.SetFrame(yourImageBytes);

That should in theory work. 

Jul 11, 2010 at 9:44 PM

No joy -- the DLLs you sent do not have content manager as a property if IRuntime.

Coordinator
Jul 12, 2010 at 3:26 PM

Ok.

I'll look it over and see what can be done. I'm in the middle of fixing a lot of this, so I'll see what I can do to speed it up, or at least get a proper answer for you on this.

Coordinator
Aug 1, 2010 at 9:09 AM

In the latest version of Balder you have something called IMap, the DiffuseMap property and the ReflectionMap property of a Material is now of type IMap - you can now easily generate your own map on the fly. Look at ImageMap for more details.

Aug 4, 2010 at 9:39 PM
Hi Adept, I can't add the texture correctly. I have a wood texture image, which has vertical grain. When I try to attach it to box, the grain is rotated about 45 degree. I really don't know why. Please help. Thanks
Coordinator
Aug 5, 2010 at 3:14 PM

This could be a bug - but you can work around it by just rotating the Box using the Rotation property. 

You could just do Rotation="0,45,0" to rotate it 45 degrees around the Y axis.

Aug 5, 2010 at 6:11 PM
Adept, I have tried. It is not working by rotating 45 degree around the Y axis. Actually this is not just for one face. all 6 faces are the same.
Coordinator
Aug 5, 2010 at 9:54 PM

This sounds like there is something else going on. 

Is it possible for you to email me a simple demo with the problem in it? (einar [at] dolittle [dot] com) - I won't be able to look at it before Monday, though. 

Aug 5, 2010 at 11:55 PM
Einar, If you look the Box carefully, You will see the edge is not so smooth, looks like sawtooth. Is that not high resolution? What is the step length( or unit measure length) from 1 to 2? Thanks
Coordinator
Aug 6, 2010 at 7:25 AM

Do you mean the edges of the box or the edges within the texture?

The texturemapping uses relative coordinates from 0-1. For screen coordinates, that is something I'm working on - its not doing subpixling at the moment. But I've started fixing this, so everything will be more accurate.

Also worth mentioning, next version will have perspective correct texture mapping plus bilinear filtering - this is in fact implemented but not enabled yet.