draw on models textur?

Posted By: Anonymous

draw on models textur? - 04/18/07 22:11

maybe it's already asked sometimes?

How can i draw (pixels/sprites) on a models texture at runtime?
And can i determin the color of a pixel of a models texture at runtime?

thanx mercuryus
Posted By: xXxGuitar511

Re: draw on models textur? - 04/19/07 02:25

check the manual, lol.

It's a combination of functions...

Code:

bmap IDK = "Whatever.bmp";
var Color[4];
//
Function readThis(_x, _y, _format, &outColor)
{
var pixel;
pixel = pixel_for_bmap(mapIDK, _x, _y);
pixel_to_vec(color, color[3], _format, pixel);
}



Input X, Y, and FORMAT of bmap. outColor is the return vector of length 4. The fourth (really [3]) is the alpha value...
Posted By: Anonymous

Re: draw on models textur? - 04/19/07 05:58

thanx - i knew this would be that apparent but sometime it's hard to remember where to be found .
Posted By: Anonymous

Re: draw on models textur? - 04/19/07 09:16

now i can draw on a bmp but how do i access to a MODELS TEXTURE (skin) this way?

edit: fixed! (it works, maybe there are better ways...)


entity* ent_cube; // assign the model with "ent_cube=me;"
bmap* bmp_skin;

var gv_format = 0;
var gv_pixel = 0;
var gv_alpha = 0;
var gv_col[3];

// get bmap from models texture
bmp_skin = bmap_for_entity(ent_cube,0);

// lock bmap
gv_format = bmap_lock(bmp_skin, 0);

// get pixel (x/y = 10/10)
gv_pixel=pixel_for_bmap(bmp_skin, 10, 10);

// get pixel color & alpha
pixel_to_vec(gv_col,gv_alpha, gv_format, gv_pixel);

// set color
temp.red = 55;
temp.green = 55;
temp.blue = 55;

// create pixel
gv_pixel = pixel_for_vec(temp,100,gv_format);

// set pixel
pixel_to_bmap(bmp_skin,10,10,gv_pixel);

// unlock skin
bmap_unlock(bmp_skin);


thanx, mercuryus
Posted By: alphaindigo

Re: draw on models textur? - 04/19/07 11:44

could i use this to let userd draw on the blend map in the first skin of my terrain? i want this so that users can create custom maps. and can i draw on a seriese of pixels such as in a small circle:
...............
...#.........##...
.###....#####.
...#.........##... etc.
...............
Posted By: xXxGuitar511

Re: draw on models textur? - 04/19/07 14:10

yeah.. you could. I'm not sure how fast these methods are though. And I THINK that there is code on the wiki in the terrain shadow-map gen for saving tga's...
© 2024 lite-C Forums