scaling animated meshes

Blitz3D Forums/Blitz3D Programming/scaling animated meshes

D4NM4N(Posted 2005) [#1]
is there a way to scale an animated mesh properly. Scaleentity is no good for this unless you know the meshes original size. Scalemesh doesnt seem to work for this either.


jfk EO-11110(Posted 2005) [#2]
I guess it depends if it's a 3ds/x or b3d animation. you may be able to scale all children of a 3ds recursively. I don't know exactly if the movement animation will be scaled too, but the rotation will work the same, no matter how much you scale it. With b3d it may be harder. I think I remember somebody said you cannot scale the animation, so it will look wrong when you scale the mesh, and not the bones.

However, you should try to scale all children recursively, if they are Meshes at all. Something like this:

Function EntityAnimScale(m,x#,y#,z#)
 If EntityClass$(m)="Mesh"
  ScaleEntity m,x,y,z,0
 Endif
 For i=1 to CountChildren(m)
  ww=GetChild(m,i)
  EntityAnimScale(ww,x,y,z)
 Next
End Function

Or you may try ScaleMesh in this Function.


Wings(Posted 2005) [#3]
then i wrote mollle the dog 3d i scaled the player. it worked.


D4NM4N(Posted 2005) [#4]
Thx JFK ill have a play around with that, They are mostly 3DS. I wanted to create a standardized loader/scaler for any 3D mesh

ie
mesh=loadscaledanimmesh(filename,sx,sy,sz)


Matty(Posted 2005) [#5]
I don't understand how scaleentity doesn't work for some people with animated b3d meshes. It has always worked fine for me:

I create a model in milkshape, export it as b3d with animation.

I then load it normally ie

someanimatedmesh=loadanimmesh("your b3d animated mesh here.b3d")

;if I want it to be twice the original size then 
scaleentity someanimatedmesh,2.0,2.0,2.0



What is it exactly that doesn't work with scaling entities - as I said I've never had a problem using it.


Nicstt(Posted 2005) [#6]
works for me too.

only thing i have to watch for is, make sure your animation is at first fram when exporting it. That causes problems irrispective of scaling, puzzled the hell out of me 'till i realised.


D4NM4N(Posted 2005) [#7]
Thanks again JFK, i had no idea there was an entityclass$!!
learn somit every day :)

hi matty, I know scaleentity works, its fine for a ratio scale, but take a anim model with an unknown size and try to scale it to say.. 30 blitz units high and 20 wide.

I could only come up with one way and ive posted it here. http://www.blitzbasic.com/codearcs/codearcs.php?code=1430

The reason is i dont have a decent 3ds editor, and have several animated meshes ive bought that i want to use. I hardly use 3ds for anything normally, because i dont like it.

If im wrong and there is a simpler more reliable way than this, Please please let me know.


jfk EO-11110(Posted 2005) [#8]
well I don't remember exactly what it was, I just thought somebody said something about problems, problably only with ScaleMesh.
To scale a mesh to a certain world size you need to use Fitmesh. So ScaleEntity can only be used, when you already know the world size of the unscaled mesh. Meshwidth doesn't seem to work as one would expect. The only solution to determine the true w-h-d size of a mesh that I came up with some time ago was to use a huge and very flat box and the MeshesIntersect Command. Moving this box from 30'000 towards the center of the mesh in a binary way, until the physical borders of all 6 sides of the mesh are found. takes up to 32 steps to determine the border in a 32 bit resolution. (check out binary search argorithm).