Copy

Creates and returns a duplicate of the asset. Changes to one copy will not affect the other.

Syntax

Returns

A new copy of the Asset.

Remarks

If you want to create an instance of the asset, which will share the resource, use Object::AddRef() instead.

Example

#include "Leadwerks.h"

using namespace Leadwerks;

window = Window::Create();
context = Context::Create(window);
world = World::Create();
camera = Camera::Create();
DirectionalLight::Create()->SetRotation(35,45,0);

//Create a material and copy it
Material* material1 = Material::Create();
Material* material2 = (Material*)material1->Copy();

//Set the two materials colors
material1->SetColor(1,0,0,1);
material2->SetColor(0,0,1,1);

//Create a model and apply the first material
Model* model1 = Model::Sphere();
model1->SetMaterial(material1);
model1->SetPosition(-1,0,2);

//Create a model and apply the second material
Model* model2 = Model::Sphere();
model2->SetMaterial(material2);
model2->SetPosition(1,0,2);

while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;

Leadwerks::Time::Update();
world->Update();
world->Render();
context->Sync();

return true;
}