コード例 #1
0
class World( Entity ):
	drawable = collidable = updatable = True
	server_sendable = True
	client_sendable = batchable = False
	def __init__( self ):
		self.bstate = BlockWorldState()
		self.bstate.random( 10 )
		self.batch = None
		self.coll = CollGeometry()

	def update( self, dt ):
		if not self.bstate.dirty:
			return

		self.coll = CollGeometry()
		self.bstate.dirty = False

		self.ground = Block( -50., -100., -50., 100. )
		self.ground.set_color( (100, 0, 0, 0) )
		self.coll.add_geometry( CollAABB(
			Vector3f( -50., -100., -50. ), Vector3f( 50., 0., 50. ) ) )

		self.blocks = [ self.ground ]
		for b in self.bstate.blocks:
			minx, minz, c = b
			b = Block( minx, 0., minz, 5. )
			b.set_color( (0, 100, c, 0) )

			self.coll.add_geometry( CollAABB(
				Vector3f( minx, 0., minz ), Vector3f( minx+5., 5, minz+5. ) ) )
			self.blocks.append( b )

		self.batch = Batch( self.blocks )

	def collision_geometry( self ):
		return self.coll

	def resolve( self, other, coll ):
		return other.resolve( self, coll )

	def state( self ):
		return self.bstate

	def draw( self ):
		if self.batch:
			self.batch.draw()
コード例 #2
0
	def __init__( self, renderer ):
		self.noise = Brownian()
		self.noise.add_component( 2., 3. )
		self.noise.add_component( 0.5, 15. )
		self.noise.add_component( 0.1, 30. )

		self.patches = [ SphericalROAM( None, self.noise.noise ) ]
		self.patches = [ SphericalROAM2( 50000, 100000, self.noise.noise ) ]

		self.batch = Batch( self.patches )
コード例 #3
0
class Planet:
	def __init__( self, renderer ):
		self.noise = Brownian()
		self.noise.add_component( 2., 3. )
		self.noise.add_component( 0.5, 15. )
		self.noise.add_component( 0.1, 30. )

		self.patches = [ SphericalROAM( None, self.noise.noise ) ]
		self.patches = [ SphericalROAM2( 50000, 100000, self.noise.noise ) ]

		self.batch = Batch( self.patches )

	def draw( self, renderer, camera ):
		camera.update( renderer )

		c_float_p = POINTER(c_float)
		pos = camera.position.astype(numpy.float32)
		look = camera.look.astype(numpy.float32)

		self.batch.update( 
			(	pos.ctypes.data_as(c_float_p), 
				look.ctypes.data_as(c_float_p) ) )

		self.batch.draw()
コード例 #4
0
	def update( self, dt ):
		if not self.bstate.dirty:
			return

		self.coll = CollGeometry()
		self.bstate.dirty = False

		self.ground = Block( -50., -100., -50., 100. )
		self.ground.set_color( (100, 0, 0, 0) )
		self.coll.add_geometry( CollAABB(
			Vector3f( -50., -100., -50. ), Vector3f( 50., 0., 50. ) ) )

		self.blocks = [ self.ground ]
		for b in self.bstate.blocks:
			minx, minz, c = b
			b = Block( minx, 0., minz, 5. )
			b.set_color( (0, 100, c, 0) )

			self.coll.add_geometry( CollAABB(
				Vector3f( minx, 0., minz ), Vector3f( minx+5., 5, minz+5. ) ) )
			self.blocks.append( b )

		self.batch = Batch( self.blocks )