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

An emergency vehicle's flash light. More...

#include <AnoPemergency1.h>

Inheritance diagram for AnoPemergency1:
AnoP::AnoPsystem< emergency1Struct > AnoP::AnoPsystemBase

Public Member Functions

void addAnimlet (emergency1Struct &animlet) throw ()
 Adds an animlet to the list of those to render.
 AnoPemergency1 (unsigned int bufSize=10)
 Constructor.
void preRender () throw ()
 Pre-rendering step.
bool render (emergency1Struct &s, unsigned int timeDiff, void *const something) throw ()
 Rendering step.
void renderAll (unsigned int timeDiff, void *const something)
 Renders all stored animlets, passing the given values to these.
Methods to override by realisation
virtual void postRender () throw ()
 Called after rendering the stored animlets.
virtual bool deleteAnimlet (emergency1Struct &which) throw ()
 Animlet deletion callback.

Data Fields

float white [4]
float yellowbright [4]
float yellowdark [4]

Protected Attributes

emergency1StructmyAnimletBuffer
 The allocated animlets.
unsigned int myAnimletNumber
 The number of currently running animlets.
unsigned int myBufferSize
 The number of allocated animlets.

Detailed Description

An emergency vehicle's flash light.

Definition at line 59 of file AnoPemergency1.h.


Constructor & Destructor Documentation

AnoPemergency1::AnoPemergency1 ( unsigned int  bufSize = 10) [inline]

Constructor.

Parameters:
[in]bufSizeThe number of animlets to pre-allocate

Definition at line 64 of file AnoPemergency1.h.

References white, yellowbright, and yellowdark.

                                            : AnoP::AnoPsystem<emergency1Struct>(bufSize) {
        white[0] = 1;
        white[1] = 1;
        white[2] = 1;
        white[3] = 1;
        yellowbright[0] = 1;
        yellowbright[1] = 1;
        yellowbright[2] = 0;
        yellowbright[3] = 1;
        yellowdark[0] = .1;
        yellowdark[1] = .1;
        yellowdark[2] = .0;
        yellowdark[3] = .1;
    }

Member Function Documentation

void AnoP::AnoPsystem< emergency1Struct >::addAnimlet ( emergency1Struct animlet) throw () [inline, inherited]

Adds an animlet to the list of those to render.

animlet The animlet to add

Definition at line 112 of file AnoP.h.

                                            {
            if(myAnimletNumber==myBufferSize) {
                int add = 10;
                T *newBuffer = new T[myBufferSize+add];
                memcpy(newBuffer, myAnimletBuffer, sizeof(T)*myBufferSize);
                std::swap(myAnimletBuffer, newBuffer);
                myBufferSize += add;
                delete[] newBuffer;
            }
            myAnimletBuffer[myAnimletNumber] = animlet;
            ++myAnimletNumber;
        }
virtual bool AnoP::AnoPsystem< emergency1Struct >::deleteAnimlet ( emergency1Struct which) throw () [inline, virtual, inherited]

Animlet deletion callback.

If this callback returns true, the animlet is removed from the list of animlets to render. In the case any memory shall be freed, this method is reponsible for doing this.

Nonetheless, there may be some reason for not deleting the animlet but reinitialise it. This can be done in this method, too. false should be returned then, so that the animlet stays in the list of animlets to render.

Parameters:
[in]whichThe animlet to delete

Definition at line 171 of file AnoP.h.

{ return true; }
virtual void AnoP::AnoPsystem< emergency1Struct >::postRender ( ) throw () [inline, virtual, inherited]

Called after rendering the stored animlets.

This method is meant to do any kind of cleaning up; does nothing per default.

Definition at line 142 of file AnoP.h.

{}
void AnoPemergency1::preRender ( ) throw () [inline, virtual]

Pre-rendering step.

Reimplemented from AnoP::AnoPsystem< emergency1Struct >.

Definition at line 82 of file AnoPemergency1.h.

                             {
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        glTranslated(-1,-1,0);
        glScaled(1./200, 1./200, 1.);
        glEnable (GL_BLEND);
        glBlendFunc(GL_ONE, GL_ONE);
        glDepthMask(GL_FALSE);
    }
bool AnoPemergency1::render ( emergency1Struct s,
unsigned int  timeDiff,
void *const  something 
) throw () [inline, virtual]

Rendering step.

Parameters:
[in]sThe settings of the animlet to render
[in]timeDiffThe time passed since last call
[in]somethingNot used here

Reimplemented from AnoP::AnoPsystem< emergency1Struct >.

Definition at line 100 of file AnoPemergency1.h.

References AnoPhelpers::drawOutlineCircle2(), s, white, yellowbright, and yellowdark.

                                                                                            {
        glPushMatrix();
        int off = s.step;
        glTranslated(s.pos[0], s.pos[1], 0.);
        double scale = off;
        glScaled(50./256., 50./256., 50./256.);
        glColor4d(1,1,0,1);
        AnoPhelpers::drawOutlineCircle2(.5, .09, 36, (s.step+10)%360, (s.step+70)%360, white, yellowdark);
        AnoPhelpers::drawOutlineCircle2(1., .09, 36, (s.step-00)%360, (s.step+80)%360, yellowbright, yellowdark);
        glRotated(180.,0,0,1);
        AnoPhelpers::drawOutlineCircle2(.5, .09, 36, (s.step+10)%360, (s.step+70)%360, white, yellowdark);
        AnoPhelpers::drawOutlineCircle2(1., .09, 36, (s.step-00)%360, (s.step+80)%360, yellowbright, yellowdark);
        glPopMatrix();
        s.step += 5;
        if(s.step>360) {
            s.step = 1;
        }
        return true;
    }
void AnoP::AnoPsystem< emergency1Struct >::renderAll ( unsigned int  timeDiff,
void *const  something 
) [inline, virtual, inherited]

Renders all stored animlets, passing the given values to these.

At first "preRender" is called.

Then, for each stored animlet the "render" method is called, passing the current animlet, the given time since last call, and the given additional data. In the case "render" returns false, "deleteAnimlet" is called. If "deleteAnimlet" returns true, the animlet is removed.

At the end "postRender" is called.

Parameters:
[in]timeDiffAssumed to be the time since last call
[in]somethingFurther thing that will be passed during the rendering

Implements AnoP::AnoPsystemBase.

Definition at line 91 of file AnoP.h.

                                                                      {
            preRender();
            for(unsigned int i=0; i<myAnimletNumber; ) {
                T &animlet = myAnimletBuffer[i];
                if(render(animlet, timeDiff, something)) {
                    ++i;
                    continue;
                }
                // animlet dies...
                if(deleteAnimlet(animlet)) {
                    myAnimletBuffer[i] = myAnimletBuffer[myAnimletNumber-1];
                    --myAnimletNumber;
                }
            }
            postRender();
        }

Field Documentation

The allocated animlets.

Definition at line 183 of file AnoP.h.

unsigned int AnoP::AnoPsystem< emergency1Struct >::myAnimletNumber [protected, inherited]

The number of currently running animlets.

Definition at line 177 of file AnoP.h.

unsigned int AnoP::AnoPsystem< emergency1Struct >::myBufferSize [protected, inherited]

The number of allocated animlets.

Definition at line 180 of file AnoP.h.

Definition at line 120 of file AnoPemergency1.h.

Referenced by AnoPemergency1(), and render().

Definition at line 120 of file AnoPemergency1.h.

Referenced by AnoPemergency1(), and render().

Definition at line 120 of file AnoPemergency1.h.

Referenced by AnoPemergency1(), and render().


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