Game Development Community

User created .pngs for imagemaps

by Brian Ratte · in Torque Game Builder · 02/08/2007 (7:43 am) · 5 replies

I am interested in adding the capability for a user to pick a color using the colorpicker gui object, and having a 64x64 pixel imagemap of the chosen color value created on the fly. This png would be saved to a file for use as part of a .dts object skin. This would allow completely custom color combinations for character skins. Allowing the user to pick different colors for pants, shirts, etc., and using them on the dts objects would greatly reduce my art workload.

Anyone have any idea how to create a png file on the fly like this?

#1
02/14/2007 (2:40 pm)
The script engine doesn't have any calls to directly perform that sort of process. If you are a c++ programmer the engine provides libraries for handling png, jpg, and gif image formats. You could write your own routines.
#2
02/14/2007 (5:18 pm)
@Brian, you can use alpha-blending and a 'slider' to alter the 'color' of a t2dStaticSprite, and then when you want to save the sprite out -- you could make it fullscreen and use the 'screenshot' function to 'save' the file -- however, the resulting image will have a minimal size of 640x480 as the engine currently will not allow you to set resolutions below that ...

As Guy suggests though, if you can do some C++ ... you could whip together a rough 'save imagemap buffer to disk' ConsoleFunction
#3
02/15/2007 (3:31 am)
Thanks Guy and David for your ideas. Unfortunately, I do not have source code access with my license. I thought about the slider/screenshot route, but in the end I am just manually making different color 64x64 texture .pngs in about 20 colors. That should be enough to give the players some customization options, without much hassle. The chosen color textures will then be placed into a skin set for application to the 3D shapes. Now I just need to find some information on how to build the skin sets for my .DTS objects.
#4
02/15/2007 (4:27 am)
There is an far way: Make your object of 2 objects actually.

The always "same looking" part and the part that you want to be changeable.
Now that changeable part is just a grayscale version of your object.

By using setBlendColor you can now specifiy the color of it by "cutting out" the rest.

This means using .setBlendColor(1,0,0,1) for example would only show the red part of the grayscale -> it will be red.

Now just mount that grayscale part to your "static colored" part and thats it :)


This is the "2D description" to make it easier to understand.
But as t2dShape3D inherits from t2dSceneObject, this theoretically should work there as well. Just with 2 3D objects instead of 2 imagemaps.
#5
02/16/2007 (6:18 pm)
Marc,

I will give it a shot. I will make my clothing object as a separate piece, and see how it behaves when mounted to the body. I have some concerns about how the animations will work. We will see!

Thanks for the suggestions!