Degenerate(Generate) _make_a_world (now populate)

100% generated - all vertex color - no textures.

Is there any reason why you often save artwork as screenshots (complete with a view of Blender’s UI and your Win10 tray) instead of rendering it out (even as an OpenGL render which you can find in the bar at the bottom of the view)?

At the least, it would help to use the GIMP’s crop tool to cut out the UI bits.

this was generated in blender game engine :smiley:

http://pasteall.org/572668/python


import bge
import mathutils
from mathutils import Vector
import math


def main():
    worldDict = {}
    cont = bge.logic.getCurrentController()
    own = cont.owner
    always = cont.sensors['Always']
    tiles = []
    master = {}
    size = 32
    if always.positive:
        for x in range(size):
            for y in range(size):
                #generate grid
                added = own.scene.addObject('Plane',own,0)
                tiles.append(added)
                added.worldPosition = [-(size/2)+(x),-(size/2)+(y),0]
                name = str([-(size/2)+(x),-(size/2)+(y),0])
                added.name = name
                new = bge.logic.LibNew(name, 'Mesh', [added.meshes[0].name])
                added.replaceMesh(new[0],1,1)
                
                #apply noise and add vertex list using pos as key
                #if key exists, append vertex to list
                 
                for index in range(added.meshes[0].getVertexArrayLength(0)):
                    vertex = added.meshes[0].getVertex(0,index)
                    
                    master.update({str(len(master)):[vertex,added]})
                    
                    #convert local space to world space
                    pos = added.worldTransform*vertex.XYZ.copy()
                    
                    
                    if str(pos) not in worldDict:
                        worldDict.update({str(pos):[ [vertex,added] ]})
                        
                    else:
                        worldDict[str(pos)].append([vertex,added])
                        
                        
                    #Sine wave 1
                    pos.z += ( math.sin(pos.x/4)+math.sin(pos.y/4) )*.75
                    
                    #Sine wave 2
                    pos.z += ( math.sin(pos.x/2)+math.sin(pos.y/2) )*-.75
                    
                    #Sine wave 3
                    pos.z += ( math.sin(pos.x)+math.sin(pos.y) )*-.75
                    
                    
                    #perlin noise
                    pos.z += mathutils.noise.fractal(pos ,.125, 0.125, 8, mathutils.noise.types.STDPERLIN)*.5
                    
                    #convert worldSpace to local
                    pos = pos - added.worldPosition 
                    pos = added.worldOrientation.inverted()*pos
                    
                    vertex.XYZ = pos
                
                added.reinstancePhysicsMesh(added,added.meshes[0],1)
                
        kd = mathutils.kdtree.KDTree(len(master))
        
        for key in master:
            point = master[key]
            point1 = point[0].XYZ.copy()
            point1.z=0
            kd.insert(point[1].worldTransform*point1, int(key))
        kd.balance()    
        own['kd']=kd
        own['Master']=master
        own['tiles']=tiles      
        for key in worldDict:
            data = worldDict[key]
            
            
            vertex = data[0][0]
            pos = data[0][1].worldTransform*vertex.XYZ
            pos = pos.copy()
            po1 = pos.copy()
            
            px = pos.x /12
            py = pos.y /12
            pos = [py,px,0]
            n = mathutils.noise.fractal(pos ,.125, 0.125, 8, mathutils.noise.types.STDPERLIN)
            
            nn = 1.0 if abs(n) <= 0.2 else 0.125
            if nn==1.0:
                
                for vert in data:
                    vert[0].color = [ nn, nn, nn,1 ]
                    
            else:
                c = [ nn*.5+(bge.logic.getRandomFloat()*.05), .25 + nn*.5+(bge.logic.getRandomFloat()*.25), nn*.5+(bge.logic.getRandomFloat()*.05 ),1 ]
                for vert in data:
                    vert[0].color = c
                
            v = vertex.XYZ.copy()
            if nn==1.0 and v.z>-1.25:
                v.z =  ( math.sin(po1.x/4)+math.sin(po1.y/4) )*.25
                v.z += ( math.sin(po1.x/2)+math.sin(po1.y/2) )*-.25
                v.z += ( math.sin(po1.x)+math.sin(po1.y) )*-.25
                v.z = (v.z*.5 + -1)/2
                for vert in data:
                    c2 = vert[0].XYZ.copy()
                    c2.z =v.z
                    vert[0].XYZ = c2
                r = 1.5
                po1.z=0
                near = kd.find_range(po1, r)
                f = bge.logic.getRandomFloat()
                for point in near:
                    p = master[str(point[1])]
                    p1o =p[1].worldTransform*p[0].XYZ 
                    p_x = p1o.x /12
                    p_y = p1o.y /12
                    pos_ = [p_y,p_x,0]
                    n2 = mathutils.noise.fractal(pos_ ,.125, 0.125, 8, mathutils.noise.types.STDPERLIN)
            
                    nn_ = 1.0 if abs(n2) <= 0.2 else 0.125
                    if nn_!=1.0:
                        vert[0].color = c
                        p1x = p[1].worldTransform*p[0].XYZ
                        z =  ( math.sin(p1x.x/4)+math.sin(p1x.y/4) )*.25
                        z += ( math.sin(p1x.x/2)+math.sin(p1x.y/2) )*-.25
                        z += ( math.sin(p1x.x)+math.sin(p1x.y) )*-.25
                        
                        p2 = p[0].XYZ.copy()
                        if point[2]<.25:
                            z = ((p2.z*6)+ v.z + (z) )/8
                            a = r-point[2]
                            p[0].color = ((p[0].color*15)+Vector([a,a,a,1]))/16
                            #z-=.00125 
                        elif point[2]<.75:
                            z = ((p2.z*14)+ v.z + (z) )/16
                            p[0].color = ((p[0].color*15)+Vector([.75,.75,.75,1]))/16
                            #z-=.000125     
                        elif point[2]<1:
                            p[0].color = ((p[0].color*15)+Vector([.5,.5,.5,1]))/16
                            z = ((p2.z*30)+ v.z + (z) )/32
                            #z-=.0000125       
                        elif point[2]<1.25:
                            z = ((p2.z*62)+ v.z + (z) )/64
                            a = r-point[2]
                            p[0].color = ((p[0].color*31)+Vector([a*.5,a,a*.5,1]))/32  
                        else:
                            z = ((p2.z*126)+ v.z + (z) )/128
                            a = r-point[2]
                            p[0].color = ((p[0].color*62)+Vector([a*.5,a,a*.5,1]))/64  
                                     
                        p2.z = z
                        
                        p[0].XYZ = p2
                        if point[2]>1:
                            p[0].r+= point[2]*.015
                            
                    elif p1o.z>-1.25:
                        p1x =p[1].worldTransform*p[0].XYZ
                        c3 = (math.sin(math.cos(p1x.x*3))+math.sin(math.cos(p1x.y*3)))*.5
                        p[0].color = [ c3 , c3 ,c3 ,1]
                    else:
                        p[0].color = [ nn*.5+(bge.logic.getRandomFloat()*.05), .25 + nn*.5+(bge.logic.getRandomFloat()*.25), nn*.5+(bge.logic.getRandomFloat()*.05 ),1 ]
                        pointW = p[1].worldTransform*p[0].XYZ
                        pointW2 = pointW.copy()
                        pointW2.z =  ( math.sin(pointW.x/4)+math.sin(pointW.y/4) )*.25
                        pointW2.z += ( math.sin(pointW.x/2)+math.sin(pointW.y/2) )*-.25
                        pointW2.z += ( math.sin(pointW.x)+math.sin(pointW.y) )*-.25
                        pointW2.z = (v.z*.5 + -1)/2
                        pointW2 = pointW2 - p[1].worldPosition
                        pointW2 = p[1].worldOrientation.inverted()*pointW2
                        p[0].XYZ = pointW2
            elif nn==1.0 and v.z<-1.25:
                for vert in data:
                    vert[0].color = [ nn*.5+(bge.logic.getRandomFloat()*.05), .25 + nn*.5+(bge.logic.getRandomFloat()*.25), nn*.5+(bge.logic.getRandomFloat()*.05 ),1 ]
                
             #calculate normals for all faces
        for Tile in tiles:
            added=Tile
            for index in range(added.meshes[0].numPolygons):
                face2 = added.meshes[0].getPolygon(index)
              
                
                index1 = face2.v1
                v1 = added.meshes[0].getVertex(0,face2.v1)
                v2 = added.meshes[0].getVertex(0,face2.v2)
                v3 = added.meshes[0].getVertex(0,face2.v3)
                v4 = added.meshes[0].getVertex(0,face2.v4)
                
                n = mathutils.geometry.normal(v1.XYZ,v2.XYZ,v3.XYZ,v4.XYZ)
                v1.normal=n
                v2.normal=n
                v3.normal=n
                v4.normal=n
        #average normals for all vertex sharing world cord             
        for key in worldDict:
           
            list = worldDict[key]
            
            norm = Vector([0,0,0])
            color = Vector([0,0,0,1])
            z = 0
            if len(list)<1:
                for vertex in list:
                    if z!=0:
                        z = (z+vertex[0].XYZ.z)/2
                        color = (color+vertex[0].color)/2
                        norm = (norm+vertex[0].normal)/2
                    else:
                        z = vertex[0].XYZ.z 
                        color = vertex[0].color.copy()
                        norm = vertex[0].normal
                       
                for vertex in list:
                    vertex[0].normal=norm 
                    vertex[0].color = color
                    v = vertex[0].XYZ
                    v.z = z
                    vertex[0].XYZ = v  
    own.state=2        
main()


update -> remove ’ craters ’ from roads using a bit more math :smiley: