Worldmap mountains

Blitz3D Forums/Blitz3D Beginners Area/Worldmap mountains

fox95871(Posted 2014) [#1]
Can someone please tell me how to make a CreateMesh sphere be editable from the center out? I know everything but that: how to make the mesh, how to edit the vertexes with a mouse by x, y, and z, even how to autosave changes to a txt, just not this last part.


Floyd(Posted 2014) [#2]
If you already know how to modify mesh vertices then the sphere is exactly the same, with one restriction. The vertex must move along a line connecting the current position with the center.

Assuming the sphere is centered at (0,0,0) and the vertex is at (x,y,z) then you should change the vertex via multiplication by a scale factor, moving it to (s*x,s*y,s*z). A factor of s=1.1 would increase the distance to the center by 10%, while s=0.8 would decrease it by 20%.

If you know how far you want to move a vertex (positive for up from ground level, negative for down), but don't know the scale factor in advance then you would compute it this way:

OldDistance# = Sqr( x*x + y*y + z*z )
s# = 1 + DistanceToMove / OldDistance


fox95871(Posted 2014) [#3]
Thanks, I had no idea where to start. It sounds like with this method, the CreateMesh sphere has to already exist for its vertex locations to be worked with in the code like that. Wouldn't it make things easier to keep everything in a positive octant?


Floyd(Posted 2014) [#4]
The ideas apply whether or not the sphere mesh actually exists. You can pretend any point (x,y,z) is on a sphere centered at (0,0,0) and do the same calculations to move it toward or away from the center.

Perhaps something you are doing will be simpler in the first octant, but it makes no difference for the way points will be moved.