Positioning Meshes

Blitz3D Forums/Blitz3D Programming/Positioning Meshes

xmlspy(Posted 2004) [#1]
I have a mesh, I do CameraPick(Camera,MouseX(),MouseY()) command, and then I do PositionEntity Object,PickedX(),PickedY(),PickedZ()

How would I be able to position the picked mesh correctly into a terrain, depending on the lowest surface of the selected mesh? The current system I'm using always positions the object so half of it is visible in the terrain, and the other half is below the visible. I made it so it depends on the mesh height; however that doesn't work, because I want to scale the mesh later on using scaleentity.


ZombieWoof(Posted 2004) [#2]
you need to get the mesh extents and translate the mesh so 0,0,0 is centered at the "bottom" of the mesh, like a character model where 0,0,0 is between the feet.

Then scaling wont be a problem as the "bottom" never moves


xmlspy(Posted 2004) [#3]
ok, that works. What if you have a lot of 3d models that aren't centered like that, I don't want to go individually with each one of them fixing this :(


ZombieWoof(Posted 2004) [#4]
Halo just posted functions for getting the extents of a mesh, its a one time calculation/transformation on load if you dont want to fix it in the model files.

your other choice is to scale the y position when you scale the model:

new_ypos = terrain_y + ((old_ypos - terrain_y) * scale_factor)