SetColor
This function sets an entity's color.
Syntax
- void SetColor(float r, float g, float b, float a=1.0, int mode=Color::Diffuse, bool recursive=false)
- void SetColor(float r, float g, float b )
- void SetColor(const Vec4& color, int mode=Color::Diffuse, bool recursive=false)
Parameters
- r: the red component of the color being set.
- g: the green component of the color being set.
- b: the blue component of the color being set.
- a: the alpha component of the color being set.
- color: the color being set.
- mode: the color to set. This may be one of the following values:
- recursive: if set to true, the entity's children will have their color set recursively.
Returns
If the entity is hidden, true is returned, otherwise false is returned.
Example
#include "Leadwerks.h"
using namespace Leadwerks;
Entity* entity[3] = { 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, -6);
Light* light = DirectionalLight::Create();
light->SetRotation(35, 35, 0);
//Create the ground
Model* ground = Model::Box(10, 1, 10);
ground->SetPosition(0, 0, -0.5);
ground->SetColor(0, 1, 0, 0);
//Create a shape
Shape* shape = Shape::Box(0, 0, 0, 0, 0, 0, 10, 1, 10);
ground->SetShape(shape);
shape->Release();
//Create a box
Model* box = Model::Box(1, 1, 1);
box->SetPosition(0, 5, 0);
box->SetColor(0, 0, 1, 0);
box->SetMass(1);
//Create a shape
shape = Shape::Box(0, 0, 0, 0, 0, 0, 1, 1, 1);
box->SetShape(shape);
shape->Release();
while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;
Leadwerks::Time::Update();
world->Update();
world->Render();
context->Sync();
}
return 0;
}