頂点の取得

2010/8/12

Blender2.49

頂点はメッシュを取得後、 getVertex メソッドを用いて取得する。引数としてマテリアルIDと頂点IDが必要。 マテリアルID、頂点IDはそれぞれが格納されているリストのIndexで、作成した順に与えられる整数。

obj = GameLogic.getCurrentController().owner

#メッシュの取得
mesh = obj.meshes[0]

#マテリアルIDの取得
mat = mesh.materials[0]
mat_id = mat.getMaterialIndex()

#頂点の取得
for vex_id in range(mesh.getVertexArrayLength(mat_id)):
    vex = mesh.getVertex(mat_id,vex_id)

    #頂点座標の取得
    x,y,z = vex.XYZ

    #頂点カラーの取得
    color = vex.color

頂点データから頂点座標、頂点カラー、UVマップの取得・変更が行える。

Class KX_MeshProxy .getVertex()
http://www.blender.org/documentation/249PythonDoc/GE/GameTypes.KX_MeshProxy-class.html#getVertex

Class KX_VertexProxy
http://www.blender.org/documentation/249PythonDoc/GE/GameTypes.KX_VertexProxy-class.html

Tutorials for Blender :Class KX_VertexProxy (2.48)
http://www.tutorialsforblender3d.com/GameModule/Modules248/ClassKX_VertexProxy.html