Back to index

kdeartwork  4.3.2
Public Member Functions | Public Attributes
flux Class Reference
Collaboration diagram for flux:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 flux ()
 ~flux ()
void update ()

Public Attributes

particleparticles
int randomize
float c [NUMCONSTS]
float cv [NUMCONSTS]
int currentSmartConstant
float oldDistance

Detailed Description

Definition at line 326 of file Flux.cpp.


Constructor & Destructor Documentation

Definition at line 343 of file Flux.cpp.

{
    whichparticle = 0;

    particles = new particle[_fc->dParticles];
    randomize = 1;

    float instability = _fc->dInstability;
    int i;
    for(i=0; i<NUMCONSTS; i++)
    {
        c[i] = myRandf(2.0f) - 1.0f;
        cv[i] = myRandf(0.000005f * instability * instability)
                + 0.000001f * instability * instability;
    }

    currentSmartConstant = 0;
    oldDistance = 0.0f;
}

Here is the call graph for this function:

Definition at line 364 of file Flux.cpp.

{
    delete[] particles;
}

Member Function Documentation

void flux::update ( )

Definition at line 370 of file Flux.cpp.

{
    int i;

    // randomize constants
    if(_fc->dRandomize){
        randomize --;
        if(randomize <= 0){
            for(i=0; i<NUMCONSTS; i++)
                c[i] = myRandf(2.0f) - 1.0f;
            int temp = 101 - _fc->dRandomize;
            temp = temp * temp;
            randomize = temp + myRandi(temp);
        }
    }

    // update constants
    for(i=0; i<NUMCONSTS; i++){
        c[i] += cv[i];
        if(c[i] >= 1.0f){
            c[i] = 1.0f;
            cv[i] = -cv[i];
        }
        if(c[i] <= -1.0f){
            c[i] = -1.0f;
            cv[i] = -cv[i];
        }
    }

    // update all particles in this flux field
    float dist;
    for(i=0; i<_fc->dParticles; i++)
        dist = particles[i].update(c);

    // use dist from last particle to activate smart constants
    _fc->dSmart = 0;
    if(_fc->dSmart){
        const float upper = 0.4f;
        const float lower = 0.2f;
        int beSmart = 0;
        if(dist > upper && dist > oldDistance)
            beSmart = 1;
        if(dist < lower && dist < oldDistance)
            beSmart = 1;
        if(beSmart){
            cv[currentSmartConstant] = -cv[currentSmartConstant];
            currentSmartConstant ++;
            if(currentSmartConstant >= _fc->dSmart)
                currentSmartConstant = 0;
        }
        oldDistance = dist;
    }
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 336 of file Flux.cpp.

Definition at line 338 of file Flux.cpp.

Definition at line 337 of file Flux.cpp.

Definition at line 339 of file Flux.cpp.

Definition at line 334 of file Flux.cpp.

Definition at line 335 of file Flux.cpp.


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