1 | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
---|
2 | /* |
---|
3 | * ---------------------------------------------------------------------- |
---|
4 | * Sphere.cpp : Sphere class |
---|
5 | * |
---|
6 | * ====================================================================== |
---|
7 | * AUTHOR: Wei Qiao <qiaow@purdue.edu> |
---|
8 | * Purdue Rendering and Perceptualization Lab (PURPL) |
---|
9 | * |
---|
10 | * Copyright (c) 2004-2012 HUBzero Foundation, LLC |
---|
11 | * |
---|
12 | * See the file "license.terms" for information on usage and |
---|
13 | * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
14 | * ====================================================================== |
---|
15 | */ |
---|
16 | |
---|
17 | #include "Sphere.h" |
---|
18 | |
---|
19 | Sphere::Sphere(float x, float y, float z, |
---|
20 | float r, float g, float b, |
---|
21 | float radius, |
---|
22 | int stack, |
---|
23 | int slice) : |
---|
24 | Renderable(Vector3(x, y, z)), |
---|
25 | _radius(radius), |
---|
26 | _color(Color(r, g, b)), |
---|
27 | _stack(stack), |
---|
28 | _slice(slice) |
---|
29 | { |
---|
30 | } |
---|
31 | |
---|
32 | Sphere::~Sphere() |
---|
33 | { |
---|
34 | } |
---|
35 | |
---|
36 | void |
---|
37 | Sphere::draw(GLUquadric *quad) |
---|
38 | { |
---|
39 | glColor3f(_color.r(), _color.g(), _color.b()); |
---|
40 | |
---|
41 | glMatrixMode(GL_MODELVIEW); |
---|
42 | glPushMatrix(); |
---|
43 | glTranslatef(_location.x, _location.y, _location.z); |
---|
44 | |
---|
45 | //draw it |
---|
46 | gluSphere(quad, _radius, _stack, _slice); |
---|
47 | |
---|
48 | glPopMatrix(); |
---|
49 | } |
---|
50 | |
---|
51 | void |
---|
52 | Sphere::setHorizontalRes(int slice) |
---|
53 | { |
---|
54 | _slice = slice; |
---|
55 | } |
---|
56 | |
---|
57 | void |
---|
58 | Sphere::setVerticalRes(int stack) |
---|
59 | { |
---|
60 | _stack = stack; |
---|
61 | } |
---|