示例#1
0
class Bin(object):
	def __init__(self, width = 1, depth = 1, initial_amount = 0):
		self.amount = initial_amount
		self.width = width
		self.depth = depth
		self.flux = []
		self.inc = 0.0
		self.threshold_interval = 100
		self.thresholds = []
		self.last_threshold = 0
		self.geos = Geometrics()

	def render_thresholds(self):
		for t in self.thresholds:
			t.render()
	
	def render(self):
		glPushMatrix()
#		glTranslate(0, (self.amount + self.inc) / 2.0, 0)
		glScale(self.width, self.amount + self.inc, self.depth)

		self.geos.blue_cube()

		glPopMatrix()

		self.render_thresholds()

	def add(self, amount):
		self.amount += amount

	def add_over_time(self, amount, seconds):
		self.flux.append(Increment(amount, seconds))

	def update(self, ts):
		self.inc = 0.0
		for a in self.flux:
			a.update(ts)
			if a.is_complete == True:
				self.amount += a.get()
			else:
				self.inc += a.get()
		self.flux = [a for a in self.flux if a.is_complete is False] 
	
		ct = int((self.inc + self.amount) / self.threshold_interval)
	#	for p in range(self.last_threshold, ct):
	#		self.thresholds.append(Threshold((p + 1) * self.threshold_interval, 0.1))

		for t in self.thresholds:
			t.update(ts)
示例#2
0
	def __init__(self, width = 1, depth = 1, initial_amount = 0):
		self.amount = initial_amount
		self.width = width
		self.depth = depth
		self.flux = []
		self.inc = 0.0
		self.threshold_interval = 100
		self.thresholds = []
		self.last_threshold = 0
		self.geos = Geometrics()