virtual bool Attach(shared_ptr<Hmd> hmd);
virtual bool Attach(shared_ptr<VrController> controller);
I've tried these methods per your suggestion and both don't work as intended.
When you attach a model to the Hmd, it's doesn't seem to consider the offset even when you move the said model it is.
if (!head)
{
head = CreateSphere(world, -0.14f);
head->SetCollider(nullptr);
head->SetShadows(false);
head->SetColor(0.0f, 0.0f, 0.0f, 0.0f);
head->SetPosition(entity->GetPosition() + hmd->GetPosition());
head->Attach(hmd);
auto mat = CreateMaterial();
mat->SetShaderFamily(LoadShaderFamily("Shaders/Unlit.fam"));
mat->SetThickness(0);
mat->SetTransparent(true);
head->SetMaterial(mat);
mat = NULL;
}
The entity update at all when attach to the controller.
// Update the model.
auto mdl = GetController(weapon_controller);
if (weapon && mdl)
{
if (weapon->extra == NULL)
{
weapon->SetMatrix(mdl->GetMatrix(true), true);
weapon->SetHidden(false);
mdl->SetHidden(true);
weapon->Attach(hmd->controllers[weapon_controller]);
weapon->extra = Self();
}
else
{
//weapon->SetMatrix(mdl->GetMatrix(true), true);
}
}
If you need the project, let me know.