Fun With Scripted Textures
Posted: Wed Feb 21, 2007 12:32 am
Awhile back Jonas mentioned to me that he could use the ability to switch between multiple textures dynamically as it would be easier, more elegant and less hacky than sheet movers or whatever his alternative was. I poked around with scripted textures a bit but didn't actually attempt anything until today, and I was suprised at how easy it was to actually do.
So now I've created two classes that take control of scripted textures and allow you to swap textures on the fly with them. One class, tnmTextureSwapController, just toggles between two and the other, tnmTextureSwitchController (perhaps not my best effort on the naming schema front), allows you to swap amongst 16 textures. I'm pretty happy with how everything came out but what I could use now are two things:
1) Some testing. I'm not entirely sure how well the engine copes with textures of different resolutions for instance, and I want to make sure these are stable.
2) Let me know if we have any other uses for them. I can't directly edit pixels or palletes, but I can, for instance, draw text on them, pan them, draw tiled textures on other textures (given a pallete that has both) and of course swap palletes and such.
The beta classes can be found here.
To use them you'll need to create a ScriptedTexture (not one of the subclasses, those are are FractalTextures are a I recall and would conflict quite heavily), setting its resolution to whatever you want and applying it to the surfaces (or actors, that'd be interesting) you want. You'd then need to create one of the TextureControllers (look under info) and get them set up pointing to your scripted texture and then it's just a matter of having something trigger them.
I appreciate the help.
So now I've created two classes that take control of scripted textures and allow you to swap textures on the fly with them. One class, tnmTextureSwapController, just toggles between two and the other, tnmTextureSwitchController (perhaps not my best effort on the naming schema front), allows you to swap amongst 16 textures. I'm pretty happy with how everything came out but what I could use now are two things:
1) Some testing. I'm not entirely sure how well the engine copes with textures of different resolutions for instance, and I want to make sure these are stable.
2) Let me know if we have any other uses for them. I can't directly edit pixels or palletes, but I can, for instance, draw text on them, pan them, draw tiled textures on other textures (given a pallete that has both) and of course swap palletes and such.
The beta classes can be found here.
To use them you'll need to create a ScriptedTexture (not one of the subclasses, those are are FractalTextures are a I recall and would conflict quite heavily), setting its resolution to whatever you want and applying it to the surfaces (or actors, that'd be interesting) you want. You'd then need to create one of the TextureControllers (look under info) and get them set up pointing to your scripted texture and then it's just a matter of having something trigger them.
I appreciate the help.