GetVelocity
This function returns the initial velocity or the random velocity of released particles.
Syntax
- Vec3 GetVelocity(int index=0)
Parameters
- index: - differentiates between setting initial velocity or random velocity. 0 = initial velocity, 1 = random velocity.
Returns
This function returns a Vec3 containing the set initial velocity of released particles.
Remarks
Please note: Starting velocity is calculated as follows: StartVelocity = velocity[0] + Random(-.5*velocity[1], .5*velocity[1]).
Example
#include "Leadwerks.h"
using namespace Leadwerks;
int main(int argc, const char *argv[])
{
float time = 0.5;
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);
//Create an emitter
Emitter* emitter = Emitter::Create(100);
int timercount = 0;
while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;
Leadwerks::Leadwerks::Time::Update();
world->Update();
world->Render();
if (++timercount % 100 == 0)
{
emitter->SetVelocity(Math::Random(-1, 1), Math::Random(-1, 1), Math::Random(-1, 1), 0);
emitter->SetVelocity(Math::Random(-1, 1), Math::Random(-1, 1), Math::Random(-1, 1), 1);
}
context->SetBlendMode(Blend::Alpha);
context->DrawText("Current Base Velocity: " + (emitter->GetVelocity(0)).ToString(), 2, 2);
context->DrawText("Current Random Velocity: " + (emitter->GetVelocity(1)).ToString(), 2, 20);
context->SetBlendMode(Blend::Solid);
context->Sync();
}
}