GetVertexPosition

This function returns a surface vertex position.

Syntax

Parameters

Returns

Returns the position of the specified vertex.

Example

--Create a window
window = Window:Create()
context = Context:Create(window)
world = World:Create()
local camera = Camera:Create()
camera:SetRotation(35,0,0)
camera:Move(0,0,-3)
local light = DirectionalLight:Create()
light:SetRotation(35,35,0)

--Create a model
model = Model:Box()

--Load a material
local material = Material:Load("Materials/Concrete/concrete_dirty.mat")
model:SetMaterial(material)
material:Release()

while true do
if window:Closed() or window:KeyHit(Key.Escape) then return false end

Time:Update()

--===========================================
--Begin Model Modification
--===========================================
local surface = model:GetSurface(0)
for v=0, surface:CountVertices()-1 do

local position = surface:GetVertexPosition(v)
local normal = surface:GetVertexNormal(v)
local texcoords = surface:GetVertexTexCoords(v)
local color = surface:GetVertexColor(v)

position = position + normal * Vec3(Math:Sin(Time:GetCurrent()/10.0) * 0.005)
texcoords.x = texcoords.x + Time:GetSpeed()/100.0
texcoords.y = texcoords.y + Time:GetSpeed()/100.0
color.r = Math:Mod(color.r + Time:GetSpeed()*0.01,1)
color.g = Math:Mod(color.g + Time:GetSpeed()*0.011,1)
color.b = Math:Mod(color.b + Time:GetSpeed()*0.012,1)

surface:SetVertexPosition(v,position)
surface:SetVertexNormal(v,normal)
surface:SetVertexTexCoords(v,texcoords)
surface:SetVertexColor(v,color)
end

--Update the surface AABB
surface:UpdateAABB()

--Update the model local and global AABBs so the renderer keeps proper track of it
model:UpdateAABB(Entity.LocalAABB)
model:UpdateAABB(Entity.GlobalAABB)

--===========================================
--End Model Modification
--===========================================

world:Update()
world:Render()
context:Sync()

end