Class KX_VertexProxy (2.48)


Methods
getNormal setNormal
getRGBA setRGBA
getUV setUV
getUV2 setUV2
getXYZ setXYZ
 
Variables
a UV
b v
color / colour x
g XYZ
normal y
r z
u ----------
 
Constants
---------- ----------

Inherited Methods:  Class PyObjectPlus
isA ----------



Methods



getNormal

getNormal()

Returns the normal vector of the vertex.

Return type:   List [ nx, ny, nz]

nx = cosine of the normal to the world x-axis
Type:  float

ny = cosine of the normal to the world y-axis
Type:  float

nz = cosine of the normal to the world z-axis
Type:  float

Sample Code

# get controller
controller = GameLogic.getCurrentController()

# get object the controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# get the vertex normal vector
normal = vert.getNormal()

getRGBA

getRGBA()

Returns the vertex color.

Return type:  integer

Note:
It returns the vertex color as a 4 byte integer with one byte per color channel in the RGBA format.

The color red is returned as (-16776961)

Sample Code

# get controller
controller = GameLogic.getCurrentController()

# get object the controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# get the vertex color
color = vert.getRGBA()

getUV

getUV()

Returns the first UV coordinates for the vertex.

Return type:  list [ u, v]

u = x position on flat image being used as uv map
Type:  float

v = y position on flat image being used as uv map
Type:  float

Note:
Make sure the object has been UV mapped.

Sample Code

# get controller
controller = GameLogic.getCurrentController()

# get object the controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# get the UV position of the vertex
pos = vert.getUV()

getUV2

getUV2()

Returns the second UV coordinates for the vertex.

Return type:  list [ u, v]

u = x position on flat image being used as uv map
Type:  float

v = y position on flat image being used as uv map
Type:  float

Note:
Make sure the object has 2 UV maps.

Sample Code

# get controller
controller = GameLogic.getCurrentController()

# get object the controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# get the UV position of the vertex
pos = vert.getUV2()

getXYZ

getXYZ()

Returns the X, Y and Z position of the vertex in local coordinates (distance form object center).

Return Type:  float

Sample Code

# get controller
controller = GameLogic.getCurrentController()

# get object the controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first mesh
vert  = mesh.getVertex( 0, 0)

# get the position
pos = vert.getXYZ()

setNormal

setNormal(nor)

sets the normal vector of the vertex.   

nor:
Type: List [ nx, ny, nz]

nx = cosine of the normal to the world x-axis
Type:  float

ny = cosine of the normal to the world y-axis
Type:  float

nz = cosine of the normal to the world z-axis
Type:  float

Sample Code


# get controller
controller = GameLogic.getCurrentController()

# get object the controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# set the vertex normal vector
vert.setNormal([0.0, 0.0, -1.0])

setRGBA

setRGBA(col)

Sets the color of specified vertex.

col:
Type:     
RGBA format
or
a 4 byte integer with one byte per colour channel in the RGBA format.
 
red = [1.0, 0.0, 0.0, 1.0] 
or
red = (-16776961)

Note:
Doesn't work with Blender GLSL Materials

Note:
The color won't change if you are using 'Generate Display Lists'.
(User Preference menu >> Game >> Generate Display Lists)

Note:
For the alpha channel to work, alpha must be turned on.
Edit Mode >> Buttons Window >> Editing (F9) >> Texture tab >> Alpha

Sample Code

# get controller
controller = GameLogic.getCurrentController()

# get object the controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# set the vertex color
vert.setRGBA([ 1.0, 0.0, 0.0, 1.0])


Example Blend:


setUV

setUV(uv)

Sets the first UV coordinates for this vertex.

uv:
Type:  list [ u, v]

u = x position on flat image being used as uv map
Type:  float

v = y position on flat image being used as uv map
Type:  float

Note:
Make sure the object has been UV mapped.

Sample Code

# get controller
controller = GameLogic.getCurrentController()

# get object the controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# set the UV position
vert.setUV([ 1.0, 0.0])

setUV2

setUV2(uv)

Sets the second UV coordinates for this vertex.

uv:
Type:  list [ u, v]

u = x position on flat image being used as uv map
Type:  float

v = y position on flat image being used as uv map
Type:  float

Note:
Make sure the object has 2 UV maps.

Sample Code

# get controller
controller = GameLogic.getCurrentController()

# get object the controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# set the UV position
vert.setUV2([ 1.0, 0.0])

setXYZ

setXYZ(pos)

Sets the position of the vertex using local coordinates (distance from the object center).

pos:
Type: list [ x, y, z]

Sample Code

# get controller
controller = GameLogic.getCurrentController()

# get object the controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# set the position
vert.setXYZ([ 1.5, 1.0, -0.5])


Variables



a

a

gets/sets the alpha color channel of the vertex

Type:  float

Range: 0.0 to 1.0

Sample Code

###### get the vertex alpha color channel

# get controller
controller = GameLogic.getCurrentController()

# get object the controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# get the alpha color channel (RGBA)
aColor = vert.a

###### set the vertex alpha color channel

# get controller
controller = GameLogic.getCurrentController()

# get object the controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# set the alpha color channel (RGBA)
vert.a = 1.0

b

b

gets/sets the blue color channel of the vertex

Type:  float

Range:  0.00 to 1.00

Sample Code

###### get the vertex blue color channel

# get controller
controller = GameLogic.getCurrentController()

# get object the controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# get the blue color channel (RGBA)
bColor = vert.b

###### set the vertex blue color channel

# get controller
controller = GameLogic.getCurrentController()

# get object the controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# set the blue color channel (RGBA)
vert.b = 1.0

color / colour

color / colour

gets/sets the vertex color.

Return type: list [ r, g, b, a]

     RGBA Format:  red returned as [1.0, 0.0, 0.0, 1.0]

Note:
You can't set the vertex color if you are using 'Generate Display Lists'.
(User Preference menu >> Game >> Generate Display Lists)

Note:
For the alpha channel to work, alpha button must be enabled.
Edit Mode >> Buttons Window >> Editing (F9) >> Texture tab >> Alpha

Sample Code

###### get vertex color

# get controller
controller = GameLogic.getCurrentController()

# get object the controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# get color of this vertex
col = vert.color

###### set vertex color

# get controller
controller = GameLogic.getCurrentController()

# get object the controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# set the color of this vertex to red
vert.color = [ 1.0, 0.0, 0.0, 1.0]

g

g

gets/sets the green color channel of the vertex

Type:  float

Range:  0.0 to 1.0

Sample Code



###### get the vertex green color channel

# get controller
controller = GameLogic.getCurrentController()

# get object the controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# get the green color channel (RGBA)
gColor = vert.g

###### set the vertex green color channel

# get controller
controller = GameLogic.getCurrentController()

# get object the controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# set the green color channel (RGBA)
vert.g = 1.0

normal

normal

gets/sets the normal vector of the vertex.

Type: List [ nx, ny, nz]

nx = cosine of the normal to the world x-axis
Type:  float

ny = cosine of the normal to the world y-axis
Type:  float

nz = cosine of the normal to the world z-axis
Type:  float

Sample Code

###### get the vertex normal vector

# get controller
controller = GameLogic.getCurrentController()

# get object the controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# get normal of this vertex
nor = vert.normal

###### set the vertex normal vector

# get controller
controller = GameLogic.getCurrentController()

# get object the controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# set the normal of this vertex
vert.normal = [ 0.0, 0.0, 1.0]

r

r

gets/sets the red color channel of the vertex

Type:  float

Range:  0.0 to 1.0

Sample Code

###### get the vertex red color channel

# get controller
controller = GameLogic.getCurrentController()

# get object the controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# get the red color channel (RGBA)
rColor = vert.r

###### set the vertex red color channel

# get controller
controller = GameLogic.getCurrentController()

# get object the controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# set the red color channel (RGBA)
vert.r = 1.0

u

u

gets/sets the u position of the vertex on the UV map.

Type:  float

Sample Code

###### get the vertex u position (UV map)

# get controller
controller = GameLogic.getCurrentController()

# get object the controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# get u position of the vertex UV map
u_pos = vert.u

###### set the vertex u position (UV map)

# get controller
controller = GameLogic.getCurrentController()

# get object the controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# set the the u position of the vertex UV map
vert.u = 1.0

UV

UV

gets/sets the UV coordinates for this vertex

Type:
List [ ux, uy]
float values

Sample Code

###### get the vertex UV coordinates

# get controller
controller = GameLogic.getCurrentController()

# get object the controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# get UV coordinates for this vertex
uv = vert.UV

###### set the vertex UV coordinates

# get controller
controller = GameLogic.getCurrentController()

# get object the controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# set the UV coordinates for this vertex
vert.UV = [ 1.0, 1.0]

v

v

gets/sets the v position of the vertex UV map.

Type:  float

Sample Code

######  get the vertex v position (UV map)

# get controller
controller = GameLogic.getCurrentController()

# get object the controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# get v position of the vertex UV map
v_pos = vert.v

######  set the vertex v position (UV map)

# get controller
controller = GameLogic.getCurrentController()

# get object the controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# set the the v position of the vertex UV map
vert.v = 1.0

x

x

gets/sets the x position of the vertex using local coordinates (distance from the object center).

Type:  float

Sample Code

######  get the vertex x position

# get controller
controller = GameLogic.getCurrentController()

# get object the controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# get x position of the vertex
x_pos = vert.x

######  set the vertex x position

# get controller
controller = GameLogic.getCurrentController()

# get object the controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# set the the x position of this vertex
vert.x = 1.0

XYZ

XYZ

gets/sets the position of the vertex using local coordinates (distance from the object center).

Type: list [ x, y, z]
  float values

Sample Code

###### get the vertex position

# get controller
controller = GameLogic.getCurrentController()

# get object controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# get position of this vertex
pos = vert.XYZ

###### set the vertex position

# get controller
controller = GameLogic.getCurrentController()

# get object controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# set the position of this vertex
vert.XYZ = [ 1.0, 1.0, 1.0]

y

y

gets/sets the y position of the vertex using local coordinates (distance from the object center).

Type:  float

Sample Code


###### get the vertex y position

# get controller
controller = GameLogic.getCurrentController()

# get object controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# get y position of the vertex
y_pos = vert.y

###### set the vertex y position

# get controller
controller = GameLogic.getCurrentController()

# get object controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# set the the y position of this vertex
vert.y = 1.0

z

z

gets/sets the z position of the vertex using local coordinates (distance from the object center).

Type:  float

Sample Code

###### get the vertex z position

# get controller
controller = GameLogic.getCurrentController()

# get object controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# get z position of the vertex
z_pos = vert.z

###### set the vertex z position

# get controller
controller = GameLogic.getCurrentController()

# get object controller is attached to
owner = controller.getOwner()

# get the mesh
mesh = owner.getMesh()

# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)

# set the the z position of this vertex
vert.z = 1.0



Blender 3D
Game Engine