Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 23, 2005, 1:28:24 PM (19 years ago)
Author:
bensch
Message:

orxonox/branches/particleEngine: minor patches, and now it renders particle-faces

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/particleEngine/src/lib/graphics/particles/particle_system.cc

    r3938 r3942  
    2121#include "particle_engine.h"
    2222#include "compiler.h"
     23#include "material.h"
    2324
    2425using namespace std;
    25 
    2626
    2727/**
     
    4343   this->setLifeSpan(.1);
    4444   this->setInheritSpeed(0);
    45 
     45   this->glID = NULL;
     46   this->setRadius(1.0, 1.0, 0.0);
     47   this->setType(PARTICLE_SPRITE, 1);
    4648   ParticleEngine::getInstance()->addSystem(this);
    4749}
     
    5860}
    5961
     62
     63void ParticleSystem::setType(PARTICLE_TYPE particleType, int count)
     64{
     65  this->particleType = particleType;
     66  this->dialectCount = count;
     67  if (glID != NULL)
     68    delete glID;
     69
     70  glID = new GLuint[count];
     71  for (int i = 0; i< count; i++)
     72    glID[i] = 0;
     73
     74  glID[0] = glGenLists(count);
     75 
     76  material = new Material("transperencyMap");
     77  material->setDiffuseMap("pictures/radialTransparency.jpg");
     78 
     79  glNewList(glID[0], GL_COMPILE);
     80  glBegin(GL_TRIANGLE_STRIP);
     81  glTexCoord2f(1, 1);
     82  glVertex3f(0.0, 1.0, 1.0);
     83  glTexCoord2f(1, 0);
     84  glVertex3f(0.0, 1.0, 0.0);
     85  glTexCoord2f(0, 1);
     86  glVertex3f(0.0, 0.0, 1.0);
     87  glTexCoord2f(0, 0);
     88  glVertex3f(0.0, 0.0, 0.0);
     89  glEnd();
     90  glEndList();
     91
     92 
     93
     94}
     95
    6096// setting properties
    6197void ParticleSystem::setMaterial(Material* material)
     
    6399  this->material = material;
    64100}
     101
    65102
    66103
     
    90127}
    91128
    92 void ParticleSystem::setRadius(float startRadius, float endRadius, float randomRadius)
     129void ParticleSystem::setRadius(float startRadius, float endRadius, float randomStartRadius, float randomEndRadius)
    93130{
    94131  this->startRadius = startRadius;
    95132  this->endRadius = endRadius;
    96   this->randomRadius = randomRadius;
     133  this->randomStartRadius = randomStartRadius;
     134  this->randomEndRadius = randomEndRadius;
    97135}
    98136
     
    117155     
    118156      tickPart->position = tickPart->position + tickPart->velocity;
    119       tickPart->radius + tickPart->radiusIt * dt;
     157      tickPart->radius += tickPart->radiusIt * dt;
     158
    120159      // many more to come
    121160
     
    153192void ParticleSystem::draw(void)
    154193{
     194  //  material->select();
     195
     196
     197  glMatrixMode(GL_MODELVIEW);
     198 
    155199  Particle* drawPart = particles;
    156200  if (likely(drawPart != NULL))
     
    160204        {
    161205          // draw in DOT mode
    162           glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z);
     206          glPushMatrix();
     207          glTranslatef(drawPart->position.x, drawPart->position.y, drawPart->position.z);
     208          glScalef(drawPart->radius, drawPart->radius, drawPart->radius);
     209          glCallList(*this->glID);
    163210         
    164          
     211          //              glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z);
    165212          drawPart = drawPart->next;
     213          glPopMatrix();
    166214        }
    167215      glEnd();
     
    193241      //  particle->rotation = ; //! \todo rotation is once again something to be done.
    194242      particles->mass = this->initialMass + (random()/RAND_MAX -.5)* this->randomInitialMass;
    195       particles->radius = this->startRadius + (random()/RAND_MAX-.5)*this->randomRadius;
     243      particles->radius = this->startRadius + (random()/RAND_MAX-.5)*this->randomStartRadius;
    196244     
    197       particles->radiusIt = (this->endRadius + (random()/RAND_MAX-.5)*this->randomRadius - particles->radius) / particles->timeToLive;
     245      particles->radiusIt = (this->endRadius + (random()/RAND_MAX-.5)*this->randomEndRadius - particles->radius) / particles->timeToLive;
    198246
    199247      ++this->count;
Note: See TracChangeset for help on using the changeset viewer.