SetAnimationFrame
Sets an entity to a specific animation frame.
Syntax
- void SetAnimationFrame(const float time, const float blend=1.0, const int index=0, const bool recursive=true)
- void SetAnimationFrame(const float time, const float blend, const std::string& name, const bool recursive=true)
Parameters
- time: the frame number to set. If a fractional number is used, the animation will be interpolated between the closest two frames.
- blend: a blend amount to modulate the current rotation and position with. This can be used to smoothly transition between two animation sequences, or to blend two animations together.
- index: the animation sequence to use.
- name: the name of the animation sequence to use, i.e. "walk", "run", "attack", etc.
- recursive: if set to true, the animation will be applied to all the entity's children recursively.
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->Turn(0, 90, 0);
camera->Move(0, 1, -2);
Light* light = DirectionalLight::Create();
light->SetRotation(35, 35, 0);
//Load a model
Model* model = Model::Load("Models/Trees/pine01.mdl");
while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;
model->SetAnimationFrame(Leadwerks::Time::GetCurrent() / 100.0, 1, 2);
Leadwerks::Time::Update();
world->Update();
world->Render();
context->Sync();
}
return 0;
}