SetViewMode

This function specifies how a particle's facing direction is determined.

Syntax

Parameters

Remarks

0: billlboard - In this mode each particle will always face the camera.
1: lock Y-axis - particles will rotate to face the camera in every direction except along the Y-axis.
2: manual facing direction - particles will always face the direction specified by SetFacingDirection

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, -1, -1);
camera->SetRotation(-45, 0, 0);

int viewmode = 0;

//Create an emitter
Emitter* emitter = Emitter::Create(100);
emitter->SetViewMode(viewmode); //set the view mode to manual facing direction
emitter->SetFacingDirection(0, 1, 0); //set particles to always face up

while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;

Leadwerks::Leadwerks::Time::Update();
world->Update();
world->Render();

//detect key hits to switch view modes
if (window->KeyHit(Key::Up) && viewmode < 2)
{
++viewmode;
emitter->SetViewMode(viewmode);
}
else if (window->KeyHit(Key::Down) && viewmode > 0)
{
--viewmode;
emitter->SetViewMode(viewmode);
}

context->SetBlendMode(Blend::Alpha);
switch (emitter->GetViewMode())
{
case 0:
context->DrawText("View Mode: Billboard. ", 2, 2);
break;
case 1:
context->DrawText("View Mode: Lock Y-axis. ", 2, 2);
break;
case 2:
context->DrawText("View Mode: Manual Direction. ", 2, 2);
break;
}
context->SetBlendMode(Blend::Solid);

context->Sync();
}
}