Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/20/24 20:05
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (7th_zorro, AndrewAMD, TedMar), 1,306 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
math problem #231607
10/15/08 17:27
10/15/08 17:27
Joined: Mar 2005
Posts: 969
ch
Loopix Offline OP
User
Loopix  Offline OP
User

Joined: Mar 2005
Posts: 969
ch
Hello

How do I calculate the vec_dist from the origin of an entity to the bounding-box of the same entity. It needs to work for the x/y size of the entity...z is not important.

Thanks for any advise (preferably code...cause I'm bad in math)

Re: math problem [Re: Loopix] #231616
10/15/08 18:09
10/15/08 18:09
Joined: Feb 2008
Posts: 337
V
Vadim647 Offline
Senior Member
Vadim647  Offline
Senior Member
V

Joined: Feb 2008
Posts: 337
vec_dist(my.x,vector(my.x+my.max_x,my.y+my.max_y,my.z));
OR look at manual - "max_x"


I switched to other account since marth 2010. Guess which.
Re: math problem [Re: Vadim647] #231626
10/15/08 18:48
10/15/08 18:48
Joined: Mar 2005
Posts: 969
ch
Loopix Offline OP
User
Loopix  Offline OP
User

Joined: Mar 2005
Posts: 969
ch
thanks...but I probably diden't explain very well

I need something like:
Code:
if(vec_dist(my.x,player.x)<(vec_dist(my.x,vector(my.x+my.max_x,my.y+my.max_y,my.z))))
{
player is within the bounding box
}

...unfortunately this doesen't seem to work

Re: math problem [Re: Loopix] #231683
10/16/08 08:43
10/16/08 08:43
Joined: Jul 2007
Posts: 959
nl
F
flits Offline
User
flits  Offline
User
F

Joined: Jul 2007
Posts: 959
nl
did you updated the bounding box

so that it isnt aa box 16,16,16


"empty"
Re: math problem [Re: flits] #231686
10/16/08 09:27
10/16/08 09:27
Joined: Mar 2005
Posts: 969
ch
Loopix Offline OP
User
Loopix  Offline OP
User

Joined: Mar 2005
Posts: 969
ch
Yes the boundingbox is updated with c_setminmax...I can see that when double pressing F11.

My above code is definately crap...so don't look at that!
What I want is that the player calls a function when it enters the bounding box of a rectancular model (scale_x is bigger than scale_y). I could easyly achieve the same by making the model non-passable and calling and event trough event_impact...but I don't want that because the model needs to be passable all the time.

Re: math problem [Re: Loopix] #231691
10/16/08 10:45
10/16/08 10:45

M
mercuryus
Unregistered
mercuryus
Unregistered
M



Quote:
How do I calculate the vec_dist from the origin of an entity to the bounding-box of the same entity.


[de]Du suchst den Abstand von dem Zentrum eines Models zu deren eigenen boundingbox?

Orientiert oder mit freiem Winkel (da ja eine boundingbox ein Quader ist)?

Orientiert: min_x, max_x, min_y, max_y (nach c_setminmax oder c_updatehull)

Mit freien Winkel wirds etwas aufwändiger...


Oder suchst Du den Abstand von dem zentrum eines Modelles zu der boundingbox eines ANDEREN Entites?



Re: math problem [Re: ] #231704
10/16/08 13:03
10/16/08 13:03
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
mercuryus ~translated:
Quote:

You are looking for the distance from the center a model for their own BoundingBox?

Oriented or with free angle (because even a bounding box is a cuboid)?

Oriented: min_x, max_x, min_y, max_y (after c_setminmax or c_updatehull)

With free angle is somewhat complicated ...


Or are you looking for the distance from the center of a model to the BoundingBox ANOTHER entities?

critical point!? "With free angle is somewhat complicated ..."

Quoting Loopix.
Quote:
I could easyly achieve the same by making the model non-passable and calling and event trough event_impact...

If the system works as designed(?; no bugs in engine?), set bbox detector entity's push lower than player entity's push, ENABLE_PUSH, and set event function for the detector, c_move IGNORE_PUSH, then check EVENT_PUSH with optional skill id in that event function!?
(Entities with lower push values are pseudo-passable !?)


Re: math problem [Re: testDummy] #231718
10/16/08 15:19
10/16/08 15:19
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
Code:
var tang[3];
vec_diff(temp, player.x, my.x);
vec_set(tang, my.pan);
vec_inverse(tang);
vec_rotate(temp, tang);
//
// Now temp holds the offset of the object in local coordinates.
//
if (temp.x > my.min_x && temp.x < my.max_x) &&
   (temp.y > my.min_y && temp.y < my.max_y)
{
    // I'm inside the XY plane!
}


...Admit I'm the best, lol.

Last edited by xXxDisciple; 10/16/08 15:23.

xXxGuitar511
- Programmer
Re: math problem [Re: xXxGuitar511] #231750
10/16/08 17:54
10/16/08 17:54
Joined: Mar 2005
Posts: 969
ch
Loopix Offline OP
User
Loopix  Offline OP
User

Joined: Mar 2005
Posts: 969
ch
Guitar...YOU ARE THE BEST laugh I will compensate your awesome piece of code with a brand new tree-pack.

Nevertheless I'd also like to thank all the others for their helpfull attitude. For a moment I thought the forum is kind of dead...but now I can feel some of the good old c-script spirit coming back. Loooooong lives c-sript and all the good old forum members wink


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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