Blitz3D+ Command Reference

CountVertices ( surface )

Parameters

surface - surface handle

Description

Returns the number of vertices in a surface.

Vertex index numbers run from 0 to CountVertices(surface)-1, so this sets the loop bounds when you sweep a surface's vertices - reading positions with VertexX/VertexY/VertexZ, or moving them all with VertexCoords for wave and deformation effects.

See also: CountTriangles, AddVertex, VertexX, VertexCoords.

Example

; CountVertices Example
; ---------------------

; CountVertices returns how many vertices one surface holds.
; Summing it over every surface of a loaded model gives the model's
; full vertex count - a handy performance statistic.

Graphics3D 640,480
SetBuffer BackBuffer()

camera=CreateCamera()
PositionEntity camera,0,0,-4

light=CreateLight()
RotateEntity light,30,40,0

; Load a real model to inspect
drum=LoadMesh("media/oil-drum/oildrum.3ds")

; Shrink the drum into a 2-unit box so it fits our view
FitMesh drum,-1,-1,-1,2,2,2,1

; Total the vertices surface by surface - the documented command
verts=0
For i=1 To CountSurfaces(drum)
    verts=verts+CountVertices(GetSurface(drum,i))
Next

While Not KeyDown(1)

    TurnEntity drum,0,1,0

    ; Arrow keys move the camera
    If KeyDown(200) Then MoveEntity camera,0,0,0.1
    If KeyDown(208) Then MoveEntity camera,0,0,-0.1
    If KeyDown(203) Then TurnEntity camera,0,1,0
    If KeyDown(205) Then TurnEntity camera,0,-1,0

    RenderWorld

    Text 0,0,"Arrow keys: move camera   Esc: exit"
    Text 0,20,"CountVertices totalled over "+CountSurfaces(drum)+" surfaces = "+verts

    Flip

Wend

End

Index