Skip to content

Range.render

Example of using a Range.types.SCA_MouseSensor, and two Range.types.KX_ObjectActuator to implement MouseLook:

# To use a mouse movement sensor "Mouse" and a
# motion actuator to mouse look:
import Range
# scale sets the speed of motion
scale = 1.0, 0.5
co = Range.logic.getCurrentController()
obj = co.owner
mouse = co.sensors["Mouse"]
lmotion = co.actuators["LMove"]
wmotion = co.actuators["WMove"]
# Transform the mouse coordinates to see how far the mouse has moved.
def mousePos():
x = (Range.render.getWindowWidth() / 2 - mouse.position[0]) * scale[0]
y = (Range.render.getWindowHeight() / 2 - mouse.position[1]) * scale[1]
return (x, y)
pos = mousePos()
# Set the amount of motion: X is applied in world coordinates...
wmotion.useLocalTorque = False
wmotion.torque = ((0.0, 0.0, pos[0]))
# ...Y is applied in local coordinates
lmotion.useLocalTorque = True
lmotion.torque = ((-pos[1], 0.0, 0.0))
# Activate both actuators
co.activate(lmotion)
co.activate(wmotion)
# Centre the mouse
Range.render.setMousePosition(int(Range.render.getWindowWidth() / 2), int(Range.render.getWindowHeight() / 2))

Deprecated.

Materials as defined by the texture face settings.

Deprecated.

Materials approximating blender materials with multitexturing.

Deprecated.

Materials approximating blender materials with GLSL.

Disables vsync Enables vsync Enables adaptive vsync if supported. Adaptive vsync enables vsync if the framerate is above the monitors refresh rate. Otherwise, vsync is diabled if the framerate is too low.

Left eye being used during stereoscopic rendering.

Right eye being used during stereoscopic rendering.

Use 8 bit per channel image format.

Use 16 bit float per channel image format.

Use 32 bit float per channel image format.

Gets the width of the window (in pixels)

Return type: integer

Gets the height of the window (in pixels)

Return type: integer

Set the width and height of the window (in pixels). This also works for fullscreen applications.

  • width: width in pixels
    • type: integer
  • height: height in pixels
    • type: integer

Set whether or not the window should be fullscreen.

  • enable: True to set full screen, False to set windowed.
    • type: bool

Returns whether or not the window is fullscreen.

Return type: bool

Get the display dimensions, in pixels, of the display (e.g., the monitor). Can return the size of the entire view, so the combination of all monitors; for example, (3840, 1080) for two side-by-side 1080p monitors.

Return type: tuple (width, height)

Writes an image file with the displayed image at the frame end.

The image is written to ‘filename’. The path may be absolute (eg. /home/foo/image) or relative when started with // (eg. //image). Note that absolute paths are not portable between platforms. If the filename contains a #, it will be replaced by an incremental index so that screenshots can be taken multiple times without overwriting the previous ones (eg. image-#).

Settings for the image are taken from the render settings (file format and respective settings, gamma and colospace conversion, etc). The image resolution matches the framebuffer, meaning, the window size and aspect ratio. When running from the standalone player, instead of the embedded player, only PNG files are supported. Additional color conversions are also not supported.

  • filename: path and name of the file to write
    • type: string

Deprecated; doesn’t do anything.

Enables or disables the operating system mouse cursor.

  • visible:
    • type: boolean

Sets the mouse cursor position.

  • x: X-coordinate in screen pixel coordinates.
    • type: integer
  • y: Y-coordinate in screen pixel coordinates.
    • type: integer

Deprecated and no longer functional. Use Range.types.KX_WorldInfo.horizonColor or Range.types.KX_WorldInfo.zenithColor instead.

Sets the eye separation for stereo mode. Usually Focal Length/30 provides a confortable value.

  • eyesep: The distance between the left and right eye.
    • type: float

Gets the current eye separation for stereo mode.

Return type: float

Sets the focal length for stereo mode. It uses the current camera focal length as initial value.

  • focallength: The focal length.
    • type: float

Gets the current focal length for stereo mode.

Return type: float

Gets the current stereoscopy eye being rendered. This function is mainly used in a Range.types.KX_Scene.pre_draw callback function to customize the camera projection matrices for each stereoscopic eye.

Return type: LEFT_EYE, RIGHT_EYE

Deprecated and no longer functional.

Set the material mode to use for OpenGL rendering.

  • mode: material mode
    • type: KX_TEXFACE_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_GLSL_MATERIAL

Deprecated and no longer functional.

Get the material mode to use for OpenGL rendering.

Return type: KX_TEXFACE_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_GLSL_MATERIAL

Enables or disables a GLSL material setting.

  • setting:
    • type: string (lights, shaders, shadows, ramps, nodes, extra_textures)
  • enable:
    • type: boolean

Get the state of a GLSL material setting.

  • setting:
    • type: string (lights, shaders, shadows, ramps, nodes, extra_textures)

Return type: boolean

Set the anisotropic filtering level for textures.

  • level: The new anisotropic filtering level to use
    • type: integer (must be one of 1, 2, 4, 8, 16)

Get the anisotropic filtering level used for textures.

Return type: integer (one of 1, 2, 4, 8, 16)

Set the anti aliasing level.

  • level: The new anti aliasing level to use
    • type: integer (must be one of 0, 2, 4, 8, 16)

Get the anti aliasing level setting.

Return type: integer (one of 0, 2, 4, 8, 16)

Change how to use mipmapping.

  • type: RAS_MIPMAP_NONE, RAS_MIPMAP_NEAREST, RAS_MIPMAP_LINEAR

Get the current mipmapping setting.

Return type: RAS_MIPMAP_NONE, RAS_MIPMAP_NEAREST, RAS_MIPMAP_LINEAR

Texture quality of a graphics menu: keep only the high resolution texture in the project and drop its largest mipmap levels when it is sent to the graphics card.

  • 0: full size
  • 1: half size (1/4 of the video memory)
  • 2: quarter size (1/16 of the video memory)

Textures never go below 256 pixels on their larger side, and textures without mipmaps (or with mipmapping off) keep their size. DDS files skip the levels stored in the file.

  • level: 0, 1 or 2
    • type: integer

Returns: the current texture quality (0 full, 1 half, 2 quarter).

Return type: integer

Draw a line in the 3D scene.

  • fromVec: the origin of the line
    • type: list [x, y, z]
  • toVec: the end of the line
    • type: list [x, y, z]
  • color: the color of the line
    • type: list [r, g, b, a]

Enable the motion blur effect.

  • factor: the ammount of motion blur to display.
    • type: float [0.0 - 1.0]

Disable the motion blur effect.

Show or hide the framerate.

  • enable:
    • type: boolean

Show or hide the profile.

  • enable:
    • type: boolean

Show or hide the debug properties.

  • enable:
    • type: boolean

Enable or disable auto adding debug properties to the debug list.

  • enable:
    • type: boolean

Clears the debug property list.

Set the vsync value

  • value: One of VSYNC_OFF, VSYNC_ON, VSYNC_ADAPTIVE
    • type: integer

Get the current vsync value

Return type: One of VSYNC_OFF, VSYNC_ON, VSYNC_ADAPTIVE

setDynamicResolution(enabled, targetFPS=60, minScale=50, maxScale=100, step=5)

Section titled “setDynamicResolution(enabled, targetFPS=60, minScale=50, maxScale=100, step=5)”

Runtime version of the scene’s Dynamic Resolution settings. The 3D scene is rendered at a scale of the window size and stretched to the screen; the window itself does not change. With dynamic resolution the scale goes down by step when the GPU time of a frame is above the target and back up when there is time left. minScale == maxScale gives a fixed render scale. Paused while “Show Render Queries” is on (both use a GPU timer query).

  • enabled: False renders at 100%.
    • type: boolean
  • targetFPS: Frame rate the GPU time is compared to.
    • type: integer
  • minScale: Lowest scale, in percent (25-100).
    • type: integer
  • maxScale: Highest scale, in percent (25-100).
    • type: integer
  • step: Scale change per adjustment, in percent (1-25).
    • type: integer

Current render scale, 1.0 = full resolution.

Return type: float

These items exist in the engine but were not in the Range documentation. The ones marked new in Anastacio were added by Anastacio Engine.

function

Overall game sound volume, from 0 to 1. See setMasterVolume().

Returns: volume

new in Anastacio function

get the stereo mode

new in Anastacio function

get the VR lens chromatic aberration correction

new in Anastacio function

get the VR lens distortion strength

function

Uses the image at path as the mouse cursor.

function

– volume in [0, 1], applies to the engine’s actual audio device

new in Anastacio function

set the stereo mode (STEREO_* constants)

new in Anastacio function

set the VR lens chromatic aberration correction (0..0.1, default 0.01)

new in Anastacio function

set the VR lens distortion strength (0..1, default 0.3)

function

Shows or hides the physics collision shapes.

constant

Linear mipmap (smoother).

constant

Nearest mipmap.

constant

No mipmap.

constant

Stereo: one image above the other.

constant

Stereo: anaglyph (red/cyan glasses).

constant

Stereo: interlaced lines.

constant

No stereo.

constant

Stereo: side by side.

constant

Adaptive VSync: syncs, but doesn’t stall when FPS drops.

constant

VSync off.

constant

VSync on.