2010 October 12 / j|d|a|v|i|s|@|c|a|r|l|e|t|o|n|.|e|d|u

**__init__(self)**

Initializes the renderer with its defaults: no lights, only diffuse lighting, no camera, no bodies.

**getBodies(self)**

Returns the renderer's list of Body3Ds, which the user can alter (append, pop, etc.) as desired, as long as they remain compatible with the rendering settings.

**setCamera(self, camera)**

Sets the renderer's Camera object, which may be None. If there is no camera, then a default camera is installed upon the first drawing.

**getCamera(self)**

Returns the renderer's Camera object, which may be None.

**setLights(self, lights)**

Sets the renderer's lights to those in the given sequence.

**getLights(self)**

Returns the tuple of lights. To change the lights, use the setLights method.

**pick(self, xy)**

The input xy is a screen coordinate pair (with the origin in the bottom left corner). Returns a pair (index, xyz). If there is no body occupying the screen point xy, then index and xyz are None. If there is a body at xy, then index is the index of the frontmost body, and xyz are the approximate world coordinates of the point on that body that is drawn at xy.

**updateShaderPrograms(self, body)**

Rewrites/compiles/links the underlying OpenGL shader programs for drawing and picking. This method is called automatically when a frame is drawn, if the rendering conditions (material codes, lights, camera) have changed since the previous frame. Alternatively, the user can call this method after setting the rendering conditions, if she prefers to choose the Body3D used to construct the shader programs.

**setTextureCoordinateCodes(self, codes)**

Sets the GLSL vertex shader expressions for texture coordinates, to those given in the sequence codes. That is, codes[i] indicates where the texture coordinates for sampler i come from. For example, if codes[0] is the string 'a2', then the bodies must supply 2D texture coordinates as attribute 2. Can refer to uniform and attribute variables. The default is the empty sequence.

**getTextureCoordinateCodes(self)**

Returns the tuple of texture coordinate codes.

**setVaryingCodesSizes(self, codes, sizes)**

Sets the GLSL vertex shader expressions for varying variables, to those given in the sequence codes, with sizes given in the sequence sizes. That is, sizes[i] indicates how many floats are in the ith varying variable and codes[i] indicates how the value of that variable is set. For example, suppose sizes[0] is 3 and codes[0] is 'a2'. Then the bodies supply 3-vectors as attribute 2; these 3-vectors are interpolated and appear in the fragment shader as v0. Can refer to uniform and attribute variables. The default for both codes and sizes is the empty sequence.

**getVaryingCodes(self)**

Returns the tuple of varying variable codes.

**getVaryingSizes(self)**

Returns the tuple of varying variable sizes.

**setVertexCode(self, code)**

Sets the GLSL vertex shader expression for the vec4 world coordinates of the vertex. Can refer to uniform and attribute variables. The default is the string 'modelingMatrix * vec4(a0, 1.0)', meaning that the bodies' meshes supply 3D vertices as attribute 0.

**getVertexCode(self)**

Returns the vertex code.

**setNormalCode(self, code)**

Sets the GLSL fragment shader expression for the vec3 world coordinates of the normal vector. Can refer to uniform, varying, and sampler variables. The default is the string 'vec3(0.0, 0.0, 1.0)', meaning the unit vector in the Z-direction. A more typical value is something like 'normalize(v0)', where varying size 0 is 3 and varying code 0 is 'normalize((modelingMatrix * vec4(a1, 0.0)).xyz)' (see setVaryingCodesSizes).

**getNormalCode(self)**

Returns the normal code.

**setIsAmbient(self, isAmbient)**

Sets whether the renderer should incorporate ambient light. The default is True.

**getIsAmbient(self)**

Returns whether ambient lighting is on.

**setAmbientColor(self, rgb)**

Sets the renderer's ambient light color to the given RGB tuple. The default is (0.1, 0.1, 0.1).

**getAmbientColor(self)**

Returns the renderer's ambient light color as an RGB tuple.

**setIsEmissive(self, isEmissive)**

Sets whether the renderer should incorporate light emission from bodies. The default is False.

**getIsEmissive(self)**

Returns whether light emission is on.

**setEmissiveCode(self, code)**

Sets the GLSL fragment shader expression for the material emissive light color. Can refer to uniform, varying, and sampler variables. The default is the string 'vec3(0.0, 0.0, 0.0, 1.0)', meaning that surfaces emit no light.

**getEmissiveCode(self)**

Returns the emissive light code.

**setIsDiffuse(self, isDiffuse)**

Sets whether the renderer should incorporate diffuse light reflections. The default is True.

**getIsDiffuse(self)**

Returns whether diffuse reflections are on.

**setDiffuseCode(self, code)**

Sets the GLSL fragment shader expression for the material diffuse reflection color. Can refer to uniform, varying, and sampler variables. The default is the string 'vec3(0.5, 0.5, 0.5, 1.0)', meaning that surfaces are gray.

**getDiffuseCode(self)**

Returns the diffuse/ambient light code.

**setIsSpecular(self, isSpecular)**

Sets whether the renderer should incorporate specular light reflections. Valid arguments are False, True, and 'Phong'. The default is False.

**getIsSpecular(self)**

Returns the specular setting.

**setSpecularCode(self, code)**

Sets the GLSL fragment shader expression for the material specular reflection color. Can refer to uniform, varying, and sampler variables. The default is the string 'vec4(1.0, 1.0, 1.0, 1.0)', meaning that specular highlights are bright white.

**getSpecularCode(self)**

Returns the specular light code.

**setShininessCode(self, code)**

Sets the GLSL fragment shader expression for the shininess. Can refer to uniform, varying, and sampler variables. The default is the string '64.0'.

**getShininessCode(self)**

Returns the shininess code.

**setIsAttenuated(self, isAttenuated)**

Sets whether positional lights are attenuated. The default is False. Directional lights are never attenuated.

**getIsAttenuated(self)**

Returns whether positional lights are attenuated.

**setAttenuation(self, constant, linear, quadratic)**

Sets the coefficients to be used in light attenuation (if attenuation is turned on). The default values are 0.0, 0.0, and 0.01.

**getConstantAttenuation(self)**

Returns the constant-term coefficient used in light attenuation (if attenuation is turned on).

**getLinearAttenuation(self)**

Returns the linear-term coefficient used in light attenuation (if attenuation is turned on).

**getQuadraticAttenuation(self)**

Returns the quadratic-term coefficient used in light attenuation (if attenuation is turned on).