コード例 #1
0
ファイル: testApp.cpp プロジェクト: neue/FromADistance
//--------------------------------------------------------------
void testApp::setup(){
	ofBackground(250,250,250);
    ofSetFrameRate(30);
	ofSetVerticalSync(true);
	ofPoint iniPos(0,0,0); //the position is refering to the center of the grid
	ofPoint gridSize(1500, 1500, 1500);
	int gridResX = 40;
	int gridResY = 40;
	int gridResZ = 40;
	marchingCubes.init(iniPos, gridSize, gridResX, gridResY, gridResZ);
	glEnable(GL_DEPTH_TEST);
	metaBalls.resize(NUM_META_BALLS);
	for(int i=0; i<metaBalls.size(); i++){
		metaBalls[i].init(iniPos);
	}
    
    
    
    ofEnableLighting();
    ofSetSmoothLighting(true);
    light.enable();
    light.setup();
    
    
	ofSetLogLevel(OF_LOG_VERBOSE);
	bSaveModel = false;
    pointLight.setDiffuseColor( ofColor(0.f, 255.f, 0.f));
    
    // specular color, the highlight/shininess color //
	pointLight.setSpecularColor( ofColor(255.f, 255.f, 0.f));
	pointLight.setPointLight();
	float threshold = 0.2;

}
コード例 #2
0
//--------------------------------------------------------------
void testApp::setup(){
	ofBackground(250,250,250);
	ofSetVerticalSync(true);
	ofPoint iniPos(0,0,0); //the position is refering to the center of the grid
	ofPoint gridSize(480, 480, 480);
	int gridResX = 70;
	int gridResY = 70;
	int gridResZ = 70;
	marchingCubes.init(iniPos, gridSize, gridResX, gridResY, gridResZ);
    	
    // populate mesh from image with alpha values
    ofImage img;
	img.loadImage("linzer.png");
	mesh.setMode(OF_PRIMITIVE_POINTS);
	for(int y = 0; y < img.getHeight(); y+=2) {
		for(int x = 0; x < img.getWidth(); x+=2) {
			ofColor cur = img.getColor(x, y);
			if(cur.a > 0) {
				// the alpha value encodes depth, let's remap it to a good depth range
				float z = ofMap(cur.a, 0, 255, -480, 480);
				cur.a = 255;
				mesh.addColor(cur);
				ofVec3f pos(x - img.getWidth() / 2, y - img.getHeight() / 2, z);
				mesh.addVertex(pos);
			}
		}
	}

    
    
    ofEnableLighting();
    light.enable();    
    light.setup();

    bModelRendered = false;
    bSaveModel = false;
    bShowCubes = false;
    
    ofSetLogLevel(OF_LOG_VERBOSE);

}
コード例 #3
0
ファイル: hotspot.cpp プロジェクト: RedwanNewaz/hextree_ros
//next best location
 void hotspot::updateMeasurement(float attribute[6])
{

    MatrixXf nei(6,2),iniPos(6,2),dummy;
    iniPos=repeatMat(initialRobotPosition);
    dummy=repeatMat(target);
    nei=array2Mat(HexSamples);

    VectorXf BaseCost(6),goalCost;
    BaseCost=distance( iniPos , nei);
    goalCost=distance(dummy,nei);


 //find direction based on measurement
    int local_best;
 //----------------------------------------------------------------
    //update measurement based on measurement gain
//    float curr_max[1],curr_min[1];
//    minMax(attribute,curr_max,curr_min);
//    local_best=tree->sampleMeasurement(attribute,BaseCost.data());

//    if(curr_max[0]-curr_min[0]<1.2)
//        local_best=area_coverage->area_coverage_direction(uav);
//    else
//        local_best=area_coverage->area_coverage_direction(uav,local_best);

//----------------------------------------------------------------
    local_best=tree->sampleMeasurement(goalCost.data(),BaseCost.data());
    updateParentLocation(uav,local_best);
    tree->addParent(uav);
    tree->currentchildren(HexSamples);
    ROS_INFO("updated uav (%f, %f)",uav[0],uav[1]);
    sampling_path_publish();



}
コード例 #4
0
ファイル: morpion.c プロジェクト: Loski/lanceur
bool Morpion()
{
    SDL_Surface *screen = NULL, *texte[3] = {NULL,NULL,NULL};
    SDL_Rect posBlock[9], posFond, posTexte[3];
    SDL_Event event_morpion;
    IMAGE images;

    bool continuer = true, correct = false, rejouer = true, full_case = false,finJeux = true;
    int joueur = 1;
    int blocks[9], i, block_boutton;
    int pointJ[2] = {0}, manche = 1;
    int n = 9;
    const int jeu = MORPION;

    /******************************************************************************/
    screen = SDL_GetVideoSurface();
    verifSetVideo(screen);
    iniPos(&posFond,0,0);

    for(i=0; i<9; i++)
    {
        blocks[i] = RIEN;
        posBlock[i].x = (Sint16)(MIN + ((i%3)*TAILLE));
        posBlock[i].y = (Sint16)(MAX + ((i/3)*TAILLE));
    }

    /* position police */
    for(i=0; i<2; i++)
    {
        posTexte[i].x = 125;
        posTexte[i].y = (Sint16)(555 + (22*i));
    }

    iniPos(&posTexte[2],322,577);

    /******************************************************************************/

    initialiseImagesMorpion(&images);
    verifChargImage(images.fond);
    verifChargImage(images.croix);
    verifChargImage(images.rond);

    /******************************************************************************/

    SDL_WM_SetCaption("Morpion", NULL);

    /******************************************************************************/

    SDL_BlitSurface(images.fond, NULL,screen, &posFond);
    SDL_Flip(screen);


    while(rejouer)
    {
        full_case = false;
        continuer = true;
        while(continuer == true)
        {
            block_boutton = 0;
            if (joueur == 1)
                joueur++;
            else
                joueur--;
            /**********/
            if (joueur == 2) /*IA*/
            {
                i = verifie(blocks);
                if (i != -1)
                {
                    blocks[i] = ROND;
                    if(check(blocks,&full_case))
                        continuer=false;
                }
                else if(continuer)
                {
                    do
                    {
                        i=(rand()%9);
                    }
                    while(blocks[i] != RIEN);
                    blocks[i] = ROND;
                }

                if(check(blocks,&full_case))
                    continuer=false;
            }
            /**********/
            else if (joueur&&continuer)
            {
                do
                {
                    correct = false;
                    SDL_WaitEvent(&event_morpion);
                    switch(event_morpion.type)
                    {
                    case SDL_QUIT:
                        correct = true;
                        continuer = false;
                        rejouer = false;
                        finJeux = false;
                        break;

                    case SDL_KEYDOWN:
                        switch (event_morpion.key.keysym.sym)
                        {
                        case SDLK_ESCAPE:
                            if(afficherMenuJeux(jeu))
                            {
                                correct = true;
                                continuer = false;
                                rejouer = false;
                            }
                            else
                            {
                                initialiseImagesMorpion(&images);
                                SDL_BlitSurface(images.fond,NULL,screen,&posFond);
                                affiche_score(texte, manche,pointJ, posTexte);

                                for(i=0; i<9; i++)
                                {
                                    if(blocks[i]==CROIX)
                                        SDL_BlitSurface(images.croix, NULL,screen, &posBlock[i]);
                                    else if(blocks[i]==ROND)
                                        SDL_BlitSurface(images.rond, NULL,screen, &posBlock[i]);

                                }
                                SDL_Flip(screen);
                            }
                            break;

                        default :
                            break;
                        }
                        break;

                    case SDL_MOUSEBUTTONUP:
                        switch(event_morpion.button.button)
                        {
                        case SDL_BUTTON_LEFT:
                            block_boutton = testPos(posBlock, TAILLE,TAILLE,n,event_morpion);
                            if (block_boutton > -1 && blocks[block_boutton] == RIEN)
                            {
                                blocks[block_boutton] = CROIX;
                                if(check(blocks, &full_case))
                                {
                                    continuer=false;
                                }
                                correct = true;
                            }
                            else if(block_boutton == -2)
                            {
                                if(afficherMenuJeux(jeu))
                                {
                                    correct = true;
                                    continuer = false;
                                    rejouer = false;
                                }
                                else
                                {
                                    initialiseImagesMorpion(&images);
                                    SDL_BlitSurface(images.fond,NULL,screen,&posFond);
                                    affiche_score(texte, manche,pointJ, posTexte);

                                    for(i=0; i<9; i++)
                                    {
                                        if(blocks[i]==CROIX)
                                            SDL_BlitSurface(images.croix, NULL,screen, &posBlock[i]);
                                        else if(blocks[i]==ROND)
                                            SDL_BlitSurface(images.rond, NULL,screen, &posBlock[i]);

                                    }
                                    SDL_Flip(screen);
                                }
                            }
                            break;

                        default :
                            break;
                        }
                        break;

                    default :
                        break;
                    }
                }
                while(!correct);
            }
            SDL_BlitSurface(images.fond, NULL,screen, &posFond);
            for(i=0; i<9; i++)
            {
                if(blocks[i]==CROIX)
                    SDL_BlitSurface(images.croix, NULL,screen, &posBlock[i]);
                else if(blocks[i]==ROND)
                    SDL_BlitSurface(images.rond, NULL,screen, &posBlock[i]);
            }
            affiche_score(texte, manche,pointJ, posTexte);
            SDL_Flip(screen);
        }
        if(rejouer)
        {
            SDL_Delay(1500);
            if(!full_case)
                pointJ[joueur - 1]++;
            manche++;
        }

        for(i=0; i<9; i++)
        {
            blocks[i] = RIEN;
        }

        SDL_BlitSurface(images.fond, NULL,screen, &posFond);
        affiche_score(texte, manche,pointJ, posTexte);
        SDL_Flip(screen);

    }

    /******************************************************************************/

    SDL_FreeSurface(images.fond);
    SDL_FreeSurface(images.croix);
    SDL_FreeSurface(images.rond);
    return finJeux;
}