Code archives/3D Graphics - Mesh/scale animated mesh to set blitz unit size

This code has been declared by its author to be Public Domain code.

Download source code

scale animated mesh to set blitz unit size by D4NM4N
(Posted 21 years ago)
This loads a 3ds file to a set blitz unit size it *should* take any animated mesh, although ive only tested it on 3ds.

(I think it works anyway :)
Function loadscaledanimmesh(filename$, sx#,sy#,sz#) ;Size in blitz units not percent!!
	
	;By Dan @ D-Grafix
	;useage :  mesh=loadscaledanimmesh(file$,width,height,depth)
	
	;create scaler and mesure static mesh
	scaler=LoadMesh(filename)
	mesh_SX#		=MeshWidth(scaler)
	mesh_SY#	=MeshHeight(scaler)
	mesh_SZ#		=MeshDepth(scaler)

	;and bin it	
	FreeEntity scaler
	
	;load 'real' mesh
	mesh=LoadAnimMesh(filename)
	
	;do some maths
	Xscale# 	= ((100/mesh_SX)   * sx) / 100.0
	Yscale# 	= ((100/mesh_SY)  * sy) / 100.0
	Zscale# 	= ((100/mesh_SZ)  * sz) / 100.0

	;scale it
	ScaleEntity mesh,Xscale#,Yscale#,Zscale#

	;return it
	Return mesh
	
End Function

Comments

Cygnus
(Posted 21 years ago)
Hi.

Neat work, but this isnt scaling the Mesh as such, it's scaling the Entity. Confused me. :)

Still very useful though :D

Code Archives Forum