Exemplo n.º 1
0
 void DrawScene() {
     m_render->Clear( 0.25f, 0.25f, 0.35f, 0.0f, 0.0f);
     
     DrawStars();
     if (m_rt) {
         DrawImage(m_rt->GetTexture(), 256, 256);
     }
 }
Exemplo n.º 2
0
 void OnTimer(GHL::UInt32 usecs) {
     ApplicationBase::OnTimer(usecs);
     //float dt = float(usecs)/1000000.0f;
     if (m_rt) {
         m_render->BeginScene(m_rt);
         m_render->Clear(0.5, 0.3, 0.3, 1, 0);
         DrawStars();
         m_render->EndScene();
     }
 }
Exemplo n.º 3
0
/*=========================================================================
// Name: DrawScene()
// Desc: Draws the whole scene!
//=======================================================================*/
static void DrawScene()
{
    char chScore[30],
         chLines[30],
         chLevel[30];

    /* Black background */
    SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0,0,0));
    DrawStars(); /* Starfield */

    if (bCrazy)
        WriteText(font, 250, 30+(boxdraw.box_x), "Cr4zY m0d3!"); /* woo hoo! */

    if (!bGameOver) {
        /* Draw border of the box */
        PutRect(boxdraw.box_x-5, boxdraw.box_y-5,
                boxdraw.box_width + 2*5, boxdraw.box_height + 2*5, 150,150,150);
        PutRect(boxdraw.box_x, boxdraw.box_y,
                boxdraw.box_width, boxdraw.box_height, 90,90,90);

        DrawCluster(); /* Draw cluster */
        sprintf(chScore, "%d", score);
        sprintf(chLines, "%d", lines);
        sprintf(chLevel, "%d", level);
        WriteText(font, 490, 80, "Score");  /*  Show SCORE */
        WriteText(font, 490, 105, chScore); 
        WriteText(font, 495, 180, "Next");  /*  Show NEXT piece */
        DrawNextPiece(490, 220);
        WriteText(font, 490, 350, "Lines"); /*  Show number of killed LINES */
        WriteText(font, 490, 375, chLines);
        WriteText(font, 95, 350, "Level");  /*  Show current LEVEL */
        WriteText(font, 95, 375, chLevel);
    }

    DrawBox();       /* Draw box bricks */
    DrawParticles();

    if (bPause)
        WriteText(font, 265, 20, "- PAUSE -");
    if (bGameOver && !bExplode) {
        WriteTextCenter(font, 120, "GAME OVER");
        sprintf(chScore, "Your Score: %d", score); 
        WriteTextCenter(font, 250, chScore);
    }

    SDL_Flip(screen); /* Let's flip! */
}
Exemplo n.º 4
0
//---------------------------------------------------------------
// Name: DynamicStarField()
// Desc:
//---------------------------------------------------------------
int DynamicStarField(RECT *starField, int nNumofStars, CVECTOR velVec, int nFrame)
{
	static PARTICLE *stars = new PARTICLE[nNumofStars];
	static RECT tempField = {0,0,1,1};
	
	//reverse the velocity vector so the stars move in the oppsoite direction as the ship
	velVec.Reverse();
	//velVec.y = -velVec.y;
	
	//init the stars
	if(!nFrame) //if first frame
		InitStars(stars, starField, tempField, nNumofStars);
	
	DrawStars(stars, nNumofStars);
	MoveStars(stars, nNumofStars, tempField, velVec);

	if(bDebugMode)
		DebugInfo(stars, nFrame, nNumofStars, tempField);

	return(1);
}
Exemplo n.º 5
0
//------------------------------------------------------------------------------
void NBodyWnd::Render()
{
    static long ct = 0;
    if (!(m_flags & dspPAUSE))
    {
        ++ct;

        if (m_bDumpImage && ct%5==0)
            SaveToTGA();
    }

    glClear(GL_COLOR_BUFFER_BIT  | GL_DEPTH_BUFFER_BIT);

    Vec3D orient;
    switch (m_camOrient)
    {
    // Default orientation
    case 0:
        orient.x = 0;
        orient.y = 1;
        orient.z = 0;
        break;

    // Rotate with galaxy core
    case 1:
    {
        Vec2D p1 = m_galaxy.GetStarPos(0),
              p2 = m_galaxy.GetStarPos(1);
        orient.x = p2.x - p1.x;
        orient.y = p2.y - p1.y;
        orient.z = 0;
    }
    break;

    // Rotate with edge of disk
    case 2:
    {
        Vec2D p1 = m_galaxy.GetStarPos(0),
              p2 = m_galaxy.GetStarPos(2);
        orient.x = p2.x - p1.x;
        orient.y = p2.y - p1.y;
        orient.z = 0;
    }
    break;
    }

    Vec3D lookAt(0, 0, 0),
          pos(0, 0, 5000);
    SetCamera(pos, lookAt, orient);

    if (!(m_flags & dspPAUSE))
    {
        m_galaxy.SingleTimeStep(100000); // time in years
    }

    if (m_flags & dspAXIS)
        DrawAxis(Vec2D(0, 0));

    if (m_flags & dspDENSITY_WAVES)
        DrawDensityWaves(50, m_galaxy.GetFarFieldRad());

    if (m_flags & dspSTAT)
        DrawStat();

    if (m_flags & dspDUST)
        DrawDust();

    if (m_flags & dspH2)
        DrawH2();

    if (m_flags & dspSTARS)
        DrawStars();

    if (m_flags & dspRADII)
        DrawGalaxyRadii();

    if (m_flags & dspVELOCITY)
        DrawVelocity();

    if (m_flags & dspHELP)
        DrawHelp();

    SDL_GL_SwapBuffers();
}
Exemplo n.º 6
0
void Draw() {
	glClear(GL_COLOR_BUFFER_BIT);
	DrawStripes();
	DrawStars();
	glFlush();
}
bool ImageRegistration::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList)
{
   StepResource pStep("Image Registration", "app", "A2E0FC44-2A31-41EE-90F8-805773D01FCA");
   if (pInArgList == NULL || pOutArgList == NULL)
   {
      return false;
   }
   Progress* pProgress = pInArgList->getPlugInArgValue<Progress>(Executable::ProgressArg());
   //RasterElement* pCube = pInArgList->getPlugInArgValue<RasterElement>(Executable::DataElementArg());

   std::vector<Window*> windows;
   Service<DesktopServices>()->getWindows(SPATIAL_DATA_WINDOW, windows);
   std::vector<RasterElement*> elements;
   for (unsigned int i = 0; i < windows.size(); ++i)
   {
       SpatialDataWindow* pWindow = dynamic_cast<SpatialDataWindow*>(windows[i]);
       if (pWindow == NULL)
       {
           continue;
       }
       LayerList* pList = pWindow->getSpatialDataView()->getLayerList();
       elements.push_back(pList->getPrimaryRasterElement());
   }

   RasterElement* pCube = elements[0];
   RasterElement* pCubeRef = elements[1];
   if ((pCube == NULL) || (pCubeRef == NULL))
   {
      std::string msg = "A raster cube must be specified.";
      pStep->finalize(Message::Failure, msg);
      if (pProgress != NULL) 
      {
         pProgress->updateProgress(msg, 0, ERRORS);
      }
      return false;
   }
   RasterDataDescriptor* pDesc = static_cast<RasterDataDescriptor*>(pCube->getDataDescriptor());
   VERIFY(pDesc != NULL);
   
   EncodingType ResultType = pDesc->getDataType();
   if (pDesc->getDataType() == INT4SCOMPLEX)
   {
      ResultType = INT4SBYTES;
   }
   else if (pDesc->getDataType() == FLT8COMPLEX)
   {
      ResultType = FLT8BYTES;
   }

   FactoryResource<DataRequest> pRequest;
   pRequest->setInterleaveFormat(BSQ);
   DataAccessor pSrcAcc = pCube->getDataAccessor(pRequest.release());

   FactoryResource<DataRequest> pRequestRef;
   pRequestRef->setInterleaveFormat(BSQ);
   DataAccessor pSrcAccRef = pCubeRef->getDataAccessor(pRequestRef.release());

   ModelResource<RasterElement> pResultCube(RasterUtilities::createRasterElement(pCube->getName() +
      "_Image_Registration_Result", pDesc->getRowCount(), pDesc->getColumnCount(), ResultType));
   if (pResultCube.get() == NULL)
   {
      std::string msg = "A raster cube could not be created.";
      pStep->finalize(Message::Failure, msg);
      if (pProgress != NULL) 
      {
         pProgress->updateProgress(msg, 0, ERRORS);
      }
      return false;
   }

   std::vector<int> badValues = pDesc->getBadValues();
   //badValues.push_back(0);
   RasterDataDescriptor* pDescriptor = dynamic_cast<RasterDataDescriptor*>(pResultCube->getDataDescriptor());
   Statistics* pStatistics = pResultCube->getStatistics(pDescriptor->getActiveBand(0));
   pStatistics->setBadValues(badValues);

   FactoryResource<DataRequest> pResultRequest;
   pResultRequest->setWritable(true);
   DataAccessor pDestAcc = pResultCube->getDataAccessor(pResultRequest.release());
   
   nCountMas = 0;
   nCountRef = 0;
   int windowSize = 6;
   double *pBuffer = (double *)calloc(pDesc->getRowCount()*pDesc->getColumnCount(), sizeof(double));

   GetGrayScale(pDesc->getDataType());

   
   for (unsigned int row = 0; row < pDesc->getRowCount(); ++row)
   {
	   if (pProgress != NULL)
       {
           pProgress->updateProgress("Image registration", row * 100 / pDesc->getRowCount(), NORMAL);
       }
       if (isAborted())
       {
          std::string msg = getName() + " has been aborted.";
          pStep->finalize(Message::Abort, msg);
          if (pProgress != NULL)
          {
             pProgress->updateProgress(msg, 0, ABORT);
          }
          return false;
       }
       for (unsigned int col = 0; col < pDesc->getColumnCount(); ++col)
       {
	       locateAllStarPosition(pSrcAcc, pSrcAccRef, row, col, pDesc->getRowCount(), pDesc->getColumnCount(), pDesc->getDataType(), windowSize, pBuffer);
       }
   }

   ModifyCenter(pSrcAcc, pDesc->getDataType(), windowSize, nCountMas, nStarPositionsMas);
   ModifyCenter(pSrcAccRef, pDesc->getDataType(), windowSize, nCountRef, nStarPositionsRef);

   GetAllNeighborStars();
   GetMatchingStars();
   
   GetParameters(pDesc->getRowCount(), pDesc->getColumnCount());
  
   DrawStars(pBuffer, pSrcAccRef, pDesc->getDataType(), matrixT, pDesc->getRowCount(), pDesc->getColumnCount());

   //Output the value 
      for (unsigned int m = 0; m < pDesc->getRowCount(); m++)
      {
	      for (unsigned int n = 0; n < pDesc->getColumnCount(); n++)
	      {
		      if (isAborted())
              {
                  std::string msg = getName() + " has been aborted.";
                  pStep->finalize(Message::Abort, msg);
                  if (pProgress != NULL)
                  {
                      pProgress->updateProgress(msg, 0, ABORT);
                  }
                  return false;
              }
				      
			  if (!pDestAcc.isValid())
              {
                  std::string msg = "Unable to access the cube data.";
                  pStep->finalize(Message::Failure, msg);
                  if (pProgress != NULL) 
                  {
                      pProgress->updateProgress(msg, 0, ERRORS);
                   }
                   return false;
               }

				       
			  switchOnEncoding(ResultType, updatePixel, pDestAcc->getColumn(), pBuffer, m, n, pDesc->getRowCount(), pDesc->getColumnCount());       
			  pDestAcc->nextColumn();
				   
		  }
				   
		  pDestAcc->nextRow();
		  
	  }
   free(pBuffer);
   


   if (!isBatch())
   {
      Service<DesktopServices> pDesktop;

      SpatialDataWindow* pWindow = static_cast<SpatialDataWindow*>(pDesktop->createWindow(pResultCube->getName(),
         SPATIAL_DATA_WINDOW));

      SpatialDataView* pView = (pWindow == NULL) ? NULL : pWindow->getSpatialDataView();
      if (pView == NULL)
      {
         std::string msg = "Unable to create view.";
         pStep->finalize(Message::Failure, msg);
         if (pProgress != NULL) 
         {
            pProgress->updateProgress(msg, 0, ERRORS);
         }
         return false;
      }

      pView->setPrimaryRasterElement(pResultCube.get());
      pView->createLayer(RASTER, pResultCube.get());
   }

   double theta = std::acos(matrixT[0][0])*180.0/3.1415926;

   std::string msg = "Image Registration is complete.\n Translation x = " +  StringUtilities::toDisplayString(round(shiftX)) + ", y = " + 
	                 StringUtilities::toDisplayString(round(shiftY)) + ", rotation = " + StringUtilities::toDisplayString(round(theta)) + " degree";
   if (pProgress != NULL)
   {
	   
       pProgress->updateProgress(msg, 100, NORMAL);
   }

   pOutArgList->setPlugInArgValue("Image Registration Result", pResultCube.release());

   pStep->finalize();


   return true;
}