Exemplo n.º 1
0
void UpdateMainCamera(Camera* main_camera, World* world) {
  auto player = world->player_component.begin()->entity;
  auto transform_component = &world->transform_component;
  main_camera->set_position(transform_component->WorldPosition(player));
  main_camera->set_facing(
      transform_component->WorldOrientation(player).Inverse() *
      mathfu::kAxisY3f);
  auto player_data = world->entity_manager.GetComponentData<PlayerData>(player);
  auto raft_orientation = transform_component->WorldOrientation(
      world->entity_manager.GetComponent<ServicesComponent>()->raft_entity());
  main_camera->set_up(raft_orientation.Inverse() * player_data->GetUp());
}
Exemplo n.º 2
0
mathfu::quat TransformComponent::WorldOrientation(corgi::EntityRef entity) {
  TransformData* transform_data = Data<TransformData>(entity);
  if (transform_data->parent) {
    return transform_data->orientation *
           WorldOrientation(transform_data->parent);
  } else {
    return transform_data->orientation;
  }
}