1 | |
---|
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-2006 Purdue Research Foundation |
---|
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 | #include <stdio.h> |
---|
19 | |
---|
20 | Sphere::Sphere(float x, float y, float z, |
---|
21 | float r, float g, float b, |
---|
22 | float _radius, |
---|
23 | int _stack, |
---|
24 | int _slice): |
---|
25 | Renderable(Vector3(x, y, z)), |
---|
26 | radius(_radius), |
---|
27 | color(Color(r,g,b)), |
---|
28 | stack(_stack), |
---|
29 | slice(_slice) |
---|
30 | { |
---|
31 | boundary = BoundBox(x-r, y-r, z-r, x+r, y+r, z+r); |
---|
32 | } |
---|
33 | |
---|
34 | Sphere::~Sphere() { |
---|
35 | /*empty*/ |
---|
36 | } |
---|
37 | |
---|
38 | void |
---|
39 | Sphere::render() |
---|
40 | { |
---|
41 | /*empty*/ |
---|
42 | } |
---|
43 | |
---|
44 | void |
---|
45 | Sphere::draw(GLUquadric* quad) |
---|
46 | { |
---|
47 | glColor3f(color.R, color.G, color.B); |
---|
48 | |
---|
49 | glMatrixMode(GL_MODELVIEW); |
---|
50 | glPushMatrix(); |
---|
51 | glTranslatef(location.x, location.y, location.z); |
---|
52 | |
---|
53 | //draw it |
---|
54 | gluSphere(quad, radius, stack, slice); |
---|
55 | |
---|
56 | glPopMatrix(); |
---|
57 | } |
---|
58 | |
---|
59 | void |
---|
60 | Sphere::set_horizontal_res(int _slice) { |
---|
61 | slice=_slice; |
---|
62 | } |
---|
63 | |
---|
64 | void |
---|
65 | Sphere::set_vertical_res(int _stack) { |
---|
66 | stack=_stack; |
---|
67 | } |
---|
68 | |
---|