GetVertexColor

This function returns a surface vertex color.

Syntax

Parameters

Returns

Returns the color of the specified vertex.

Example

#include "Leadwerks.h"

using namespace Leadwerks;

Model* model = NULL;

int main(int argc, const char *argv[])
{
Leadwerks::Window* window = Leadwerks::Window::Create();
Context* context = Context::Create(window);
World* world = World::Create();
Camera* camera = Camera::Create();
camera->SetRotation(35, 0, 0);
camera->Move(0, 0, -3);
Light* light = DirectionalLight::Create();
light->SetRotation(35, 35, 0);

//Create a model
model = Model::Box();

//Load a material
Material* material = Material::Load("Materials/Concrete/concrete_dirty.mat");
model->SetMaterial(material);
material->Release();
while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;

Leadwerks::Time::Update();

//===========================================
//Begin Model Modification
//===========================================
Surface* surface = model->GetSurface(0);
for (int v = 0; v < surface->CountVertices(); v++)
{
Vec3 position = surface->GetVertexPosition(v);
Vec3 normal = surface->GetVertexNormal(v);
Vec2 texcoords = surface->GetVertexTexCoords(v);
Vec4 color = surface->GetVertexColor(v);

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

surface->SetVertexPosition(v, position);
surface->SetVertexNormal(v, normal);
surface->SetVertexTexCoords(v, texcoords);
surface->SetVertexColor(v, color);
}

//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 | Entity::GlobalAABB);

//===========================================
//End Model Modification
//===========================================

world->Update();
world->Render();
context->Sync(false);
}
return 0;
}