LoadAnimation
Loads one or more animations from a model file, onto an existing entity. The hierarchy in the loaded file must match the hierarchy of the entity.
Syntax
- int LoadAnimation(const std::string& path, int flags=0)
Returns
Returns the index of the first loaded animation. If the file cannot be loaded, or if it contains no animations -1 is returned.
Example
#include "Leadwerks.h"
using namespace Leadwerks;
Entity* entity = 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->Move(0, 1, -3);
Light* light = DirectionalLight::Create();
light->SetRotation(35, 35, 0);
//Load a model
Model* model = Model::Load("Models/Trees/pine01.mdl");
//Load an animation onto the model
int animationsequence = model->LoadAnimation("Models/Trees/pine01@walk.mdl");
while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;
//Play animation
if (animationsequence>-1) model->SetAnimationFrame(Leadwerks::Time::GetCurrent() / 100.0, 1, animationsequence);
Leadwerks::Time::Update();
world->Update();
world->Render();
context->Sync();
}
return 0;
}