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-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 | |
---|
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 | boundary = BoundBox(x-r, y-r, z-r, x+r, y+r, z+r); |
---|
31 | } |
---|
32 | |
---|
33 | Sphere::~Sphere() |
---|
34 | { |
---|
35 | } |
---|
36 | |
---|
37 | void |
---|
38 | Sphere::render() |
---|
39 | { |
---|
40 | } |
---|
41 | |
---|
42 | void |
---|
43 | Sphere::draw(GLUquadric* quad) |
---|
44 | { |
---|
45 | glColor3f(color.R, color.G, color.B); |
---|
46 | |
---|
47 | glMatrixMode(GL_MODELVIEW); |
---|
48 | glPushMatrix(); |
---|
49 | glTranslatef(location.x, location.y, location.z); |
---|
50 | |
---|
51 | //draw it |
---|
52 | gluSphere(quad, radius, stack, slice); |
---|
53 | |
---|
54 | glPopMatrix(); |
---|
55 | } |
---|
56 | |
---|
57 | void |
---|
58 | Sphere::set_horizontal_res(int _slice) { |
---|
59 | slice=_slice; |
---|
60 | } |
---|
61 | |
---|
62 | void |
---|
63 | Sphere::set_vertical_res(int _stack) { |
---|
64 | stack=_stack; |
---|
65 | } |
---|
66 | |
---|