Example #1
0
def frustumProjMtx(fovy, near, far, aspect=0):
	if aspect == 0:
		from gltools import getViewportSize
		w,h = getViewportSize()
		aspect = float(w) / float(h)

	h = math.tan(fovy / 360.0 * math.pi) * near
	w = h * aspect

	return T.clip_matrix(-w, w, -h, h, near, far, perspective=True)
Example #2
0
    def init(self):
        self.resetModelview()
        self._normal_m = N.array([(1,0,0),(0,1,0),(0,0,1)],dtype="f")
        self._light_m = T.identity_matrix()


        self._perspective_m = frustumProjMtx(60, 0.5, 500.0)
        vpw, vph = getViewportSize()
        self._ortho_m = T.clip_matrix(0, vpw, vph, 0, -1, 1)#  0.,0.,.,1.,-1.,1.,False)
        self._modelview_m_stack = []

        self.setPerspectiveMode()

        print self._modelview_m
        print self._projection_m

        self.pushTransform()
Example #3
0
	def setArea(self, x_max, y_max=None, x_min=None, y_min=None):

		self._area_set = (x_min, y_min, x_max, y_max)

		if y_min is None:
			if y_max is None:
				self._y_min = -1
				self._y_max =  1
			else:
				self._y_min = -y_max*0.5
				self._y_max =  y_max*0.5
		elif y_max is None:
			assert(False) # can't just specify minimum
		else:
			self._y_min = y_min
			self._y_max = y_max

		if x_min is None:
			if x_max is None:

				vpw, vph = getViewportSize()
				f = float(vpw)/float(vph) * (self._y_max - self._y_min)

				self._x_min = -f*0.5
				self._x_max =  f*0.5
			else:
				self._x_min = -x_max*0.5
				self._x_max =  x_max*0.5
		elif x_max is None:
			assert(False) # can't just specify minimum
		else:
			self._x_min = x_min
			self._x_max = x_max


		self._projection_changed = True
		if self._scene: self._scene.flagCameraChanged(self)