SetRotationByVelocityMode
This function switches between two particle rotation modes: rotate by velocity and rotate by rotation speed.
Syntax
- SetRotationByVelocityMode(bool index)
Parameters
- index: - Differentiates between two particle rotation modes: 0 = rotate by rotation speed, 1 = rotate by velocity.
Remarks
When particles are rotated by velocity, it is assumed that the direction the particle is pointing is to the right.
Rotate by velocity should be used anytime that particles need to face the direction that they are heading.
Particles not rotating by velocity. Arrows are not pointing in the direction that they are heading.
Particles rotating by velocity.
Example
#include "Leadwerks.h"
using namespace Leadwerks;
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, 0, -3);
//Create an emitter
Emitter* emitter = Emitter::Create(500);
Material* material = Material::Load("Materials/Effects/spark.mat");
if (material)
{
emitter->SetMaterial(material);
material->Release();
}
emitter->SetVelocity(0, 0, 0, 0);
emitter->SetVelocity(8, 8, 0, 1);
emitter->SetRotationByVelocityMode(true);
emitter->SetEmissionVolume(0, 0, 0);
while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;
Leadwerks::Leadwerks::Time::Update();
world->Update();
world->Render();
//Press space to toggle mode
if (window->KeyHit(Key::Space))
{
emitter->SetRotationByVelocityMode(!emitter->GetRotationByVelocityMode());
}
context->Sync();
}
}