00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "Teddy/Maths/Vector.h"
00026 #include "Teddy/Models/Ring.h"
00027 #include "Teddy/Models/QuadStrip.h"
00028 #include "Teddy/Models/Vertex.h"
00029 #include "Teddy/SysSupport/StdMaths.h"
00030 using namespace Teddy::SysSupport;
00031
00032
00033 namespace Teddy {
00034 namespace Models {
00035
00036
00044 Ring::Ring(
00045 const std::string &name,
00046 const double inner_radius,
00047 const double outer_radius,
00048 const int slices )
00049 :
00050 Model( name )
00051 {
00052 QuadStrip *qs = new QuadStrip();
00053 for( int i=0; i<=slices; i++ ){
00054 double theta = i*M_2_PI/slices;
00055 double slice = 1.0 - (double)(i)/(double)(slices);
00056 Vertex *v1 = new Vertex( inner_radius * cos(theta), 0, inner_radius * sin(theta) );
00057 v1->setNormal ( 0.0f, 1.0f, 0.0f );
00058 v1->setTexture( slice, 0.0f, 0.0f );
00059 Vertex *v2 = new Vertex( outer_radius * cos(theta), 0, outer_radius * sin(theta) );
00060 v1->setNormal ( 0.0f, 1.0f, 0.0f );
00061 v1->setTexture( slice, 1.0f, 0.0f );
00062 qs->add( v1 );
00063 qs->add( v2 );
00064 }
00065 add( qs );
00066 setClipRadius( outer_radius );
00067 }
00068
00069
00070 };
00071 };
00072