AnoPlib - Animlets are not Particles library
 All Data Structures Namespaces Files Functions Variables
AnoPhelpers Class Reference

Some helper methods and data. More...

#include <AnoPhelpers.h>

Static Public Member Functions

static void close ()
static void drawOutlineCircle (double width, double iwidth, int steps, double beg, double end) throw ()
static void drawOutlineCircle2 (double width, double iwidth, int steps, double beg, double end, float *rgba1, float *rgba2) throw ()
static void init ()

Static Public Attributes

static double * costab
static double * sintab

Detailed Description

Some helper methods and data.

Definition at line 49 of file AnoPhelpers.h.


Member Function Documentation

void AnoPhelpers::close ( ) [static]

Definition at line 66 of file AnoPhelpers.cpp.

References costab, and sintab.

Referenced by main().

                        {
    delete[] sintab;
    delete[] costab;
}
void AnoPhelpers::drawOutlineCircle ( double  width,
double  iwidth,
int  steps,
double  beg,
double  end 
) throw () [static]

Definition at line 73 of file AnoPhelpers.cpp.

Referenced by AnoPwavepropagation1::render().

                                                                                                     {
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
    double p1x = beg==0 ? sintab[0] : sintab[((int) beg)%360];
    double p1y = beg==0 ? costab[0] : costab[((int) beg)%360];
    for (int i=(int)(beg); i<steps&&(360.0/(double) steps *(double) i)<end; i++) {
        double p2x = sintab[(size_t)(360.0/(double) steps * (double) i)%360];
        double p2y = costab[(size_t)(360.0/(double) steps * (double) i)%360];
        glBegin(GL_TRIANGLES);
        glVertex2d(p1x * width, p1y * width);
        glVertex2d(p2x * width, p2y * width);
        glVertex2d(p2x * iwidth, p2y * iwidth);

        glVertex2d(p2x * iwidth, p2y * iwidth);
        glVertex2d(p1x * iwidth, p1y * iwidth);
        glVertex2d(p1x * width, p1y * width);
        glEnd();
        p1x = p2x;
        p1y = p2y;
    }
    double p2x = end==360 ? sintab[0] : sintab[((int) end)%360];
    double p2y = end==360 ? costab[0] : costab[((int) end)%360];
    glBegin(GL_TRIANGLES);
    glVertex2d(p1x * width, p1y * width);
    glVertex2d(p2x * width, p2y * width);
    glVertex2d(p2x * iwidth, p2y * iwidth);

    glVertex2d(p2x * iwidth, p2y * iwidth);
    glVertex2d(p1x * iwidth, p1y * iwidth);
    glVertex2d(p1x * width, p1y * width);
    glEnd();
}
void AnoPhelpers::drawOutlineCircle2 ( double  width,
double  iwidth,
int  steps,
double  beg,
double  end,
float *  rgba1,
float *  rgba2 
) throw () [static]

Definition at line 107 of file AnoPhelpers.cpp.

References s.

Referenced by AnoPemergency1::render(), and AnoPflashlight1::render().

                                                       {
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
    double p1x = beg==0 ? sintab[0] : sintab[((int) beg)%360];
    double p1y = beg==0 ? costab[0] : costab[((int) beg)%360];
    double s = end - beg;
    if(s<0) {
        s = 360. + s;
    }
    for (int i=0; i<steps; ++i) {
        double p2x = sintab[(size_t)(s/(double) steps * (double) i + beg)%360];
        double p2y = costab[(size_t)(s/(double) steps * (double) i + beg)%360];
        glBegin(GL_TRIANGLES);
        glColor4fv(rgba2);
        glVertex2d(p1x * width, p1y * width);
        glVertex2d(p2x * width, p2y * width);
        glColor4fv(rgba1);
        glVertex2d(p2x * iwidth, p2y * iwidth);

        glVertex2d(p2x * iwidth, p2y * iwidth);
        glVertex2d(p1x * iwidth, p1y * iwidth);
        glColor4fv(rgba2);
        glVertex2d(p1x * width, p1y * width);
        glEnd();
        p1x = p2x;
        p1y = p2y;
    }
    double p2x = end==360 ? sintab[0] : sintab[((int) end)%360];
    double p2y = end==360 ? costab[0] : costab[((int) end)%360];
    glBegin(GL_TRIANGLES);
    glColor4fv(rgba2);
    glVertex2d(p1x * width, p1y * width);
    glVertex2d(p2x * width, p2y * width);
    glColor4fv(rgba1);
    glVertex2d(p2x * iwidth, p2y * iwidth);

    glVertex2d(p2x * iwidth, p2y * iwidth);
    glVertex2d(p1x * iwidth, p1y * iwidth);
    glColor4fv(rgba2);
    glVertex2d(p1x * width, p1y * width);
    glEnd();
}
void AnoPhelpers::init ( ) [static]

Definition at line 55 of file AnoPhelpers.cpp.

References costab, and sintab.

                       {
    double PI = 3.1415926535897932384626433832795;
    sintab = new double[360];
    costab = new double[360];
    for(int i=0; i<360; ++i) {
        sintab[i] = 256. * sin(PI/180.*(double)i);
        costab[i] = 256. * cos(PI/180.*(double)i);
    }
}

Field Documentation

double * AnoPhelpers::costab [static]

Definition at line 53 of file AnoPhelpers.h.

Referenced by close(), init(), and AnoPwavelogo1::render().


The documentation for this class was generated from the following files: