Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
3 registered members (AndrewAMD, Grant, Neb), 908 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
make BOUNDING-BOX visible #64887
02/24/06 07:48
02/24/06 07:48
Joined: Dec 2005
Posts: 490
Germany/Berlin-Velten
kasimir Offline OP
Senior Member
kasimir  Offline OP
Senior Member

Joined: Dec 2005
Posts: 490
Germany/Berlin-Velten
Hi, i saw a treat asking about it - so i think it is very usable:
Code:
 
string bounding_box_mdl = <bounding_box.mdl>;

var bounding_box_visible = 0;

function bounding_box
{
my.overlay = on;
my.ambient = 100;
my.transparent = on;
my.passable = on;

my.scale_x = your.max_x / my.max_x;
my.scale_y = your.max_y / my.max_y;
my.scale_z = your.min_z / my.min_z;

while(1)
{
my.invisible = 1 - bounding_box_visible;
vec_set(my.x,your.x);
wait(1);
}
}

function toogle_bounding_box
{
if(bounding_box_visible)
{
bounding_box_visible = 0;
}else{
bounding_box_visible = 1;
}
}

on_F11 = toogle_bounding_box;


include this line for every entity you want to make the BB visible:
ent_create(bounding_box_mdl,my.x,bounding_box);
bounding_box.mdl is a simply cube! (I used 32x32x32)

Re: make BOUNDING-BOX visible [Re: kasimir] #64888
02/24/06 08:37
02/24/06 08:37
Joined: Apr 2005
Posts: 3,815
Finland
Inestical Offline
Rabbit Developer
Inestical  Offline
Rabbit Developer

Joined: Apr 2005
Posts: 3,815
Finland
nice ^_^ will be pretty useful! thank you!


"Yesterday was once today's tomorrow."
Re: make BOUNDING-BOX visible [Re: Inestical] #64889
02/24/06 09:11
02/24/06 09:11
Joined: Dec 2005
Posts: 490
Germany/Berlin-Velten
kasimir Offline OP
Senior Member
kasimir  Offline OP
Senior Member

Joined: Dec 2005
Posts: 490
Germany/Berlin-Velten
Yes i like this code because i can see the size of the bounding box. That helps to center the origin right and get to know when two entities exactly collids.

Re: make BOUNDING-BOX visible [Re: kasimir] #64890
02/24/06 10:41
02/24/06 10:41
Joined: Sep 2002
Posts: 8,177
Netherlands
PHeMoX Offline
Senior Expert
PHeMoX  Offline
Senior Expert

Joined: Sep 2002
Posts: 8,177
Netherlands
There's another bounding box code floating around, eeuhm this one :

Code:

//-----------------------------------------------------------------------------line
function boldline3d(&_start, &_end, &_color, _alpha)
{
var _s[3];
var _e[3];
vec_set(_s, _start);
vec_set(_e, _end);
vec_to_screen(_s, camera);
vec_to_screen(_e, camera);

// todo: clipping algorithm?

if (_s.z > camera.clip_near && _e.z > camera.clip_near) // if there is no distortion
{
// bold line 3x3
draw_line(_s, null, _alpha);
draw_line(_s, _color, _alpha);
draw_line(_e, _color, _alpha);
draw_line(vector(_s.x+1, _s.y+1, 0), null, _alpha);
draw_line(vector(_e.x+1, _e.y+1, 0), _color, _alpha);
draw_line(vector(_s.x-1, _s.y-1, 0), null, _alpha);
draw_line(vector(_e.x-1, _e.y-1, 0), _color, _alpha);
draw_line(vector(_s.x+1, _s.y-1, 0), null, _alpha);
draw_line(vector(_e.x+1, _e.y-1, 0), _color, _alpha);
draw_line(vector(_s.x-1, _s.y+1, 0), null, _alpha);
draw_line(vector(_e.x-1, _e.y+1, 0), _color, _alpha);
draw_line(vector(_s.x, _s.y+1, 0), null, _alpha);
draw_line(vector(_e.x, _e.y+1, 0), _color, _alpha);
draw_line(vector(_s.x, _s.y-1, 0), null, _alpha);
draw_line(vector(_e.x, _e.y-1, 0), _color, _alpha);
draw_line(vector(_s.x+1, _s.y, 0), null, _alpha);
draw_line(vector(_e.x+1, _e.y, 0), _color, _alpha);
draw_line(vector(_s.x-1, _s.y, 0), null, _alpha);
draw_line(vector(_e.x-1, _e.y, 0), _color, _alpha);
}
}

function line3d(&_start, &_end, &_color, _alpha)
{
var _s[3];
var _e[3];
vec_set(_s, _start);
vec_set(_e, _end);
vec_to_screen(_s, camera);
vec_to_screen(_e, camera);

// todo: clipping algorithm?

if (_s.z > camera.clip_near && _e.z > camera.clip_near) // if there is no distortion
{
draw_line(_s, null, _alpha);
draw_line(_s, _color, _alpha);
draw_line(_e, _color, _alpha);
}
}

//-----------------------------------------------------------------------------box
var p1[3];
var p2[3];
var p3[3];
var p4[3];
var p5[3];
var p6[3];
var p7[3];
var p8[3];
function drawbox(_entity, &_color, _alpha)
{
you = _entity;
vec_set(p1, vector(you.min_x, you.min_y, you.min_z));
vec_set(p2, vector(you.min_x, you.max_y, you.min_z));
vec_set(p3, vector(you.max_x, you.max_y, you.min_z));
vec_set(p4, vector(you.max_x, you.min_y, you.min_z));
vec_set(p5, vector(you.min_x, you.min_y, you.max_z));
vec_set(p6, vector(you.min_x, you.max_y, you.max_z));
vec_set(p7, vector(you.max_x, you.max_y, you.max_z));
vec_set(p8, vector(you.max_x, you.min_y, you.max_z));
vec_rotate(p1, you.pan); vec_add(p1, you.x);
vec_rotate(p2, you.pan); vec_add(p2, you.x);
vec_rotate(p3, you.pan); vec_add(p3, you.x);
vec_rotate(p4, you.pan); vec_add(p4, you.x);
vec_rotate(p5, you.pan); vec_add(p5, you.x);
vec_rotate(p6, you.pan); vec_add(p6, you.x);
vec_rotate(p7, you.pan); vec_add(p7, you.x);
vec_rotate(p8, you.pan); vec_add(p8, you.x);
line3d(p1, p2, _color, _alpha);
line3d(p2, p3, _color, _alpha);
line3d(p3, p4, _color, _alpha);
line3d(p4, p1, _color, _alpha);
line3d(p1, p5, _color, _alpha);
line3d(p2, p6, _color, _alpha);
line3d(p3, p7, _color, _alpha);
line3d(p4, p8, _color, _alpha);
line3d(p5, p6, _color, _alpha);
line3d(p6, p7, _color, _alpha);
line3d(p7, p8, _color, _alpha);
line3d(p8, p5, _color, _alpha);
}



I'm not sure who made it, but it's already quite some years old,

Cheers


PHeMoX, Innervision Software (c) 1995-2008

For more info visit: Innervision Software
Re: make BOUNDING-BOX visible [Re: PHeMoX] #64891
02/24/06 12:49
02/24/06 12:49
Joined: Dec 2005
Posts: 490
Germany/Berlin-Velten
kasimir Offline OP
Senior Member
kasimir  Offline OP
Senior Member

Joined: Dec 2005
Posts: 490
Germany/Berlin-Velten
A bit to long i think - my code is quite easy

Re: make BOUNDING-BOX visible [Re: kasimir] #64892
02/25/06 11:16
02/25/06 11:16
Joined: Apr 2004
Posts: 320
TheGameMaker Offline
Senior Member
TheGameMaker  Offline
Senior Member

Joined: Apr 2004
Posts: 320
right, but i think u need a modell??
No, yours is definitv a lot better
greetz tgm

Re: make BOUNDING-BOX visible [Re: TheGameMaker] #64893
03/14/06 22:15
03/14/06 22:15
Joined: Jun 2005
Posts: 656
G
Grafton Offline
User
Grafton  Offline
User
G

Joined: Jun 2005
Posts: 656
Kasmir, It is very nice of you to contribute this. However it needs more work.

If the bounding box of the entity is not exactly symetrical and the models
and entitys origins are not dead center, the true size cannot be shown with
this code, also I had some problems with the models scale_z "flickering"?

The problem is that a model will always scale symetricaly about its origin,
but a bounding box does not have to be symetrical about its origin.

It would be better to set the verts of the box model to the bounding boxes
min_x, max_x, ect. But to do this, the box models verts indexes would have
to match the code. So not just any box model would work.

For now, the line drawing code seems to be the most accurate representation.


Not two, not one.

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1