V-ART
sphere.cpp
Go to the documentation of this file.
1 
5 #ifdef WIN32
6 #include <windows.h>
7 #endif
8 #ifdef VART_OGL
9 #include <GL/glu.h>
10 #endif
11 #include "vart/sphere.h"
12 #include <iostream>
13 
14 using namespace std;
15 
17  radius = 1.0;
19 }
20 
22 {
23  this->operator=(sphere);
24 }
25 
27 {
28  this->GraphicObj::operator=(sphere);
29  radius = sphere.radius;
30  material = sphere.material;
31  return *this;
32 }
33 
35 {
36  return new Sphere(*this);
37 }
38 
39 VART::Sphere::Sphere( float fRad ) : VART::GraphicObj() {
40  radius = fRad;
42 }
43 
44 void VART::Sphere::SetRadius( float r ) {
45  radius = r;
46  ComputeBoundingBox();
47 }
48 
49 float VART::Sphere::GetRadius( void ) {
50  return radius;
51 }
52 
54  bBox.SetSmallerX(-radius);
55  bBox.SetSmallerY(-radius);
56  bBox.SetSmallerZ(-radius);
57  bBox.SetGreaterX(radius);
58  bBox.SetGreaterY(radius);
59  bBox.SetGreaterZ(radius);
60  //oobBox=VART::OOBoundingBox(bBox);
61 }
62 
64 #ifdef VART_OGL
65  GLUquadricObj* qObj = gluNewQuadric();
66  bool result = true;
67 
68  if (show)
69  {
70  if( material.GetTexture().HasData() )
71  {
72  gluQuadricTexture(qObj,GL_TRUE);
73  }
74  result = material.DrawOGL();
75  gluQuadricDrawStyle(qObj, GLU_FILL);
76  gluQuadricNormals(qObj, GLU_SMOOTH);
77  gluSphere(qObj, radius, 15, 15);
78  gluDeleteQuadric(qObj);
79  }
80  if (bBox.visible)
81  bBox.DrawInstanceOGL();
82  if (recBBox.visible)
83  recBBox.DrawInstanceOGL();
84  return result;
85 #else
86  return false;
87 #endif
88 }
Base class for objects that compose a scene graph.
Definition: scenenode.h:25
void SetRadius(float r)
Definition: sphere.cpp:44
virtual VART::SceneNode * Copy()
Returns a copy of an Sphere. Every derived class must reimplements this method, to avoid errors with ...
Definition: sphere.cpp:34
float GetRadius()
Definition: sphere.cpp:49
A sphere.
Definition: sphere.h:16
Header file for V-ART class "Sphere".
bool DrawInstanceOGL() const
Draws the sphere using OpenGL engine.
Definition: sphere.cpp:63
An scene node that is associated with a shape.
Definition: graphicobj.h:18
SceneNode & operator=(const SceneNode &node)
Definition: scenenode.cpp:47
virtual void ComputeBoundingBox()
Computes the bounding box.
Definition: sphere.cpp:53
VART::Sphere & operator=(const VART::Sphere &sphere)
Copies all Sphere data to another sphere.
Definition: sphere.cpp:26