|
1 registered members (AndrewAMD),
599
guests, and 3
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
drawing onto models
#251069
02/11/09 13:57
02/11/09 13:57
|
Joined: Jul 2008
Posts: 1,178 England
MrGuest
OP
Serious User
|
OP
Serious User
Joined: Jul 2008
Posts: 1,178
England
|
Hey all, I'm trying to find a way of drawing realtime onto terrain, but, unfortunately have no success as of yet... I can draw pixels onto bmaps in panels, but these don't update on terrains... Is anyone able to point me in the right direction for this?  Many thanks in advance!
|
|
|
Re: [SORTED] drawing onto models
[Re: Carlos3DGS]
#253747
02/26/09 15:23
02/26/09 15:23
|
Joined: Jul 2008
Posts: 1,178 England
MrGuest
OP
Serious User
|
OP
Serious User
Joined: Jul 2008
Posts: 1,178
England
|
heya, 1stly find where the mouse is hitting, function mouse_3d(){
VECTOR from, to;
from.x = mouse_pos.x;
from.y = mouse_pos.y;
from.z = 1000;
to.x = mouse_pos.x;
to.y = mouse_pos.y;
to.z = -1000;
vec_for_screen(from, camera);
vec_for_screen(to, camera);
c_trace(from, to, IGNORE_PASSABLE | SCAN_TEXTURE);
return(you);
}make the terrain recognisable as being able to be drawn on #define __class skill1
#define _class_scribe 1
action terrain(){
my.__class = _class_scribe;
}
then make sure you've hit somethign and it's terrain you can write on
[code]function scribe_sand(){
VECTOR vec_hit;
while(1)
if(you){
if(your.__class == _class_scribe){
if(mouse_left){ //find the pixel that was hit and mark it
vec_set(vec_hit.x, target.x);
mark_sand(bmp_sand_scribe, vector(0, 255, 0), (_vec_hit.x + ent_terrain.max_x) * 1.524, (-_vec_hit.y + ent_terrain.max_y) * 1.524);
}
}
wait(1);
}
}then write on the terrain function mark_sand(BMAP* _bmp, VECTOR* _col, _pos_x, _pos_y){
var format; var pixel;
format = bmap_lock(_bmp, 0);
pixel = pixel_for_vec(_col, 100, format);
pixel_to_bmap(_bmp, _pos_x + 0, _pos_y - 2, pixel);
pixel_to_bmap(_bmp, _pos_x - 1, _pos_y - 1, pixel);
pixel_to_bmap(_bmp, _pos_x + 0, _pos_y - 1, pixel);
pixel_to_bmap(_bmp, _pos_x + 1, _pos_y - 1, pixel);
pixel_to_bmap(_bmp, _pos_x - 2, _pos_y + 0, pixel);
pixel_to_bmap(_bmp, _pos_x - 1, _pos_y + 0, pixel);
pixel_to_bmap(_bmp, _pos_x + 0, _pos_y + 0, pixel);
pixel_to_bmap(_bmp, _pos_x + 1, _pos_y + 0, pixel);
pixel_to_bmap(_bmp, _pos_x + 2, _pos_y + 0, pixel);
pixel_to_bmap(_bmp, _pos_x - 1, _pos_y + 1, pixel);
pixel_to_bmap(_bmp, _pos_x + 0, _pos_y + 1, pixel);
pixel_to_bmap(_bmp, _pos_x + 1, _pos_y + 1, pixel);
pixel_to_bmap(_bmp, _pos_x + 0, _pos_y + 2, pixel);
bmap_unlock(_bmp);
ent_setskin(ent_terrain, _bmp, 3);
}these will need to be rearrange in the proper order, i've just ripped them out of my code, so there may be a couple of mistakes in there one problem which i haven't had the time to fix yet is moving at a high pace and only placing dots rather than a line hope this helps
|
|
|
|