Add
This function adds the contents of one surface to another. This can be used to collapse multiple surfaces into one.
Syntax
- void Add(Surface* surface, const Mat4& mat)
Parameters
- surface: the surface to add.
- mat: surface positions and normals will be transformed by this 4x4 matrix before adding.
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 model
Model* box = Model::Box();
box->SetColor(0.0, 1.0, 0.0);
Surface* surface1 = box->GetSurface(0);
//Create a second model
model = Model::Cylinder();
model->SetColor(0.0, 0.0, 1.0);
Surface* surface2 = model->GetSurface(0);
//Add the first surface to the second one
Mat4 mat;
mat[3][0] = 1.5;// Offset the matrix position by 1.5 on the x axis
surface1->Add(surface2, mat);
model->UpdateAABB(Entity::LocalAABB | Entity::GlobalAABB);
//Release the first model
box->Release();
while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;
model->Turn(0, Leadwerks::Time::GetSpeed(), 0);
Leadwerks::Time::Update();
world->Update();
world->Render();
context->Sync();
}
return 0;
}