X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fcapsule.cpp;h=65a18eb3e2cbf6e8915d4c239b4a4460dc4b4eb3;hp=fd4dbb0fb5e974b793492845dfa918c3349729a3;hb=HEAD;hpb=aa9884e69bc543682d1fe36ec5d054fdf11bcfac diff --git a/source/capsule.cpp b/source/capsule.cpp deleted file mode 100644 index fd4dbb0f..00000000 --- a/source/capsule.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* $Id$ - -This file is part of libmspgl -Copyright © 2011 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - -#include -#include "capsule.h" -#include "primitivebuilder.h" - -using namespace std; - -namespace Msp { -namespace GL { - -CapsuleBuilder::CapsuleBuilder(float r, float l, unsigned s, unsigned n): - radius(r), - length(l), - segments(s), - rings(n) -{ - if(segments<3) - segments = 3; - rings |= 1; - if(rings<3) - rings = 3; -} - -void CapsuleBuilder::build(PrimitiveBuilder &builder) const -{ - float u_scale = 1.0/segments; - float v_scale = 1/(length+radius*M_PI); - if(tex_fit!=STRETCH) - { - float l1 = radius*M_PI*2; - float l2 = length+radius*M_PI; - if((l1rings/2 ? 0.5 : -0.5); - float v = (i*radius*M_PI/rings+(i>rings/2 ? length : 0))*v_scale; - float ra = (i>rings/2 ? i-1 : i)*M_PI/(rings-1); - float rc = cos(ra); - float rs = sin(ra); - for(unsigned j=0; j<=segments; ++j) - { - float sa = j*M_PI*2/segments; - float sc = cos(sa); - float ss = sin(sa); - builder.normal(rs*sc, rs*ss, -rc); - if(tangent_attr>=0) - builder.attrib(tangent_attr, -ss, sc, 0); - if(binormal_attr>=0) - builder.attrib(binormal_attr, rc*sc, rc*ss, rs); - builder.texcoord(j*u_scale, v); - builder.vertex(rs*sc*radius, rs*ss*radius, cz-rc*radius); - } - } - builder.normal(0, 0, 1); - builder.texcoord(0.5, (length+radius*M_PI)*v_scale); - builder.vertex(0, 0, length/2-radius); - - for(unsigned i=0; i