示例#1
0
void locWmGlDisplay::drawField()
{
    glPushMatrix();
    glEnable(GL_BLEND);		// Turn Blending On
    glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);

    glColor3f(1.0f,1.0f,1.0f);                                // Set The Color To White

    glEnable(GL_TEXTURE_2D);                                            // Enable Texture Mapping
    glBindTexture(GL_TEXTURE_2D, grassTexture);
            glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);    // Turn off filtering of textures
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);    // Turn off filtering of textures
    glBegin(GL_QUADS);
        glNormal3f(0.0f,0.0f,1.0f);	// Set The Normal
        glTexCoord2f(0.0f, 0.0f); glVertex3f(-370.0f,  270.0f,  0.0f);      // Bottom Left Of The Texture and Quad
        glTexCoord2f(7.4f, 0.0f); glVertex3f( 370.0f,  270.0f,  0.0f);    // Bottom Right Of The Texture and Quad
        glTexCoord2f(7.4f, 5.4f); glVertex3f( 370.0f, -270.0f,  0.0f);     // Top Right Of The Texture and Quad
        glTexCoord2f(0.0f, 5.4f); glVertex3f(-370.0f, -270.0f,  0.0f);       // Top Left Of The Texture and Quad
    glEnd();

    glBindTexture(GL_TEXTURE_2D, fieldLineTexture);
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);    // Turn off filtering of textures
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);    // Turn off filtering of textures
    glBegin(GL_QUADS);
        glNormal3f(0.0f,0.0f,1.0f);	// Set The Normal
        glTexCoord2f(0.0f, 0.0f); glVertex3f(-370.0f,  270.0f,  0.0f);      // Bottom Left Of The Texture and Quad
        glTexCoord2f(1.0f, 0.0f); glVertex3f( 370.0f,  270.0f,  0.0f);    // Bottom Right Of The Texture and Quad
        glTexCoord2f(1.0f, 1.0f); glVertex3f( 370.0f, -270.0f,  0.0f);     // Top Right Of The Texture and Quad
        glTexCoord2f(0.0f, 1.0f); glVertex3f(-370.0f, -270.0f,  0.0f);       // Top Left Of The Texture and Quad
    glEnd();
    glDisable(GL_BLEND);            // Turn Blending Off
    glDisable(GL_TEXTURE_2D);       // Disable Texture Mapping

    drawGoal(QColor(0,0,255,255),-300,0.0,0.0);
    drawGoal(QColor(255,255,0,255),300,0.0,180.0);
    glPopMatrix();
}
示例#2
0
void
drawSchool(XColor *colors, School *s,
		   GLuint bboxList, GLuint goalList, GLuint fishList,
		   int rotCounter, Bool drawGoal_p, Bool drawBBox_p)
{
	double			xVect[3];
	double			colorVect[3];
	int				i = 0;
	double			rotTheta = 0.0;
	double			colTheta = 0.0;
	Fish			*f = (Fish *)0;
	int				nFish = SCHOOL_NFISH(s);
	Fish			*theFishes = SCHOOL_FISHES(s);

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	if (drawBBox_p) {
		glDisable(GL_LIGHTING);
		glCallList(bboxList);
		glEnable(GL_LIGHTING);
	}

	if (drawGoal_p)	drawGoal(SCHOOL_GOAL(s), goalList);

	for(i = 0, f = theFishes; i < nFish; i++, f++) {
		colTheta = computeNormalAndThetaToPlusZ(FISH_AVGVEL(f), xVect);
		rotTheta = computeNormalAndThetaToPlusZ(FISH_VEL(f), xVect);

		if (FISH_IAVGVEL(f,2) < 0.0) colTheta = 180.0 - colTheta;
		if (FISH_VZ(f) < 0.0) rotTheta = 180.0 - rotTheta;

		getColorVect(colors, (int)(colTheta+240)%360, colorVect);
		glColor3f(colorVect[0], colorVect[1], colorVect[2]);

		glPushMatrix();
		{
			glTranslatef(FISH_X(f), FISH_Y(f), FISH_Z(f));
			glRotatef(180.0+rotTheta, xVect[0], xVect[1], xVect[2]);
			glCallList(fishList);
		}
		glPopMatrix();
	}

	glFinish();
}
示例#3
0
/*** シミュレーションループ ***/
static void simLoop(int pause)
{
    if (!pause)
    {
        dSpaceCollide(space,0,&nearCallback); // add
        control();
        dWorldStep(world, 0.01);
        dJointGroupEmpty(contactgroup); // add
    }

    const dReal *linear_vel = dBodyGetLinearVel(base.body);
    const dReal *angular_vel = dBodyGetAngularVel(base.body);
    printf("linear : %.3f %.3f %.3f\n", linear_vel[0], linear_vel[1], linear_vel[2]);
    printf("angular: %.3f %.3f %.3f\n", angular_vel[0], angular_vel[1], angular_vel[2]);

    drawBase();
    drawWheel();  // add
    drawBall();   //add
    drawGoal();
}
示例#4
0
void display(void)
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();
    gluLookAt(viewer[0], viewer[1], viewer[2], reference[0], reference[1], reference[2], 0.0, 1.0, 0.0);
    
    drawRink();
    drawGoal();
    drawShotMeter();
    drawPuck();
    moveStick();
    renderUI();
    if (textNum != 999){
        renderPuckText();
    }

    
    glFlush();
	glutSwapBuffers(); /*Display next buffer*/
}
示例#5
0
文件: main.cpp 项目: theevann/Boids
void Dessiner(Boids & b, double * cam)
{
    newTime = SDL_GetTicks();

    if(newTime - lastTime < intervalle)
    { return;}
     lastTime = newTime;

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) ;
    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity( );

    gluLookAt(cam[0],cam[1],cam[2],0,0,0,0,0,1);
    //gluLookAt(3,4,2,0,0,0,0,0,1);

    glColor3ub(0,0,0);
    GLUquadric * params = gluNewQuadric();
    gluQuadricDrawStyle(params, GLU_FILL);

    if(!pause){
        b.updateAcceleration();
        b.updateVitesse();
    }

    for(int i = 0 ; i < b.nb_boid ; i++)
    {
        if(!pause)
            b.tab[i].deplace();
        drawBoid(b.tab[i], params);
    }


    drawGoal(b, params);

    gluDeleteQuadric(params);
/*
    glRotated(angleX,1,0,0);
    glRotated(angleZ,0,0,1);
*/
    glBegin(GL_QUADS);
    glColor3ub(255,0,0); //face rouge
    glVertex3d(LargeurX,LargeurY,LargeurZ);
    glVertex3d(LargeurX,LargeurY,-LargeurZ);
    glVertex3d(-LargeurX,LargeurY,-LargeurZ);
    glVertex3d(-LargeurX,LargeurY,LargeurZ);
    glEnd();
/*
    glBegin(GL_QUADS);
    glColor3ub(0,255,0); //face verte
    glVertex3d(LargeurX,-LargeurY,LargeurZ);
    glVertex3d(LargeurX,-LargeurY,-LargeurZ);
    glVertex3d(LargeurX,LargeurY,-LargeurZ);
    glVertex3d(LargeurX,LargeurY,LargeurZ);
    glEnd();
*/
     glBegin(GL_QUADS);
    glColor3ub(0,0,255); //face bleu
    glVertex3d(LargeurX,-LargeurY,LargeurZ);
    glVertex3d(LargeurX,LargeurY,LargeurZ);
    glVertex3d(-LargeurX,LargeurY,LargeurZ);
    glVertex3d(-LargeurX,-LargeurY,LargeurZ);
    glEnd();

    glBegin(GL_QUADS);
    glColor3ub(0,255,255); //face cyan
    glVertex3d(LargeurX,-LargeurY,LargeurZ);
    glVertex3d(LargeurX,-LargeurY,-LargeurZ);
    glVertex3d(-LargeurX,-LargeurY,-LargeurZ);
    glVertex3d(-LargeurX,-LargeurY,LargeurZ);
    glEnd();

    glBegin(GL_QUADS);
    glColor3ub(255,0,255); //face magenta
    glVertex3d(LargeurX,-LargeurY,-LargeurZ);
    glVertex3d(LargeurX,LargeurY,-LargeurZ);
    glVertex3d(-LargeurX,LargeurY,-LargeurZ);
    glVertex3d(-LargeurX,-LargeurY,-LargeurZ);
    glEnd();

    glBegin(GL_QUADS);
    glColor3ub(255,255,0); //face verte
    glVertex3d(-LargeurX,-LargeurY,LargeurZ);
    glVertex3d(-LargeurX,-LargeurY,-LargeurZ);
    glVertex3d(-LargeurX,LargeurY,-LargeurZ);
    glVertex3d(-LargeurX,LargeurY,LargeurZ);
    glEnd();

/*
    glRotated(-angleZ,0,0,1);
    glRotated(-angleX,1,0,0);
*/
    glDisable(GL_DEPTH_TEST);

    glBegin(GL_LINES);
    glColor3ub(255,0,0); //face rouge
    glVertex3d(0,0,0);
    glVertex3d(2,0,0);
    glEnd();

    glBegin(GL_LINES);
    glColor3ub(0,255,0); //face rouge
    glVertex3d(0,0,0);
    glVertex3d(0,2,0);
    glEnd();

    glBegin(GL_LINES);
    glColor3ub(0,0,255); //face rouge
    glVertex3d(0,0,0);
    glVertex3d(0,0,2);
    glEnd();

    glEnable(GL_DEPTH_TEST);
//*/

    glFlush();
    SDL_GL_SwapBuffers();
}