Exemple #1
0
void Circle3DOverlay::render(RenderArgs* args) {
    if (!_visible) {
        return; // do nothing if we're not visible
    }

    float alpha = getAlpha();

    if (alpha == 0.0) {
        return; // do nothing if our alpha is 0, we're not visible
    }
    
    // Create the circle in the coordinates origin
    float outerRadius = getOuterRadius();
    float innerRadius = getInnerRadius(); // only used in solid case
    float startAt = getStartAt();
    float endAt = getEndAt();
    
    bool geometryChanged = (startAt != _lastStartAt || endAt != _lastEndAt ||
                                innerRadius != _lastInnerRadius || outerRadius != _lastOuterRadius);

    
    const float FULL_CIRCLE = 360.0f;
    const float SLICES = 180.0f;  // The amount of segment to create the circle
    const float SLICE_ANGLE = FULL_CIRCLE / SLICES;

    //const int slices = 15;
    xColor colorX = getColor();
    const float MAX_COLOR = 255.0f;
    glm::vec4 color(colorX.red / MAX_COLOR, colorX.green / MAX_COLOR, colorX.blue / MAX_COLOR, alpha);

    bool colorChanged = colorX.red != _lastColor.red || colorX.green != _lastColor.green || colorX.blue != _lastColor.blue;
    _lastColor = colorX;

    glDisable(GL_LIGHTING);
    
    glm::vec3 position = getPosition();
    glm::vec3 center = getCenter();
    glm::vec2 dimensions = getDimensions();
    glm::quat rotation = getRotation();

    float glowLevel = getGlowLevel();
    Glower* glower = NULL;
    if (glowLevel > 0.0f) {
        glower = new Glower(glowLevel);
    }

    glPushMatrix();
        glTranslatef(position.x, position.y, position.z);
        glm::vec3 axis = glm::axis(rotation);
        glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
        glPushMatrix();
            glm::vec3 positionToCenter = center - position;
            glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
            glScalef(dimensions.x / 2.0f, dimensions.y / 2.0f, 1.0f);

            glLineWidth(_lineWidth);

            auto geometryCache = DependencyManager::get<GeometryCache>();
            
            // for our overlay, is solid means we draw a ring between the inner and outer radius of the circle, otherwise
            // we just draw a line...
            if (getIsSolid()) {
                if (_quadVerticesID == GeometryCache::UNKNOWN_ID) {
                    _quadVerticesID = geometryCache->allocateID();
                }
                
                if (geometryChanged || colorChanged) {
                    
                    QVector<glm::vec2> points;

                    float angle = startAt;
                    float angleInRadians = glm::radians(angle);
                    glm::vec2 firstInnerPoint(cos(angleInRadians) * innerRadius, sin(angleInRadians) * innerRadius);
                    glm::vec2 firstOuterPoint(cos(angleInRadians) * outerRadius, sin(angleInRadians) * outerRadius);

                    points << firstInnerPoint << firstOuterPoint;

                    while (angle < endAt) {
                        angleInRadians = glm::radians(angle);
                        glm::vec2 thisInnerPoint(cos(angleInRadians) * innerRadius, sin(angleInRadians) * innerRadius);
                        glm::vec2 thisOuterPoint(cos(angleInRadians) * outerRadius, sin(angleInRadians) * outerRadius);

                        points << thisOuterPoint << thisInnerPoint;
                
                        angle += SLICE_ANGLE;
                    }
            
                    // get the last slice portion....
                    angle = endAt;
                    angleInRadians = glm::radians(angle);
                    glm::vec2 lastInnerPoint(cos(angleInRadians) * innerRadius, sin(angleInRadians) * innerRadius);
                    glm::vec2 lastOuterPoint(cos(angleInRadians) * outerRadius, sin(angleInRadians) * outerRadius);
            
                    points << lastOuterPoint << lastInnerPoint;

                    geometryCache->updateVertices(_quadVerticesID, points, color);
                }
                
                geometryCache->renderVertices(gpu::QUAD_STRIP, _quadVerticesID);

            } else {
                if (_lineVerticesID == GeometryCache::UNKNOWN_ID) {
                    _lineVerticesID = geometryCache->allocateID();
                }

                if (geometryChanged || colorChanged) {
                    QVector<glm::vec2> points;
                    
                    float angle = startAt;
                    float angleInRadians = glm::radians(angle);
                    glm::vec2 firstPoint(cos(angleInRadians) * outerRadius, sin(angleInRadians) * outerRadius);
                    points << firstPoint;

                    while (angle < endAt) {
                        angle += SLICE_ANGLE;
                        angleInRadians = glm::radians(angle);
                        glm::vec2 thisPoint(cos(angleInRadians) * outerRadius, sin(angleInRadians) * outerRadius);
                        points << thisPoint;

                        if (getIsDashedLine()) {
                            angle += SLICE_ANGLE / 2.0f; // short gap
                            angleInRadians = glm::radians(angle);
                            glm::vec2 dashStartPoint(cos(angleInRadians) * outerRadius, sin(angleInRadians) * outerRadius);
                            points << dashStartPoint;
                        }
                    }
            
                    // get the last slice portion....
                    angle = endAt;
                    angleInRadians = glm::radians(angle);
                    glm::vec2 lastPoint(cos(angleInRadians) * outerRadius, sin(angleInRadians) * outerRadius);
                    points << lastPoint;

                    geometryCache->updateVertices(_lineVerticesID, points, color);
                }

                if (getIsDashedLine()) {
                    geometryCache->renderVertices(gpu::LINES, _lineVerticesID);
                } else {
                    geometryCache->renderVertices(gpu::LINE_STRIP, _lineVerticesID);
                }
            }
            
            // draw our tick marks
            // for our overlay, is solid means we draw a ring between the inner and outer radius of the circle, otherwise
            // we just draw a line...
            if (getHasTickMarks()) {

                if (_majorTicksVerticesID == GeometryCache::UNKNOWN_ID) {
                    _majorTicksVerticesID = geometryCache->allocateID();
                }
                if (_minorTicksVerticesID == GeometryCache::UNKNOWN_ID) {
                    _minorTicksVerticesID = geometryCache->allocateID();
                }

                if (geometryChanged) {
                    QVector<glm::vec2> majorPoints;
                    QVector<glm::vec2> minorPoints;

                    // draw our major tick marks
                    if (getMajorTickMarksAngle() > 0.0f && getMajorTickMarksLength() != 0.0f) {
                
                        float tickMarkAngle = getMajorTickMarksAngle();
                        float angle = startAt - fmod(startAt, tickMarkAngle) + tickMarkAngle; 
                        float angleInRadians = glm::radians(angle);
                        float tickMarkLength = getMajorTickMarksLength();
                        float startRadius = (tickMarkLength > 0.0f) ? innerRadius : outerRadius;
                        float endRadius = startRadius + tickMarkLength;

                        while (angle <= endAt) {
                            angleInRadians = glm::radians(angle);

                            glm::vec2 thisPointA(cos(angleInRadians) * startRadius, sin(angleInRadians) * startRadius);
                            glm::vec2 thisPointB(cos(angleInRadians) * endRadius, sin(angleInRadians) * endRadius);

                            majorPoints << thisPointA << thisPointB;
                
                            angle += tickMarkAngle;
                        }
                    }

                    // draw our minor tick marks
                    if (getMinorTickMarksAngle() > 0.0f && getMinorTickMarksLength() != 0.0f) {
                
                        float tickMarkAngle = getMinorTickMarksAngle();
                        float angle = startAt - fmod(startAt, tickMarkAngle) + tickMarkAngle; 
                        float angleInRadians = glm::radians(angle);
                        float tickMarkLength = getMinorTickMarksLength();
                        float startRadius = (tickMarkLength > 0.0f) ? innerRadius : outerRadius;
                        float endRadius = startRadius + tickMarkLength;

                        while (angle <= endAt) {
                            angleInRadians = glm::radians(angle);

                            glm::vec2 thisPointA(cos(angleInRadians) * startRadius, sin(angleInRadians) * startRadius);
                            glm::vec2 thisPointB(cos(angleInRadians) * endRadius, sin(angleInRadians) * endRadius);

                            minorPoints << thisPointA << thisPointB;
                
                            angle += tickMarkAngle;
                        }
                    }

                    xColor majorColorX = getMajorTickMarksColor();
                    glm::vec4 majorColor(majorColorX.red / MAX_COLOR, majorColorX.green / MAX_COLOR, majorColorX.blue / MAX_COLOR, alpha);

                    geometryCache->updateVertices(_majorTicksVerticesID, majorPoints, majorColor);

                    xColor minorColorX = getMinorTickMarksColor();
                    glm::vec4 minorColor(minorColorX.red / MAX_COLOR, minorColorX.green / MAX_COLOR, minorColorX.blue / MAX_COLOR, alpha);

                    geometryCache->updateVertices(_minorTicksVerticesID, minorPoints, minorColor);
                }

                geometryCache->renderVertices(gpu::LINES, _majorTicksVerticesID);

                geometryCache->renderVertices(gpu::LINES, _minorTicksVerticesID);
            }
            
 
        glPopMatrix();
    glPopMatrix();
    
    if (geometryChanged) {
        _lastStartAt = startAt;
        _lastEndAt = endAt;
        _lastInnerRadius = innerRadius;
        _lastOuterRadius = outerRadius;
    }
    
    if (glower) {
        delete glower;
    }
}
//----------------------------------------------------------
void ofGLRenderer::setupScreenPerspective(float width, float height, int orientation, bool vFlip, float fov, float nearDist, float farDist) {
	if(width == 0) width = ofGetWidth();
	if(height == 0) height = ofGetHeight();
	if( orientation == 0 ) orientation = ofGetOrientation();

	float w = width;
	float h = height;

	//we do this because ofGetWidth and ofGetHeight return orientated widths and height
	//for the camera we need width and height of the actual screen
	if( orientation == OF_ORIENTATION_90_LEFT || orientation == OF_ORIENTATION_90_RIGHT ){
		h = width;
		w = height;
	}

	float eyeX = w / 2;
	float eyeY = h / 2;
	float halfFov = PI * fov / 360;
	float theTan = tanf(halfFov);
	float dist = eyeY / theTan;
	float aspect = (float) w / h;

	if(nearDist == 0) nearDist = dist / 10.0f;
	if(farDist == 0) farDist = dist * 10.0f;

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(fov, aspect, nearDist, farDist);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	gluLookAt(eyeX, eyeY, dist, eyeX, eyeY, 0, 0, 1, 0);

	//note - theo checked this on iPhone and Desktop for both vFlip = false and true
	switch(orientation) {
		case OF_ORIENTATION_180:
			glRotatef(-180, 0, 0, 1);
			if(vFlip){
				glScalef(1, -1, 1);
				glTranslatef(-width, 0, 0);
			}else{
				glTranslatef(-width, -height, 0);
			}

			break;

		case OF_ORIENTATION_90_RIGHT:
			glRotatef(-90, 0, 0, 1);
			if(vFlip){
				glScalef(-1, 1, 1);
			}else{
				glScalef(-1, -1, 1);
				glTranslatef(0, -height, 0);
			}
			break;

		case OF_ORIENTATION_90_LEFT:
			glRotatef(90, 0, 0, 1);
			if(vFlip){
				glScalef(-1, 1, 1);
				glTranslatef(-width, -height, 0);
			}else{
				glScalef(-1, -1, 1);
				glTranslatef(-width, 0, 0);
			}
			break;

		case OF_ORIENTATION_DEFAULT:
		default:
			if(vFlip){
				glScalef(1, -1, 1);
				glTranslatef(0, -height, 0);
			}
			break;
	}

}
static void draw_keyframe_shape(float x, float y, float xscale, float yscale, bool sel, float alpha)
{
	/* coordinates for diamond shape */
	static const float _unit_diamond_shape[4][2] = {
		{0.0f, 1.0f},   /* top vert */
		{1.0f, 0.0f},   /* mid-right */
		{0.0f, -1.0f},  /* bottom vert */
		{-1.0f, 0.0f}   /* mid-left */
	};
	static GLuint displist1 = 0;
	static GLuint displist2 = 0;
	int hsize = STRIP_HEIGHT_HALF;

	/* initialize 2 display lists for diamond shape - one empty, one filled */
	if (displist1 == 0) {
		displist1 = glGenLists(1);
		glNewList(displist1, GL_COMPILE);

		glBegin(GL_LINE_LOOP);
		glVertex2fv(_unit_diamond_shape[0]);
		glVertex2fv(_unit_diamond_shape[1]);
		glVertex2fv(_unit_diamond_shape[2]);
		glVertex2fv(_unit_diamond_shape[3]);
		glEnd();
		glEndList();
	}
	if (displist2 == 0) {
		displist2 = glGenLists(1);
		glNewList(displist2, GL_COMPILE);

		glBegin(GL_QUADS);
		glVertex2fv(_unit_diamond_shape[0]);
		glVertex2fv(_unit_diamond_shape[1]);
		glVertex2fv(_unit_diamond_shape[2]);
		glVertex2fv(_unit_diamond_shape[3]);
		glEnd();
		glEndList();
	}

	glPushMatrix();

	/* adjust view transform before starting */
	glTranslatef(x, y, 0.0f);
	glScalef(1.0f / xscale * hsize, 1.0f / yscale * hsize, 1.0f);

	/* anti-aliased lines for more consistent appearance */
	glEnable(GL_LINE_SMOOTH);

	if (sel)
		UI_ThemeColorShadeAlpha(TH_STRIP_SELECT, 50, -255 * (1.0f - alpha));
	else
		glColor4f(0.91f, 0.91f, 0.91f, alpha);

	glCallList(displist2);

	/* exterior - black frame */
	glColor4f(0.0f, 0.0f, 0.0f, alpha);
	glCallList(displist1);

	glDisable(GL_LINE_SMOOTH);

	/* restore view transform */
	glPopMatrix();
}
Exemple #4
0
// render terrain
void Terrain::render (float x, float z) {
    // multitexturing functions
    glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) SDL_GL_GetProcAddress("glActiveTextureARB");
    glMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC) SDL_GL_GetProcAddress("glMultiTexCoord2fARB");

    // enable multitexturing
    glActiveTextureARB (GL_TEXTURE0_ARB);
    glEnable (GL_TEXTURE_2D);
    tm -> setTexture (TERRAIN_GREEN);					// carica la texture del terreno
    glActiveTextureARB (GL_TEXTURE1_ARB);
    glEnable (GL_TEXTURE_2D);
    glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
    glTexEnvi (GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2);
    tm -> setTexture (TERRAIN_DETAIL);					// carica la texture del dettaglio
    // scala la seconda texture (quella del dettaglio)
    glMatrixMode (GL_TEXTURE);								// entra nel modello delle texture
    glLoadIdentity ();									// resetta la matrice corrente e scala la texture
    glScalef (TEXTURE_DATAIL, TEXTURE_DATAIL, 1);
    glMatrixMode (GL_MODELVIEW);							// torna alla matrice del modello (NORMALE)

    // draw
    bool poly_is_near = false;
    static float res_to_check = res;
    glBegin (GL_TRIANGLES);
    for (int loop = 0; loop < num_vert; loop += 4) {
        glNormal3fv (&normal[loop/4].x);					// normal
        // controlla se il poligono è vicino
        if (	fabs(vertex[loop].x - x) < res_to_check || fabs(vertex[loop+1].x - x) < res_to_check ||
                fabs(vertex[loop+2].x - x) < res_to_check || fabs(vertex[loop+3].x - x) < res_to_check)
            if (	fabs(vertex[loop].z - z) < res_to_check || fabs(vertex[loop+1].z - z) < res_to_check ||
                    fabs(vertex[loop+2].z - z) < res_to_check || fabs(vertex[loop+3].z - z) < res_to_check)
                poly_is_near = true;
        // triangle 1 - check frustum
        if (	poly_is_near ||
                frustum -> pointInFrustum(vertex[loop].x, vertex[loop].y, vertex[loop].z) ||
                frustum -> pointInFrustum(vertex[loop+1].x, vertex[loop+1].y, vertex[loop+1].z) ||
                frustum -> pointInFrustum(vertex[loop+2].x, vertex[loop+2].y, vertex[loop+2].z)) {
            // draw triangle
            glMultiTexCoord2fARB (GL_TEXTURE0_ARB, texcoord[loop].u, texcoord[loop].v);
            glMultiTexCoord2fARB (GL_TEXTURE1_ARB, texcoord[loop].u, texcoord[loop].v);
            glVertex3fv (&vertex[loop].x);					// vertex
            glMultiTexCoord2fARB (GL_TEXTURE0_ARB, texcoord[loop+1].u, texcoord[loop+1].v);
            glMultiTexCoord2fARB (GL_TEXTURE1_ARB, texcoord[loop+1].u, texcoord[loop+1].v);
            glVertex3fv (&vertex[loop+1].x);					// vertex
            glMultiTexCoord2fARB (GL_TEXTURE0_ARB, texcoord[loop+2].u, texcoord[loop+2].v);
            glMultiTexCoord2fARB (GL_TEXTURE1_ARB, texcoord[loop+2].u, texcoord[loop+2].v);
            glVertex3fv (&vertex[loop+2].x);					// vertex
        }
        // triangle 2 - check frustum
        if (	poly_is_near ||
                frustum -> pointInFrustum(vertex[loop].x, vertex[loop].y, vertex[loop].z) ||
                frustum -> pointInFrustum(vertex[loop+2].x, vertex[loop+2].y, vertex[loop+2].z) ||
                frustum -> pointInFrustum(vertex[loop+3].x, vertex[loop+3].y, vertex[loop+3].z)) {
            // draw triangle
            glMultiTexCoord2fARB (GL_TEXTURE0_ARB, texcoord[loop].u, texcoord[loop].v);
            glMultiTexCoord2fARB (GL_TEXTURE1_ARB, texcoord[loop].u, texcoord[loop].v);
            glVertex3fv (&vertex[loop].x);					// vertex
            glMultiTexCoord2fARB (GL_TEXTURE0_ARB, texcoord[loop+2].u, texcoord[loop+2].v);
            glMultiTexCoord2fARB (GL_TEXTURE1_ARB, texcoord[loop+2].u, texcoord[loop+2].v);
            glVertex3fv (&vertex[loop+2].x);					// vertex
            glMultiTexCoord2fARB (GL_TEXTURE0_ARB, texcoord[loop+3].u, texcoord[loop+3].v);
            glMultiTexCoord2fARB (GL_TEXTURE1_ARB, texcoord[loop+3].u, texcoord[loop+3].v);
            glVertex3fv (&vertex[loop+3].x);					// vertex
        }
    }
    glEnd ();

    // disable multitexturing
    glActiveTextureARB (GL_TEXTURE1_ARB);
    glDisable (GL_TEXTURE_2D);
    glActiveTextureARB (GL_TEXTURE0_ARB);
    glDisable (GL_TEXTURE_2D);
}
Exemple #5
0
ENTRYPOINT void
draw_unicrud (ModeInfo *mi)
{
  unicrud_configuration *bp = &bps[MI_SCREEN(mi)];
  Display *dpy = MI_DISPLAY(mi);
  Window window = MI_WINDOW(mi);

  if (!bp->glx_context)
    return;

  glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(bp->glx_context));

  glShadeModel (GL_FLAT);
  glEnable (GL_NORMALIZE);
  glDisable (GL_CULL_FACE);
  glDisable (GL_LIGHTING);

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  if (! bp->button_down_p)
    switch (bp->state) {
    case IN:     bp->ratio += speed * 0.05;  break;
    case OUT:    bp->ratio += speed * 0.05;  break;
    case LINGER: bp->ratio += speed * 0.005; break;
    default:     abort();
    }

  if (bp->ratio > 1.0)
    {
      bp->ratio = 0;
      switch (bp->state) {
      case IN:
        bp->state = LINGER;
        break;
      case LINGER:
        bp->state = OUT;
        bp->spin_direction = (random() & 1) ? 1 : -1;
        break;
      case OUT:
        bp->state = IN;
        pick_unichar(mi);
        break;
      default:     abort();
      }
    }

  glPushMatrix ();

  {
    double x, y, z;
    get_position (bp->rot, &x, &y, &z, !bp->button_down_p);
    glTranslatef((x - 0.5) * 6,
                 (y - 0.5) * 6,
                 (z - 0.5) * 6);

    gltrackball_rotate (bp->trackball);

    get_rotation (bp->rot, &x, &y, &z, !bp->button_down_p);
    x = y = 0;
    glRotatef (x * 360, 1.0, 0.0, 0.0);
    glRotatef (y * 360, 0.0, 1.0, 0.0);
    glRotatef (z * 360, 0.0, 0.0, 1.0);
  }

# define SINOID(N) (sin(M_PI - (N) / 2 * M_PI))
  {
    GLfloat s;
    switch (bp->state) {
    case IN:  s = SINOID (bp->ratio);   break;
    case OUT: s = SINOID (1-bp->ratio); break;
    default:  s = 1; break;
    }
    glScalef (s, s, s);
    glRotatef (360 * s * bp->spin_direction * (bp->state == IN ? -1 : 1),
               0, 0, 1);
  }

  draw_unichar (mi);

  glPopMatrix ();

  if (mi->fps_p) do_fps (mi);
  glFinish();

  glXSwapBuffers(dpy, window);
}
void GaManagerApp::draw()
{
	
	if(screenW != ofGetWidth() )
	{
		int diffX = ofGetWidth()- screenW;
		for( int i = 0; i < 3; i++)
			polyButtons[i].moveAllPointsBy( ofPoint(diffX,0) );
		
		screenW = ofGetWidth();
		
	}
	
	if(bSetSplashTag)
	{
	
	glEnable(GL_DEPTH_TEST);
	
	glPushMatrix();
	
		glTranslatef(tag.position.x,tag.position.y, 0);
		glTranslatef(ofGetWidth()/2.f, ofGetHeight()/2.f, 0);
		glScalef(tag.position.z,tag.position.z,tag.position.z);
		glRotatef(tag.rotation.x,1,0,0);
		glRotatef(tag.rotation.y+rotationY,0,1,0);
		glRotatef(tag.rotation.z,0,0,1);
	
		glTranslatef(-tag.min.x*tag.drawScale,-tag.min.y*tag.drawScale,-tag.min.z);
		glTranslatef(-tag.center.x*tag.drawScale,-tag.center.y*tag.drawScale,-tag.center.z);
		
		glDisable(GL_DEPTH_TEST);
		particleDrawer.draw(myTagPlayer.getCurrentPoint().z,  ofGetWidth(),  ofGetHeight());
		glEnable(GL_DEPTH_TEST);
						  
						  
		glPushMatrix();
			glScalef( tag.drawScale, tag.drawScale, 1);
			drawer.draw( myTagPlayer.getCurrentStroke(), myTagPlayer.getCurrentId() );
		glPopMatrix();
		
	glPopMatrix();
	
	}
	
	glDisable(GL_DEPTH_TEST);
	
	xp = ofGetWidth()-320;
	yp = 120;
	
	ofEnableAlphaBlending();
	
	ofFill();
	ofSetColor(0, 0, 0, 220);
	ofRect(xp,-10,380,ofGetHeight()+20);
	
	ofNoFill();
	ofSetColor(100, 100, 100);
	ofRect(xp,-10,380,ofGetHeight()+20);
	
	xp += 20;
	
	ofSetColor(255, 255, 255);
	titleImage.draw(xp-3,yp);
	
	yp += titleImage.height + 40;
	
	fontSS.drawString("Graffiti Analysis 3.0 by Evan Roth.",xp,yp);
	fontSS.drawString("Software development by Chris Sugrue.",xp,yp+=20);
	fontSS.drawString("Laser input integration by Theo Watson.",xp,yp+=20);
	fontSS.drawString("Complies with all <GML> standards.",xp,yp+=20);
	fontSS.drawString("GNU General Public License.",xp,yp+=20);
	fontSS.drawString("graffitianalysis.com", xp, yp+=30);
	
	
	yp+=90;
	fontSS.drawString("LAUNCH", xp, yp);
	fontS.drawString("PLAYBACK", xp+60, yp);
	
	fontSS.drawString("LAUNCH", xp, yp+=40);
	fontS.drawString("LASER INPUT ", xp+60, yp);
	
	//fontSS.drawString("LAUNCH", xp, yp+80);
	//fontS.drawString("RECORDER", xp+60, yp+80);
	
	for( int i = 0; i < tModes; i++) polyButtons[i].draw();
	
	
	fontSS.drawString("F1: home", xp, yp+=80);
	fontSS.drawString("x: toggle controls", xp, yp+=20);
	fontSS.drawString("f: toggle fullscreen", xp, yp+=20);
}
/**************************Desenho do mundo************************************/
void display(void){
 
  int i;
  glClear(GL_COLOR_BUFFER_BIT);
  glColor3f (1.0, 1.0, 1.0);
 
//girar o objeto
 glRotatef((GLfloat) eixoxObjeto, 1.0, 0.0, 0.0);
 glRotatef((GLfloat) eixoyObjeto, 0.0, 1.0, 0.0);
 glRotatef((GLfloat) eixozObjeto, 0.0, 0.0, 1.0);
 
 

//  glPushMatrix();
 
  /*parte da frentde do barquinho*/
  glBegin(GL_POLYGON);
  glColor3f (0.0, 1.0, 0.0);// VERDE
  glVertex3f(15.0, 0.0,0.0);
  glVertex3f(5.0, 5.0,0.0);
  glVertex3f(40.0, 5.0,0.0);
  glVertex3f(30.0, 0.0,0.0);
  glEnd();
 
  /*parte de trás do barquinho*/
  glBegin(GL_POLYGON);
  glColor3f (0.0, 1.0, 0.0);// AMARELO
  glVertex3f(15.0, 0.0,-10.0);
  glVertex3f(5.0, 5.0,-10.0);
  glVertex3f(40.0, 5.0,-10.0);
  glVertex3f(30.0, 0.0,-10.0);
  glEnd();
 
   /*parte de baixo do barquinho*/
  glBegin(GL_POLYGON);
  glColor3f (0.0, 1.0, 0.0);// VERDE
  glVertex3f(15.0, 0.0,-10.0);
  glVertex3f(15.0, 0.0,0.0);
  glVertex3f(30.0, 0.0,0.0);
  glVertex3f(30.0, 0.0,-10.0);
  glEnd();
 
 
 /*parte esquerda do barquinho*/
  glBegin(GL_POLYGON);
  glColor3f (0.0, 1.0, 1.0);// AZUL
  glVertex3f(15.0, 0.0,0.0);
  glVertex3f(15.0, 0.0,-10.0);
  glVertex3f(5.0, 5.0,-10.0);
  glVertex3f(5.0, 5.0,0.0);
  glEnd();

 
 /*parte direita do barquinho*/
  glBegin(GL_POLYGON);
  glColor3f (0.0, 1.0, 0.0);//
  glVertex3f(30.0, 0.0,0.0);
  glVertex3f(30.0, 0.0,-10.0);
  glVertex3f(40.0, 5.0,-10.0);
  glVertex3f(40.0, 5.0,0.0);
  glEnd();
 
/**************************PARTE DO SALVA VIDAS**************************************/

   /* PRIMEIRO salva Vidas do barquinho*/
   glPushMatrix();
        glColor3f (1.5, 0.5, 0.5);// NAO SEI Q COR EH ESSA
        glTranslated(15.0,3.5,-6);
        glutSolidTorus(0.5,1,20,20);
    glPopMatrix();
    
    /* SEGUNDO salva Vidas do barquinho*/
   glPushMatrix();
        glColor3f (1.5, 0.5, 0.5);// NAO SEI Q COR EH ESSA
        glTranslated(20.0,3.5,-6);
        glutSolidTorus(0.5,1,20,20);
    glPopMatrix();
    
    /* TERCEIRO salva Vidas do barquinho*/
   glPushMatrix();
        glColor3f (1.5, 0.5, 0.5);// NAO SEI Q COR EH ESSA
        glTranslated(25.0,3.5,-6);
        glutSolidTorus(0.5,1,20,20);
    glPopMatrix();
   
   /* QUARTO salva Vidas do barquinho*/
   glPushMatrix();
        glColor3f (1.5, 0.5, 0.5);// NAO SEI Q COR EH ESSA
        glTranslated(30.0,3.5,-6);
        glutSolidTorus(0.5,1,20,20);
    glPopMatrix();

  /*************************Mastro do barquinho***************************/
  glBegin(GL_LINES);
  glColor3f (0.0, 0.0, 0.0);// PRETO
  glVertex3f(23.0, 5.0,0.0);
  glVertex3f(23.0, 15.0,0.0);
  glEnd();
   

  /*************************Bandeirinha do barquinho********************************/
     glPushMatrix();
          glColor3f (0.5, 0.7, 1.0);
          glTranslatef(23.0,12.0,0.0);
          glRotatef(-270,0,1,0);
          glScalef(1.0,3.0,1.0);
          glutSolidCone(1.0,5.0, 15.0, 15.0);        
          glPopMatrix();
 
  /***************************desenho de mar*******************************************/
  glBegin(GL_LINE_STRIP);
  glColor3f (0.0, 0.0, 1.0);
      for (i = 0; i <= 30; i++)
         glEvalCoord1f((GLfloat) i/30.0);
   glEnd();
  /* `mostragem dos pontos de controle  */
  glPointSize(5.0);
   glColor3f(0.0, 0.0, 1.0);
   
   glBegin(GL_POINTS);
      for (i = 0; i < 4; i++)
         glVertex3fv(&ctrlpoints[i][0]);
   glEnd();
   
   
  desenhaSol();
 
  glFlush();
  glutSwapBuffers();
}
static void
_draw_track (RendererSimTraffic *self, const lcmtypes_track_t *vd)
{
    // generate a stable non-black, non-white color from object ID
    srand(vd->id);
    GLfloat rgb[4];
    rand_color(rgb);

    glColorMaterial (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
    glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT, rgb);
    glMaterialfv (GL_FRONT_AND_BACK, GL_DIFFUSE, rgb);

    // assumes viewing, modeling matrices, etc. set up for local frame
    // leaves these matrices as they were before invocation
    glMatrixMode (GL_MODELVIEW);
    glPushMatrix();

    glTranslated (vd->pos[0], vd->pos[1], 0);

// rotate basis to body coords of vehicle (rotate by theta about Z axis)
    glRotated (to_degrees(vd->theta), 0.0, 0.0, 1.0); // convert rad to deg

    if (self->ehandler.hovering && 
            self->selected_vehicle_id == vd->id) {
        glColor4f (1, 1, 1, 0.6);
    } else {
        glColor4fv(rgb);
    }

//    int use_model =  gtku_param_widget_get_bool(self->pw, PARAM_PRETTY);
//
//    if (use_model) {
//
//        glRotated(90, 0, 0, 1);
//        glRotated(90, 1, 0, 0);
//        
//        double s = 4.5;
//        glScalef(s,s,s);
//        
//        glTranslated(0,.115,0); // car height
//        glTranslated(0,0,.1); // front-to-back offset
//        glBegin(GL_TRIANGLES);
//        for (int i = 0; i < numChevy_vanFaces; i++) {
//            int *vs = Chevy_vanFaces[i];
//            for (int j = 0; j < 3; j++) {
//                glNormal3fv(Chevy_vanVertNorms[vs[j]]);
//                glVertex3fv(Chevy_vanVerts[vs[j]]);
//            }
//            
//        }
//        glEnd();
//    } else {

    glTranslated ( 0, 0, VEHICLE_HEIGHT / 2);

    glScalef (vd->size[0], vd->size[1], VEHICLE_HEIGHT);
    glutil_draw_cube();
//    }

    // restore matrix state
    glPopMatrix();

    if (self->ehandler.picking && self->selected_vehicle_id == vd->id) {
        glColor4f (1, 1, 1, 0.6);
        glPushMatrix ();
        glTranslatef (self->last_xy[0], self->last_xy[1], 0);
        glRotated (to_degrees(vd->theta), 0.0, 0.0, 1.0); // convert rad to deg
        glScalef (vd->size[0], vd->size[1], VEHICLE_HEIGHT);
        glutil_draw_cube_frame ();
        glPopMatrix ();
    }
}
Exemple #9
0
/* draw an ant */
static Bool draw_antinspect_ant(ModeInfo *mi, antinspectstruct * mp, 
                                const float *Material, int mono,
                                Bool (*sphere)(float), Bool (*cone)(float)) 
{
  float       cos1 = cos(mp->ant_step);
  float       cos2 = cos(mp->ant_step + 2 * Pi / 3);
  float       cos3 = cos(mp->ant_step + 4 * Pi / 3);
  float       sin1 = sin(mp->ant_step);
  float       sin2 = sin(mp->ant_step + 2 * Pi / 3);
  float       sin3 = sin(mp->ant_step + 4 * Pi / 3);
  
  if (mono)
    glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialGray5);
  else
    glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, Material);
  glEnable(GL_CULL_FACE);
  glPushMatrix();
  glScalef(1, 1.3, 1);
  if (!((*sphere)(0.18)))
    return False;
  glScalef(1, 1 / 1.3, 1);
  glTranslatef(0.00, 0.30, 0.00);
  if (!((*sphere)(0.2)))
    return False;
  
  glTranslatef(-0.05, 0.17, 0.05);
  glRotatef(-90, 1, 0, 0);
  glRotatef(-25, 0, 1, 0);
  if (!((*cone)(0.05)))
    return False;
  glTranslatef(0.00, 0.10, 0.00);
  if (!((*cone)(0.05)))
    return False;
  glRotatef(25, 0, 1, 0);
  glRotatef(90, 1, 0, 0);
  
  glScalef(1, 1.3, 1);
  glTranslatef(0.15, -0.65, 0.05);
  if (!((*sphere)(0.25)))
    return False;
  glScalef(1, 1 / 1.3, 1);
  glPopMatrix();
  glDisable(GL_CULL_FACE);
  
  glDisable(GL_LIGHTING);
  
  /* ANTENNAS */
  glBegin(GL_LINES);
  if (mono)
    glColor3fv(MaterialGray5);
  else
    glColor3fv(Material);
  glVertex3f(0.00, 0.30, 0.00);
  glColor3fv(MaterialGray);
  glVertex3f(0.40, 0.70, 0.40);
  mi->polygon_count++;
  if (mono)
    glColor3fv(MaterialGray5);
  else
    glColor3fv(Material);
  glVertex3f(0.00, 0.30, 0.00);
  glColor3fv(MaterialGray);
  glVertex3f(0.40, 0.70, -0.40);
  mi->polygon_count++;
  glEnd();
  glBegin(GL_POINTS);
  if (mono)
    glColor3fv(MaterialGray6);
  else
    glColor3fv(Material);
  glVertex3f(0.40, 0.70, 0.40);
  mi->polygon_count++;
  glVertex3f(0.40, 0.70, -0.40);
  mi->polygon_count++;
  glEnd();
  
  /* LEFT-FRONT ARM */
  glBegin(GL_LINE_STRIP);
  if (mono)
    glColor3fv(MaterialGray5);
  else
    glColor3fv(Material);
  glVertex3f(0.00, 0.05, 0.18);
  glVertex3f(0.35 + 0.05 * cos1, 0.15, 0.25);
  mi->polygon_count++;
  glColor3fv(MaterialGray);
  glVertex3f(-0.20 + 0.05 * cos1, 0.25 + 0.1 * sin1, 0.45);
  mi->polygon_count++;
  glEnd();
  
  /* LEFT-CENTER ARM */
  glBegin(GL_LINE_STRIP);
  if (mono)
    glColor3fv(MaterialGray5);
  else
    glColor3fv(Material);
  glVertex3f(0.00, 0.00, 0.18);
  glVertex3f(0.35 + 0.05 * cos2, 0.00, 0.25);
  mi->polygon_count++;
  glColor3fv(MaterialGray);
  glVertex3f(-0.20 + 0.05 * cos2, 0.00 + 0.1 * sin2, 0.45);
  mi->polygon_count++;
  glEnd();
  mi->polygon_count++;
  
  /* LEFT-BACK ARM */
  glBegin(GL_LINE_STRIP);
  if (mono)
    glColor3fv(MaterialGray5);
  else
    glColor3fv(Material);
  glVertex3f(0.00, -0.05, 0.18);
  glVertex3f(0.35 + 0.05 * cos3, -0.15, 0.25);
  mi->polygon_count++;
  glColor3fv(MaterialGray);
  glVertex3f(-0.20 + 0.05 * cos3, -0.25 + 0.1 * sin3, 0.45);
  mi->polygon_count++;
  glEnd();
  
  /* RIGHT-FRONT ARM */
  glBegin(GL_LINE_STRIP);
  if (mono)
    glColor3fv(MaterialGray5);
  else
    glColor3fv(Material);
  glVertex3f(0.00, 0.05, -0.18);
  glVertex3f(0.35 - 0.05 * sin1, 0.15, -0.25);
  mi->polygon_count++;
  glColor3fv(MaterialGray);
  glVertex3f(-0.20 - 0.05 * sin1, 0.25 + 0.1 * cos1, -0.45);
  mi->polygon_count++;
  glEnd();
  
  /* RIGHT-CENTER ARM */
  glBegin(GL_LINE_STRIP);
  if (mono)
    glColor3fv(MaterialGray5);
  else
    glColor3fv(Material);
  glVertex3f(0.00, 0.00, -0.18);
  glVertex3f(0.35 - 0.05 * sin2, 0.00, -0.25);
  mi->polygon_count++;
  glColor3fv(MaterialGray);
  glVertex3f(-0.20 - 0.05 * sin2, 0.00 + 0.1 * cos2, -0.45);
  mi->polygon_count++;
  glEnd();
  
  /* RIGHT-BACK ARM */
  glBegin(GL_LINE_STRIP);
  if (mono)
    glColor3fv(MaterialGray5);
  else
    glColor3fv(Material);
  glVertex3f(0.00, -0.05, -0.18);
  glVertex3f(0.35 - 0.05 * sin3, -0.15, -0.25);
  mi->polygon_count++;
  glColor3fv(MaterialGray);
  glVertex3f(-0.20 - 0.05 * sin3, -0.25 + 0.1 * cos3, -0.45);
  mi->polygon_count++;
  glEnd();
    
  glEnable(GL_LIGHTING);
  
  return True;
}
Exemple #10
0
static void createRobot() {
    
    // Create body
    glPushMatrix();
    glTranslatef(0, 0, 0);
    glColor3f(red, green, blue);
    glScalef(3, 3, 2);
    glutSolidCube(1);
    glPopMatrix();

    // Create head
    glPushMatrix();
    glTranslatef(0, 2, 0);
    glColor3f(red, green, blue);
    glScalef(1.5, 1, 1);
    glutSolidCube(1);
    glPopMatrix();
    
    // Create right leg
    glPushMatrix();
    glTranslatef(-1, -2.5, 0);
    glRotatef(rightRun, 1.0f, 0, 0);
    glColor3f(red, green, blue);
    glScalef(1, 2.5, 1);
    glutSolidCube(1);
    glPopMatrix();
    
    // Create left leg
    glPushMatrix();
    glTranslatef(1, -2.5, 0);
    glRotatef(leftRun, 1.0f, 0, 0);
    glColor3f(red, green, blue);
    glScalef(1, 2.5, 1);
    glutSolidCube(1);
    glPopMatrix();
    
    // Right arm
    glPushMatrix();
    glTranslatef(-armPos, 1, 0);
    //glRotatef(leftRun, 2.0f, 0, 0);
    glRotatef(angle, 0, 0, 1.0f);
    glColor3f(red, green, blue);
    glScalef(0.3, 1.8, 0.5);
    glutSolidCube(1);
    glPopMatrix();
    
    // Left arm
    glPushMatrix();
    glTranslatef(armPos, 1, 0);
    //glRotatef(rightRun, 1.0f, 0, 0);
    glRotatef(-angle, 0, 0, 1.0f);
    glColor3f(red, green, blue);
    glScalef(0.3, 1.8, 0.5);
    glutSolidCube(1);
    glPopMatrix();
    
    // Right eye
    glPushMatrix();
    glTranslatef(-0.5, 2, 0.5);
    glColor3f(eyeRed, eyeGreen, eyeBlue);
    glScalef(0.1, 0.1, 0.1);
    glutSolidCube(1);
    glPopMatrix();
    
    // Left eye
    glPushMatrix();
    glTranslatef(0.5, 2, 0.5);
    glColor3f(eyeRed, eyeGreen, eyeBlue);
    glScalef(0.1, 0.1, 0.1);
    glutSolidCube(1);
    glPopMatrix();
    
}
int a_DrawGLScene(GLfloat globtime)
{
	if (init) {a_InitGL();init=false;}
	a_time=2.0+globtime*.01;
	// MOTION
	if (a_time<10.0f)
	{
		a_zeta=25.0f*cos((3.1415f/2.0f)*(1+a_time/10.0f));
		a_xrot=-45.0f*cos((3.1415f/2.0f)*(1+a_time/10.0f));
	}
	else
	{
		a_xrot=45.0f-30.0f*sin((a_time-10.0f)/20.0f)*sin((a_time-10.0f)/20.0f);
		a_zrot=360.0f*sin((a_time-10.0f)/50.0f)*sin((a_time-10.0f)/50.0f);
		a_zeta=-25.0f+5.0f*sin((a_time-10.0f)/10.0f)*sin((a_time-10.0f)/10.0f);
	}

	if (a_time>90.0f) a_zeta=-20.0f+10.0f*(1.0f-cos((a_time-90.0f)*3.1415f/10.0f));

	if (a_zeta>-2.5f) a_zeta=-2.5f;
	a_factor=(a_xrot/.5+20)/50.0f;

	if (a_mod>0.5f) a_mod=1.0-.03f*(a_time-a_gets); else a_mod=.5-0.015f*(a_time-a_gets);
	if (a_mod<0.0f) a_mod=0.0f;
	glDisable(GL_TEXTURE_2D);
	glLoadIdentity();
	glTranslatef(0,0,-5);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	if (a_zeta>-20.0f) glColor4f(0,0,0,-(a_zeta+20.0f)/40.0f+.25f);
	else glColor4f(0,0,0,.25f);
	glDisable(GL_LIGHTING);
	glEnable(GL_BLEND);
	a_drawquad(6);
	if (first)//a_time<3.01f)
	{
		glDisable(GL_BLEND);
		glColor4ub(255,255,255,255);
		a_drawquad(6);
		glEnable(GL_BLEND);
		first=false;
	}
	if (a_time>95.0f)
	{
		glColor4f(1.0f,1.0f,1.0f,(a_time-95.0f)/1.5f);
		a_drawquad(6);
	}
	glEnable(GL_TEXTURE_2D);
	glBlendFunc(GL_SRC_ALPHA,GL_ONE);
	glEnable(GL_LIGHTING);
	glLoadIdentity();
	if (a_time>30.0) glTranslatef(0.0f,1.5f,a_zeta);
	else glTranslatef(0.0f,.5+.5f*(1.0-cos((a_time-2.0f)*3.1415f/28.0f)),a_zeta);
	glRotatef(-90+2*a_xrot,1.0f,0.0f,0.0f);
	glRotatef(a_yrot,0.0f,1.0f,0.0f);
	glRotatef(a_zrot,0.0f,0.0f,1.0f);


	for (int a_xx=0; a_xx<size; a_xx++) for (int a_yy=0; a_yy<size; a_yy++)
	{
		double raggio;
		double value;
		double arg;

		if (quantos>0.0f)
		{
			raggio=.5*sqrt((double)((a_points[a_xx][a_yy][0]-a_points[size/2][size/2][0])*(a_points[a_xx][a_yy][0]-a_points[size/2][size/2][0])
										  +(a_points[a_xx][a_yy][1]-a_points[size/2][size/2][1])*(a_points[a_xx][a_yy][1]-a_points[size/2][size/2][1])));
			arg=2.5*raggio-quantos*2+30;
			if ((arg<-2*6.28)||(arg>4*6.28)) value=0; else
			value=.05*sin(arg)*sin(arg)*exp(arg/7);
			a_points[a_xx][a_yy][2]=value;
		}
		if (quantos>10)
		{
			raggio=.5*sqrt((double)((a_points[a_xx][a_yy][0]-a_points[48][48][0])*(a_points[a_xx][a_yy][0]-a_points[48][48][0])
									  +(a_points[a_xx][a_yy][1]-a_points[48][48][1])*(a_points[a_xx][a_yy][1]-a_points[48][48][1])));
			arg=2.5*raggio-(quantos-10)*3+30;
			if ((arg<-2*6.28)||(arg>4*6.28)) value=0; else
			value=.025*sin(arg)*sin(arg)*exp(arg/7);
			a_points[a_xx][a_yy][2]+=value;
		}
		if (quantos>24)
		{
			raggio=.5*sqrt((double)((a_points[a_xx][a_yy][0]-a_points[50][22][0])*(a_points[a_xx][a_yy][0]-a_points[50][22][0])
									  +(a_points[a_xx][a_yy][1]-a_points[50][22][1])*(a_points[a_xx][a_yy][1]-a_points[50][22][1])));
			arg=3.0*raggio-(quantos-24)*4+30;
			if ((arg<-2*6.28)||(arg>4*6.28)) value=0; else
			value=.02*sin(arg)*sin(arg)*exp(arg/7);
			a_points[a_xx][a_yy][2]+=value;
		}
		if (quantos>32)
		{
			raggio=.5*sqrt((double)((a_points[a_xx][a_yy][0]-a_points[32][32][0])*(a_points[a_xx][a_yy][0]-a_points[32][32][0])
									  +(a_points[a_xx][a_yy][1]-a_points[32][32][1])*(a_points[a_xx][a_yy][1]-a_points[32][32][1])));
			arg=2.5*raggio-(quantos-32)*3+30;
			if ((arg<0*6.28)||(arg>4*6.28)) value=0; else
			value=.035*sin(arg)*sin(arg)*exp(arg/7);
			a_points[a_xx][a_yy][2]+=value;
		}

		calcul(a_xx,a_yy);
	}
	if (a_time>34.0f) quantos=2.0+(a_time-34.0)/1.5f;

	a_Text[1].Use();
	glMaterialfv(GL_FRONT,GL_DIFFUSE,a_diffuse);
	glMaterialfv(GL_FRONT,GL_AMBIENT,a_ambient);
	glMaterialfv(GL_FRONT,GL_SPECULAR,a_specular);
	glMaterialf(GL_FRONT,GL_SHININESS,10.0f);
//	glPushMatrix(); // what for?
	//glDisable(GL_LIGHTING);
	glScalef(-1,-1,1);
	glColor4f(1,1,1,1);

//	glPushMatrix(); // what for?
	glTranslatef(-12.8,12.8,0);



	glNormal3f(0,0,1);
	for (int cc=0; cc<1; cc++)
	{
		if ((cc%2)==0)
		{
			glScalef(1,-1,1);
			glFrontFace(GL_CCW);
		}
		else
		{
			glScalef(-1,1,1);
			glFrontFace(GL_CW);
		}
		glBegin(GL_QUADS);
		for( a_x = 0; a_x < size-1; a_x++ )
		{
			if (1)//a_x%2==0)
			{
			for( a_y = 0; a_y < size-1; a_y++ )
			{
				glTexCoord2fv(newcoord[a_x][a_y]);
				//glNormal3f(-norm[a_x][a_y][0],-norm[a_x][a_y][1],-norm[a_x][a_y][2]);
				glVertex3fv( a_points[a_x][a_y]);

				glTexCoord2fv(newcoord[a_x][a_y+1]);
				//glNormal3f(-norm[a_x][a_y+1][0],-norm[a_x][a_y+1][1],-norm[a_x][a_y+1][2]);
				glVertex3fv( a_points[a_x][a_y+1]);

				glTexCoord2fv(newcoord[a_x+1][a_y+1]);
				//glNormal3f(-norm[a_x+1][a_y+1][0],-norm[a_x+1][a_y+1][1],-norm[a_x+1][a_y+1][2]);
				glVertex3fv( a_points[a_x+1][a_y+1]);

				glTexCoord2fv(newcoord[a_x+1][a_y]);
				//glNormal3f(-norm[a_x+1][a_y][0],-norm[a_x+1][a_y][1],-norm[a_x+1][a_y][2]);
				glVertex3fv( a_points[a_x+1][a_y]);
			}
			}
			else
			{
			for(a_y=size-2;a_y>=0;a_y--)
			{
				glTexCoord2fv(newcoord[a_x][a_y]);
				glVertex3fv( a_points[a_x][a_y]);

				glTexCoord2fv(newcoord[a_x][a_y+1]);
				glVertex3fv( a_points[a_x][a_y+1]);

				glTexCoord2fv(newcoord[a_x+1][a_y+1]);
				glVertex3fv( a_points[a_x+1][a_y+1]);

				glTexCoord2fv(newcoord[a_x+1][a_y]);
				glVertex3fv( a_points[a_x+1][a_y]);
			}
			}
		}
		glEnd();
	}
//	glPushMatrix(); // what for?
	glDisable(GL_DEPTH_TEST);
//	glPopMatrix(); // what for?
	glDisable(GL_LIGHTING);
	a_Text[4].Use();
	a_counter=a_time*10.0f;

	for (int p=0; p<a_num; p++)
	{
		GLfloat time;
		time=a_time*500-2.0-parts[p].time;//********************************************************
		glPushMatrix();
		glTranslatef(parts[p].a_x,parts[p].a_y,parts[p].z);
		glRotatef(-a_zrot,0,0,1);
		glRotatef(90-2.0f*a_xrot,1,0,0);
		glRotatef(parts[p].angle-135,0,0,1);
		glTranslatef(parts[p].a_mod,0,0);

		if (a_time<20.0f) glColor4ub(parts[p].r,parts[p].g,parts[p].b,(unsigned char)((parts[p].a-(int)((GLfloat)time/8.0f))*(a_time-6.0)/14.0));
		else glColor4ub(parts[p].r,parts[p].g,parts[p].b,(unsigned char)(parts[p].a-(int)((GLfloat)time/8.0f)));

		if (a_time>6.0) a_drawquad(1.125f-.75*p/a_num);
		parts[p].a_mod=parts[p].speed*time/35.0f;
		parts[p].speed=parts[p].speedlim-time/2500000.0f;
		if (parts[p].speed<0.005f) parts[p].speed=0.005f;
		if (parts[p].a-(int)((GLfloat)time/8.0f)<3)

		{
			parts[p].a_x=10.0f*sin(a_counter*4.0f*3.14f/360.0f);
			parts[p].a_y=0.0f+10.0f*sin(a_counter*2*3.14/360.0);
			parts[p].z=a_Sinus[2]=3.0f-2.5f*cos(a_counter*8.0f*3.14f/360.0f);
			parts[p].r=128+rand()%128;
			parts[p].g=128+rand()%128;
			parts[p].b=128+rand()%128;
			parts[p].a=rand()%255;
			parts[p].a_mod=0.0f;
			parts[p].speedlim=.005+.0001*((GLfloat)(rand()%1000));
			parts[p].speed=parts[p].speedlim;
			parts[p].time=(int)(a_time*500-2);//*********************************
		}

		glPopMatrix();
	}
	glPushMatrix();
	a_Sinus[0]=10.0f*sin(a_counter*4.0f*3.14f/360.0f);
	a_Sinus[1]=0.0f+10.0f*sin(a_counter*2*3.14/360.0);
	a_Sinus[2]=3.0f-2.5f*cos(a_counter*8.0f*3.14f/360.0f);
	glTranslatef(a_Sinus[0],a_Sinus[1],a_Sinus[2]);

	glRotatef(-a_zrot,0,0,1);
	glRotatef(90-2*a_xrot,1,0,0);
	glColor4ub(255,128,255,255);
	glColor4ub(128,192,255,255);
	glRotatef(2*a_counter,0,0,1);

	a_LightPosition[0]=0;//a_Sinus[0];//10.0f*sin(a_counter*4.0f*3.14f/360.0f);
	a_LightPosition[1]=0;//a_Sinus[1];//0.0f+10.0f*sin(a_counter*2*3.14/360.0);
	a_LightPosition[2]=0;//a_Sinus[2];//3.0f-2.5f*cos(a_counter*8.0f*3.14f/360.0f);
	glEnable(GL_LIGHTING);
	glLightfv(GL_LIGHT1,GL_POSITION,a_LightPosition);
	glDisable(GL_LIGHTING);
	a_Text[2].Use();
	a_drawquad(1.0f+sin(a_counter*12.0f*3.1415f/360.0)+3.1415f/2.0f);
	a_Text[3].Use();
	a_drawquad(3.0f+2*sin(a_counter*6.0f*3.1415f/360.0));
	glPopMatrix();

/*
	a_LightPosition[0]=10.0f*sin(a_counter*4.0f*3.14f/360.0f);
	a_LightPosition[1]=0.0f+10.0f*sin(a_counter*2*3.14/360.0);
	a_LightPosition[2]=3.0f-2.5f*cos(a_counter*8.0f*3.14f/360.0f);
//	glTranslatef(a_LightPosition[0],a_LightPosition[1],a_LightPosition[2]);
	glEnable(GL_LIGHTING);
	glLightfv(GL_LIGHT1,GL_POSITION,a_LightPosition);
	*/

//	a_time=2.0f+(1)/500.0f;//************************************


	if (a_time>96.0f)
	{
		//****************************** FINISH
		//a_Clean();
		return false;
	}
	glutSwapBuffers();
	return true;
}
Exemple #12
0
void draw_options_menu(MenuData *menu) {
	draw_options_menu_bg(menu);
	
	draw_text(AL_Right, 140*(1-menu->fade), 30, "Options", _fonts.mainmenu);
	
	glPushMatrix();
	glTranslatef(100, 100, 0);
	
	/*
	glPushMatrix();
	glTranslatef(SCREEN_W/2 - 100, menu->drawdata[2], 0);
	glScalef(SCREEN_W - 200, 20, 1);
	glColor4f(0,0,0,0.5);
	draw_quad();
	glPopMatrix();
	*/
	
	Texture *bg = get_tex("part/smoke");
	glPushMatrix();
	glTranslatef(menu->drawdata[0], menu->drawdata[2], 0);
	glScalef(menu->drawdata[1]/100.0, 0.2, 1);
	glRotatef(menu->frames*2,0,0,1);
	glColor4f(0,0,0,0.5);
	draw_texture_p(0,0,bg);
	glPopMatrix();
	
	OptionBinding *binds = (OptionBinding*)menu->context;
	OptionBinding *bind;
	
	menu->drawdata[0] += ((SCREEN_W/2 - 100) - menu->drawdata[0])/10.0;
	menu->drawdata[1] += ((SCREEN_W - 200) - menu->drawdata[1])/10.0;
	menu->drawdata[2] += (20*menu->cursor - menu->drawdata[2])/10.0;
	
	int i, caption_drawn = 0;
	
	for(i = 0; i < menu->ecount; i++) {
		if(!menu->entries[i].name)
			continue;
		
		menu->entries[i].drawdata += 0.2 * (10*(i == menu->cursor) - menu->entries[i].drawdata);
		float a = menu->entries[i].drawdata * 0.1;
		
		bind = &(binds[i]);
		int hasbind = bind->enabled;
		float alpha = (!hasbind || bind_isactive(bind))? 1 : 0.5;
		
		if(menu->entries[i].action == NULL) {
			glColor4f(0.5, 0.5, 0.5, 0.7 * alpha);
		} else {
			//glColor4f(0.7 + 0.3 * (1-a), 1, 1, (0.7 + 0.3 * a) * alpha);
			float ia = 1-a;
			glColor4f(0.9 + ia * 0.1, 0.6 + ia * 0.4, 0.2 + ia * 0.8, (0.7 + 0.3 * a) * alpha);
		}
		
		draw_text(AL_Left,
					((hasbind && bind->dependence)? 20 : 0)	// hack hack hack
					+ 20 - menu->entries[i].drawdata, 20*i, menu->entries[i].name, _fonts.standard);
		
		if(hasbind)
		{
			int j, origin = SCREEN_W - 220;
			
			switch(bind->type)
			{
				case BT_IntValue:
					if(bind->valrange_max) {
						char tmp[16];	// who'd use a 16-digit number here anyway?
						snprintf(tmp, 16, "%d", bind_getvalue(bind));
						draw_text(AL_Right, origin, 20*i, tmp, _fonts.standard);
					} else for(j = bind->valcount-1; j+1; --j) {
						if(j != bind->valcount-1)
							origin -= strlen(bind->values[j+1])/2.0 * 20;
						
						if(bind_getvalue(bind) == j) {
							glColor4f(0.9, 0.6, 0.2, alpha);
						} else {
							glColor4f(0.5,0.5,0.5,0.7 * alpha);
						}
							
						draw_text(AL_Right, origin, 20*i, bind->values[j], _fonts.standard);
					}
					break;
				
				case BT_KeyBinding:
					if(bind->blockinput) {
						glColor4f(0.5, 1, 0.5, 1);
						draw_text(AL_Right, origin, 20*i, "Press a key to assign, ESC to cancel", _fonts.standard);
					} else
						draw_text(AL_Right, origin, 20*i, SDL_GetKeyName(tconfig.intval[bind->configentry]), _fonts.standard);
					
					if(!caption_drawn) {
						glColor4f(1,1,1,0.7);
						draw_text(AL_Center, (SCREEN_W - 200)/2, 20*(i-1), "Controls", _fonts.standard);
						caption_drawn = 1;
					}
					break;
				
				case BT_StrValue:
					if(bind->blockinput) {
						glColor4f(0.5, 1, 0.5, 1.0);
						if(strlen(*bind->values))
							draw_text(AL_Right, origin, 20*i, *bind->values, _fonts.standard);
					} else
						draw_text(AL_Right, origin, 20*i, tconfig.strval[bind->configentry], _fonts.standard);
					break;
				
				case BT_Resolution: {
					char tmp[16];
					int w, h;
					
					if(bind->selected == -1) {
						w = video.intended.width;
						h = video.intended.height;
					} else {
						VideoMode *m = &(video.modes[bind->selected]);
						w = m->width;
						h = m->height;
					}
					
					snprintf(tmp, 16, "%dx%d", w, h);
					draw_text(AL_Right, origin, 20*i, tmp, _fonts.standard);
					break;
				}
			}
		}
	}
	
	
	glPopMatrix();
	
	fade_out(menu->fade);
}
Exemple #13
0
void CCanvasContext::scale(float scaleX, float scaleY)
{
	cleanDrawImage();

	glScalef(scaleX, scaleY, 0);
}
//----------------------------------------------------------
void ofGLRenderer::scale(float xAmnt, float yAmnt, float zAmnt){
	glScalef(xAmnt, yAmnt, zAmnt);
}
void EDA_3D_CANVAS::generateFakeShadowsTextures( REPORTER* aErrorMessages, REPORTER* aActivity )
{
    if( m_shadow_init == true )
    {
        return;
    }

    // Init info 3d parameters and create gl lists:
    CreateDrawGL_List( aErrorMessages, aActivity );

    DBG( unsigned strtime = GetRunningMicroSecs() );

    m_shadow_init = true;

    glClearColor( 0, 0, 0, 1 );

    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();

    const float zDistMax = Millimeter2iu( 3.5 ) * GetPrm3DVisu().m_BiuTo3Dunits;

    glOrtho( -GetPrm3DVisu().m_BoardSize.x * GetPrm3DVisu().m_BiuTo3Dunits / 2.0f,
             GetPrm3DVisu().m_BoardSize.x * GetPrm3DVisu().m_BiuTo3Dunits / 2.0f,
             -GetPrm3DVisu().m_BoardSize.y * GetPrm3DVisu().m_BiuTo3Dunits / 2.0f,
             GetPrm3DVisu().m_BoardSize.y * GetPrm3DVisu().m_BiuTo3Dunits / 2.0f,
             0.0, zDistMax );

    float zpos = GetPrm3DVisu().GetLayerZcoordBIU( F_Paste ) * GetPrm3DVisu().m_BiuTo3Dunits;

    // Render FRONT shadow
    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity();
    glTranslatef( 0.0f, 0.0f, zpos );
    glRotatef( 180.0f, 0.0f, 1.0f, 0.0f );

    // move the board in order to draw it with its center at 0,0 3D coordinates
    glTranslatef( -GetPrm3DVisu().m_BoardPos.x * GetPrm3DVisu().m_BiuTo3Dunits,
                  -GetPrm3DVisu().m_BoardPos.y * GetPrm3DVisu().m_BiuTo3Dunits,
                  0.0f );

    create_and_render_shadow_buffer( &m_text_fake_shadow_front, 512, false, 1 );

    zpos = GetPrm3DVisu().GetLayerZcoordBIU( B_Paste ) * GetPrm3DVisu().m_BiuTo3Dunits;

    // Render BACK shadow
    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity();
    glTranslatef( 0.0f, 0.0f, fabs( zpos ) );


    // move the board in order to draw it with its center at 0,0 3D coordinates
    glTranslatef( -GetPrm3DVisu().m_BoardPos.x * GetPrm3DVisu().m_BiuTo3Dunits,
                  -GetPrm3DVisu().m_BoardPos.y * GetPrm3DVisu().m_BiuTo3Dunits,
                  0.0f );

    create_and_render_shadow_buffer( &m_text_fake_shadow_back, 512, false, 1 );


    // Render ALL BOARD shadow
    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();

    // Normalization scale to convert bouding box
    // to normalize 3D units between -1.0 and +1.0

    S3D_VERTEX v = m_fastAABBox_Shadow.Max() - m_fastAABBox_Shadow.Min();
    float BoundingBoxBoardiuTo3Dunits = 2.0f / glm::max( v.x, v.y );

    //float zDistance = (m_lightPos.z * zDistMax) / sqrt( (m_lightPos.z - m_fastAABBox_Shadow.Min().z) );
    float zDistance = (m_lightPos.z - m_fastAABBox_Shadow.Min().z) / 3.0f;

    glOrtho( -v.x * BoundingBoxBoardiuTo3Dunits / 2.0f,
              v.x * BoundingBoxBoardiuTo3Dunits / 2.0f,
             -v.y * BoundingBoxBoardiuTo3Dunits / 2.0f,
              v.y * BoundingBoxBoardiuTo3Dunits / 2.0f,
             0.0f, zDistance );

    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity();

    // fits the bouding box to scale this size
    glScalef( BoundingBoxBoardiuTo3Dunits, BoundingBoxBoardiuTo3Dunits, 1.0f );

    // Place the eye in the lowerpoint of boudingbox and turn arround and look up to the model
    glTranslatef( 0.0f, 0.0f, m_fastAABBox_Shadow.Min().z );
    glRotatef( 180.0, 0.0f, 1.0f, 0.0f );

    // move the bouding box in order to draw it with its center at 0,0 3D coordinates
    glTranslatef( -(m_fastAABBox_Shadow.Min().x + v.x / 2.0f), -(m_fastAABBox_Shadow.Min().y + v.y / 2.0f), 0.0f );

    create_and_render_shadow_buffer( &m_text_fake_shadow_board, 512, true, 10 );

    DBG( printf( "  generateFakeShadowsTextures total time %f ms\n", (double) (GetRunningMicroSecs() - strtime) / 1000.0 ) );
}
Exemple #16
0
void RenderScene(void)
{
	GLUquadric *orbitQuad = gluNewQuadric();
	gluQuadricDrawStyle(orbitQuad , GLU_LINE );


	GLUquadric *planetQuad = gluNewQuadric();

		GLUquadricObj *pObj;	// Quadric Object
	pObj = gluNewQuadric(); 
	gluQuadricNormals(pObj, GLU_SMOOTH);
	GLfloat horizontalMovement=1;
	GLfloat verticalMovement=0;
	horizontalMovement=cos(xRotationAngle*PI/180);
	verticalMovement=-sin(xRotationAngle*PI/180);

	if (lookDown)
	{
		xRotationAngle+=1;
		if (xRotationAngle>=90)
			xRotationAngle=90;
	}
	if (lookUp)
	{
		xRotationAngle-=1;
		if (xRotationAngle<=-90)
			xRotationAngle=-90;
	}
	if (lookRight)
	{
		yRotationAngle+=1;
		if (yRotationAngle>=360)
			yRotationAngle=0;
	}
	if (lookLeft)
	{
		yRotationAngle-=1;
		if (yRotationAngle<=-360)
			yRotationAngle=0;
	}
	if (walkForward)
	{
		zTranslation+=cos(yRotationAngle*PI/180)*horizontalMovement;
		xTranslation-=sin(yRotationAngle*PI/180)*horizontalMovement;
		yTranslation-=verticalMovement;
	}
	if (walkBackward)
	{
		zTranslation-=cos(yRotationAngle*PI/180)*horizontalMovement;
		xTranslation+=sin(yRotationAngle*PI/180)*horizontalMovement;
		yTranslation+=verticalMovement;
	}
	if (strafeRight)
	{
		zTranslation+=cos((yRotationAngle+90)*PI/180);
		xTranslation-=sin((yRotationAngle+90)*PI/180);
	}
	if (strafeLeft)
	{
		zTranslation-=cos((yRotationAngle+90)*PI/180);
		xTranslation+=sin((yRotationAngle+90)*PI/180);
	}

	if (setback)
	{
		zTranslation=0;
		xTranslation=0;
		yTranslation=0;
	}

	// Clear the window with current clearing color
	glClear(GL_COLOR_BUFFER_BIT |  GL_DEPTH_BUFFER_BIT);

		// Reset Model view matrix stack
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	
	glRotatef(xRotationAngle,1,0,0);
	glRotatef(zRotationAngle,0,0,1);
	glRotatef(yRotationAngle,0,1,0);
	glDisable(GL_LIGHTING);
	glBindTexture(GL_TEXTURE_2D, textureObjects[CUBE_MAP_TEX]);
			DrawSkyBox();
	glEnable(GL_LIGHTING);
			glTranslatef(xTranslation,yTranslation,zTranslation);



	
	glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
	
	
	
	
	glScalef(10,10,10);
	glDisable(GL_LIGHTING);
	//sun
	glEnable(GL_TEXTURE_2D);
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
	glColor3f(1,1,0);
	glBindTexture(GL_TEXTURE_2D, textureObjects[SUN]); 
	gltDrawSphere(0.65,100,100);//radius .15
	GLfloat lightPos[] = {0.0f,0.0f,0.0f,1.0f};
	glLightfv(GL_LIGHT0, GL_POSITION, lightPos);
	glEnable(GL_LIGHTING);
	
	//glRotatef(90,1,0,0);
	glPushMatrix();
	glBindTexture(GL_TEXTURE_2D, textureObjects[ASTERIODS]);
	//glutWireTorus(2,6,0,4);
	
	gltDrawTorus(6,2,6,2);
	glPopMatrix();
	//glRotatef(-90,1,0,0);
	//Draw Jupiter - orange
	glPushMatrix();
	
	glBindTexture(GL_TEXTURE_2D, textureObjects[JUPITER]); 
		makeplanets(249,100,0,JUPITER_INCLINATION,JUPITER_ORBIT,JUPITER_RADIUS,EARTH_RADIUS,JUPITER_PERIOD, jupiter_speed, jupiter_rotation, JUPITER_TILT, EARTH_DEGREES_PER_FRAME);
		
		
		glPopMatrix();

	//Draw Venus - greenish blue
	glPushMatrix();
	glBindTexture(GL_TEXTURE_2D, textureObjects[VENUS]); 
		makeplanets(43,146,164,VENUS_INCLINATION,VENUS_ORBIT,VENUS_RADIUS,EARTH_RADIUS,VENUS_PERIOD, venus_speed, venus_rotation, VENUS_TILT, EARTH_DEGREES_PER_FRAME);
	glPopMatrix();

	//Draw Mercury - graywhite
	glPushMatrix();
	glBindTexture(GL_TEXTURE_2D, textureObjects[MERCURY]); 
		makeplanets(191,164,142,MERCURY_INCLINATION,MERCURY_ORBIT,MERCURY_RADIUS,EARTH_RADIUS,MERCURY_PERIOD, mercury_speed, mercury_rotation, MERCURY_TILT, EARTH_DEGREES_PER_FRAME);
	glPopMatrix();

	//Draw Uranus - dark blue
	glPushMatrix();
	glBindTexture(GL_TEXTURE_2D, textureObjects[URANUS]); 
		makeplanets(120,112,224,URANUS_INCLINATION,URANUS_ORBIT,URANUS_RADIUS,EARTH_RADIUS,URANUS_PERIOD, uranus_speed, uranus_rotation, URANUS_TILT, EARTH_DEGREES_PER_FRAME);
	glPopMatrix();

	//Draw Neptune -light blue
	glPushMatrix();
	glBindTexture(GL_TEXTURE_2D, textureObjects[NEPTUNE]); 
		makeplanets(53,45,206,NEPTUNE_INCLINATION,NEPTUNE_ORBIT,NEPTUNE_RADIUS,EARTH_RADIUS,NEPTUNE_PERIOD, neptune_speed, neptune_rotation, NEPTUNE_TILT, EARTH_DEGREES_PER_FRAME);
	glPopMatrix();

	//Draw Mars - pink
	glPushMatrix();
	glBindTexture(GL_TEXTURE_2D, textureObjects[MARS]); 
		makeplanets(255,43,43,MARS_INCLINATION,MARS_ORBIT,MARS_RADIUS,EARTH_RADIUS,MARS_PERIOD, mars_speed, mars_rotation, MARS_TILT, EARTH_DEGREES_PER_FRAME);
	glPopMatrix();

	//Draw Saturn - yellow whitegl
	glBindTexture(GL_TEXTURE_2D, textureObjects[SATURN]); 
	glPushMatrix();
		makeplanets(255,255,145,SATURN_INCLINATION,SATURN_ORBIT,SATURN_RADIUS,EARTH_RADIUS,SATURN_PERIOD, saturn_speed, saturn_rotation, SATURN_TILT, EARTH_DEGREES_PER_FRAME);
	glPopMatrix();



	//draw the Earth - BLUE GREEN
	glPushMatrix();
	
	glBindTexture(GL_TEXTURE_2D, textureObjects[EARTH]); 
		makeplanets(43,146,164,EARTH_INCLINATION,EARTH_ORBIT,EARTH_RADIUS,EARTH_RADIUS,EARTH_PERIOD, earth_speed, earth_rotation, EARTH_TILT, EARTH_DEGREES_PER_FRAME);
	glRotatef(-90,1,0,0);
		glBindTexture(GL_TEXTURE_2D, textureObjects[MOON]); 
		makeplanets(191,164,142,MOON_INCLINATION,MOON_ORBIT,MOON_RADIUS,EARTH_RADIUS,MOON_PERIOD, moon_speed, moon_rotation, MOON_TILT, EARTH_DEGREES_PER_FRAME);
	//glBindTexture(GL_TEXTURE_2D, textureObjects[CLOUDS]); 
		//gltDrawSphere(0.8,40,40);
		
	glPopMatrix();

	// Flush drawing commands
	glutSwapBuffers();

	// Set color shading model to flat
	glShadeModel(GL_SMOOTH);


}
Exemple #17
0
void myInit(void)
{

/*	glGetIntegerv(GL_MAX_CLIP_PLANES, nest);
	 printf("GL_MAX_CLIP_PLANES are %d \n", nest[0]); */

/*%%%%%%%% Initialize Positional Light and Ambient Light %%%%%%%%*/

#if 0
        glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
#endif

#if 0
    	glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
	   glLightfv(GL_LIGHT0, GL_POSITION, lightPos);
	   glLightfv(GL_LIGHT0, GL_AMBIENT, lightAmb);
	   glLightfv(GL_LIGHT0, GL_DIFFUSE, lightDiff);
	   glLightfv(GL_LIGHT0, GL_SPECULAR, lightSpec);
	   glEnable(GL_LIGHT0);
#endif

/*** Initial light position is declared in the display function ***/

	   glLightfv(GL_LIGHT1, GL_AMBIENT, light1Amb);
	   glLightfv(GL_LIGHT1, GL_DIFFUSE, light1Diff);
	   glLightfv(GL_LIGHT1, GL_SPECULAR, light1Spec);
	   glEnable(GL_LIGHT1);
	   
	   glEnable(GL_LIGHTING);	   

/*  glLightf(GL_LIGHT1, GL_CONSTANT_ATTENUATION, 0.7);*/ 
/*  glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, 0.04);*/ /* use 0.04 w/ 24 bit color */
  glLightf(GL_LIGHT1, GL_QUADRATIC_ATTENUATION, 0.07); /* try 0.07 w/ 24 bit color */


/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/

/*########### Initialize Fog ##################*/

/*
{	
	GLfloat fog_color[] = {0.5, 0.5, 0.5, 1.0};
	GLfloat fog_start[] = {0.0, 0.0, 1.0, 20.0};
	
	glEnable(GL_FOG);
	glFogi(GL_FOG_MODE, GL_LINEAR);
	glFogfv(GL_FOG_COLOR, fog_color);
	glFogf(GL_FOG_DENSITY, 0.35);
	glFogfv(GL_FOG_START, fog_start);
	glHint(GL_FOG_HINT, GL_FASTEST);
}	

*/

/*##########################################*/

/*....Shadow Matrices For Floor, Left Wall, Back Wall, and Right Wall......*/


/* For light0 */

	   myShadowMatrix(groundPlane, lightPos, shadowMat_ground);
	   myShadowMatrix(leftPlane, lightPos, shadowMat_left);
	   myShadowMatrix(columnPlane, lightPos, shadowMat_column);
	   myShadowMatrix(backPlane, lightPos, shadowMat_back);   
	   myShadowMatrix(rightPlane, lightPos, shadowMat_right);

/* For light1 */

	   myShadowMatrix(groundPlane, light1Pos, shadowMat1_ground);
	   myShadowMatrix(leftPlane, light1Pos, shadowMat1_left);
	   myShadowMatrix(backPlane, light1Pos, shadowMat1_back);
	   myShadowMatrix(rightPlane, light1Pos, shadowMat1_right);   

/*.......................................................................*/

/*sssssssssssssssss Make Satellite Body and Shadow ssssssssssssssssssssssss*/

  glNewList(satellite1, GL_COMPILE);
    glPushMatrix();
	drawSatellite(satellite_diffuse, satellite_ambient, satellite_specular, satellite_shiny);
    glPopMatrix();
  glEndList();
  glNewList(satellite2, GL_COMPILE);
    glPushMatrix();
	drawSatellite(shadow_diffuse, shadow_ambient, shadow_specular, shadow_shiny);
    glPopMatrix();
  glEndList();

/*sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss*/

/*ppppppppppppppppppppppppppp Make Solar Panels and Shadows pppppppppppppppppp*/

  glNewList(panel1, GL_COMPILE);
    glPushMatrix();
		drawPanels(panel_color, panel_ambient);
    glPopMatrix();
  glEndList();
  
  glNewList(panel2, GL_COMPILE);
    glPushMatrix();
		drawPanels(shadow_diffuse, shadow_ambient);
    glPopMatrix();
  glEndList();  


/*pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp*/

/*========= Make Floor ==============*/ 

  glNewList(ground, GL_COMPILE);
    glPushMatrix();
      	glPushAttrib(GL_LIGHTING_BIT);
      		glMaterialfv(GL_FRONT, GL_DIFFUSE, floor_color);
      		glMaterialfv(GL_FRONT, GL_AMBIENT, shadow_ambient);
      		glTranslatef(0.0, -1.5, -5.0);
      		glRotatef(-90.0, 1, 0, 0);
      		glScalef(5.0, 5.0, 1.0);           
      		drawGround();  /* draw ground */
   		glPopAttrib();
    glPopMatrix();
  glEndList();

/*==================================*/

/*@@@@@@@@@@ Make Lamp Post and Lamp @@@@@@@@@@@@*/

	 glNewList(21, GL_COMPILE);
      glPushMatrix(); 
      	glPushAttrib(GL_LIGHTING_BIT); 
			glMaterialfv(GL_FRONT, GL_AMBIENT, lamp_post_specular);
			glTranslatef(0.0, -0.1, -5.0);
	      	glScalef(0.07, 1.45, 0.07);    
	      	drawCube(lamp_post_diffuse, lamp_post_ambient);  /* draw lamp post */ 
   		glPopAttrib();
      glPopMatrix();
      glPushMatrix();
		  glTranslatef(0.0, -1.45, -5.0);      
	      glScalef(0.3, 0.05, 0.3);
	      drawCube(wall_color, cube_ambient);  /* draw lamp post base */
      glPopMatrix();
	 glEndList();

	 glNewList(22, GL_COMPILE);
      glPushMatrix();
      	glPushAttrib(GL_LIGHTING_BIT); 
			glMaterialfv(GL_FRONT, GL_AMBIENT, lamp_ambient);
			glMaterialfv(GL_FRONT, GL_DIFFUSE, lamp_diffuse);				
			glMaterialfv(GL_FRONT, GL_SPECULAR, lamp_specular);				
			glTranslatef(0.0, 1.6, -5.0);
   			glutSolidSphere(0.3, 20.0, 20.0);   /* draw lamp */
   		glPopAttrib();
      glPopMatrix();
	 glEndList();

/*** Lamp post base shadow ***/

	 glNewList(501, GL_COMPILE);
      glPushMatrix();
      	glPushAttrib(GL_LIGHTING_BIT); 
			glMaterialfv(GL_FRONT, GL_AMBIENT, shadow_ambient);
			glMaterialfv(GL_FRONT, GL_DIFFUSE, shadow_diffuse);
			glMaterialfv(GL_FRONT, GL_SPECULAR, shadow_specular);
			glMaterialfv(GL_FRONT, GL_SHININESS, shadow_shiny);
			glTranslatef(0.0, -1.49, -5.0);
			glRotatef(-90.0, 1.0, 0.0, 0.0);
			glScalef(0.7, 0.7, 1.0);
			drawOct();
   		glPopAttrib();
      glPopMatrix();
	 glEndList();





/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

/*||||||||||| Make Left Wall |||||||||||||*/

  glNewList(left_wall, GL_COMPILE);
    glPushMatrix();      
    glPushAttrib(GL_LIGHTING_BIT);
      		glMaterialfv(GL_FRONT, GL_DIFFUSE, wall_color);
      		glMaterialfv(GL_FRONT, GL_AMBIENT, wall_ambient);
      		glTranslatef(0.0, -1.5, 0.0);
     		glTranslatef(0.0, 1.2, 0.0);      
      		glTranslatef(0.0, 0.0, -5.0);
      		glTranslatef(-5.0, 0.0, 0.0);
      		glRotatef(90.0, 0, 1, 0);
      		glScalef(4.5, 1.2, 1.0);       
      		glNormal3f (0.0, 0.0, 1.0);
      		drawGround();  /* draw left wall */
	glPopAttrib();
    glPopMatrix();
  glEndList();

/*||||||||||||||||||||||||||||||||||||||||*/

/*\\\\\\\\\\\\\ Make Right Wall \\\\\\\\\\\\\\\\\\\*/

  glNewList(right_wall, GL_COMPILE);
    glPushMatrix();
    glPushAttrib(GL_LIGHTING_BIT);
      glMaterialfv(GL_FRONT, GL_DIFFUSE, wall_color);
      glMaterialfv(GL_FRONT, GL_AMBIENT, wall_ambient);
      glTranslatef(0.0, -1.5, 0.0);
      glTranslatef(0.0, 1.2, 0.0);

      glTranslatef(0.0, 0.0, -5.0);
      glTranslatef(5.0, 0.0, 0.0);
      glRotatef(270.0, 0, 1, 0);      
                
      glScalef(4.5, 1.2, 1.0);
      glNormal3f (0.0, 0.0, 1.0);      
      drawGround();  /* draw right wall */
    glPopAttrib();
    glPopMatrix();
  glEndList();                        

/*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/

/*[[[[[[[[[[[ Build Columns ]]]]]]]]]]]*/
	
glPushMatrix();    
	 glNewList(1, GL_COMPILE);
      glPushMatrix(); 
	      glScalef(0.4, 1.4, 0.4);    
	      drawCube(column_color, column_ambient);  /* draw column1 */ 
      glPopMatrix();
	 glEndList();

	glNewList(2, GL_COMPILE);
        glPushMatrix();
            glTranslatef(0.0, -1.45, 0.0);
            glScalef(0.5, 0.1, 0.5);
            drawCube(wall_color, cube_ambient); /* draw base */
        glPopMatrix();
        glPushMatrix();	    
		    glTranslatef(0.0, 1.45, 0.0);
 	        glScalef(0.5, 0.1, 0.5);
	        drawCube(wall_color, cube_ambient); /* draw top */
        glPopMatrix();
    glEndList();    	  
glPopMatrix();
    
   glNewList(column, GL_COMPILE);
 		glPushMatrix();
     		glCallList(1);
			glCallList(2);
 		glPopMatrix();
	glEndList(); 

/***** Place columns at front of scene. *****/

glNewList(4, GL_COMPILE);
       glPushMatrix();
         glTranslatef(-5.0, 0.0, -0.5);
         glCallList(column);	
       glPopMatrix();
glEndList();
                    	
glNewList(5, GL_COMPILE);
       glPushMatrix();
         glTranslatef(-1.75, 0.0, -0.5);
         glCallList(column);	
       glPopMatrix();
glEndList();       

glNewList(6, GL_COMPILE);
       glPushMatrix();
         glTranslatef(1.75, 0.0, -0.5);
         glCallList(column);	
       glPopMatrix();
glEndList();       
       
glNewList(17, GL_COMPILE);
       glPushMatrix();
         glTranslatef(5.0, 0.0, -0.5);
         glCallList(column);	
       glPopMatrix();
glEndList();     


/*** Get the modelview matrix once ***/
       glPushMatrix();
			glRotatef(-mvr_d, mvr_x, mvr_y, mvr_z);
         		glTranslatef(-mvt_x, -mvt_y, -mvt_z);
         glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat *) four_columnsXform);
       glPopMatrix();

glNewList(four_columns, GL_COMPILE);
       glPushMatrix();
			glCallList(4);
			glCallList(5);
			glCallList(6);
			glCallList(17);
       glPopMatrix();	
glEndList();

/***** Make two columns for sides of scene *****/

glNewList(two_columns, GL_COMPILE);
     glPushMatrix();
		glRotatef(90.0, 0.0, 1.0, 0.0);
        glTranslatef(5.0, 0.0, -5.0);
       		glPushMatrix();
           		glTranslatef(0.0, 0.0, -0.3);
           		glCallList(column);	
       		glPopMatrix();
       		glPushMatrix();
           		glTranslatef(0.0, 0.0, 10.3);
           		glCallList(column);	
       		glPopMatrix();
     glPopMatrix();
glEndList();     




/*[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]*/


/* .......................Make shadows .........................*/

    glPushMatrix();    	   
	 glNewList(8, GL_COMPILE);
        glPushMatrix(); 
	    		glScalef(0.4, 1.4, 0.4);    
	    		drawCube(shadow_diffuse, shadow_ambient);  /* draw column1 */ 
        glPopMatrix();
	 glEndList();


	glNewList(9, GL_COMPILE);
          glPushMatrix();
            glTranslatef(0.0, -1.45, 0.0);
            glScalef(0.5, 0.1, 0.5);
            drawCube(shadow_diffuse, shadow_ambient); /* draw base. */
          glPopMatrix();
          glPushMatrix();	    
			 glTranslatef(0.0, 1.45, 0.0);
 	         glScalef(0.5, 0.1, 0.5);
	         drawCube(shadow_diffuse, shadow_ambient); /* draw top. */
          glPopMatrix();
    glEndList();
   glPopMatrix();
    
    glNewList(10, GL_COMPILE);
    	glPushMatrix(); 
     		glCallList(8);
			glCallList(9);
    	glPopMatrix();
	 glEndList();

glNewList(11, GL_COMPILE);
       glPushMatrix();
       glTranslatef(-5.0, 0.0, -0.5);
       glCallList(10);	
       glPopMatrix();
glEndList();
                    	
glNewList(12, GL_COMPILE);
       glPushMatrix();
       glTranslatef(-1.75, 0.0, -0.5);
       glCallList(10);	
       glPopMatrix();
glEndList();       

glNewList(13, GL_COMPILE);
       glPushMatrix();
       glTranslatef(1.75, 0.0, -0.5 );
       glCallList(10);	
       glPopMatrix();
glEndList();       
       
glNewList(14, GL_COMPILE);
       glPushMatrix();
       glTranslatef(5.0, 0.0, -0.5 );
       glCallList(10);	
       glPopMatrix();
glEndList();       

glNewList(15, GL_COMPILE);
        glPushMatrix();
	glCallList(11);
	glCallList(12);
	glCallList(13);
	glCallList(14);	
	glPopMatrix();
glEndList();
       	
glNewList(100, GL_COMPILE);
       glPushMatrix();
	  glMultMatrixf((const GLfloat *) shadowMat_ground);	
	  glTranslatef(-mvt_x, -mvt_y, -mvt_z);	/* correct for modelview matrix */
	  glRotatef(-mvr_d, mvr_x, mvr_y, mvr_z);
	  glMultMatrixf((const GLfloat *) four_columnsXform);
       	  glCallList(15);
        glPopMatrix();
glEndList();

glNewList(101, GL_COMPILE);
       glPushMatrix();
	  glMultMatrixf((const GLfloat *) shadowMat_left);	
	  glTranslatef(-mvt_x, -mvt_y, -mvt_z);	/* correct for modelview matrix */
	  glRotatef(-mvr_d, mvr_x, mvr_y, mvr_z);
	  glMultMatrixf((const GLfloat *) four_columnsXform);
       	  glCallList(15);
        glPopMatrix();
glEndList();

glNewList(102, GL_COMPILE);
       glPushMatrix();
	  glMultMatrixf((const GLfloat *) shadowMat_back);	
	  glRotatef(-mvr_d, mvr_x, mvr_y, mvr_z);
	  glTranslatef(-mvt_x, -mvt_y, -mvt_z);	/* correct for modelview matrix */
	  glMultMatrixf((const GLfloat *) four_columnsXform);
       	  glCallList(15);
        glPopMatrix();
glEndList();

glNewList(103, GL_COMPILE);
       glPushMatrix();
	  glMultMatrixf((const GLfloat *) shadowMat_right);	
	  glRotatef(-mvr_d, mvr_x, mvr_y, mvr_z);
	  glTranslatef(-mvt_x, -mvt_y, -mvt_z);	/* correct for modelview matrix */
	  glMultMatrixf((const GLfloat *) four_columnsXform);
       	  glCallList(15);
        glPopMatrix();
glEndList();


/* ......................................................*/

}
Exemple #18
0
void base::active_square_render (void)
{ //with frame-animation, but without set-type img
	//0 alive, 1 - dead, nocontrol, 2 -  delete
	int *gb;
	if (!bitd){
		gb = (int*) dBodyGetData (body);
		if (gb <= (int*) 1900 && gb != (int*) 0 ){
			printf("DEAD\n");
			if(!bitd) bitd=1;
		}
	} else {
		last=DL;
		translated_val=0;
	}

	if(bitd==1 && !up){
		dBodyDestroy(body);
		dGeomDestroy(geom);
		printf("DESTROY\n");
		bitd=2;
	}
	
	if(bitd!=2){
		if(body) odepos=dBodyGetPosition(body);
		else if(geom) odepos=dGeomGetPosition(geom);

		x=odepos[0]-texture[last].w/2; //is it needed?
		y=odepos[1]-texture[last].h/2; //here maybe some troubles with up
	}
	
	glMatrixMode(GL_TEXTURE);
	glLoadIdentity();
	
	glTranslated(translated_val, 0, 0); //for all except stand anim
	glScalef((float)1/texture[last].n, 1.0f, 1.0f); //1==fullsize. -(w+1/n)==one frame size + -- invers	
	/*invers---------------------------
	glTranslated(-translated_val, 0, 0);
	glScalef(-(float)1/texture[last].n, 1.0f, 1.0f);
	invers----------------------------- */
	
	glBindTexture( GL_TEXTURE_2D, texture[last].texture );
	
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	if(rotatebit)
		rotate();
		
	glTranslated(x, y, 0);	//set position
	glTranslated(texture[last].w/2, texture[last].h/2, 0); //all three for rotate
	glRotatef(rotate_angle,0,0,1);
	glTranslated(-texture[last].w/2, -texture[last].h/2, 0);

	glBegin( GL_QUADS );
	    glColor3f(1.0f,1.0f,1.0f);
		//Bottom-r vertex (corner)
		glTexCoord2i( 0, 1 );
		glVertex3f( 0.f, 0.f, 0.0f );
		
		//Bottom-l vertex (corner)
		glTexCoord2i( 1,1 );
		glVertex3f( texture[last].w, 0.f, 0.f );
		
		//Top-l vertex (corner)
		glTexCoord2i( 1, 0 );
		glVertex3f( texture[last].w, texture[last].h, 0.f );
		
		//Top-r vertex (corner)
		glTexCoord2i( 0,0 );
		glVertex3f( 0.f, texture[last].h, 0.f );
	glEnd();
	if(body && bitd!=2)hack_2d();
}
Exemple #19
0
void Hud::drawMapv()
{
    if(!Hud::compiled) return;
    
    glPushMatrix();
    glTranslatef(0.0, 0.0, -2);
    glColor3f(1.0, 1.0, 1.0);
    glScalef(0.001, 0.001, 0.001);
    glTranslatef(-1000, -1000, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 's');
    glTranslatef(30, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 'p');
    glTranslatef(30, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 'a');
    glTranslatef(30, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 'c');
    glTranslatef(30, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 'e');
    glTranslatef(80, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 't');
    glTranslatef(30, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 'o');
    glTranslatef(80, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 'b');
    glTranslatef(30, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 'u');
    glTranslatef(30, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 'y');
    glTranslatef(80, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 's');
    glTranslatef(30, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 'h');
    glTranslatef(30, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 'i');
    glTranslatef(30, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 'p');
    glTranslatef(80, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, '(');
    glTranslatef(30, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, '1');
    glTranslatef(30, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, '0');
    glTranslatef(60, 40, 0.0);
    gluSphere(gluNewQuadric(), 40, 5, 5);
    glTranslatef(40, -40, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, ')');
    glPopMatrix();
    
    glPushMatrix();
    glTranslatef(0.0, 0.0, -2);
    if(Model::getSelf()->playerturn == P_ONE_TURN)
        glColor3f(PLAYER_1_R, PLAYER_1_G, PLAYER_1_B);
    else
        glColor3f(PLAYER_2_R, PLAYER_2_G, PLAYER_2_B);
    glScalef(0.001, 0.001, 0.001);
    glTranslatef(-700, 800, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, '\'');
    glTranslatef(30, 0, 0.0);
    if(Model::getSelf()->playerturn == P_ONE_TURN)
        glutStrokeCharacter(GLUT_STROKE_ROMAN, 'q');
    else
        glutStrokeCharacter(GLUT_STROKE_ROMAN, 'p');
    glTranslatef(30, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, '\'');
    glTranslatef(30, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 't');
    glTranslatef(30, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 'o');
    glTranslatef(80, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 'e');
    glTranslatef(30, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 'n');
    glTranslatef(30, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 'd');
    glTranslatef(80, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 't');
    glTranslatef(30, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 'u');
    glTranslatef(30, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 'r');
    glTranslatef(30, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 'n');
    glPopMatrix();

    
    
    
    setColor(0.5f, 0.5f, 0.5f, 1.0f, 0.1f, 0.5f, 0.7f);
    setGLColor();
    glCallList(mapvDl);
    float dif = -2.0f/((float)NUM_TYPES+2.0f);
    glPushMatrix();
    glTranslated(-1.5, 0.2, 0.0);
    glTranslatef(0.0, 1.0, -2.0);
    glTranslatef(0.0, dif, 0.0);
    
    glPushMatrix();
    //glTranslated(0.1, 0.0, 0.0);
    glColor3f(1.0, 1.0, 1.0);
    glScalef(0.001, 0.001, 0.001);
    glTranslated(200.0, 0.0, 0.0);
    //glRotated(-90, 1.0, 0.0, 0.0);
    strokeNumber(pOneShip->owner->numShips);
    glPopMatrix();
    glPushMatrix();
    glScalef(0.2, 0.2, 0.2);
    glRotatef(pOneRot, 0.0, 1.0, 0.0);
    glTranslated(0.0, 0.0, -0.4);
    glRotatef(80, 1.0f, 0.0f, 0.0f);
    pOneShip->numWaterUnits = ((float)pOneShip->owner->waterNodesOwned/(float)(pOneShip->owner->nodesOwned-pOneShip->owner->darkNodesOwned))*MAX_UNITS;
    pOneShip->numEarthUnits = ((float)pOneShip->owner->earthNodesOwned/(float)(pOneShip->owner->nodesOwned-pOneShip->owner->darkNodesOwned))*MAX_UNITS;
    pOneShip->numWindUnits = ((float)pOneShip->owner->windNodesOwned/(float)(pOneShip->owner->nodesOwned-pOneShip->owner->darkNodesOwned))*MAX_UNITS;
    pOneShip->numFireUnits = ((float)pOneShip->owner->fireNodesOwned/(float)(pOneShip->owner->nodesOwned-pOneShip->owner->darkNodesOwned))*MAX_UNITS;
    pOneShip->draw();
    
    glPopMatrix();
    
    for(int i = 0; i < NUM_TYPES; i++)
    {
        glTranslatef(0.0, dif, 0.0);
        glPushMatrix();
        //glTranslated(0.1, 0.0, 0.0);
        glColor3f(1.0, 1.0, 1.0);
        glScalef(0.001, 0.001, 0.001);
        glTranslated(200.0, 0.0, 0.0);
        //glRotated(-90, 1.0, 0.0, 0.0);
        if(i == 0)
            strokeNumber(pOneShip->owner->waterNodesOwned);
        else if(i == 1)
            strokeNumber(pOneShip->owner->earthNodesOwned);
        else if(i == 2)
            strokeNumber(pOneShip->owner->windNodesOwned);
        else if(i == 3)
            strokeNumber(pOneShip->owner->fireNodesOwned);
        else if(i == 4)
            strokeNumber(pOneShip->owner->darkNodesOwned);

        glPopMatrix();
        glPushMatrix();
        if(Model::getSelf()->playerturn == P_ONE_TURN)
            pOneRot+=0.1f;
        else
            pOneRot+=.01f;
        if(pOneRot == 360.0f)
            pOneRot = 0.0;
        glRotatef(pOneRot, 0.0, 1.0, 0.0);
        glRotatef(80, 1.0f, 0.0f, 0.0f);
        glScalef(0.1,0.1,0.1);
        pOneNodes[i]->draw();
        glPopMatrix();
    }
    glTranslatef(0.0, dif, 0.0);
    glPushMatrix();
    //glTranslated(0.1, 0.0, 0.0);
    glColor3f(1.0, 1.0, 1.0);
    glScalef(0.001, 0.001, 0.001);
    glTranslated(200.0, 0.0, 0.0);
    //glRotated(-90, 1.0, 0.0, 0.0);
    strokeNumber(pOneShip->owner->darkResources);
    glPopMatrix();
    glRotatef(pOneRot, 0.0, 1.0, 0.0);

    gluSphere(gluNewQuadric(), 0.15, 5, 5);
    glPopMatrix();
    
    
    
    glPushMatrix();
    glTranslated(1.5, 0.2, 0.0);
    glTranslatef(0.0, 1.0, -2.0);
    glTranslatef(0.0, dif, 0.0);
    glPushMatrix();
    //glTranslated(0.1, 0.0, 0.0);
    glColor3f(1.0, 1.0, 1.0);
    glScalef(0.001, 0.001, 0.001);
    glTranslated(-270.0, 0.0, 0.0);
    //glRotated(-90, 1.0, 0.0, 0.0);
    glPushMatrix();
    if(pTwoShip->owner->numShips > 10)
        glTranslatef(-180, 0.0, 0.0);
    if(pTwoShip->owner->numShips > 100)
        glTranslatef(-180, 0.0, 0.0);
    strokeNumber(pTwoShip->owner->numShips);
    glPopMatrix();
    glPopMatrix();
    glPushMatrix();
    glScalef(0.2, 0.2, 0.2);
    glRotatef(pTwoRot, 0.0, 1.0, 0.0);
    glTranslated(0.0, 0.0, -0.4);
    glRotatef(80, 1.0f, 0.0f, 0.0f);
    pTwoShip->numWaterUnits = ((float)pTwoShip->owner->waterNodesOwned/(float)(pOneShip->owner->nodesOwned-pOneShip->owner->darkNodesOwned))*MAX_UNITS;
    pTwoShip->numEarthUnits = ((float)pTwoShip->owner->earthNodesOwned/(float)(pOneShip->owner->nodesOwned-pOneShip->owner->darkNodesOwned))*MAX_UNITS;
    pTwoShip->numWindUnits = ((float)pTwoShip->owner->windNodesOwned/(float)(pOneShip->owner->nodesOwned-pOneShip->owner->darkNodesOwned))*MAX_UNITS;
    pTwoShip->numFireUnits = ((float)pTwoShip->owner->fireNodesOwned/(float)(pOneShip->owner->nodesOwned-pOneShip->owner->darkNodesOwned))*MAX_UNITS;
    pTwoShip->draw();
    glPopMatrix();
    
    for(int i = 0; i < NUM_TYPES; i++)
    {
        glTranslatef(0.0, dif, 0.0);
        glPushMatrix();
        //glTranslated(0.1, 0.0, 0.0);
        glColor3f(1.0, 1.0, 1.0);
        glScalef(0.001, 0.001, 0.001);
        glTranslated(-270.0, 0.0, 0.0);
        //glRotated(-90, 1.0, 0.0, 0.0);
        if(i == 0)
        {
            glPushMatrix();
            if(pTwoShip->owner->waterNodesOwned > 10)
                glTranslatef(-180, 0.0, 0.0);
            if(pTwoShip->owner->waterNodesOwned > 100)
                glTranslatef(-180, 0.0, 0.0);
            strokeNumber(pTwoShip->owner->waterNodesOwned);
            glPopMatrix();
        }
        else if(i == 1)
        {
            glPushMatrix();
            if(pTwoShip->owner->earthNodesOwned > 10)
                glTranslatef(-180, 0.0, 0.0);
            if(pTwoShip->owner->earthNodesOwned > 100)
                glTranslatef(-180, 0.0, 0.0);
            strokeNumber(pTwoShip->owner->earthNodesOwned);
            glPopMatrix();
        }
        else if(i == 2)
        {
            glPushMatrix();
            if(pTwoShip->owner->windNodesOwned > 10)
                glTranslatef(-180, 0.0, 0.0);
            if(pTwoShip->owner->windNodesOwned> 100)
                glTranslatef(-180, 0.0, 0.0);
            strokeNumber(pTwoShip->owner->windNodesOwned);
            glPopMatrix();
        }
        else if(i == 3)
        {
            glPushMatrix();
            if(pTwoShip->owner->fireNodesOwned > 10)
                glTranslatef(-180, 0.0, 0.0);
            if(pTwoShip->owner->fireNodesOwned > 100)
                glTranslatef(-180, 0.0, 0.0);
            strokeNumber(pTwoShip->owner->fireNodesOwned);
            glPopMatrix();
        }
        else if(i == 4)
        {
            glPushMatrix();
            if(pTwoShip->owner->darkNodesOwned > 10)
                glTranslatef(-180, 0.0, 0.0);
            if(pTwoShip->owner->darkNodesOwned > 100)
                glTranslatef(-180, 0.0, 0.0);
            strokeNumber(pTwoShip->owner->darkNodesOwned);
            glPopMatrix();
        }
        
        glPopMatrix();
        glPushMatrix();
        if(Model::getSelf()->playerturn == P_TWO_TURN)
            pTwoRot+=0.1f;
        else
            pTwoRot+=0.01f;
        if(pTwoRot == 360.0f)
            pTwoRot = 0.0;
        glRotatef(pTwoRot, 0.0, 1.0, 0.0);       
        glRotatef(80, 1.0f, 0.0f, 0.0f);
        glScalef(0.1,0.1,0.1);
        pTwoNodes[i]->draw();
        glPopMatrix();
    }
    glTranslatef(0.0, dif, 0.0);
    glPushMatrix();
    //glTranslated(0.1, 0.0, 0.0);
    glColor3f(1.0, 1.0, 1.0);
    glScalef(0.001, 0.001, 0.001);
    glTranslated(-270.0, 0.0, 0.0);
    //glRotated(-90, 1.0, 0.0, 0.0);
    glPushMatrix();
    if(pTwoShip->owner->darkResources > 10)
        glTranslatef(-180, 0.0, 0.0);
    if(pTwoShip->owner->darkResources > 100)
        glTranslatef(-180, 0.0, 0.0);
    strokeNumber(pTwoShip->owner->darkResources);
    glPopMatrix();
    glPopMatrix();
    glRotatef(pTwoRot, 0.0, 1.0, 0.0);
    
    gluSphere(gluNewQuadric(), 0.15, 5, 5);
    glPopMatrix();
    
	//if (Model::getSelf()->zoom < 0) 
	//	TextPrint::hudText(0, 17, -2, 0.77f, 0.29f, 0.13f,GLUT_BITMAP_TIMES_ROMAN_24, "WARNING: ZOOMED PAST RECOMENDED AREA");


}
Exemple #20
0
void PickScene::display() 
{

	// ---- BEGIN Background, camera and axis setup
	
	// Clear image and depth buffer everytime we update the scene
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

	// Initialize Model-View matrix as identity (no transformation
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	// Apply transformations corresponding to the camera position relative to the origin
	CGFscene::activeCamera->applyView();

	// Draw (and update) light
	light0->draw();

	// Draw axis
	axis.draw();


	// ---- END Background, camera and axis setup


	// ---- BEGIN feature demos

	materialAppearance->apply();

	// scale down a bit	
	glScalef(0.2, 0.2, 0.2);

	// picking example, the important parts are the gl*Name functions
	// and the code in the associted PickInterface class

	// Example 1: simple naming
	glPushMatrix();

	glPushName(-1);		// Load a default name

	for (int i=0; i< NUM_OBJS;i++)
	{
		glPushMatrix();
		glTranslatef(i*5,0,0);
		glLoadName(i);		//replaces the value on top of the name stack
		obj->draw();
		glPopMatrix();
	}
	glPopMatrix();

	// example 2: structured naming
	for (int r=0; r < NUM_ROWS; r++)
	{
		glPushMatrix();
		glTranslatef(0, r*4, 0);
		glLoadName(r);
		for (int c=0; c < NUM_COLS; c++)
		{
			glPushMatrix();
			glTranslatef(0,0,(c+1)*5);
			glRotatef(90,0,1,0);
			glPushName(c);
			obj->draw();
			glPopName();
			glPopMatrix();
		}
		glPopMatrix();
	}

	// ---- END feature demos

	// glutSwapBuffers() will swap pointers so that the back buffer becomes the front buffer and vice-versa
	glutSwapBuffers();
}
Exemple #21
0
void Hud::compileDL()
{
    if(Hud::compiled) return;
    
    Hud::metaDl = glGenLists(1);
    glNewList(Hud::metaDl, GL_COMPILE);
    
    glPushMatrix();
    glBegin(GL_TRIANGLES);
    
    glEnd();
    glPopMatrix();
    
    glEndList();   
    
    
    
    
    Hud::miniDl = glGenLists(1);
    glNewList(Hud::miniDl, GL_COMPILE);
    
    glPushMatrix();
    glBegin(GL_TRIANGLES);
    
    glEnd();
    glPopMatrix();
    
    glEndList();   
    
    
    Hud::typeMappingDlA = glGenLists(1);
    glNewList(Hud::typeMappingDlA, GL_COMPILE);
    
    glPushMatrix();
    glColor3f(1.0, 1.0, 1.0);
    glScalef(0.001, 0.001, 0.001);
    glTranslatef(-460, 300, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, '<');
    glTranslatef(70, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, '-');
    glTranslatef(70, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 'w');
    glTranslatef(150, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 'e');
    glTranslatef(70, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, '-');
    glTranslatef(70, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, '>');
    glPopMatrix();
    
    
    glPushMatrix();
    glTranslated(-0.5, 0.0, 0.0);
    glColor3f(WATER_R, WATER_G, WATER_B);
    glBegin(GL_QUADS);
    glVertex3d(0.0, 0.25, 0.0);
    glVertex3d(0.25, 0.25, 0.0);
    glVertex3d(0.25, 0.0, 0.0);
    glVertex3d(0.0, 0.0, 0.0);
    glEnd();
    glPushMatrix();
    glTranslatef(0.1, -0.1, 0.0);
    glScalef(0.001, 0.001, 0.001);
    glColor3f(1.0, 1.0, 1.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 'a');
    glPopMatrix();
    glTranslated(0.25, 0.0, 0.0);
    glColor3f(EARTH_R, EARTH_G, EARTH_B);
    glBegin(GL_QUADS);
    glVertex3d(0.0, 0.25, 0.0);
    glVertex3d(0.25, 0.25, 0.0);
    glVertex3d(0.25, 0.0, 0.0);
    glVertex3d(0.0, 0.0, 0.0);
    glEnd();
    glPushMatrix();
    glTranslatef(0.1, -0.1, 0.0);
    glScalef(0.001, 0.001, 0.001);
    glColor3f(1.0, 1.0, 1.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 's');
    glPopMatrix();
    glTranslated(0.25, 0.0, 0.0);
    glColor3f(WIND_R, WIND_G, WIND_B);
    glBegin(GL_QUADS);
    glVertex3d(0.0, 0.25, 0.0);
    glVertex3d(0.25, 0.25, 0.0);
    glVertex3d(0.25, 0.0, 0.0);
    glVertex3d(0.0, 0.0, 0.0);
    glEnd();
    glPushMatrix();
    glTranslatef(0.1, -0.1, 0.0);
    glScalef(0.001, 0.001, 0.001);
    glColor3f(1.0, 1.0, 1.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 'd');
    glPopMatrix();
    glTranslated(0.25, 0.0, 0.0);
    glColor3f(FIRE_R, FIRE_G, FIRE_B);
    glBegin(GL_QUADS);
    glVertex3d(0.0, 0.25, 0.0);
    glVertex3d(0.25, 0.25, 0.0);
    glVertex3d(0.25, 0.0, 0.0);
    glVertex3d(0.0, 0.0, 0.0);
    glEnd();
    glPushMatrix();
    glTranslatef(0.1, -0.1, 0.0);
    glScalef(0.001, 0.001, 0.001);
    glColor3f(1.0, 1.0, 1.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 'f');
    glPopMatrix();
    glPopMatrix();
    
    glEndList();
    
    
    Hud::typeMappingDlB = glGenLists(1);
    glNewList(Hud::typeMappingDlB, GL_COMPILE);
    
    glPushMatrix();
    glColor3f(1.0, 1.0, 1.0);
    glScalef(0.001, 0.001, 0.001);
    glTranslatef(-460, 300, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, '<');
    glTranslatef(70, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, '-');
    glTranslatef(70, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 'i');
    glTranslatef(150, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 'o');
    glTranslatef(70, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, '-');
    glTranslatef(70, 0, 0.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, '>');
    glPopMatrix();
    
    glPushMatrix();
    glTranslated(-0.5, 0.0, 0.0);
    glColor3f(WATER_R, WATER_G, WATER_B);
    glBegin(GL_QUADS);
    glVertex3d(0.0, 0.25, 0.0);
    glVertex3d(0.25, 0.25, 0.0);
    glVertex3d(0.25, 0.0, 0.0);
    glVertex3d(0.0, 0.0, 0.0);
    glEnd();
    glPushMatrix();
    glTranslatef(0.1, -0.1, 0.0);
    glScalef(0.001, 0.001, 0.001);
    glColor3f(1.0, 1.0, 1.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 'j');
    glPopMatrix();
    glTranslated(0.25, 0.0, 0.0);
    glColor3f(EARTH_R, EARTH_G, EARTH_B);
    glBegin(GL_QUADS);
    glVertex3d(0.0, 0.25, 0.0);
    glVertex3d(0.25, 0.25, 0.0);
    glVertex3d(0.25, 0.0, 0.0);
    glVertex3d(0.0, 0.0, 0.0);
    glEnd();
    glPushMatrix();
    glTranslatef(0.1, -0.1, 0.0);
    glScalef(0.001, 0.001, 0.001);
    glColor3f(1.0, 1.0, 1.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 'k');
    glPopMatrix();
    glTranslated(0.25, 0.0, 0.0);
    glColor3f(WIND_R, WIND_G, WIND_B);
    glBegin(GL_QUADS);
    glVertex3d(0.0, 0.25, 0.0);
    glVertex3d(0.25, 0.25, 0.0);
    glVertex3d(0.25, 0.0, 0.0);
    glVertex3d(0.0, 0.0, 0.0);
    glEnd();
    glPushMatrix();
    glTranslatef(0.1, -0.1, 0.0);
    glScalef(0.001, 0.001, 0.001);
    glColor3f(1.0, 1.0, 1.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, 'l');
    glPopMatrix();
    glTranslated(0.25, 0.0, 0.0);
    glColor3f(FIRE_R, FIRE_G, FIRE_B);
    glBegin(GL_QUADS);
    glVertex3d(0.0, 0.25, 0.0);
    glVertex3d(0.25, 0.25, 0.0);
    glVertex3d(0.25, 0.0, 0.0);
    glVertex3d(0.0, 0.0, 0.0);
    glEnd();
    glPushMatrix();
    glTranslatef(0.1, -0.1, 0.0);
    glScalef(0.001, 0.001, 0.001);
    glColor3f(1.0, 1.0, 1.0);
    glutStrokeCharacter(GLUT_STROKE_ROMAN, ';');
    glPopMatrix();
    glPopMatrix();
    
    glEndList();
    
    
    Hud::mapvDl = glGenLists(1);
    glNewList(Hud::mapvDl, GL_COMPILE);
    /*
    float w = (float)Model::getSelf()->width/(float)Model::getSelf()->height;
    float h = (float)Model::getSelf()->height/(float)Model::getSelf()->width;
    glPushMatrix();
    glScalef(w*1.5, h*1.5, 1.0);
    glBegin(GL_QUADS);
    
    //Left
    glVertex3f(-1, -1, -2.0f);
    glVertex3f(-1, 1, -2.0f);
    glVertex3f(-.9, 1, -2.0f);
    glVertex3f(-.9, -1, -2.0f);
    
    //Right
    glVertex3f(.9, -1, -2.0f);
    glVertex3f(.9, 1, -2.0f);
    glVertex3f(1, 1, -2.0f);
    glVertex3f(1, -1, -2.0f);
    
    //Top
    glVertex3f(-1, .9, -2.0f);
    glVertex3f(-1, 1, -2.0f);
    glVertex3f(1, 1, -2.0f);
    glVertex3f(1, .9, -2.0f);
    
    //Bottom
    glVertex3f(-1, -1, -2.0f);
    glVertex3f(-1, -.9, -2.0f);
    glVertex3f(1, -.9, -2.0f);
    glVertex3f(1, -1, -2.0f);

    glEnd();
    glPopMatrix();
    */
    glEndList();   
    
    
    
    
    Hud::compiled = true;
}
Exemple #22
0
void BasicTestingState::Update(float mouseX, float mouseY, bool mouseClick){
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
	glScalef(0.1f, 0.1f, 0.1f);
	Renderer::drawGameObject(testObject,vao);
}
Exemple #23
0
void LLDrawPoolTree::renderTree(BOOL selecting)
{
	LLGLState normalize(GL_NORMALIZE, TRUE);
	
	// Bind the texture for this tree.
	LLViewerImage::bindTexture(mTexturep,sDiffTex);
	if (mTexturep)
	{
		if (mTexturep->getClampS()) {
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
		}
		if (mTexturep->getClampT()) {
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
		}
	}

	U32 indices_drawn = 0;

	glMatrixMode(GL_MODELVIEW);
	
	for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
		 iter != mDrawFace.end(); iter++)
	{
		LLFace *face = *iter;
		LLDrawable *drawablep = face->getDrawable();

		if (drawablep->isDead() || face->mVertexBuffer.isNull())
		{
			continue;
		}

		face->mVertexBuffer->setBuffer(LLDrawPoolTree::VERTEX_DATA_MASK);
		U32* indicesp = (U32*) face->mVertexBuffer->getIndicesPointer();

		// Render each of the trees
		LLVOTree *treep = (LLVOTree *)drawablep->getVObj().get();

		LLColor4U color(255,255,255,255);

		if (!selecting || treep->mGLName != 0)
		{
			if (selecting)
			{
				S32 name = treep->mGLName;
				
				color = LLColor4U((U8)(name >> 16), (U8)(name >> 8), (U8)name, 255);
			}
			
			glPushMatrix();
			
			// Translate to tree base  HACK - adjustment in Z plants tree underground
			const LLVector3 &pos_agent = treep->getPositionAgent();
			glTranslatef(pos_agent.mV[VX], pos_agent.mV[VY], pos_agent.mV[VZ] - 0.1f);

			// Rotate to tree position
			F32 angle_radians, x, y, z;
			treep->getRotation().getAngleAxis(&angle_radians, &x, &y, &z);
			glRotatef(angle_radians * RAD_TO_DEG, x, y, z);

			// Rotate and bend for current trunk/wind
			// Note that trunk stiffness controls the amount of bend at the trunk as 
			// opposed to the crown of the tree
			// 
			glRotatef(90.f, 0, 0, 1);
			const F32 TRUNK_STIFF = 22.f;
			glRotatef(treep->mTrunkBend.magVec()*TRUNK_STIFF, treep->mTrunkBend.mV[VX], treep->mTrunkBend.mV[VY], 0);

			F32 radius = treep->getScale().magVec()*0.5f;
			radius *= 0.1f;
			glScalef(radius, radius, radius);

			const F32 THRESH_ANGLE_FOR_BILLBOARD = 15.f;
			const F32 BLEND_RANGE_FOR_BILLBOARD = 3.f;

			F32 droop = treep->mDroop + 25.f*(1.f - treep->mTrunkBend.magVec());
			
			S32 stop_depth = 0;
			F32 app_angle = treep->getAppAngle()*LLVOTree::sTreeFactor;
			F32 alpha = 1.0;
			S32 trunk_LOD = 0;

			for (S32 j = 0; j < 4; j++)
			{

				if (app_angle > LLVOTree::sLODAngles[j])
				{
					trunk_LOD = j;
					break;
				}
			} 

			if (app_angle < (THRESH_ANGLE_FOR_BILLBOARD - BLEND_RANGE_FOR_BILLBOARD))
			{
				//
				//  Draw only the billboard 
				//
				//  Only the billboard, can use closer to normal alpha func.
				stop_depth = -1;
				LLFacePool::LLOverrideFaceColor clr(this, color); 
				indices_drawn += treep->drawBranchPipeline(indicesp, trunk_LOD, stop_depth, treep->mDepth, treep->mTrunkDepth, 1.0, treep->mTwist, droop, treep->mBranches, alpha);
			}
			else // if (app_angle > (THRESH_ANGLE_FOR_BILLBOARD + BLEND_RANGE_FOR_BILLBOARD))
			{
				//
				//  Draw only the full geometry tree
				//
				//stop_depth = (app_angle < THRESH_ANGLE_FOR_RECURSION_REDUCTION);
				LLFacePool::LLOverrideFaceColor clr(this, color); 
				indices_drawn += treep->drawBranchPipeline(indicesp, trunk_LOD, stop_depth, treep->mDepth, treep->mTrunkDepth, 1.0, treep->mTwist, droop, treep->mBranches, alpha);
			}
			
			glPopMatrix();
		}
	}

	if (mTexturep)
	{
		if (mTexturep->getClampS()) {
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
		}
		if (mTexturep->getClampT()) {
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
		}
	}

	addIndicesDrawn(indices_drawn);
}
static void time_draw_cache(SpaceTime *stime, Object *ob, Scene *scene)
{
	PTCacheID *pid;
	ListBase pidlist;
	SpaceTimeCache *stc = stime->caches.first;
	const float cache_draw_height = (4.0f * UI_DPI_FAC * U.pixelsize);
	float yoffs = 0.f;
	
	if (!(stime->cache_display & TIME_CACHE_DISPLAY) || (!ob))
		return;

	BKE_ptcache_ids_from_object(&pidlist, ob, scene, 0);

	/* iterate over pointcaches on the active object, 
	 * add spacetimecache and vertex array for each */
	for (pid = pidlist.first; pid; pid = pid->next) {
		float col[4], *fp;
		int i, sta = pid->cache->startframe, end = pid->cache->endframe;
		int len = (end - sta + 1) * 4;

		switch (pid->type) {
			case PTCACHE_TYPE_SOFTBODY:
				if (!(stime->cache_display & TIME_CACHE_SOFTBODY)) continue;
				break;
			case PTCACHE_TYPE_PARTICLES:
				if (!(stime->cache_display & TIME_CACHE_PARTICLES)) continue;
				break;
			case PTCACHE_TYPE_CLOTH:
				if (!(stime->cache_display & TIME_CACHE_CLOTH)) continue;
				break;
			case PTCACHE_TYPE_SMOKE_DOMAIN:
			case PTCACHE_TYPE_SMOKE_HIGHRES:
				if (!(stime->cache_display & TIME_CACHE_SMOKE)) continue;
				break;
			case PTCACHE_TYPE_DYNAMICPAINT:
				if (!(stime->cache_display & TIME_CACHE_DYNAMICPAINT)) continue;
				break;
			case PTCACHE_TYPE_RIGIDBODY:
				if (!(stime->cache_display & TIME_CACHE_RIGIDBODY)) continue;
				break;
		}

		if (pid->cache->cached_frames == NULL)
			continue;

		/* make sure we have stc with correct array length */
		if (stc == NULL || MEM_allocN_len(stc->array) != len * 2 * sizeof(float)) {
			if (stc) {
				MEM_freeN(stc->array);
			}
			else {
				stc = MEM_callocN(sizeof(SpaceTimeCache), "spacetimecache");
				BLI_addtail(&stime->caches, stc);
			}

			stc->array = MEM_callocN(len * 2 * sizeof(float), "SpaceTimeCache array");
		}

		/* fill the vertex array with a quad for each cached frame */
		for (i = sta, fp = stc->array; i <= end; i++) {
			if (pid->cache->cached_frames[i - sta]) {
				fp[0] = (float)i - 0.5f;
				fp[1] = 0.0;
				fp += 2;
				
				fp[0] = (float)i - 0.5f;
				fp[1] = 1.0;
				fp += 2;
				
				fp[0] = (float)i + 0.5f;
				fp[1] = 1.0;
				fp += 2;
				
				fp[0] = (float)i + 0.5f;
				fp[1] = 0.0;
				fp += 2;
			}
		}
		
		glPushMatrix();
		glTranslatef(0.0, (float)V2D_SCROLL_HEIGHT + yoffs, 0.0);
		glScalef(1.0, cache_draw_height, 0.0);
		
		switch (pid->type) {
			case PTCACHE_TYPE_SOFTBODY:
				col[0] = 1.0;   col[1] = 0.4;   col[2] = 0.02;
				col[3] = 0.1;
				break;
			case PTCACHE_TYPE_PARTICLES:
				col[0] = 1.0;   col[1] = 0.1;   col[2] = 0.02;
				col[3] = 0.1;
				break;
			case PTCACHE_TYPE_CLOTH:
				col[0] = 0.1;   col[1] = 0.1;   col[2] = 0.75;
				col[3] = 0.1;
				break;
			case PTCACHE_TYPE_SMOKE_DOMAIN:
			case PTCACHE_TYPE_SMOKE_HIGHRES:
				col[0] = 0.2;   col[1] = 0.2;   col[2] = 0.2;
				col[3] = 0.1;
				break;
			case PTCACHE_TYPE_DYNAMICPAINT:
				col[0] = 1.0;   col[1] = 0.1;   col[2] = 0.75;
				col[3] = 0.1;
				break;
			case PTCACHE_TYPE_RIGIDBODY:
				col[0] = 1.0;   col[1] = 0.6;   col[2] = 0.0;
				col[3] = 0.1;
				break;
			default:
				col[0] = 1.0;   col[1] = 0.0;   col[2] = 1.0;
				col[3] = 0.1;
				BLI_assert(0);
				break;
		}
		glColor4fv(col);
		
		glEnable(GL_BLEND);
		
		glRectf((float)sta, 0.0, (float)end, 1.0);
		
		col[3] = 0.4f;
		if (pid->cache->flag & PTCACHE_BAKED) {
			col[0] -= 0.4f; col[1] -= 0.4f; col[2] -= 0.4f;
		}
		else if (pid->cache->flag & PTCACHE_OUTDATED) {
			col[0] += 0.4f; col[1] += 0.4f; col[2] += 0.4f;
		}
		glColor4fv(col);
		
		glEnableClientState(GL_VERTEX_ARRAY);
		glVertexPointer(2, GL_FLOAT, 0, stc->array);
		glDrawArrays(GL_QUADS, 0, (fp - stc->array) / 2);
		glDisableClientState(GL_VERTEX_ARRAY);
		
		glDisable(GL_BLEND);
		
		glPopMatrix();
		
		yoffs += cache_draw_height;

		stc = stc->next;
	}

	BLI_freelistN(&pidlist);

	/* free excessive caches */
	while (stc) {
		SpaceTimeCache *tmp = stc->next;
		BLI_remlink(&stime->caches, stc);
		MEM_freeN(stc->array);
		MEM_freeN(stc);
		stc = tmp;
	}
}
Exemple #25
0
/* sets up the opengl context.
 * width, height are to match the values from ED_mask_get_size() */
void ED_mask_draw_region(Mask *mask, ARegion *ar,
                         const char draw_flag, const char draw_type, const char overlay_mode,
                         const int width_i, const int height_i,  /* convert directly into aspect corrected vars */
                         const float aspx, const float aspy,
                         const bool do_scale_applied, const bool do_draw_cb,
                         float stabmat[4][4], /* optional - only used by clip */
                         const bContext *C    /* optional - only used when do_post_draw is set or called from clip editor */
                         )
{
	struct View2D *v2d = &ar->v2d;

	/* aspect always scales vertically in movie and image spaces */
	const float width = width_i, height = (float)height_i * (aspy / aspx);

	int x, y;
	/* int w, h; */
	float zoomx, zoomy;

	/* frame image */
	float maxdim;
	float xofs, yofs;

	/* find window pixel coordinates of origin */
	UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y);


	/* w = BLI_rctf_size_x(&v2d->tot); */
	/* h = BLI_rctf_size_y(&v2d->tot);/*/


	zoomx = (float)(BLI_rcti_size_x(&ar->winrct) + 1) / BLI_rctf_size_x(&ar->v2d.cur);
	zoomy = (float)(BLI_rcti_size_y(&ar->winrct) + 1) / BLI_rctf_size_y(&ar->v2d.cur);

	if (do_scale_applied) {
		zoomx /= width;
		zoomy /= height;
	}

	x += v2d->tot.xmin * zoomx;
	y += v2d->tot.ymin * zoomy;

	/* frame the image */
	maxdim = max_ff(width, height);
	if (width == height) {
		xofs = yofs = 0;
	}
	else if (width < height) {
		xofs = ((height - width) / -2.0f) * zoomx;
		yofs = 0.0f;
	}
	else { /* (width > height) */
		xofs = 0.0f;
		yofs = ((width - height) / -2.0f) * zoomy;
	}

	if (draw_flag & MASK_DRAWFLAG_OVERLAY) {
		float *buffer = threaded_mask_rasterize(mask, width, height);
		int format;

		if (overlay_mode == MASK_OVERLAY_ALPHACHANNEL) {
			glColor3f(1.0f, 1.0f, 1.0f);
			format = GL_LUMINANCE;
		}
		else {
			/* More blending types could be supported in the future. */
			glEnable(GL_BLEND);
			glBlendFunc(GL_DST_COLOR, GL_SRC_ALPHA);
			format = GL_ALPHA;
		}

		glPushMatrix();
		glTranslatef(x, y, 0);
		glScalef(zoomx, zoomy, 0);
		if (stabmat) {
			glMultMatrixf(stabmat);
		}
		glaDrawPixelsTex(0.0f, 0.0f, width, height, format, GL_FLOAT, GL_NEAREST, buffer);
		glPopMatrix();

		if (overlay_mode != MASK_OVERLAY_ALPHACHANNEL) {
			glDisable(GL_BLEND);
		}

		MEM_freeN(buffer);
	}

	/* apply transformation so mask editing tools will assume drawing from the origin in normalized space */
	glPushMatrix();
	glTranslatef(x + xofs, y + yofs, 0);
	glScalef(maxdim * zoomx, maxdim * zoomy, 0);

	if (stabmat) {
		glMultMatrixf(stabmat);
	}

	if (do_draw_cb) {
		ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
	}

	/* draw! */
	draw_masklays(C, mask, draw_flag, draw_type, width, height);

	if (do_draw_cb) {
		ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
	}

	glPopMatrix();
}