Exemplo n.º 1
0
/*!
SLSphere::SLSphere ctor for spheric revolution object around the z-axis.
*/
SLSphere::SLSphere(SLfloat sphereRadius,
                     SLint stacks, 
                     SLint slices,
                     SLstring name,
                     SLMaterial* mat) : SLRevolver(name)
{
    assert(slices >= 3 && "Error: Not enough slices.");
    assert(slices >  0 && "Error: Not enough stacks.");
   
    _radius = sphereRadius;
    _stacks = stacks;

    _slices = slices;
    _smoothFirst = true;
    _smoothLast  = true;
    _revAxis.set(0,0,1);
    _revPoints.reserve(stacks+1);

    SLfloat theta = -SL_PI;
    SLfloat phi   = 0;
    SLfloat dTheta= SL_PI / stacks;
   
    for (SLint i=0; i<=stacks; ++i)
    {   SLVec3f p;
        p.fromSpherical(sphereRadius, theta, phi);
        _revPoints.push_back(p);
        theta += dTheta;
    }
   
    buildMesh(mat);
}