Example of using a bge.types.SCA_MouseSensor, and two bge.types.KX_ObjectActuator to implement MouseLook:
Note
This can also be achieved with the bge.types.KX_MouseActuator.
# To use a mouse movement sensor "Mouse" and a
# motion actuator to mouse look:
import bge
# scale sets the speed of motion
scale = 1.0, 0.5
co = bge.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 = (bge.render.getWindowWidth() / 2 - mouse.position[0]) * scale[0]
y = (bge.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
bge.render.setMousePosition(int(bge.render.getWindowWidth() / 2), int(bge.render.getWindowHeight() / 2))
Materials as defined by the texture face settings.
Materials approximating blender materials with multitexturing.
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.
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.
Set whether or not the window should be fullscreen.
Returns whether or not the window is fullscreen.
Return type: | bool |
---|
Writes a screenshot to the given filename.
If filename starts with // the image will be saved relative to the current directory. If the filename contains # it will be replaced with the frame number.
The standalone player saves .png files. It does not support color space conversion or gamma correction.
When run from Blender, makeScreenshot supports all Blender image file formats like PNG, TGA, Jpeg and OpenEXR. Gamma, Colorspace conversion and Jpeg compression are taken from the Render settings panels.
Doesn’t really do anything...
Enables or disables the operating system mouse cursor.
Sets the mouse cursor position.
Sets the window background color.
Sets the mist color.
Sets the color of ambient light.
Sets the mist start value. Objects further away than start will have mist applied to them.
Sets the mist end value. Objects further away from this will be colored solid with the color set by setMistColor().
Disables mist.
Note
Set any of the mist properties to enable mist.
Sets the eye separation for stereo mode. Usually Focal Length/30 provides a confortable value.
Parameters: | eyesep (float) – The distance between the left and right eye. |
---|
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.
Parameters: | focallength (float) – The focal length. |
---|
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 bge.types.KX_Scene.pre_draw callback function to customize the camera projection matrices for each stereoscopic eye.
Return type: | LEFT_EYE, RIGHT_EYE |
---|
Set the material mode to use for OpenGL rendering.
Note
Changes will only affect newly created scenes.
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.
Get the state of a GLSL material setting.
Return type: | boolean |
---|
Set the anisotropic filtering level for textures.
Parameters: | level (integer (must be one of 1, 2, 4, 8, 16)) – The new anisotropic filtering level to use |
---|
Note
Changing this value can cause all textures to be recreated, which can be slow.
Get the anisotropic filtering level used for textures.
Return type: | integer (one of 1, 2, 4, 8, 16) |
---|
Change how to use mipmapping.
Note
Changing this value can cause all textures to be recreated, which can be slow.
Get the current mipmapping setting.
Return type: | RAS_MIPMAP_NONE, RAS_MIPMAP_NEAREST, RAS_MIPMAP_LINEAR |
---|
Draw a line in the 3D scene.
Parameters: |
|
---|
Enable the motion blur effect.
Parameters: | factor (float [0.0 - 1.0]) – the ammount of motion blur to display. |
---|
Disable the motion blur effect.
Show or hide the framerate.
Show or hide the profile.
Show or hide the debug properties.
Enable or disable auto adding debug properties to the debug list.
Clears the debug property list.
Set the vsync value
Parameters: | value (integer) – One of VSYNC_OFF, VSYNC_ON, VSYNC_ADAPTIVE |
---|
Get the current vsync value
Return type: | One of VSYNC_OFF, VSYNC_ON, VSYNC_ADAPTIVE |
---|