~ubuntu-branches/ubuntu/lucid/structure-synth/lucid

« back to all changes in this revision

Viewing changes to SyntopiaCore/GLEngine/Sphere.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Miriam Ruiz
  • Date: 2009-04-13 13:28:45 UTC
  • Revision ID: james.westby@ubuntu.com-20090413132845-d7d42t4llxjxq0ez
Tags: upstream-0.9
ImportĀ upstreamĀ versionĀ 0.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "Sphere.h"
 
2
 
 
3
using namespace SyntopiaCore::Math;
 
4
 
 
5
 
 
6
namespace SyntopiaCore {
 
7
        namespace GLEngine {
 
8
 
 
9
 
 
10
                //GLUquadric* Sphere::myQuad = 0;    
 
11
 
 
12
                Sphere::Sphere(SyntopiaCore::Math::Vector3f center, float radius) : center(center), radius(radius) {
 
13
                        myQuad = gluNewQuadric();    
 
14
                        gluQuadricDrawStyle(myQuad, GLU_FILL);
 
15
                        
 
16
                        /// Bounding box
 
17
                        Vector3f v = Vector3f(radius,radius,radius);
 
18
                        from = center-v;
 
19
                        to = center+v;
 
20
                };
 
21
 
 
22
                Sphere::~Sphere() {
 
23
                        gluDeleteQuadric(myQuad);
 
24
                };
 
25
 
 
26
                void Sphere::draw() const {
 
27
                        glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, primaryColor );
 
28
                        if (primaryColor[3] < 1) {
 
29
                                glEnable( GL_BLEND );
 
30
                        }
 
31
 
 
32
                        glPushMatrix();
 
33
                        glTranslatef( center.x(), center.y(), center.z() );
 
34
                        gluSphere(myQuad, radius, 7, 7);        
 
35
                        glPopMatrix();                  
 
36
                };
 
37
 
 
38
        }
 
39
}
 
40