Пример #1
0
    def updateChunk(self, obj):
        """ Updates the hight of a lod chunk from the disk. """

        lod = int(obj.name[15:])

        x, y = (obj.worldPosition.x / Tile.size,
                obj.worldPosition.y / Tile.size)
        msx, msy = self.terrain_file._msx, self.terrain_file._msy
        chunkpos = (int(x) + int(msx / 2), int(y) + int(msy / 2))

        vlist = self.terrain_file.getChunkArray(lod, chunkpos)

        i = 0
        cn = False
        mesh = obj.meshes[0]
        for vertex in vlist:
            z, nx, ny, nz = vertex
            v = mesh.getVertex(0, i)
            v.XYZ = (v.x, v.y, z)

            #if nx != None: v.setNormal((nx, ny, nz))
            #else: cn = True
            i += 1

        if True: utils.recalculateNormals(obj)
Пример #2
0
	def onKeyPressed(self, keys):
		if not (key.LEFTMOUSE in keys or key.RIGHTMOUSE in keys): return
		
		hitobj = module.window.hitobj
		hitpoly = module.window.hitpoly
		
		if not hitobj or not hitobj.name.startswith("DYN_Terrain."): return
		
		v = utils.getNearestVertexToPoly(hitobj, hitpoly, self.obj.worldPosition)
		
		if key.LEFTMOUSE in keys:
			v.XYZ = [v.x, v.y, v.z+self.force]
		if key.RIGHTMOUSE in keys:
			v.XYZ = [v.x, v.y, v.z-self.force]

		self.obj.worldPosition = module.window.hitobj.worldPosition + v.XYZ
		utils.recalculateNormals(hitobj)
		hitobj.reinstancePhysicsMesh(hitobj, hitobj.meshes[0])
Пример #3
0
    def onKeyPressed(self, keys):
        if not (key.LEFTMOUSE in keys or key.RIGHTMOUSE in keys): return

        hitobj = module.window.hitobj
        hitpoly = module.window.hitpoly

        if not hitobj or not hitobj.name.startswith("DYN_Terrain."): return

        v = utils.getNearestVertexToPoly(hitobj, hitpoly,
                                         self.obj.worldPosition)

        if key.LEFTMOUSE in keys:
            v.XYZ = [v.x, v.y, v.z + self.force]
        if key.RIGHTMOUSE in keys:
            v.XYZ = [v.x, v.y, v.z - self.force]

        self.obj.worldPosition = module.window.hitobj.worldPosition + v.XYZ
        utils.recalculateNormals(hitobj)
        hitobj.reinstancePhysicsMesh(hitobj, hitobj.meshes[0])
Пример #4
0
	def updateChunk(self, obj):
		""" Updates the hight of a lod chunk from the disk. """
	
		lod = int(obj.name[15:])
		
		x, y = (obj.worldPosition.x/Tile.size, obj.worldPosition.y/Tile.size)
		msx, msy = self.terrain_file._msx, self.terrain_file._msy
		chunkpos = (int(x)+int(msx/2), int(y)+int(msy/2))
		
		vlist = self.terrain_file.getChunkArray(lod, chunkpos)
		
		i = 0
		cn = False
		mesh = obj.meshes[0]
		for vertex in vlist:
			z, nx, ny, nz = vertex
			v = mesh.getVertex(0, i)
			v.XYZ = (v.x, v.y, z)
			
			#if nx != None: v.setNormal((nx, ny, nz))
			#else: cn = True
			i += 1
			
		if True: utils.recalculateNormals(obj)