Finding relationship ???

Blitz3D Forums/Blitz3D Programming/Finding relationship ???

Jack(Posted 2010) [#1]
Using a simple example.....

I have a variable height mesh used as "the ground"

There is an object, say a b3d created sphere, above this ground.

The sphere has been scaled by (example 20) and placed some
distance above the ground level.

Taking a point some distance from the sphere as a starting point I need to get the difference in "Y" from my starting point to the TOP of the scaled sphere. And the bottom of the sphere too for that matter.

Using many linepicks etc I THINK this can be solved but far too many statements are necessary this way it seems.

Can someone give me a faster and eaiser way to get this done.

In case it helps what, I am looking for is how much in the "Y" direction I must go up to get over the top of the sphere. And under the bottom.


jfk EO-11110(Posted 2010) [#2]
You can parse the vertices and determine the minimum x,y and z, as well as the maximum y,x and z. You'd use VertexX, Tformpoint etc. for that.

As long as your sphere or whatever is not turned or scaled during runtime, you can use precalucated data for these min/max values. But it's still rather fast to get them with a function call in the game loop.

Once you have the min and max Y, you also got the top and bottom of the sphere.


Jack(Posted 2010) [#3]
Thanks jfk. Big help.

Not sure if I will make my own meshes or use B3D spheres,boxes.etc.

If I use B3D items then they must be scaled. May want to do that even with custom made meshes.

What came to me in the middle of the night was that I could get the high point by comparing the entityY of the object to the entityY of the start point.Then adding the Y scale factor. The low would simply the same but not factoring in the scale.

I will need to do more testing but it looks OK.

What would make it a little easier would be if there were a command to get the scale factor I use rather than the need to create a variable
to match the scale.Any chance there is one and I missed it.


Charrua(Posted 2010) [#4]
hi, the following functinons aren't mine, didn't remember when and where i found them but return the x, y and z scale of an entity.



juan


Jack(Posted 2010) [#5]
Thanks Charrua.
Looks like just the ticket.
I'll give it a try later today.


K(Posted 2010) [#6]
You could call MeshHeight()to get scale factor, but it only works with meshes of course.And only if you used ScaleMesh instead of ScaleEntity.

Last edited 2010


Serpent(Posted 2010) [#7]
A combination of MeshHeight() and Charrua's functions should work. Very nice btw - useful to have 'get' entity scale functions.


Serpent(Posted 2010) [#8]
BTW this seems to work as well for getting Entity scales:



Last edited 2010


Charrua(Posted 2010) [#9]
that's the aproach of Blitz3D+
basically indexing in the Entity's struct in memory:
FreeBasic code included:

Function GetEntityScaleX ( ByVal entity As Any Ptr ) As Single Export
Function = Peek(Single, entity + 76)
End Function

Function GetEntityScaleY ( ByVal entity As Any Ptr ) As Single Export
Function = Peek(Single, entity + 80)
End Function

Function GetEntityScaleZ ( ByVal entity As Any Ptr ) As Single Export
Function = Peek(Single, entity + 84)
End Function

(in serpent's code offsets are in Hexa, in the above are in decimal but they are the same)
http://blitzbasic.com/Community/posts.php?topic=75711

look at the end of the thread for a working link

Juan