]> git.tdb.fi Git - libs/gl.git/blobdiff - source/cylinder.cpp
Check the flat qualifier from the correct member
[libs/gl.git] / source / cylinder.cpp
diff --git a/source/cylinder.cpp b/source/cylinder.cpp
deleted file mode 100644 (file)
index 30c3530..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/* $Id$
-
-This file is part of libmspgl
-Copyright © 2011  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
-#include <cmath>
-#include "cylinder.h"
-#include "primitivebuilder.h"
-
-using namespace std;
-
-namespace Msp {
-namespace GL {
-
-CylinderBuilder::CylinderBuilder(float r, float l, unsigned s):
-       radius(r),
-       length(l),
-       segments(s)
-{
-       if(segments<3)
-               segments = 3;
-}
-
-void CylinderBuilder::build(PrimitiveBuilder &builder) const
-{
-       if(binormal_attr>=0)
-               builder.attrib(binormal_attr, 0, 1, 0);
-       for(unsigned i=0; i<2; ++i)
-       {
-               float z = (i-0.5)*length;
-               builder.normal(0, 0, i*2.0-1.0);
-               builder.texcoord(0.5, 0.5);
-               if(tangent_attr>=0)
-                       builder.attrib(tangent_attr, (i ? 1 : -1), 0, 0);
-               builder.vertex(0, 0, z);
-               for(unsigned j=0; j<segments; ++j)
-               {
-                       float a = j*M_PI*2/segments;
-                       float c = cos(a);
-                       float s = sin(a);
-                       builder.texcoord(0.5+(i ? 0.5 : -0.5)*c, 0.5+0.5*s);
-                       builder.vertex(radius*c, radius*s, z);
-               }
-       }
-
-       float u_scale = 1.0/segments;
-       float v_scale = 1;
-       adjust_texture_scale(u_scale, v_scale, radius*M_PI*2, length);
-
-       if(binormal_attr>=0)
-               builder.attrib(binormal_attr, 0, 0, 1);
-       for(unsigned i=0; i<2; ++i)
-       {
-               float z = (i-0.5)*length;
-               for(unsigned j=0; j<=segments; ++j)
-               {
-                       float a = j*M_PI*2/segments;
-                       float c = cos(a);
-                       float s = sin(a);
-                       builder.normal(c, s, 0);
-                       builder.texcoord(j*u_scale, i*v_scale);
-                       if(tangent_attr>=0)
-                               builder.attrib(tangent_attr, -s, c, 0);
-                       builder.vertex(radius*c, radius*s, z);
-               }
-       }
-
-       unsigned base = 0;
-       for(unsigned i=0; i<2; ++i)
-       {
-               builder.begin(TRIANGLE_FAN);
-               builder.element(base);
-               for(unsigned j=0; j<=segments; ++j)
-                       builder.element(base+1+j%segments);
-               builder.end();
-
-               base += segments+1;
-       }
-
-       builder.begin(TRIANGLE_STRIP);
-       for(unsigned j=0; j<=segments; ++j)
-       {
-               builder.element(base+segments+1+j);
-               builder.element(base+j);
-       }
-       builder.end();
-}
-
-} // namespace GL
-} // namespace Msp