void drawLight(SceneLoader* scene){ //Ligar as luzes glEnable(GL_COLOR_MATERIAL); vector<Light*> lights = scene->sceneManager->illumination->lights; vector<Light*>::iterator it= lights.begin(); int counter = 0; for( ; it != lights.end(); it++){ if((*it)->enabled == 1){ //Luz ligada glEnable(GL_LIGHT0+counter); // esfera que simboliza a LIGHT0+ counter glColor3f(1.0,1.0,0.0); // cor amarela gluQuadricOrientation( glQ, GLU_INSIDE); glPushMatrix(); glTranslated((*it)->position[0],(*it)->position[1],(*it)->position[2]); gluSphere(glQ, symb_light0_radius, symb_light0_slices, symb_light0_stacks); glPopMatrix(); gluQuadricOrientation(glQ, GLU_OUTSIDE); } counter++; } glDisable(GL_COLOR_MATERIAL); }
void GLCanvas::drawJoint(const JointConstraint &constraint, float radius) const { // auto points = constraint.getAxisAngleToAngleKeyPoints(); std::vector<Vector3> vectors = constraint.getKeyPointsInterpolated(radius, 2.0f); glBegin(GL_LINE_LOOP); glColor4f(1.0f, 0.0f, 0.0f, 1.0f); for (size_t i = 0; i < vectors.size(); ++i) { glVertex3f(vectors[i].x(), vectors[i].y(), vectors[i].z()); } glEnd(); vectors = constraint.getKeyPoints(radius); glBegin(GL_LINE_LOOP); glColor4f(0.0f, 1.0f, 0.0f, 1.0f); for (size_t i = 0; i < vectors.size(); ++i) { glVertex3f(vectors[i].x(), vectors[i].y(), vectors[i].z()); } glEnd(); glBegin(GL_LINE_LOOP); glColor4f(1.0f, 0, 0, 1.0f); for (size_t i = 0; i < 360; ++i) { float angle = constraint.getMaxAngleAt(i); glVertex3f(float(i)/60.0f - 2, angle/60.0f + 1.5, 1.0f); } glEnd(); glRenderMode(GL_SMOOTH); glPolygonMode(GL_FRONT, GL_FILL); //glColor3f(0.5f, 0.5f, 0.5f); glColor4f(0.5f, 0.5f, 0.5f, 0.5f); gluSphere(_sphereQuad, radius, 10, 8); }
void RenderWorld() { // This function will draw our entire scene except for the light. // We could speed up our application by not using quadrics and using // display lists, but just to make things simple I chose to not add extras. // Draw our walls and move them back into the screen by 15 glPushMatrix(); glTranslatef(0, 0, -15); DrawWalls(); glPopMatrix(); // Color the tube green glColor4f(0.0f, 1.0f, 0.1f, 1.0); // Create a new quadric and render it normally GLUquadricObj *pObj = gluNewQuadric(); gluQuadricDrawStyle(pObj, GLU_FILL); // Create an empty tube that spins around glPushMatrix(); static float rotY = 0; glTranslatef(-2, 0, -10); glRotatef(rotY++, 0, 1, 0); gluCylinder(pObj, 0.5f, 0.5f, 2.0f, 25, 25); glPopMatrix(); // Color the sphere yellow glColor4f(1.0f, 1.0f, 0.1f, 1.0); // Create the sphere and move it back and to the right of the tube glPushMatrix(); glTranslatef(2, 0, -10); gluSphere(pObj, 0.5f, 25, 25); glPopMatrix(); // Free the quadric object gluDeleteQuadric(pObj); }
void Shoulder(char solid) { glNewList(SOLID_MECH_SHOULDER, GL_COMPILE); #ifdef LIGHT SetMaterial(mat_specular, mat_ambient, mat_diffuse, mat_shininess); #endif glColor3f(1.0, 1.0, 0.0); Box(1.0, 0.5, 0.5, solid); glTranslatef(0.9, 0.0, 0.0); #ifdef LIGHT SetMaterial(mat_specular2, mat_ambient2, mat_diffuse2, mat_shininess2); #endif glColor3f(0.5, 0.5, 0.5); #ifdef SPHERE if (!solid) gluQuadricDrawStyle(qobj, GLU_LINE); gluSphere(qobj, 0.6, 16, 16); #endif glTranslatef(-0.9, 0.0, 0.0); glEndList(); }
void SurfaceObj::drawEdgesAroundPoint(int idx) { GLUquadricObj *qobj = 0; qobj = gluNewQuadric(); glColor3f(1,0,0); glPushMatrix(); glTranslatef(Point[idx][0],Point[idx][1],Point[idx][2]); gluSphere(qobj,1,20,20); glPopMatrix(); std::vector<std::vector<int>>* edgesAroundPoint=Container->edgesAroundPoint(); glLineWidth(2.0); glBegin(GL_LINES); for(int i=0;i<(*edgesAroundPoint)[idx].size();i++) { Vec2i edge=Edge[(*edgesAroundPoint)[idx][i]]; glVertex3f(Point[edge[0]][0],Point[edge[0]][1],Point[edge[0]][2]); glVertex3f(Point[edge[1]][0],Point[edge[1]][1],Point[edge[1]][2]); } glEnd(); }
void cFileData::drawPoints(float radius) { cDataFieldT<vtkPoint>* df_p = static_cast<cDataFieldT<vtkPoint>*>(getDatafield("POINTS")); if (!df_p) return; cDataFieldT<float>* df_a = static_cast<cDataFieldT<float>*>(getDatafield("altitude")); if (!df_a) return; cDataFieldT<unsigned char>* df_d = static_cast<cDataFieldT<unsigned char>*>(getDatafield("detection")); if (!df_d) return; GLUquadricObj *gSphere = gluNewQuadric(); gluQuadricNormals(gSphere, GLU_SMOOTH); float mat_emission_detection4[4] = {0.8f, 0.2f, 0.2f, 0.0f}; float mat_emission[4] = {0.2f, 0.2f, 0.8f, 0.0f}; float scaleFac = radius/EARTH_RADIUS; glEnable(GL_LIGHTING); for (int i=0; i < df_p->numEntries(); ++i) { vtkPoint p = df_p->getValueAt(i); float a = df_a->getValueAt(i)*scaleFac; if (df_d->getValueAt(i) == 4) glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_emission_detection4); else glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_emission); glPushMatrix(); glTranslatef((radius+a)*sin(THETA(p.y))*sin(PHI(p.x)), (radius+a)*cos(THETA(p.y)), (radius+a)*sin(THETA(p.y))*cos(PHI(p.x))); gluSphere(gSphere, 0.1f, 6, 6); glPopMatrix(); } glEnable(GL_LIGHTING); gluDeleteQuadric(gSphere); }
void Skybox::draw() const { if (m_fShow) { double planeEq[] = {0,1,0,0}; glEnable(GL_CLIP_PLANE0); //glClipPlane(0, planeEq); glEnable(GL_CULL_FACE); glCullFace(GL_FRONT_FACE); glPushMatrix(); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, m_textureId); glColor3f(255,255,255); glTranslatef(m_camera.position().X(), m_camera.position().Y(), m_camera.position().Z()); glRotatef(90, 1, 0, 0); gluSphere(m_pQuadric,900,20,20); glPopMatrix(); glBindTexture(GL_TEXTURE_2D, 0); glDisable(GL_TEXTURE_2D); glCullFace(GL_NONE); glDisable(GL_CULL_FACE); //glDisable(GL_CLIP_PLANE0); //TODO msati3: Replace this by a height map? glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, m_groundTexture); glColor3f(0,255,0); glBegin(GL_QUADS); glTexCoord2d(0,0); glVertex3f(-1000,0,1000); glTexCoord2d(1,0); glVertex3f(1000,0,1000); glTexCoord2d(1,1); glVertex3f(1000,0,-1000); glTexCoord2d(0,1); glVertex3f(-1000,0,-1000); glEnd(); glBindTexture(GL_TEXTURE_2D, 0); glDisable(GL_TEXTURE_2D); } }
void draw_scene(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glRotatef(state.rot_y, 1.0, 0.0, 0.0); glRotatef(state.rot_x, 0.0, 1.0, 0.0); Vector pos_tmp; vector_copy(pos_tmp, state.pos); if(state.locked_planet >= 0) vector_add(pos_tmp, pos_tmp, state.sys->planets[state.locked_planet].position); glTranslatef(-pos_tmp[0], -pos_tmp[1], -pos_tmp[2]); glPushMatrix(); for(int i = 0; i < state.sys->nplanets; i++) { glColor3fv(get_planet_color(i)); Planet* planet = &state.sys->planets[i]; glTranslatef(planet->position[0], planet->position[1], planet->position[2]); glScalef(state.scale, state.scale, state.scale); glDisable(GL_LIGHTING); glBegin(GL_POINTS); glVertex3f(0.0f, 0.0f, 0.0f); glEnd(); glEnable(GL_LIGHTING); gluSphere(sphere, get_planet_radius(i), 32, 32); glPopMatrix(); glPushMatrix(); } glDisable(GL_LIGHTING); draw_grid(); draw_trails(); glPopMatrix(); }
void nehewidget::paintGL() { glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslatef(0.0,0.0,zoom); glEnable(GL_TEXTURE_GEN_S); // 自动生成s方向纹理坐标 glEnable(GL_TEXTURE_GEN_T); // 自动生成t方向纹理坐标 glBindTexture(GL_TEXTURE_2D,texture[filter]); glPushMatrix(); glRotatef(xrot,1.0,0.0,0.0); glRotatef(yrot,0.0,1.0,0.0); switch(object) { case 0: glDrawCube(); break; case 1: glTranslatef(0.0f,0.0f,-1.5f); gluCylinder(quadratic,1.0f,1.0f,3.0f,32,32); break; case 2: gluSphere(quadratic,1.3f,32,32); break; case 3: glTranslatef(0.0f,0.0f,-1.5f); gluCylinder(quadratic,1.0f,0.0f,3.0f,32,32); break; default: break; } glPopMatrix(); glDisable(GL_TEXTURE_GEN_S); // 禁止自动生成纹理坐标 glDisable(GL_TEXTURE_GEN_T); xrot+=xspeed; yrot+=yspeed; }
void desenharTerra(GLuint texture, GLUquadric * Q, GLuint texture2, GLUquadric * Q2) { glPushMatrix(); glRotatef(orbitalTiltTerra,0.0,0.0,1.0); angTerra += ((2*PI)/velTerra)*timeFactor; posicoes[4][0]=distFactor*distSolTerra*sin(angTerra+((2*PI)/velTerra)*timeFactor); posicoes[4][1]=distFactor*distSolTerra*sin(angTerra) * sin(orbitalTiltTerra*(PI/180)) ; posicoes[4][2]=distFactor*distSolTerra*cos(angTerra+((2*PI)/velTerra)*timeFactor); raios[4]=raioTerra*scale; //colisao planeta -> nave if((cameraMode==0 && haColisao(camZ,camX,camY,4)) || (cameraMode == 1 && haColisaoNave2(camZ,camX,camY,camlookZ,camlookX,camlookY,4)) ) afastaCamara(4); glTranslatef(distFactor*distSolTerra*sin(angTerra), 0, distFactor*distSolTerra*cos(angTerra)); //glColor3f(0,0,1);//azul //angRotTerra += ((0.25*360)/velRTerra)*timeFactor; angRotTerra += (360/velRTerra)*timeFactor; rotacao(angRotTerra,axisTiltTerra); glEnable (GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture); glRotatef(-90,1,0,0); if(sphereInFrustum(posicoes[4],raios[4])) gluSphere (Q,scale*raioTerra,calcularFatias(4),32); glDisable(GL_TEXTURE_2D); glRotatef(90,1,0,0); desenharLua(texture2, Q2); glPopMatrix(); //glColor3f(0,0,1);//azul if(orbitas)draw_orbita(distFactor*distSolTerra,90,0.0,orbitalTiltTerra); }
void render_world(void) { GLUquadricObj *obj; int mode=GL_FRONT; obj=gluNewQuadric(); glMaterialfv(mode,GL_AMBIENT,ambient); glMaterialfv(mode,GL_DIFFUSE,diffuse); glMaterialfv(mode,GL_SPECULAR,specular); glMaterialf(mode,GL_SHININESS,0.0); glMaterialfv(mode,GL_EMISSION,emission); glPushMatrix(); glTranslatef(0.0,0.0,0.0); gluQuadricDrawStyle(obj,GLU_SMOOTH); gluQuadricOrientation(obj,GLU_INSIDE); gluSphere(obj,WORLD_SIZE,10,10); glPopMatrix(); gluDeleteQuadric(obj); }
// Render the void tile void ThemeSimple::RenderItemPlayer(float X, float Y) { static GLUquadricObj* PlayerSphere = gluNewQuadric(); X = (X + 1.0f) * m_fTileOffsetGap; Y = (Y + 1.0f) * m_fTileOffsetGap; float Z = 0.5f; glEnable(GL_LIGHTING); glPushMatrix(); glTranslatef(X, Z, Y); // glColor3f(0.5f, 0.5f, 0.5f); // light grey // Draw a sphere using GLU quadric object. Radius = 0.85 Slices = 8 Stacks = 8 gluSphere(PlayerSphere, 0.85, 8, 8); glPopMatrix(); glDisable(GL_LIGHTING); }
void draw_object() { glPushMatrix(); /*----Draw a white sphere to represent the original-----*/ //glLoadIdentity(); /*----position light1 (fixed) in eye coord sys ---*/ glColor3f(0.9, 0.9, 0.9); glTranslatef(-30.0, 9.0, -30.0); gluSphere(sphere, 2.0, /* radius=2.0 */ 12, /* composing of 12 slices*/ 12); /* composing of 8 stacks */ glPopMatrix(); glPushMatrix(); glTranslatef(-30.0, -2.5, -30.0); glRotatef(-90.0, 1.0, 0.0, 0.0); /*Rotate about x by -90', z becomes y */ glColor3f(0.95, 0.0, 0.95); gluCylinder(cylind, 2.0, 0.5, /* radius of top and bottom circle */ 10.0, /* height of the cylinder */ 12, /* use 12-side polygon approximating circle*/ 3); /* Divide it into 3 sections */ glPopMatrix(); }
void Joint::drawPhysics(unsigned int flags) const { glPushMatrix(); glMultMatrixf(transformation); if(flags & SimRobotCore2::Renderer::showPhysics) { glBegin(GL_LINES); glNormal3f(0, 0, 1.f); glColor3f(std::abs(axis->x), std::abs(axis->y), std::abs(axis->z)); glVertex3f(axis->x * -0.05f, axis->y * -0.05f, axis->z * -0.05f); glVertex3f(axis->x * 0.05f, axis->y * 0.05f, axis->z * 0.05f); glEnd(); GLUquadricObj* q = gluNewQuadric(); gluSphere(q, 0.002, 10, 10); gluDeleteQuadric(q); } PrimaryObject::drawPhysics(flags); glPopMatrix(); }
void Ball::draw() { glNewList(data, GL_COMPILE); int green = getCount() * 20; if (green > 255) green = 255; glColor3ub(55, 100, green); gluSphere(qobj, radius, 20, 20); if (!vel.isNull()) { glColor3ub(0, 255, 0); glRotatef(vel.angleXY(), 0, 0, 1); glBegin(GL_LINES); glVertex3f(0, 0, pos.z); glVertex3f(1, 0, pos.z); glEnd(); glBegin(GL_POLYGON); glVertex3f(1, 0, pos.z); glVertex3f(0.9, -.1, pos.z); glVertex3f(0.9, .1, pos.z); glEnd(); } }
void sfBranch::_drawSubBranches() { if( isActive() && _subBranches.size() > 0 ) { // Draw any branches that branch off from this one. for( unsigned int i = 0; i < _subBranches.size(); i++ ) { sfBranchPoint* vPoint = _subBranches.at( i ); ofxVec3f vPointLoc = vPoint->getLoc(); glPushMatrix(); glTranslatef( vPointLoc.x, vPointLoc.y, vPointLoc.z ); // Draw a dot a branch points. gluSphere( _quadric, _thickness * 6, 10, 10 ); // Draw any branches at this branch point. vPoint->draw(); glPopMatrix(); } } }
//-------------------------------------------------------------- void testApp::draw(){ ofBackgroundGradient(ofColor::gray, ofColor::black); glEnable(GL_DEPTH_TEST); ofEnableLighting(); directionalLight.enable(); cam.begin(); ofPushStyle(); ofSetColor(255); ofSetLineWidth(5); glPushMatrix(); glTranslatef(SIZE*-1.5,0, SIZE*-1.5); ofScale(1, -1); for(int i = 0 ; i < NUM_DEVICE ; i ++) { int x = SIZE*((i%3)); int y = -SIZE; int z = SIZE*((i/3.0f)); glPushMatrix(); glTranslatef(x, y, z); ofLine(0, 0, 0, dataSet[i].length); // ofCircle(0,dataSet[i].length,50); glPushMatrix(); glTranslatef(0,dataSet[i].length,0); gluSphere(quadric, 50, 64, 64); glPopMatrix(); glPopMatrix(); } glPopMatrix(); ofPopStyle(); cam.end(); directionalLight.disable(); ofDisableLighting(); glDisable(GL_DEPTH_TEST); timeline.draw(); }
void draw_torus(GLdouble angle) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); glEnable(GL_TEXTURE_2D); glEnable(GL_CULL_FACE); glPushMatrix(); glTranslatef(0, 0, -3); glRotatef(angle, 1, 1, 0); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); if (drawTorus) { glutSolidTorus(.4, .75, 32, 32); } else { GLUquadricObj *sphere = gluNewQuadric(); gluSphere(sphere, 1, 32, 32); } glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); glEnable(GL_LIGHTING); glDisable(GL_CULL_FACE); glPopMatrix(); }
void displayBall(void){ int i; glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, fire); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 100, 100, 0, GL_RGBA, GL_UNSIGNED_BYTE, fireTexture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); for(i=0;i<numSpheres;i++){ glPushMatrix(); glTranslatef(spheres[i][0], spheres[i][1], spheres[i][2]); glScalef(10.0, 10.0, 10.0); glutSolidDodecahedron(); //glutSolidSphere(spheres[i][3], 50, 50); //glutSolidCube(spheres[i][3]); glPopMatrix(); } glDisable(GL_TEXTURE_2D); glEnable(GL_BLEND); glEnable(GL_COLOR_MATERIAL); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(1.0, 0.0, 0.0, 0.2); for(i=0;i<numSpheres;i++){ glPushMatrix(); //glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, sphere_mat); glTranslatef(spheres[i][0], spheres[i][1], spheres[i][2]+5); gluSphere(qsphere,20, 50, 50); glPopMatrix(); } glDisable(GL_COLOR_MATERIAL); glDisable(GL_BLEND); }
void Sphere::draw(){ glPushMatrix(); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(_sourceFactor, _destFactor); glMaterialfv (GL_FRONT, GL_AMBIENT, _matAmbient); glMaterialfv (GL_FRONT, GL_DIFFUSE, _matDiffuse); glMaterialfv (GL_FRONT, GL_SPECULAR, _matSpecular); glMaterialf (GL_FRONT, GL_SHININESS, HIGH_SHININESS); glColor4f(_arrayColor[0], _arrayColor[1], _arrayColor[2], _arrayColor[3]); glTranslatef(_posX, _posY, _posZ); glRotatef(_rotZ, 0.0, 0.0, 1.0); glRotatef(_rotX, 1.0, 0.0, 0.0); glRotatef(_rotY, 0.0, 1.0, 0.0); glScalef(_scaleX,_scaleY,_scaleZ); glBindTexture(GL_TEXTURE_2D, _texture); //glPolygonMode(GL_FRONT, GL_FILL); //glPolygonMode(GL_BACK, GL_FILL); gluSphere(_quad, _radius,_slices, _stacks); glDisable(GL_BLEND); glDisable(GL_TEXTURE_2D); glPopMatrix(); }
void drawSphere(double r) { ModelerDrawState *mds = ModelerDrawState::Instance(); _setupOpenGl(); if (mds->m_rayFile) { _dump_current_modelview(); fprintf(mds->m_rayFile, "scale(%f,%f,%f,sphere {\n", r, r, r ); _dump_current_material(); fprintf(mds->m_rayFile, "}))\n" ); } else { int divisions; GLUquadricObj* gluq; switch(mds->m_quality) { case HIGH: divisions = 32; break; case MEDIUM: divisions = 20; break; case LOW: divisions = 12; break; case POOR: divisions = 8; break; } gluq = gluNewQuadric(); gluQuadricDrawStyle( gluq, GLU_FILL ); gluQuadricTexture( gluq, GL_TRUE ); gluSphere(gluq, r, divisions, divisions); gluDeleteQuadric( gluq ); } }
void MechHip(char solid) { int i; GLUquadricObj *hip[2]; glNewList(SOLID_MECH_HIP, GL_COMPILE); #ifdef LIGHT SetMaterial(mat_specular, mat_ambient, mat_diffuse, mat_shininess); #endif glColor3f(1.0, 1.0, 0.0); Octagon(0.7, 0.5, solid); #ifdef SPHERE for (i = 0; i < 2; i++) { if (i) { glScalef(-1.0, 1.0, 1.0); } glTranslatef(1.0, 0.0, 0.0); hip[i] = gluNewQuadric(); #ifdef LIGHT SetMaterial(mat_specular2, mat_ambient2, mat_diffuse2, mat_shininess2); #endif glColor3f(0.5, 0.5, 0.5); if (!solid) { gluQuadricDrawStyle(hip[i], GLU_LINE); } gluSphere(hip[0], 0.2, 16, 16); glTranslatef(-1.0, 0.0, 0.0); } glScalef(-1.0, 1.0, 1.0); #endif glEndList(); }
void Ball::draw() { if (displist == -1) { displist = glGenLists(1); glNewList(displist, GL_COMPILE); GLfloat mat_ambient[] = {0.22610818, 0.10305943, 0.0}; GLfloat mat_diffuse[] = {0.90440222, 0.41225299, 0.0}; GLfloat mat_specular[] = {0.09559777, 0.09559777, 0.09559777}; GLfloat mat_emission[] = {0.0, 0.0, 0.0}; GLfloat mat_shininess = 0.07812619; glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, mat_emission); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess); if (quad == NULL) { quad = gluNewQuadric(); gluQuadricNormals(quad, GLU_SMOOTH); //gluQuadricTexture(quad, GL_TRUE); } gluSphere(quad, radius, 32, 32); glEndList(); } glPushMatrix(); /* Move to position */ glTranslatef(position.x, position.y, position.z); /* shrink/grow */ glScalef(scale, scale, scale); glCallList(displist); glPopMatrix(); }
void lab2::draw(void) { //draw f**k std::cout << "Draw object" << std::endl; //setup draw styles for objects gluQuadricDrawStyle (cylinder, GL_POLYGON); gluQuadricDrawStyle (sphere, GL_POLYGON); gluQuadricDrawStyle (conus, GL_POLYGON); //enable or disable texture on objects gluQuadricTexture(cylinder, GL_TRUE); gluQuadricTexture(sphere, GL_TRUE); gluQuadricTexture(conus, GL_TRUE); //draw cylinder std::cout << "Draw cylinder" << std::endl; glBindTexture(GL_TEXTURE_2D, _textureId[0]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTranslatef(xCenterCylinder, yCenterCylinder, zCenterCylinder); gluCylinder(cylinder, baseRad, topRad, cyheight, slices, stacks); //draw sphere std::cout << "Draw sphere" << std::endl; glBindTexture(GL_TEXTURE_2D, _textureId[1]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTranslatef(xCenterSphere, yCenterSphere, zCenterSphere); gluSphere(sphere, spRad, slices, stacks); //draw conus std::cout << "Draw conus" << std::endl; glBindTexture(GL_TEXTURE_2D, _textureId[2]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTranslatef(xCenterConus, yCenterConus, zCenterConus); gluCylinder(conus, conusRad, 0, coheight, slices, stacks); }
void desenharMarte(GLuint texture, GLUquadric * Q, GLuint texture2, GLUquadric * Q2) { glPushMatrix(); glRotatef(orbitalTiltMarte,0.0,0.0,1.0); angMarte+= ((2*PI)/velMarte)*timeFactor; posicoes[7][0]=distFactor*distSolMarte*sin(angMarte); posicoes[7][1]=distFactor*distSolMarte*sin(angMarte) * sin(orbitalTiltMarte*(PI/180)) ; posicoes[7][2]=distFactor*distSolMarte*cos(angMarte); raios[7]=raioMarte*scale; //colisao planeta -> nave if((cameraMode==0 && haColisao(camZ,camX,camY,7)) || (cameraMode == 1 && haColisaoNave2(camZ,camX,camY,camlookZ,camlookX,camlookY,7)) ) afastaCamara(7); glTranslatef(distFactor*distSolMarte*sin(angMarte), 0, distFactor*distSolMarte*cos(angMarte)); desenharDeimos(texture2, Q2); desenharFobos(texture2, Q2); //glColor3f(1,0,0);//vermelho angRotMarte += (360/velRMarte)*timeFactor; rotacao(angRotMarte,axisTiltMarte); glEnable (GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture); glRotatef(-90,1,0,0); if(sphereInFrustum(posicoes[7],raios[7])) gluSphere (Q,scale*raioMarte,calcularFatias(7),32); glDisable(GL_TEXTURE_2D); glPopMatrix(); if(orbitas)draw_orbita(distFactor*distSolMarte,90,0.0,orbitalTiltMarte); }
void Shell::draw () { glPushMatrix(); float m[16]; d->trx.getOpenGLMatrix(m); glMultMatrixf(m); static GLuint dlist = 0; if (glIsList(dlist)) { glCallList(dlist); } else { dlist = glGenLists(1); glNewList(dlist, GL_COMPILE_AND_EXECUTE); GLUquadric* quadric = gluNewQuadric(); gluSphere(quadric, d->radius, 3, 3); gluDeleteQuadric(quadric); glEndList(); } glPopMatrix(); }
void drawTexturedSphere(jrPlanet *pPlanet) { GLUquadricObj* quadro = gluNewQuadric(); gluQuadricNormals(quadro, GLU_SMOOTH); gluQuadricTexture(quadro, GL_TRUE); glEnable(GL_TEXTURE_2D); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glPushMatrix(); switch (pPlanet->iType) { case SUN: { glBindTexture(GL_TEXTURE_2D, g_uiTexture[0]); float af_SunEmissive[]={1.0f, 0.1f, 0.1f, 1.0f}; glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, af_SunEmissive); break; } case EARTH: glBindTexture(GL_TEXTURE_2D, g_uiTexture[1]); break; case MOON: glBindTexture(GL_TEXTURE_2D, g_uiTexture[2]); break; case MARS: glBindTexture(GL_TEXTURE_2D, g_uiTexture[3]); break; case DEATH_STAR: glBindTexture(GL_TEXTURE_2D, g_uiTexture[4]); break; } gluSphere(quadro, pPlanet->fSize, pPlanet->iSlices, pPlanet->iSegments); glPopMatrix(); glDisable(GL_TEXTURE_2D); gluDeleteQuadric(quadro); }
void init_graphics(void) { int width = 600; int height = 600; xmax = width; ymax = height; glDrawBuffer(GL_BACK); glEnable(GL_DEPTH_TEST); glClearColor(0.0, 0.0, 0.0, 0.0); glClearDepth(1.0); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); glViewport(0, 0, xmax, ymax); setPerspective(fovy, (float)xmax/(float)ymax, 0.01, farplane); quadObj = gluNewQuadric(); gluQuadricNormals(quadObj, GLU_NONE); asphere = glGenLists(1); glNewList(asphere, GL_COMPILE); gluSphere(quadObj, 0.3, 12, 8); glEndList(); }
void cSphere::render(float rotAngle) { glMatrixMode(GL_MODELVIEW); glPushMatrix(); glEnable(GL_TEXTURE_2D); glEnable(GL_NORMALIZE); glEnable(GL_COLOR_MATERIAL); glBindTexture(GL_TEXTURE_2D, m_TextureID); glTranslatef(m_Position.x, m_Position.y, m_Position.z); glRotatef(90.0f, 1.0f, 0.0f, 0.0f); // Rotate Sphere to take account of gluSphere caps glRotatef(getRotAngle(), 0, 0, 1); // Rotation is now on z rather than Y to make sphere spin gluSphere(quad, sRadius, sSlices, sStacks); glDisable(GL_NORMALIZE); glDisable(GL_COLOR_MATERIAL); glDisable(GL_TEXTURE_2D); glPopMatrix(); }
//============================================================================== void cDrawSphere(const double& a_radius, const unsigned int a_numSlices, const unsigned int a_numStacks) { #ifdef C_USE_OPENGL // allocate a new OpenGL quadric object for rendering a sphere GLUquadricObj *quadObj; quadObj = gluNewQuadric (); // set rendering style gluQuadricDrawStyle (quadObj, GLU_FILL); // set normal-rendering mode gluQuadricNormals (quadObj, GLU_SMOOTH); // render a sphere gluSphere(quadObj, a_radius, a_numSlices, a_numStacks); // delete our quadric object gluDeleteQuadric(quadObj); #endif }