本文整理匯總了Python中pi3d.util.Utility.load_identity方法的典型用法代碼示例。如果您正苦於以下問題:Python Utility.load_identity方法的具體用法?Python Utility.load_identity怎麽用?Python Utility.load_identity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pi3d.util.Utility
的用法示例。
在下文中一共展示了Utility.load_identity方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: create3D
# 需要導入模塊: from pi3d.util import Utility [as 別名]
# 或者: from pi3d.util.Utility import load_identity [as 別名]
def create3D(self, x=0, y=0, w=0, h=0,
near=1.0, far=800.0, aspect=60.0, depth=24):
if w <= 0 or h <= 0:
w = self.max_width
h = self.max_height
self.win_width = w
self.win_height = h
self.near = near
self.far = far
self.left = x
self.top = y
self.right = x + w
self.bottom = y + h
self.create_display(x, y, w, h, depth)
#Setup perspective view
opengles.glMatrixMode(GL_PROJECTION)
Utility.load_identity()
hht = near * math.tan(math.radians(aspect / 2.0))
hwd = hht * w / h
opengles.glFrustumf(c_float(-hwd), c_float(hwd),
c_float(-hht), c_float(hht),
c_float(near), c_float(far))
opengles.glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
opengles.glMatrixMode(GL_MODELVIEW)
Utility.load_identity()
示例2: perspective
# 需要導入模塊: from pi3d.util import Utility [as 別名]
# 或者: from pi3d.util.Utility import load_identity [as 別名]
def perspective(self, w, h, zoom, near=1, far=500):
opengles.glMatrixMode(GL_PROJECTION)
Utility.load_identity()
hht = near * math.tan(math.radians(45.0))
hwd = hht * w / h
opengles.glFrustumf(c_float(-hwd), c_float(hwd), c_float(-hht), c_float(hht), c_float(near), c_float(far))
opengles.glMatrixMode(GL_MODELVIEW)
示例3: _draw
# 需要導入模塊: from pi3d.util import Utility [as 別名]
# 或者: from pi3d.util.Utility import load_identity [as 別名]
def _draw(verts, tex, x, y, w, h, r, z):
opengles.glNormalPointer(GL_BYTE, 0, RECT_NORMALS);
opengles.glVertexPointer(3, GL_BYTE, 0, verts);
Utility.load_identity()
Utility.translatef(x, y, z)
Utility.scalef(w, h, 1)
if r:
Utility.rotatef(r, 0, 0, 1)
with Texture.Loader(tex,RECT_TEX_COORDS,GL_BYTE):
opengles.glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, RECT_TRIANGLES)
示例4: position
# 需要導入模塊: from pi3d.util import Utility [as 別名]
# 或者: from pi3d.util.Utility import load_identity [as 別名]
def position(self, x, y, z, w=1):
""" move or rotate the light and change its type
x,y,z -- location or direction components
w -- type 0 for directional, 1 for point (default 1)
"""
mtrx = (ctypes.c_float * 16)()
opengles.glGetFloatv(GL_MODELVIEW_MATRIX, ctypes.byref(mtrx))
Utility.load_identity()
self.xyz = c_floats((x, y, z , w))
opengles.glLightfv(self.no, GL_POSITION, self.xyz)
opengles.glLoadMatrixf(mtrx)
示例5: orthographic
# 需要導入模塊: from pi3d.util import Utility [as 別名]
# 或者: from pi3d.util.Utility import load_identity [as 別名]
def orthographic(self, left, right, bottom, top, zoom=1, near=-1, far=10):
opengles.glMatrixMode(GL_PROJECTION)
Utility.load_identity()
# opengles.glOrthof(c_float(-10), c_float(10), c_float(10), c_float(-10.0), c_float(near), c_float(far))
opengles.glOrthof(
c_float(left / zoom),
c_float(right / zoom),
c_float(bottom / zoom),
c_float(top / zoom),
c_float(near),
c_float(far),
)
opengles.glMatrixMode(GL_MODELVIEW)
Utility.load_identity()
示例6: create2D
# 需要導入模塊: from pi3d.util import Utility [as 別名]
# 或者: from pi3d.util.Utility import load_identity [as 別名]
def create2D(self, x=0, y=0, w=0, h=0, depth=24, near=-1.0, far=100.0):
if w <= 0 or h <= 0:
w = self.max_width
h = self.max_height
self.win_width = w
self.win_height = h
self.near = near
self.far = far
self.left = x
self.top = y
self.right = x + w
self.bottom = y + h
self.create_display(x, y, w, h, depth)
opengles.glMatrixMode(GL_PROJECTION)
Utility.load_identity()
opengles.glOrthof(c_float(0), c_float(w), c_float(0),
c_float(h), c_float(-1), c_float(500))
opengles.glMatrixMode(GL_MODELVIEW)
Utility.load_identity()
示例7: Model
# 需要導入模塊: from pi3d.util import Utility [as 別名]
# 或者: from pi3d.util.Utility import load_identity [as 別名]
mymodel = Model("models/Triceratops/Triceratops.egg",texs,"Triceratops", 0,-1,0, -90,0,0, .005,.005,.005)
# Fetch key presses
mykeys = Keyboard()
# mastrix and rotate variables
rot=0
#create a light
mylight = Light(0,1,1,1,"",10,10,0)
mylight.on()
while 1:
display.clear()
Utility.load_identity()
Utility.translatef(0,0, -40)
Utility.rotatef(rot, 0, 1, 0)
rot += 3
mymodel.draw()
k = mykeys.read()
if k >-1:
if k==112: display.screenshot("Triceratops.jpg")
elif k==27:
mykeys.close()
texs.deleteAll()
display.destroy()
break
else:
示例8: identity
# 需要導入模塊: from pi3d.util import Utility [as 別名]
# 或者: from pi3d.util.Utility import load_identity [as 別名]
def identity(self):
Utility.load_identity()
self.mc = 0
示例9: create
# 需要導入模塊: from pi3d.util import Utility [as 別名]
# 或者: from pi3d.util.Utility import load_identity [as 別名]
def create(x=None, y=None, w=None, h=None, near=None, far=None,
fov=DEFAULT_FOV, depth=DEFAULT_DEPTH, background=None,
tk=False, window_title='', window_parent=None, mouse=False,
frames_per_second=None):
"""
Creates a pi3d Display.
*x*
Left x coordinate of the display. If None, defaults to the x coordinate of
the tkwindow parent, if any.
*y*
Top y coordinate of the display. If None, defaults to the y coordinate of
the tkwindow parent, if any.
*w*
Width of the display. If None, full the width of the screen.
*h*
Height of the display. If None, full the height of the screen.
*near*
This will be used for the default instance of Camera *near* plane
*far*
This will be used for the default instance of Camera *far* plane
*fov*
Used to define the Camera lens field of view
*depth*
The bit depth of the display - must be 8, 16 or 24.
*background*
r,g,b,alpha (opacity)
*tk*
Do we use the tk windowing system?
*window_title*
A window title for tk windows only.
*window_parent*
An optional tk parent window.
*mouse*
Automatically create a Mouse.
*frames_per_second*
Maximum frames per second to render (None means "free running").
"""
if tk:
from pi3d.util import TkWin
if not (w and h):
# TODO: how do we do full-screen in tk?
#LOGGER.error("Can't compute default window size when using tk")
#raise Exception
# ... just force full screen - TK will automatically fit itself into the screen
w = 1920
h = 1180
tkwin = TkWin.TkWin(window_parent, window_title, w, h)
tkwin.update()
if x is None:
x = tkwin.winx
if y is None:
y = tkwin.winy
else:
tkwin = None
x = x or 0
y = y or 0
display = Display(tkwin)
if (w or 0) <= 0:
w = display.max_width - 2 * x
if w <= 0:
w = display.max_width
if (h or 0) <= 0:
h = display.max_height - 2 * y
if h <= 0:
h = display.max_height
LOGGER.debug('Display size is w=%d, h=%d', w, h)
display.frames_per_second = frames_per_second
if near is None:
near = DEFAULT_NEAR
if far is None:
far = DEFAULT_FAR
display.width = w
display.height = h
display.near = near
display.far = far
display.fov = fov
display.left = x
display.top = y
display.right = x + w
display.bottom = y + h
display.opengl.create_display(x, y, w, h, depth)
display.mouse = None
if mouse:
from pi3d.Mouse import Mouse
display.mouse = Mouse(width=w, height=h)
display.mouse.start()
# This code now replaced by camera 'lens'
"""opengles.glMatrixMode(GL_PROJECTION)
Utility.load_identity()
if is_3d:
#.........這裏部分代碼省略.........