/*!
   \brief Initialize the RenderWindowInteractor

   This function is called from the two constructors
*/
void RenderWindowInteractor::InitRenderWindowInteractor() {
   this->SetLeftButtonFunction( SLOT(CameraRotate()) );
   this->SetMiddleButtonFunction( SLOT(CameraTranslate()) );
   this->SetRightButtonFunction( SLOT(CameraZoom()) );
   this->SetShiftLeftButtonFunction( SLOT(CameraRoll()) );

   this->mouseEventActive = false;
   this->SetInteractionTime( 50 );
   this->SetSensitivity( 10.0 );

   this->stepTimer = new QTimer();
   CHECK_PTR( this->stepTimer );

   this->currentCamera = this->GetRenderer()->GetActiveCamera();
   CHECK_PTR( this->currentCamera );

   // get the light we are using
   vtkLightCollection *lightCollection = this->GetRenderer()->GetLights();
   lightCollection->InitTraversal();
   this->currentLight = lightCollection->GetNextItem();
   CHECK_PTR( this->currentLight );

   this->interactionActor = NULL;
   this->collisionActor = NULL;
}
Exemplo n.º 2
0
Arquivo: GridCell.c Projeto: osen/gc
void GridCellDraw(struct GridCell *ctx)
{
  SDL_Rect rect = {0};
  struct Camera *camera = NULL;
  int mouseX = 0;
  int mouseY = 0;
  SDL_Rect mouseRect = {0};

  camera = ctx->world->camera;

  rect.x = ctx->x;
  rect.y = ctx->y;
  rect.w = GRIDCELL_SIZE;
  rect.h = GRIDCELL_SIZE;

  MousePosition(ctx->world->mouse, &mouseX, &mouseY);
  CameraTranslate(camera, &mouseX, &mouseY);
  //mouseRect.x = mouseX + ctx->world->camera->x;
  //mouseRect.y = mouseY + ctx->world->camera->y;
  mouseRect.x = mouseX;
  mouseRect.y = mouseY;
  mouseRect.w = 1;
  mouseRect.h = 1;

  if(ctx->type == 0)
  {
    CameraDrawImage(camera, ctx->image, ctx->x, ctx->y);
  }
  else
  {
    CameraDrawImage(camera, ctx->blockImage, ctx->x, ctx->y);
  }

  ctx->active = 0;

  if(check_collision(rect, mouseRect) == 1)
  {
    ctx->active = 1;

    if(MouseClicked(ctx->world->mouse) == 1)
    {
      ctx->type = 1;

      //printf("Connections: ^%p >%p \\/%p <%p \\%p /%p \\%p /%p\n",
      //  ctx->top, ctx->right, ctx->bottom, ctx->left,
      //  ctx->topLeft, ctx->topRight, ctx->bottomRight, ctx->bottomLeft);
    }

    CameraDrawImage(camera, ctx->cursorImage, ctx->x, ctx->y);
  }

  if(_GridCellHasNeighbourActive(ctx) == 1)
  {
    CameraDrawImage(camera, ctx->highlightImage, ctx->x, ctx->y);
  }
}