How to set the EntityRadius?

Blitz3D Forums/Blitz3D Beginners Area/How to set the EntityRadius?

Happy Sammy(Posted 2005) [#1]
Hi all,

Whenever we use collisions, we must set EntityRadius of colliding Objects.
"Collisions" command is always is sphere to something.
If the colliding object is a cube or a plane, how should we set the EntityRadius?

Thanks in advance.
Sammy
:)


Beaker(Posted 2005) [#2]
The radius refers to an imaginary sphere not an entity sphere. It doesn't matter what shape the colliding object is, you still use the EntityRadius() command.


Happy Sammy(Posted 2005) [#3]
Hi all,
1. If I create a cube with 1 unit.
cube = CreateCube()
EntityRadius cube, r

what is the appropriate values of r for checking collisions?

2. If I create a complex .3ds model with 3d modelling tool (eg. milkshape3D), how to determine this value of r? By Trial and error?

Could you give some values for reference?

Thanks in advance.
Sammy
:)


WolRon(Posted 2005) [#4]
By Trial and error?
Yes.

Do remember that EntityRadius also has a seperate Y value, so you don't have to just work with spheres. You can also use ellipsoids.


jfk EO-11110(Posted 2005) [#5]
You may use TFormpoint to find the XYZ Min and Max of all vertices. Then calculate the required radius using pytagoras formula in 3D.


big10p(Posted 2005) [#6]
Why can't you use MeshWidth/Height/Depth? ...assuming the entity hasn't been scaled.


jfk EO-11110(Posted 2005) [#7]
MeshWdth and MeshHeight and Meshdepth can be used if the
logical center is about the same as the physical center of the mesh. If it's not, you may set it this way:

fitmesh mesh, -meshwidth(mesh)/2.0,-meshheight(mesh)/2.0,-meshdepth(mesh)/2.0,meshwidth(mesh),meshheight(mesh),meshdepth(mesh)

and then the pytagoras in 3D, as suggested before:

r#=sqr( ((meshwidth(mesh)/2.0)^2) + ((meshheight(mesh)/2.0)^2) + ((meshdepth(mesh)/2.0)^2)  )
entityradius mesh, r#


Tho, not sure if this really works, but in theory it should, I guess :)

If you want to use ellipsoid collision detection, then you could use this after setting the center of the mesh:

entityradius mesh, max#(entitywidth(mesh)/2.0,entitydepth(mesh)/2.0),entityheight(mesh)/2.0
...
function max#(a#,b#)
if a#>b# then return a#
return b#
end function