def __init__(self, name, params): GLObject.__init__(self, params) # segment name self.segmentID = name self.shaderProgram = -1 self.shader = None # texture for base coloring self.baseImage = None # segments needs material self.material = params.get('material') # get some default attributes self.isPlanar = self.getAttr("isPlane", False) if self.isPlanar: self.createReflectionHandler = createPlaneReflectionHandler else: pass self.reflectionHandler = None self.vertexPositionName = "vec4(vertexPosition, 1.0)" self.vertexNormalName = "vertexNormal" self.vertexColorName = "vertexColor" self.vertexUVName = "vertexUV"
def __init__(self, params): GLObject.__init__(self, params) self.matReflection = self.getAttr("matReflectionIntensity", 0.0) self.textures = [] textures = params.get('textures', []) for tex in textures: self.addTexture(tex)
def __init__(self, position=None): GLObject.__init__(self, {}) # the camera position self.position = position # model viw matrix of this camera self.modelViewMatrix = None print "REGISTER CAM MV ", Camera.CAMERA_MODELVIEW_SIGNAL # register the signal on this object self.signalRegister( Camera.CAMERA_MODELVIEW_SIGNAL )
def __init__(self, params): # FIXME: lights may be on the same unit for long time, # we do not have to set the states each frame then! self.name = params.get('name') GLObject.__init__(self, params) self.lightCutOff = self.getAttr("lightCutOff", 180.0) # signal stuff self.signalRegister( Light.LIGHT_POSITION_SIGNAL ) self.signalRegister( Light.LIGHT_DIRECTION_SIGNAL ) # shadow maps for this light self.shadowMapArray = None # TODO: make xml configurable self.dimming = 0.3
def __init__(self, params, name, dynamic=False): self.name = name self.dynamic = dynamic GLObject.__init__(self, params)
def __init__(self, params): GLObject.__init__(self, params) self.controlPoints = params.get("ctrls") self.params = params.get("params") self.target = params.get("target")
def __init__(self, winSize=(1024,768), modes=OPENGL|DOUBLEBUF|HWSURFACE, nearClip=1.0, farClip=200.0, fov=45.0, caption='OpenGL fun', iconName=None, useJoysticks=[0], hideCursor=False): ''' Constructor, opens the window and initials opengl/pygame. ''' GLObject.__init__(self, {}) # signal stuff self.signalRegister( GLApp.APP_SIZE_SIGNAL ) self.signalRegister( GLApp.APP_PROJECTION_CHANGED ) self.modes = modes self.winSize = winSize self.timePassed = 0 self.FPS = 0 self.farClip = farClip self.nearClip = nearClip self.fov = fov self.caption = caption self.sceneBounds = None # save the projection for faster calculations self.projectionMat = None pygame.init() # init display pygame.display.gl_set_attribute(pygame.GL_RED_SIZE, 8) pygame.display.gl_set_attribute(pygame.GL_GREEN_SIZE, 8) pygame.display.gl_set_attribute(pygame.GL_BLUE_SIZE, 8) pygame.display.gl_set_attribute(pygame.GL_ALPHA_SIZE, 8) # vsync pygame.display.gl_set_attribute(pygame.GL_SWAP_CONTROL, 1) (self.screen, self.winSize) = self.setWindowSize(winSize) print "INFO: OpenGL and PyGame initialed." printGLInfo() # hide cursor for custom mouse drawing pygame.mouse.set_visible(not hideCursor) # lookup joystick devices if useJoysticks!=[]: numJoysticks = pygame.joystick.get_count() self.joypads = [] if not numJoysticks: print "WARNING: No joystick connected." else: if numJoysticks<len(useJoysticks): print "WARNING: Only %d joysticks connected." % numJoysticks for x in useJoysticks: if x < numJoysticks: j = pygame.joystick.Joystick(x) self.joypads.append(JoyStick(j)) print "INFO: Using joystick: '%s' with %d buttons and %d axes." \ % (j.get_name(), j.get_numbuttons(), j.get_numaxes()) else: self.joypads = [] # set window title pygame.display.set_caption(caption) # set window icon if iconName!=None: surface = image.load("../textures/" + iconName) pygame.display.set_icon(surface) self.loadFonts() self.running = True (self.mouseX, self.mouseY) = (0, 0) self.initGL()
def __init__(self, segments, params): GLObject.__init__(self, params) # list of segments self.segments = segments self.lights = []