SetEmissionShape
This function sets the shape in which a particle will spawn from.
Syntax
- void SetEmissionShape(int ShapeId=0)
Parameters
- ShapeId: indicates emissions shape. Cube = 0 Sphere = 1 Cylinder = 2 Tube = 3 Torus = 4 Cone = 5
Example
#include "Leadwerks.h"
using namespace Leadwerks;
int main(int argc, const char *argv[])
{
float duration = 3000;
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);
int emissionshape = 0;
//Create an emitter
Emitter* emitter = Emitter::Create(1000);
emitter->SetVelocity(0, 0, 0, 0);
emitter->SetVelocity(0, 0, 0, 1);
emitter->SetEmissionShape(emissionshape);
while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;
Leadwerks::Leadwerks::Time::Update();
world->Update();
world->Render();
if (window->KeyHit(Key::Up) && emissionshape < 5)
{
++emissionshape;
emitter->SetEmissionShape(emissionshape);
}
else if (window->KeyHit(Key::Down) && emissionshape > 0)
{
--emissionshape;
emitter->SetEmissionShape(emissionshape);
}
context->SetBlendMode(Blend::Alpha);
switch (emitter->GetEmissionShape())
{
case 0:
context->DrawText("Emission Shape: Cube", 2, 2);
break;
case 1:
context->DrawText("Emission Shape: Sphere", 2, 2);
break;
case 2:
context->DrawText("Emission Shape: Cylinder", 2, 2);
break;
case 3:
context->DrawText("Emission Shape: Tube", 2, 2);
break;
case 4:
context->DrawText("Emission Shape: Torus", 2, 2);
break;
case 5:
context->DrawText("Emission Shape: Cone", 2, 2);
break;
}
context->SetBlendMode(Blend::Solid);
context->Sync();
}
}