コード例 #1
0
ファイル: mainIUP.c プロジェクト: lfmachadodasilva/raytracing
/* carrega uma nova cena */
int load_cb(void) {
  char* filename = get_file_name();  /* chama o dialogo de abertura de arquivo */
  char buffer[30];

  if (filename==NULL) return 0;

  /* Le a cena especificada */
  scene = sceLoad( filename );
  if( scene == NULL ) return IUP_DEFAULT;

  sceGetCamera( scene, &camera );
  camGetEye( camera, eye );
  camGetScreenWidth( camera, &width );
  camGetScreenHeight( camera, &height );
  yc=0;

  if (image) imgDestroy(image);
  image = imgCreate( width, height );
  IupSetfAttribute(label, "TITLE", "%3dx%3d", width, height);
  sprintf(buffer,"%3dx%3d", width, height);
  IupSetAttribute(canvas,IUP_RASTERSIZE,buffer);
  IupSetFunction (IUP_IDLE_ACTION, (Icallback) idle_cb);
  start_time  = clock(); 
  return IUP_DEFAULT;
}
コード例 #2
0
ファイル: mainIUP.c プロジェクト: juliords/pucrio-cg-20112
/* carrega uma nova cena */
int load_cb(void) {
	char* filename = get_file_name();  /* chama o dialogo de abertura de arquivo */
	char buffer[30];

	if (filename==NULL) return 0;

	/* Le a cena especificada */
	scene = sceLoad( filename );
	if( scene == NULL ) return IUP_DEFAULT;

	camera = sceGetCamera( scene );
	eye = camGetEye( camera );
	width = camGetScreenWidth( camera );
	height = camGetScreenHeight( camera );
	yc=0;

	if (image) imgDestroy(image);
	image = imgCreate( width, height );
	IupSetfAttribute(label, "TITLE", "%3dx%3d", width, height);
	sprintf(buffer,"%3dx%3d", width, height);
	IupSetAttribute(canvas,IUP_RASTERSIZE,buffer);
	IupSetFunction (IUP_IDLE_ACTION, (Icallback) idle_cb);
	start_time  = clock(); 

	IupGLMakeCurrent(canvas);
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
	glClear(GL_COLOR_BUFFER_BIT);
	glEnd();
	glFlush();
	IupGLSwapBuffers(canvas);  /* change the back buffer with the front buffer */

	return IUP_DEFAULT;
}
コード例 #3
0
ファイル: Environment.cpp プロジェクト: wmaciel/aco-fault
Image* Environment::getVisibilityImage()
{
    Image* output = imgCreate( _width, _height, 1 );
    
    for (int x = 0; x < _width; ++x)
    {
        for (int y = 0; y < _height; ++y)
        {
            float visibility = _imageMatrix[id(x,y)];
            imgSetPixelf( output, x, y, visibility );
        }
    }
    
    return output;
}
コード例 #4
0
ファイル: Environment.cpp プロジェクト: wmaciel/aco-fault
Image* Environment::getPheromoneImage()
{
    Image* output = imgCreate( _width, _height, 1 );

    #pragma omp parallel for
    for (int x = 0; x < _width; ++x)
    {
        for (int y = 0; y < _height; ++y)
        {
            imgSetPixelf( output, x, y, _pheromoneMatrix[id(x,y)] );
        }
    }
    
    imgNormalize( output );
    return output;
}
コード例 #5
0
ファイル: Colony.cpp プロジェクト: wmaciel/aco-fault
void Colony::printDebugImage()
{
    static int step = 0;
    Image* imgIn = _environment->getPheromoneImage();
    imgNormalize( imgIn, 2 );
    
    Image* img = imgCreate( _environment->getWidth(), _environment->getHeight(), 3 );
    
    for (int x = 0; x < _environment->getWidth(); ++x)
    {
        for (int y = 0; y < _environment->getHeight(); ++y)
        {
            float lum = imgGetPixelf( imgIn, x, y );
            imgSetPixelf( img, x, y, lum );
        }
    }  
    
    int nAnts = _ants.size();
    for (int i = 0; i < nAnts; ++i)
    {
        Ant* ant = _ants[i];
        if (ant->isAlive())
        {
            // each ant has a color
            imgSetPixel3f( img, ant->_position.x, ant->_position.y, 1.0f - i/(float)nAnts, (0.0f + i) / nAnts, 0.0f );
            
            //all ants are red
            //imgSetPixel3f( img, ant->_position.x, ant->_position.y, 1,0,0 );
        }
        else
        {
            imgSetPixel3f( img, ant->_position.x, ant->_position.y, 0.0f, 0.0f, 1.0f );
        }
    }

    
    //postProcessing( &img );
    char filename[150];
    sprintf( filename, "debugImg/debugImage%04d.bmp", ++step );
    imgWriteBMP( filename, img );
    imgDestroy( img );
}