~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to doc/python_api/rst/bge_types/bge.types.KX_MeshProxy.rst

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
KX_MeshProxy(SCA_IObject)
 
2
=========================
 
3
 
 
4
.. module:: bge.types
 
5
 
 
6
base class --- :class:`SCA_IObject`
 
7
 
 
8
.. class:: KX_MeshProxy(SCA_IObject)
 
9
 
 
10
   A mesh object.
 
11
 
 
12
   You can only change the vertex properties of a mesh object, not the mesh topology.
 
13
 
 
14
   To use mesh objects effectively, you should know a bit about how the game engine handles them.
 
15
 
 
16
   #. Mesh Objects are converted from Blender at scene load.
 
17
   #. The Converter groups polygons by Material.  This means they can be sent to the renderer efficiently.  A material holds:
 
18
 
 
19
      #. The texture.
 
20
      #. The Blender material.
 
21
      #. The Tile properties
 
22
      #. The face properties - (From the "Texture Face" panel)
 
23
      #. Transparency & z sorting
 
24
      #. Light layer
 
25
      #. Polygon shape (triangle/quad)
 
26
      #. Game Object
 
27
 
 
28
   #. Vertices will be split by face if necessary.  Vertices can only be shared between faces if:
 
29
 
 
30
      #. They are at the same position
 
31
      #. UV coordinates are the same
 
32
      #. Their normals are the same (both polygons are "Set Smooth")
 
33
      #. They are the same color, for example: a cube has 24 vertices: 6 faces with 4 vertices per face.
 
34
 
 
35
   The correct method of iterating over every :class:`KX_VertexProxy` in a game object
 
36
   
 
37
   .. code-block:: python
 
38
 
 
39
      from bge import logic
 
40
 
 
41
      cont = logic.getCurrentController()
 
42
      object = cont.owner
 
43
 
 
44
      for mesh in object.meshes:
 
45
         for m_index in range(len(mesh.materials)):
 
46
            for v_index in range(mesh.getVertexArrayLength(m_index)):
 
47
               vertex = mesh.getVertex(m_index, v_index)
 
48
               # Do something with vertex here...
 
49
               # ... eg: color the vertex red.
 
50
               vertex.color = [1.0, 0.0, 0.0, 1.0]
 
51
 
 
52
   .. attribute:: materials
 
53
 
 
54
      :type: list of :class:`KX_BlenderMaterial` or :class:`KX_PolygonMaterial` types
 
55
 
 
56
   .. attribute:: numPolygons
 
57
 
 
58
      :type: integer
 
59
 
 
60
   .. attribute:: numMaterials
 
61
 
 
62
      :type: integer
 
63
 
 
64
   .. method:: getMaterialName(matid)
 
65
 
 
66
      Gets the name of the specified material.
 
67
 
 
68
      :arg matid: the specified material.
 
69
      :type matid: integer
 
70
      :return: the attached material name.
 
71
      :rtype: string
 
72
 
 
73
   .. method:: getTextureName(matid)
 
74
 
 
75
      Gets the name of the specified material's texture.
 
76
 
 
77
      :arg matid: the specified material
 
78
      :type matid: integer
 
79
      :return: the attached material's texture name.
 
80
      :rtype: string
 
81
 
 
82
   .. method:: getVertexArrayLength(matid)
 
83
 
 
84
      Gets the length of the vertex array associated with the specified material.
 
85
 
 
86
      There is one vertex array for each material.
 
87
 
 
88
      :arg matid: the specified material
 
89
      :type matid: integer
 
90
      :return: the number of verticies in the vertex array.
 
91
      :rtype: integer
 
92
 
 
93
   .. method:: getVertex(matid, index)
 
94
 
 
95
      Gets the specified vertex from the mesh object.
 
96
 
 
97
      :arg matid: the specified material
 
98
      :type matid: integer
 
99
      :arg index: the index into the vertex array.
 
100
      :type index: integer
 
101
      :return: a vertex object.
 
102
      :rtype: :class:`KX_VertexProxy`
 
103
 
 
104
   .. method:: getPolygon(index)
 
105
 
 
106
      Gets the specified polygon from the mesh.
 
107
 
 
108
      :arg index: polygon number
 
109
      :type index: integer
 
110
      :return: a polygon object.
 
111
      :rtype: :class:`PolyProxy`
 
112
 
 
113
   .. method:: transform(matid, matrix)
 
114
 
 
115
      Transforms the vertices of a mesh.
 
116
 
 
117
      :arg matid: material index, -1 transforms all.
 
118
      :type matid: integer
 
119
      :arg matrix: transformation matrix.
 
120
      :type matrix: 4x4 matrix [[float]]
 
121
 
 
122
   .. method:: transformUV(matid, matrix, uv_index=-1, uv_index_from=-1)
 
123
 
 
124
      Transforms the vertices UV's of a mesh.
 
125
 
 
126
      :arg matid: material index, -1 transforms all.
 
127
      :type matid: integer
 
128
      :arg matrix: transformation matrix.
 
129
      :type matrix: 4x4 matrix [[float]]
 
130
      :arg uv_index: optional uv index, -1 for all, otherwise 0 or 1.
 
131
      :type uv_index: integer
 
132
      :arg uv_index_from: optional uv index to copy from, -1 to transform the current uv.
 
133
      :type uv_index_from: integer
 
134