Best way to scale and rotate Models ?

Blitz3D Forums/Blitz3D Beginners Area/Best way to scale and rotate Models ?

Well, Storm3, i wouldn't bother about the entity boxes for levels and pillars and such. Just use sphere>>poly collisions. Unless you need box collisions, i'd just use sphere >> poly ones. I'm sure a bit of fruit is more rounded than boxed.

You can use entitywidth, entityheight, entitydepth (i think) to get the dimentions (x,y,z) of an entity, and you could i suppose use these figure to work out the bounding box, regardless of the scale.

I always had problems with entitybox command, i guess i was too stupid to learn how to use it. :)

Sorry, my mistake, the commands are meshdepth, mesh height and mesh width. You must use scalemesh when scaling the entity, NOT scaleentity, or the results given by the height,depth, and width commands will be wrong.

As i say, i hate the entitybox command :S, but here is an example.

Use the left and right arrow keys to move the sphere.
Use the up and down arrow keys to increase the size of the box. I have include a small function that will increase the entitybox accordingly :)

Credit to AuzingLG for the resize mesh function. You MUST use scalemesh to scale the box, or the function won't work to resize the entitybox, that's what resizemesh is for :)

Graphics3D 800,600
SetBuffer BackBuffer()


Global camera=CreateCamera()
PositionEntity camera,0,0,-15

Global box=CreateCube()
PositionEntity box,-4,0,0
EntityType box,2
EntityBox box,0,-0.5,0,1,1,1


Global sphere=CreateSphere()
PositionEntity sphere,4,0,0
EntityType sphere,1
EntityColor sphere,10,40,200


Collisions 1,2,3,1

Global scale#=1


While Not KeyHit(1)



	If KeyDown(200) Then
		scale=scale+0.2
		resizeMesh(box,scale,scale,scale)
		update_bounding_box(box)
	End If
	If KeyDown(208) Then
		scale=scale-0.2
		resizeMesh(box,scale,scale,scale)
		update_bounding_box(box)
	End If


	If KeyDown(203) Then
		MoveEntity sphere,-0.1,0,0
	ElseIf KeyDown(205) Then
		MoveEntity sphere,0.1,0,0
	End If
	
	UpdateWorld
	RenderWorld
	Flip
Wend


Function update_bounding_box(entity)
	x=MeshWidth(entity)
	y=MeshHeight(entity)
	z=MeshDepth(entity)
	EntityBox box,0,-0.5,0,x/2,y/2,z/2
End Function
	
Function ResizeMesh(mesh,width#,height#,depth#)
   
   ScaleMesh mesh,1/MeshWidth#(mesh)*width#,1/MeshHeight#(mesh)*height#,(1/MeshDepth#(mesh))*depth#

End Function