1 | /*
|
---|
2 | * ----------------------------------------------------------------------
|
---|
3 | * Sphere.cpp : Sphere class
|
---|
4 | *
|
---|
5 | * ======================================================================
|
---|
6 | * AUTHOR: Wei Qiao <qiaow@purdue.edu>
|
---|
7 | * Purdue Rendering and Perceptualization Lab (PURPL)
|
---|
8 | *
|
---|
9 | * Copyright (c) 2004-2006 Purdue Research Foundation
|
---|
10 | *
|
---|
11 | * See the file "license.terms" for information on usage and
|
---|
12 | * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
---|
13 | * ======================================================================
|
---|
14 | */
|
---|
15 |
|
---|
16 | #include "Sphere.h"
|
---|
17 | #include <stdio.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 | stack(_stack),
|
---|
27 | slice(_slice),
|
---|
28 | color(Color(r,g,b))
|
---|
29 | {
|
---|
30 | boundary = BoundBox(x-r, y-r, z-r, x+r, y+r, z+r);
|
---|
31 | }
|
---|
32 |
|
---|
33 | Sphere::~Sphere(){}
|
---|
34 |
|
---|
35 | void Sphere::render(){}
|
---|
36 |
|
---|
37 | void Sphere::draw(GLUquadric* quad){
|
---|
38 | glColor3f(color.R, color.G, color.B);
|
---|
39 |
|
---|
40 | glMatrixMode(GL_MODELVIEW);
|
---|
41 | glPushMatrix();
|
---|
42 | glTranslatef(location.x, location.y, location.z);
|
---|
43 |
|
---|
44 | //draw it
|
---|
45 | gluSphere(quad, radius, stack, slice);
|
---|
46 |
|
---|
47 | glPopMatrix();
|
---|
48 | }
|
---|
49 |
|
---|
50 | void Sphere::set_horizontal_res(int _slice) {slice=_slice;}
|
---|
51 | void Sphere::set_vertical_res(int _stack) {stack=_stack;}
|
---|
52 |
|
---|