X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fcylinder.cpp;h=901a0f4b43cf057872a752960e30678a2a980b24;hp=30c3530c85b3ab63e068eeb6891d78922b58de7b;hb=HEAD;hpb=aa9884e69bc543682d1fe36ec5d054fdf11bcfac diff --git a/source/cylinder.cpp b/source/cylinder.cpp deleted file mode 100644 index 30c3530c..00000000 --- a/source/cylinder.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* $Id$ - -This file is part of libmspgl -Copyright © 2011 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - -#include -#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=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