As I prepare my game, I’ve been once again tackling a problem I’ve encountered from the beginning.
Use one mesh for the entire terrain. This has been done one a planar mesh, but it’s much difficult to me to make it work on a spherical mesh.
My theory is the following:
- Get the vertices position in the sphere and save them somewhere.
- Use the positions multiplied by the object orientation, the get the vertices global position and then apply a noise function to get an altitude.(The sphere will orient it’s denser part towards the camera).
3.Set the vertex position added by the vector pointing from the center of the object to that vertex multiplied by the altitude.
Result: Every time the sphere rotates, a new set of values is acquired.
I really don’t see where the problem is, I believed my maths were correct, but it shows I’m wrong!
import bge, mathutils from mathutils import* def map(ob): ob= ob.owner mesh= ob.meshes ob["map"]= for a in range(mesh.getVertexArrayLength(0)): b=() vert= mesh.getVertex(0,a) vp= vert.getXYZ() b= (vert, vp); ob["map"].append(b) ob["on"]= True def up(ob): ob=ob.owner for v in ob["map"]: vert=v; vp= v pos= vp*ob.orientation h= mathutils.noise.hybrid_multi_fractal(pos, 0.21, 1, 3, 0.5, 0.75, 3) p= vp+(ob.getVectTo(vp)*(h*10)) n= Vector((0.1,0.1,0.1))+(ob.getVectTo(vp))*(h*5) vert.setXYZ((p)) vert.setNormal((n))
Thank you for your time!