EntityBox weirdness

Blitz3D Forums/Blitz3D Programming/EntityBox weirdness

There seems to be a discrepancy between the origin of a mesh and the zero-points of the same mesh as applied to the function EntityBox. For instance:

	width#  = MeshWidth(Entity)
	height# = MeshHeight(Entity)
	depth#  = MeshDepth(Entity)

	x# = EntityX(Entity)
	y# = EntityY(Entity)
	z# = EntityZ(Entity)

;Draw a ghost box around the mesh
	cube = CreateCube() ; Cube starts as 2x2x2
	ScaleEntity cube,width/2,height/2,depth/2
	PositionEntity cube,x,y+height/2,z
	RotateEntity cube,EntityPitch(Entity),EntityYaw(Entity),EntityRoll(Entity)
	EntityAlpha cube,0.3
	EntityParent cube,Entity

;The ghost box perfectly encloses the mesh

;Set corresponding bounding box
;Same parameters as ghost box
	EntityBox Entity,0,height/2,0,width,height,depth	; wrong!
;But it doesn't work

;Translate the y and z coordinates by 1/2 their value
	EntityBox Entity,0,0,depth/2,width,height,depth		; right!
;Now it works!


The above code applies to a mesh with the origin at the bottom center.

But... no matter where the origin is of a mesh is placed, the same parameters that create a _visible_ bounding box should create a _pickable_ bounding box - but they don't!

Can anyone explain this?

Thanks... and be careful when using EntityBox!

im not sure but dont your entitybox coords have to start from the corner? it seems by specifiing 0,0,depth you are starting from the center of the mesh??
shouldnt it be:
when you create the mesh at 0,0,0

entitybox entity,-width/2,-height/2,-depth/2,width,height,depth

if you have to create it when you do you will have to add the correct offset using entityx/y/z()
Hope it helps,

Its probably irrelevent but i find fitmesh useful, it sets the meshes origin to 0,0,0 and you can offset the mesh in relation to this. Then after doing this i use entitybox with the same parameters

One thing's for sure. The reference document fails to state whether the zero-point of an entity box matches the center of the box, the corner of the box, or the 330 foot sign in left field <gn>. Does anyone know for sure?

Offsetting by EntityX/Y/Z is not necessary unless you specify the "global" flag in your call to EntityBox.

I believe it is the corner of the box, and then the wdith depth and height params go from that.

So you need to use...
entitybox entity,-width/2,-height/2,-depth/2,width,height,depth 

...as D_Grafix said.

I would love an official explanation on how to use the command :) cos seemingly it doesnt obey my commands at all.