|
|
| boxInsideFrusturm |
pointInsideFrustum |
| enableViewport |
setOnTop |
| getCameraToWorld |
setProjectionMatrix |
| getProjectionMatrix |
setViewport |
| getWorldToCamera |
sphereInsideFrustum |
|
|
| camera_to_world |
near |
| far |
perspective |
| frustum_culling |
projection_matrix |
| lens |
world_to_camera |
| modelview_matrix |
----------
|
|
|
| INSIDE |
OUTSIDE |
| INTERSECT |
----------
|
|
|
|
| alignAxisToVect |
getState |
| applyImpulse |
getVectTo |
| disableRigidBody |
getVelocity |
| enableRigidBody |
getVisible |
| endObject |
rayCast |
| getAngularVelocity |
rayCastTo |
| getAxisVect |
removeParent |
| getChildren |
restoreDynamics |
| getChildrenRecursive |
setAngularVelocity |
| getDistanceTo |
setCollisionMargin |
| getLinearVelocity |
setLinearVelocity |
| getMass |
setOrientation |
| getMesh |
setParent |
| getOrientation |
setPosition |
| getParent |
setState |
| getPhysicsId |
setVisible |
| getPosition |
setWorldPosition |
| getPropertyNames |
suspendDynamics |
| getReactionForce |
---------- |
|
|
|
| mass |
position |
| name |
scaling |
| orientation |
timeOffset |
| parent |
visible |
|
|
boxInsideFrusturm
boxInsideFrusturm(box)
Tests the given box against the view frustum
Returns: INSIDE, OUTSIDE or INTERSECT
box:
Type: a
matrix (float values)
Sample
Code
# get the active camera
cam = GameLogic.getCurrentScene().active_camera
################ Box to test
# create an empty array
box = [ ]
# enter the position of the corner vertices
box.append([ -1.0, -1.0, -1.0])
box.append([ -1.0, -1.0, 1.0])
box.append([ -1.0, 1.0, -1.0])
box.append([ -1.0, 1.0, 1.0])
box.append([ 1.0, -1.0, -1.0])
box.append([ 1.0, -1.0, 1.0])
box.append([ 1.0, 1.0, -1.0])
box.append([ 1.0, 1.0, 1.0])
# camera inside box?
if cam.boxInsideFrustum(box) != cam.OUTSIDE:
# box is inside
# your code here
else:
# box is outside
# your code here
enableViewport
enableViewport(enable)
enable/disable viewport. For more information, see
setViewport function below.
enable:
Type:
Bool (True or false. 1 or 0)
Sample
Code
# need to get game window size so...
import Rasterizer
# get current scene
scene = GameLogic.getCurrentScene()
# get a list of the objects in scene
objList = scene.getObjectList()
# already using active camera
# get 2nd camera named "ViewPort"
viewCam = objList["OBViewPort"]
# set split screen
viewCam.setViewport( 0,
Rasterizer.getWindowHeight()/2,
Rasterizer.getWindowWidth(),
Rasterizer.getWindowHeight() )
# use viewCam to create split screen
viewCam.enableViewport(True)
getCameraToWorld
getCameraToWorld()
Returns the camera to world transform
Return type: 4x4 matrix.
Sample
Code
# get the current scene
scene = GameLogic.getCurrentScene()
# get the active camera
cam = scene.active_camera
# get transform
transform = cam.getCameraToWorld()
getProjectionMatrix
getProjectionMatrix()
Returns the camera projection matrix
Return type: 4x4 matrix.
Sample
Code
# get the current scene
scene = GameLogic.getCurrentScene()
# get the active camera
cam = scene.active_camera
# get projection matrix
matrix = cam.getProjectionMatrix()
getWorldToCamera
getWorldToCamera()
Returns the world to camera transform (which is the inverse matrix of
the camera to world transform)
Return type: 4x4 matrix.
Sample
Code
# get the current scene
scene = GameLogic.getCurrentScene()
# get the active camera
cam = scene.active_camera
# get transform
transform = cam.getWorldToCamera()
pointInsideFrustum
pointInsideFrustum(point)
Tests whether or not a point is inside the camera view frustum.
Return Type: Bool
True (1) if the
point is inside the view frustum.
False (0) if it isn't.
point:
Type:
list [ x, y, z]
Sample
Code
# get the current scene
scene = GameLogic.getCurrentScene()
# get the active camera
cam = scene.active_camera
# point inside view frustum
pointInside = cam.pointInsideFrustum( [0.0, 0.0, 0.0])
setOnTop
setOnTop()
Sets this camera's viewport on top
Note:
The camera's viewport must be enabled.
See enableViewport function above
Sample
Code
# get controller
controller = GameLogic.getCurrentController()
# get camera that controller is attached to
cam = controller.getOwner()
# set camera's viewport on top of the other enabled
viewports
cam.setOnTop()
setProjectionMatrix
setProjectionMatrix(matrix)
Sets the camera projection matrix
matrix:
Type is 4x4 Matrix
Sample
Code
# get the current scene
scene = GameLogic.getCurrentScene()
# get the active camera
cam = scene.active_camera
# your four by four matrix
matrix = [ your four by four matrix here]
# set projection matrix
cam.setProjectionMatrix(matrix)
setViewport
setViewport( left, bottom, right, top)
setViewport allows you to display more than one camera view in the game
window at the same time.
left
Type:
integer
bottom
Type:
integer
right
Type:
integer
top
Type:
integer
Note:
left, bottom, right and top aren't the positions of the
corner vertices. They are the positions of the sides
Sample Code
# Create a rear view mirror
# need to get game window size so...
import Rasterizer
# get current scene
scene = GameLogic.getCurrentScene()
# get list of objects in scene
objList = scene.getObjectList()
# get 2nd camera named "RearView"
viewCam = objList["OBRearView"]
# set the sides of the rear view mirror
left = Rasterizer.getWindowWidth() * 1/4
bottom = Rasterizer.getWindowHeight() * 3/4
right = Rasterizer.getWindowWidth() * 3/4
top = Rasterizer.getWindowHeight() * 95/100
# set picture in picture size
viewCam.setViewport( left, bottom, right, top)
# use rear view mirror
viewCam.enableViewport(True)
sphereInsideFrustum
sphereInsideFrustum(centre, radius)
Checks to see if a sphere is inside the camera's view frustum.
Returns: INSIDE, OUTSIDE or INTERSECT
center:
Type: List
[ x, y, z]
Center of the sphere in World Coordinates.
radius:
Type:
float number.
Radius of the sphere
Sample Code
# get the current scene
scene = GameLogic.getCurrentScene()
# get the active camera
cam = scene.active_camera
# check if sphere is inside view frustum
sphereInside = cam.sphereInsideFrustum( [0.0, 0.0, 0.0], 4.5)
if sphereInside == cam.INSIDE:
# your code here
if sphereInside == cam.OUTSIDE:
# your code here
if sphereInside == cam.INTERSECT:
# your code here
Instance Variables
camera_to_world
camera_to_world
Returns the camera to world transform
Type: 4x4 matrix.
Sample Code
# get the current scene
scene = GameLogic.getCurrentScene()
# get the active camera
cam = scene.active_camera
# get transform
transform = cam.camera_to_world
far
far
Returns/Sets the camera's far clip distance
Type: float
Sample Code
###### get camera far clip distance
# get the current scene
scene = GameLogic.getCurrentScene()
# get the active camera
cam = scene.active_camera
# get far clipping distance
farClip = cam.far
###### set camera far clip distance
# get the current scene
scene = GameLogic.getCurrentScene()
# get the active camera
cam = scene.active_camera
# set the clipping distance to 500
cam.far = 500.0
frustum_culling
frustum_culling
Returns/Sets whether or not camera is frustum culling.
Type: bool
True or False
1 or 0
Sample Code
######### get frusturm culling
get the current scene
scene = GameLogic.getCurrentScene()
# get the active camera
cam = scene.active_camera
# get frustum culling
culling = cam.frustum_culling
######## set frusturm culling
get the current scene
scene = GameLogic.getCurrentScene()
# get the active camera
cam = scene.active_camera
# set it to False
cam.frustum_culling = False
lens
lens
Returns/Sets the camera's lens value.
Type: float
Sample Code
###### get lens value
# get the current scene
scene = GameLogic.getCurrentScene()
# get the active camera
cam = scene.active_camera
# get lens
lens = cam.lens
###### set the lens value
# get the current scene
scene = GameLogic.getCurrentScene()
# get the active camera
cam = scene.active_camera
# set lens to 100.0
cam.lens = 100.0
modelview_matrix
modelview_matrix
Returns the camera's 4x4 model view matrix
Type: 4x4 matrix.
Sample Code
# get the current scene
scene = GameLogic.getCurrentScene()
# get the active camera
cam = scene.active_camera
# get matrix
matrix = cam.modelview_matrix
near
near
Return/Set the camera's near clip distance
Type: float
Sample Code
###### get camera's near clipping distance
# get the current scene
scene = GameLogic.getCurrentScene()
# get the active camera
cam = scene.active_camera
# get near clipping distance
nearClip = cam.near
###### set the camera's near clipping distance
# get the current scene
scene = GameLogic.getCurrentScene()
# get the active camera
cam = scene.active_camera
# set the clipping distance to 5
cam.near = 5.0
perspective
perspective
Return/Set whether or not camera is using a perspective transform
Type: Bool
True or False
1 or 0
Sample Code
###### get if camera using perspective transform
# get the current scene
scene = GameLogic.getCurrentScene()
# get the active camera
cam = scene.active_camera
# camera using perspective view?
perspective = cam.perspective
###### set camera perspective transform
# get the current scene
scene = GameLogic.getCurrentScene()
# get the active camera
cam = scene.active_camera
# set camera to orthographic view
cam.perspective = False
projection_matrix
projection_matrix
Return/Set camera's 4x4 projection matrix
Type: 4 x 4 matrix
Sample Code
###### get the camera's projection matrix
# get the current scene
scene = GameLogic.getCurrentScene()
# get the active camera
cam = scene.active_camera
# get projection matrix
matrix = cam.projection_matrix
###### set the camera's projection matrix
# get the current scene
scene = GameLogic.getCurrentScene()
# get the active camera
cam = scene.active_camera
# your four by four matrix
matrix = [ your four by four matrix here]
# set projection matrix
cam.projection_matrix = matrix
world_to_camera
world_to_camera
Returns camera's world to camera transform
Type: 4x4 matrix.
Sample Code
# get the current scene
scene = GameLogic.getCurrentScene()
# get the active camera
cam = scene.active_camera
# get transform
transform = cam.world_to_camera
Constants
INSIDE
a return value for
sphereInsideFrustum() and boxInsideFrustum()
INTERSECT
a return value for
sphereInsideFrustum() and boxInsideFrustum()
OUTSIDE
a return value for
sphereInsideFrustum() and boxInsideFrustum()
|