Blitz3D+ Command Reference

VertexW# ( surface,index[,coord_set] )

Parameters

surface - surface handle
index - index of the vertex, from 0 to CountVertices( surface )-1
coord_set (optional) - which texture coordinate set to read:
0: first coordinate set (default)
1: second coordinate set

Description

Returns the w texture coordinate of a vertex - always 1.0 in this engine.

The w coordinate is a leftover from Blitz3D's original 3-component texture coordinates. Vertices only store u and v now: the w values passed to AddVertex and VertexTexCoords are accepted but not kept, and this command simply returns 1.0 whatever was written. It exists so old code keeps compiling and running.

For the coordinates that actually shape texture mapping, read VertexU and VertexV.

See also: VertexU, VertexV, VertexTexCoords.

Example

; VertexW Example
; ---------------

; Every vertex stores a position, a normal, a colour and a set of
; uv texture coordinates. VertexW reads back the w texture coordinate of one vertex.
; Space steps the magenta marker through the pyramid's five vertices.

Graphics3D 640,480
SetBuffer BackBuffer()

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

light=CreateLight()
RotateEntity light,45,45,0

; A small pyramid: base corners v0-v3 and apex v4
mesh=CreateMesh()
surf=CreateSurface(mesh)
v0=AddVertex(surf,-1,0,-1,0,1,0)
v1=AddVertex(surf,1,0,-1,1,1,0.25)
v2=AddVertex(surf,1,0,1,1,0,0.5)
v3=AddVertex(surf,-1,0,1,0,0,0.75)
v4=AddVertex(surf,0,1.5,0,0.5,0.5,1)

; Texture the pyramid so the uv mapping is visible (fullbright)
tex=LoadTexture("media/b3dlogo.jpg")
EntityTexture mesh,tex
EntityFX mesh,1

; Sides then base, wound clockwise seen from outside
AddTriangle surf,v0,v4,v1
AddTriangle surf,v1,v4,v2
AddTriangle surf,v2,v4,v3
AddTriangle surf,v3,v4,v0
AddTriangle surf,v2,v1,v0
AddTriangle surf,v3,v2,v0

; A marker sphere parented to the mesh highlights the queried vertex
marker=CreateSphere()
ScaleEntity marker,0.1,0.1,0.1
EntityColor marker,255,0,255
EntityFX marker,1
EntityParent marker,mesh

index=0

While Not KeyDown(1)

    ; Space cycles through vertices 0-4
    If KeyHit(57) Then index=(index+1) Mod 5

    ; Query the highlighted vertex - the documented command
    value#=VertexW(surf,index)

    ; Park the marker on the queried vertex (local mesh coordinates)
    PositionEntity marker,VertexX(surf,index),VertexY(surf,index),VertexZ(surf,index)

    TurnEntity mesh,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,"Space: next vertex   Arrow keys: move camera   Esc: exit"
    Text 0,20,"VertexW(surf,"+index+") = "+value
    Text 0,40,"w is stored per vertex but reserved for future use"

    Flip

Wend

End

Index