base class — KX_GameObject
A Camera object.
See sphereInsideFrustum and boxInsideFrustum
See sphereInsideFrustum and boxInsideFrustum
See sphereInsideFrustum and boxInsideFrustum
The camera’s lens value.
Type: | float |
---|
The camera’s field of view value.
Type: | float |
---|
The camera’s view scale when in orthographic mode.
Type: | float |
---|
The camera’s near clip distance.
Type: | float |
---|
The camera’s far clip distance.
Type: | float |
---|
True if this camera has a perspective transform, False for an orthographic projection.
Type: | boolean |
---|
True if this camera is frustum culling.
Type: | boolean |
---|
This camera’s 4x4 projection matrix.
Note
This is the identity matrix prior to rendering the first frame (any Python done on frame 1).
Type: | 4x4 Matrix [[float]] |
---|
This camera’s 4x4 model view matrix. (read-only).
Type: | 4x4 Matrix [[float]] |
---|
Note
This matrix is regenerated every frame from the camera’s position and orientation. Also, this is the identity matrix prior to rendering the first frame (any Python done on frame 1).
This camera’s camera to world transform. (read-only).
Type: | 4x4 Matrix [[float]] |
---|
Note
This matrix is regenerated every frame from the camera’s position and orientation.
This camera’s world to camera transform. (read-only).
Type: | 4x4 Matrix [[float]] |
---|
Note
Regenerated every frame from the camera’s position and orientation.
Note
This is camera_to_world inverted.
True when the camera is used as a viewport, set True to enable a viewport for this camera.
Type: | boolean |
---|
Tests the given sphere against the view frustum.
Parameters: |
|
---|---|
Returns: | |
Return type: | integer |
Note
When the camera is first initialized the result will be invalid because the projection matrix has not been set.
from bge import logic
cont = logic.getCurrentController()
cam = cont.owner
# A sphere of radius 4.0 located at [x, y, z] = [1.0, 1.0, 1.0]
if (cam.sphereInsideFrustum([1.0, 1.0, 1.0], 4) != cam.OUTSIDE):
# Sphere is inside frustum !
# Do something useful !
else:
# Sphere is outside frustum
Tests the given box against the view frustum.
Parameters: | box (list of lists) – Eight (8) corner points of the box (in world coordinates.) |
---|---|
Returns: | INSIDE, OUTSIDE or INTERSECT |
Note
When the camera is first initialized the result will be invalid because the projection matrix has not been set.
from bge import logic
cont = logic.getCurrentController()
cam = cont.owner
# Box to test...
box = []
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])
if (cam.boxInsideFrustum(box) != cam.OUTSIDE):
# Box is inside/intersects frustum !
# Do something useful !
else:
# Box is outside the frustum !
Tests the given point against the view frustum.
Parameters: | point (3D Vector) – The point to test (in world coordinates.) |
---|---|
Returns: | True if the given point is inside this camera’s viewing frustum. |
Return type: | boolean |
Note
When the camera is first initialized the result will be invalid because the projection matrix has not been set.
from bge import logic
cont = logic.getCurrentController()
cam = cont.owner
# Test point [0.0, 0.0, 0.0]
if (cam.pointInsideFrustum([0.0, 0.0, 0.0])):
# Point is inside frustum !
# Do something useful !
else:
# Box is outside the frustum !
Returns the camera-to-world transform.
Returns: | the camera-to-world transform matrix. |
---|---|
Return type: | matrix (4x4 list) |
Returns the world-to-camera transform.
This returns the inverse matrix of getCameraToWorld().
Returns: | the world-to-camera transform matrix. |
---|---|
Return type: | matrix (4x4 list) |
Set this cameras viewport ontop of all other viewport.
Sets the region of this viewport on the screen in pixels.
Use bge.render.getWindowHeight and bge.render.getWindowWidth to calculate values relative to the entire display.
Parameters: |
|
---|
Gets the position of an object projected on screen space.
# For an object in the middle of the screen, coord = [0.5, 0.5]
coord = camera.getScreenPosition(object)
Parameters: | object (KX_GameObject or 3D Vector) – object name or list [x, y, z] |
---|---|
Returns: | the object’s position in screen coordinates. |
Return type: | list [x, y] |
Gets the vector from the camera position in the screen coordinate direction.
Parameters: |
|
---|---|
Return type: | 3D Vector |
Returns: | The vector from screen coordinate. |
# Gets the vector of the camera front direction:
m_vect = camera.getScreenVect(0.5, 0.5)
Look towards a screen coordinate (x, y) and find first object hit within dist that matches prop. The ray is similar to KX_GameObject->rayCastTo.
Parameters: |
|
---|---|
Return type: | |
Returns: | the first object hit or None if no object or object does not match prop |
# Gets an object with a property "wall" in front of the camera within a distance of 100:
target = camera.getScreenRay(0.5, 0.5, 100, "wall")