SetPickRadius
This function sets an entity's pick radius, for use with the Pick::Sphere pick mode.
Syntax
- void SetPickRadius(float radius)
Parameters
- radius: the new pick radius to set.
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->SetRotation(35, 0, 0);
camera->Move(0, 0, -8);
Light* light = DirectionalLight::Create();
light->SetRotation(35, 35, 0);
//Create a model
float spherescale = 3.6;
Model* model = Model::Sphere();
model->SetPickMode(Entity::SpherePick);
model->SetPickRadius(spherescale / 2.0);
model->SetScale(model->GetPickRadius()*2.0);
//Create a sphere to indicate where the pick hits
Model* picksphere = Model::Sphere();
picksphere->SetColor(1.0, 0.0, 0.0);
picksphere->SetPickMode(0);
float pickradius = 0.25;
picksphere->SetScale(pickradius*2.0);
PickInfo pickinfo;
if (world->Pick(-10, 1, 0, 10, 1, 0, pickinfo, pickradius, true))
{
picksphere->SetPosition(pickinfo.position);
}
else
{
picksphere->Release();
}
while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;
Leadwerks::Leadwerks::Time::Update();
world->Update();
world->Render();
context->Sync();
}
}