Resize mesh

Blitz3D Forums/Blitz3D Beginners Area/Resize mesh

Mike0101(Posted 2006) [#1]
How can resize an animated b3d model?
Must resize each childmesh but each childmesh stays on own original center position and roll away widely.
This is the problem.


b32(Posted 2006) [#2]
And ScaleEntity ? Or do you want to alter the actual data ?


D4NM4N(Posted 2006) [#3]
the trick i worked out was kind of like this, it may or may not help, but it allows you to scale using blitz units rather than percent/100, so you can fit your model into a 'box' say 100x200x50:
Note, this may not work so well if the animated mesh expands with animation (not tested) but works great for normal animated models.

;--------------------------------------------------------------------------------
;loads and scales an animmesh
;--------------------------------------------------------------------------------
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)
	
	;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 meshes
	ScaleEntity mesh,Xscale#,Yscale#,Zscale#

	;and bin tempmesh
	FreeEntity scaler

	;return it
	Return mesh
End Function


You can modify this to center the mesh by adding an extra parent pivot and moving it to an offset of the meshs parent pos.

What exactly do you need it for, if you have to change the scale of individual children's physical mesh, this gets a lot harder as you will have to adjust the internal transformation matrix(see online manual)


Mike0101(Posted 2006) [#4]
I have to use scalemesh. My map is separeted zones because of my occlusion system.
Each zone is child mesh. When I'm loading my map I have to use LoadAnimMesh and I have resize my map with scaleMesh command because of the shadow system.
Very hard and important thing in a game to integrate and to aling the diverse systems


D4NM4N(Posted 2006) [#5]
can you not scale it in your modeller b4 exporting?


Mike0101(Posted 2006) [#6]
This will be the solution but with this I have to change every parameters , lightmap light ranges ect.