Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / get object height

Author
Message
adamika2000
16
Years of Service
User Offline
Joined: 30th Jun 2010
Location: Hungary
Posted: 15th Aug 2010 20:22
Please write me down, how I get object height. I can get the matrix height using get ground height, but I don't know how I get object height...
Mugen Wizardry
User Banned
Posted: 15th Aug 2010 23:59
object size y(object)

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 16th Aug 2010 00:07 Edited at: 16th Aug 2010 00:09
Well first you need to position a small sphere above your object. Lets say we record that Y position as pos1 as an example. Then move that sphere down until it collides with your object. Now record that Y position as pos2. Then you need to find the distance between these points and record it as Dist so you do pos1-pos2. Then just use the distance from the top point of your object, subtract dist from the y position of pos1 and add that to the object position to get the height of your object. So it would be


Heres a function I wrote up to save you some work.
Just call up getobjectheight(obj,x#,z#) and it will return the height at the x and z positions.



Heres a demo.


My computer can render anything no matter the complexity of it in real time.
The memory is enormous. My computer is unique to everyone else’s. What computer do I have?

Bursar
17
Years of Service
User Offline
Joined: 17th Sep 2008
Location:
Posted: 16th Aug 2010 00:28
Rather than that, you could do:


Change 200 number to a height that you know will definately be above ground, and the -10 number to one that you know will definately be below ground.

GH# will then contain the height of the terrain obj.
LBFN
19
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 16th Aug 2010 01:17
OBJECT SIZE Y(ObjectNumber)

So many games to code.......so little time.
BillR
23
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 16th Aug 2010 01:33
@LBFN - close but...
Where the dimensions are not the same value, an average of the X, Y and Z size is used to report the overall object size.
The average might not be good enough for his use

@Madscientist - I like your code but.....maybe its a typo to have a non-zero number in the function call

text 0,0,"object height: "+str$(getobjectheight(1,0.1,0.0))
it seems to miss the center point of the cone, I changed it to
text 0,0,"object height: "+str$(getobjectheight(1,0.0,0.0))
which hits the very top of the cone, here is your modified code I use...

Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 16th Aug 2010 03:06
It was offset to the side on purpose.

My computer can render anything no matter the complexity of it in real time.
The memory is enormous. My computer is unique to everyone else’s. What computer do I have?

LBFN
19
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 16th Aug 2010 04:18
Hi BillR,

Quote: "Where the dimensions are not the same value, an average of the X, Y and Z size is used to report the overall object size.
The average might not be good enough for his use"


I would agree with you if I said to use OBJECT SIZE(ObjectNumber), but I did not.

So many games to code.......so little time.
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 16th Aug 2010 04:28 Edited at: 16th Aug 2010 04:29
Actually notice how adamika2000 said LIKE get ground height which means he wants the height of the poly at a given point.
Not the size.

My computer can render anything no matter the complexity of it in real time.
The memory is enormous. My computer is unique to everyone else’s. What computer do I have?

adamika2000
16
Years of Service
User Offline
Joined: 30th Jun 2010
Location: Hungary
Posted: 16th Aug 2010 08:24
Thank you Madscientist!
Bursar
17
Years of Service
User Offline
Joined: 17th Sep 2008
Location:
Posted: 16th Aug 2010 13:58
Quote: "I would agree with you if I said to use OBJECT SIZE(ObjectNumber), but I did not."

True, but OBJECT SIZE Y according to the help file will "...return the full height of the object"

Now if you have an object shaped like an L, I'm guessing that means you will be told the height according to the vertical stroke.

If you were flying a plane over that letter L, you would be able to fly lower over the horizontal stroke, but the result of your suggested solution will result in a crash.

Using my INTERSECT OBJECT command, you would be able to tell that the ground was lower over the horizontal stroke, and would fly safer over it, whilst still being below the height of the vertical stroke.
LBFN
19
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 16th Aug 2010 19:19
The OP was asking how to obtain the height. Anyway, it seems like a moot point now. Apparently the Madscientist gave the OP what he wanted.

So many games to code.......so little time.
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 16th Aug 2010 19:25
He wanted to get the height of an object at a certain point for a terrain object so he could position an object at the height of the terrain.

My computer can render anything no matter the complexity of it in real time.
The memory is enormous. My computer is unique to everyone else’s. What computer do I have?

Login to post a reply

Server time is: 2026-07-25 07:01:35
Your offset time is: 2026-07-25 07:01:35