Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/gameengine/PyDoc')
-rw-r--r--source/gameengine/PyDoc/GameLogic.py7
-rw-r--r--source/gameengine/PyDoc/KX_MeshProxy.py50
-rw-r--r--source/gameengine/PyDoc/KX_SCA_ReplaceMeshActuator.py50
-rw-r--r--source/gameengine/PyDoc/KX_Scene.py68
4 files changed, 169 insertions, 6 deletions
diff --git a/source/gameengine/PyDoc/GameLogic.py b/source/gameengine/PyDoc/GameLogic.py
index b372cec0481..08f71e50f97 100644
--- a/source/gameengine/PyDoc/GameLogic.py
+++ b/source/gameengine/PyDoc/GameLogic.py
@@ -86,6 +86,12 @@ def getCurrentController():
@rtype: L{SCA_PythonController}
"""
+def getCurrentScene():
+ """
+ Gets the current Scene.
+
+ @rtype: L{KX_Scene}
+ """
def addActiveActuator(actuator, activate):
"""
Activates the given actuator.
@@ -118,3 +124,4 @@ def stopDSP():
Only the fmod sound driver supports this.
DSP can be computationally expensive.
"""
+
diff --git a/source/gameengine/PyDoc/KX_MeshProxy.py b/source/gameengine/PyDoc/KX_MeshProxy.py
index 41955c34345..f93cd5c1f7b 100644
--- a/source/gameengine/PyDoc/KX_MeshProxy.py
+++ b/source/gameengine/PyDoc/KX_MeshProxy.py
@@ -6,16 +6,56 @@ class KX_MeshProxy:
A mesh object.
You can only change the vertex properties of a mesh object, not the mesh topology.
+
+ To use mesh objects effectively, you should know a bit about how the game engine handles them.
+ 1. Mesh Objects are converted from Blender at scene load.
+ 2. The Converter groups polygons by Material. This means they can be sent to the
+ renderer efficiently. A material holds:
+ 1. The texture.
+ 2. The Blender material.
+ 3. The Tile properties
+ 4. The face properties - (From the "Texture Face" panel)
+ 5. Transparency & z sorting
+ 6. Light layer
+ 7. Polygon shape (triangle/quad)
+ 8. Game Object
+ 3. Verticies will be split by face if necessary. Verticies can only be shared between
+ faces if:
+ 1. They are at the same position
+ 2. UV coordinates are the same
+ 3. Their normals are the same (both polygons are "Set Smooth")
+ 4. They are the same colour
+ For example: a cube has 24 verticies: 6 faces with 4 verticies per face.
+
+ The correct method of iterating over every L{KX_VertexProxy} in a game object::
+ import GameLogic
+
+ co = GameLogic.getcurrentController()
+ obj = co.getOwner()
+
+ m_i = 0
+ mesh = obj.getMesh(m_i) # There can be more than one mesh...
+ while mesh != None:
+ for mat in range(mesh.getNumMaterials()):
+ for v_index in range(mesh.getVertexArrayLength(mat)):
+ vertex = mesh.getVertex(mat, v_index)
+ # Do something with vertex here...
+ # ... eg: colour the vertex red.
+ vertex.colour = [1.0, 0.0, 0.0, 1.0]
+ m_i += 1
+ mesh = obj.getMesh(m_i)
+
+
"""
- def GetNumMaterials():
+ def getNumMaterials():
"""
Gets the number of materials associated with this object.
@rtype: integer
"""
- def GetMaterialName(matid):
+ def getMaterialName(matid):
"""
Gets the name of the specified material.
@@ -24,7 +64,7 @@ class KX_MeshProxy:
@rtype: string
@return: the attached material name.
"""
- def GetTextureName(matid):
+ def getTextureName(matid):
"""
Gets the name of the specified material's texture.
@@ -33,7 +73,7 @@ class KX_MeshProxy:
@rtype: string
@return: the attached material's texture name.
"""
- def GetVertexArrayLength(matid):
+ def getVertexArrayLength(matid):
"""
Gets the length of the vertex array associated with the specified material.
@@ -44,7 +84,7 @@ class KX_MeshProxy:
@rtype: integer
@return: the number of verticies in the vertex array.
"""
- def GetVertex(matid, index):
+ def getVertex(matid, index):
"""
Gets the specified vertex from the mesh object.
diff --git a/source/gameengine/PyDoc/KX_SCA_ReplaceMeshActuator.py b/source/gameengine/PyDoc/KX_SCA_ReplaceMeshActuator.py
index da1fbe6651e..63100e40532 100644
--- a/source/gameengine/PyDoc/KX_SCA_ReplaceMeshActuator.py
+++ b/source/gameengine/PyDoc/KX_SCA_ReplaceMeshActuator.py
@@ -6,13 +6,55 @@ class KX_SCA_ReplaceMeshActuator(SCA_IActuator):
"""
Edit Object actuator, in Replace Mesh mode.
+ Example::
+ # Level-of-detail
+ # Switch a game object's mesh based on its depth in the camera view.
+ # +----------+ +-----------+ +-------------------------------------+
+ # | Always +-----+ Python +-----+ Edit Object (Replace Mesh) LOD.Mesh |
+ # +----------+ +-----------+ +-------------------------------------+
+ import GameLogic
+
+ # List detail meshes here
+ # Mesh (name, near, far)
+ # Meshes overlap so that they don't 'pop' when on the edge of the distance.
+ meshes = ((".Hi", 0.0, -20.0),
+ (".Med", -15.0, -50.0),
+ (".Lo", -40.0, -100.0)
+ )
+
+ co = GameLogic.getCurrentController()
+ obj = co.getOwner()
+ act = co.getActuator("LOD." + obj.getName())
+ cam = GameLogic.getCurrentScene().active_camera
+
+ def Depth(pos, plane):
+ return pos[0]*plane[0] + pos[1]*plane[1] + pos[2]*plane[2] + plane[3]
+
+ # Depth is negative and decreasing further from the camera
+ depth = Depth(obj.position, cam.world_to_camera[2])
+
+ newmesh = None
+ curmesh = None
+ # Find the lowest detail mesh for depth
+ for mesh in meshes:
+ if depth < mesh[1] and depth > mesh[2]:
+ newmesh = mesh
+ if "ME" + obj.getName() + mesh[0] == act.getMesh():
+ curmesh = mesh
+
+ if newmesh != None and "ME" + obj.getName() + newmesh[0] != act.getMesh():
+ # The mesh is a different mesh - switch it.
+ # Check the current mesh is not a better fit.
+ if curmesh == None or curmesh[1] < depth or curmesh[2] > depth:
+ act.setMesh(obj.getName() + newmesh[0])
+ GameLogic.addActiveActuator(act, True)
+
@warning: Replace mesh actuators will be ignored if at game start, the
named mesh doesn't exist.
This will generate a warning in the console:
C{ERROR: GameObject I{OBName} ReplaceMeshActuator I{ActuatorName} without object}
-
"""
def setMesh(name):
"""
@@ -20,4 +62,10 @@ class KX_SCA_ReplaceMeshActuator(SCA_IActuator):
@type name: string
"""
+ def getMesh():
+ """
+ Returns the name of the mesh that will replace the current one.
+
+ @rtype: string
+ """
diff --git a/source/gameengine/PyDoc/KX_Scene.py b/source/gameengine/PyDoc/KX_Scene.py
new file mode 100644
index 00000000000..2ba57dc9d78
--- /dev/null
+++ b/source/gameengine/PyDoc/KX_Scene.py
@@ -0,0 +1,68 @@
+# $Id$
+# Documentation for KX_Scene.py
+
+class KX_Scene:
+ """
+ Scene.
+
+ The activity culling stuff is supposed to disable logic bricks when their owner gets too far
+ from the active camera. It was taken from some code lurking at the back of KX_Scene - who knows
+ what it does!
+
+ Example::
+ import GameLogic
+
+ # get the scene
+ scene = GameLogic.getCurrentScene()
+
+ # print all the objects in the scene
+ for obj in scene.getObjectList():
+ print obj.getName()
+
+ # get an object named 'Cube'
+ obj = scene.getObjectList()["OBCube"]
+
+ # get the first object in the scene.
+ obj = scene.getObjectList()[0]
+
+ Example::
+ # Get the depth of an object in the camera view.
+ import GameLogic
+
+ obj = GameLogic.getCurrentController().getOwner()
+ cam = GameLogic.getCurrentScene().active_camera
+
+ # Depth is negative and decreasing further from the camera
+ depth = obj.position[0]*cam.world_to_camera[2][0] + obj.position[1]*cam.world_to_camera[2][1] + obj.position[2]*cam.world_to_camera[2][2] + cam.world_to_camera[2][3]
+
+ @ivar name: The scene's name
+ @type name: string
+ @ivar active_camera: The current active camera
+ @type active_camera: L{KX_Camera}
+ @ivar suspended: True if the scene is suspended.
+ @type suspended: boolean
+ @ivar activity_culling: True if the scene is activity culling
+ @type activity_culling: boolean
+ @ivar activity_culling_radius: The distance outside which to do activity culling. Measured in manhattan distance.
+ @type activity_culling_radius: float
+ """
+
+ def getLightList():
+ """
+ Returns the list of lights in the scene.
+
+ @rtype: list [L{KX_Light}]
+ """
+ def getObjectList():
+ """
+ Returns the list of objects in the scene.
+
+ @rtype: list [L{KX_GameObject}]
+ """
+ def getName():
+ """
+ Returns the name of the scene.
+
+ @rtype: string
+ """
+