entitybox question

Blitz3D Forums/Blitz3D Programming/entitybox question

ryan scott(Posted 2004) [#1]
i'm trying to put a box around an entity and want to compute the collision box

EntityBox wallentity,0,0,0,MeshWidth(wallmesh),MeshHeight(wallmesh),MeshDepth(wallmesh)

seems to make a mesh of maybe the right size, but offset a bit.

where is the handle on a 3d object? dead center? center middle bottom? does it vary, is that set in the modelling software?

how can i compute a bounding box (or ellipse) for any arbitrary mesh, for collisions?


Zethrax(Posted 2004) [#2]
The centerpoint of a mesh is set by the modelling program. You can use 'PositionMesh' to change it once you get the model into Blitz, but I'm not sure how you go about calculating the positioning values to use.


Bot Builder(Posted 2004) [#3]
err... try this:

Function AutoBox(entity)
	ux#=-100000
	uy#=-100000
	uz#=-100000
	lx#=100000
	ly#=100000
	lz#=100000
	cs=CountSurfaces(entity)
	For s=1 To cs
		surf=GetSurface(entity,s)
		cv=CountVertices(surf)-1
		For v=0 To cv
			vx#=VertexX#(surf,v)
			vy#=VertexY#(surf,v)
			vz#=VertexZ#(surf,v)
			If vx#<lx# Then lx#=vx#
			If vx#>ux# Then ux#=vx#
			If vy#<ly# Then ly#=vy#
			If vy#>uy# Then uy#=vy#
			If vz#<lz# Then lz#=vz#
			If vz#>uz# Then uz#=vz#
		Next
	Next
	EntityBox entity,lx,ly,lz,ux-lx,uy-ly,uz-lz
	;Could be: EntityBox entity,ux,uy,uz,ux-lx,uy-ly,uz-lz
	;Or: EntityBox entity,0,0,0,ux-lx,uy-ly,uz-lz
End Function


Not really sure though (untested)


big10p(Posted 2004) [#4]
As far as I remember, the parameters of EntityBox (x,y,z,width,height,depth) are used to define 2 opposite corners of the box, so:

EntityBox entity,-1,-1,-1,2,2,2

defines a box of dimensions 2x2x2, centred around the entity's origin. The -1,-1,-1 part specifies the corner of the box to start from and the 2,2,2 part specifies the distances to the opposite corner of the box.

Does that make sense? Probably not but at least I tried. :P


ryan scott(Posted 2004) [#5]
thanks bot builder!

it seems to work, actually.

it seems like the modelling program should let you specify the collision boxes. i haven't messed with modelling software yet so i am talking out of school...

thanks again