Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/particles/dot_particles.cc @ 7832

Last change on this file since 7832 was 7198, checked in by bensch, 19 years ago

orxonox/trunk: new Default Values… they now too are in MultiType instead of (count, …) or (count, va_arg) style

File size: 2.7 KB
RevLine 
[4597]1/*
[1853]2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
[1855]10
11   ### File Specific:
[3925]12   main-programmer: Benjamin Grauer
[1855]13   co-programmer: ...
[1853]14*/
15
[5357]16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GRAPHICS
[1853]17
[6652]18#include "dot_particles.h"
[1853]19
[7193]20#include "util/loading/load_param.h"
21#include "util/loading/factory.h"
[3942]22#include "material.h"
[4338]23#include "state.h"
[5446]24#include "shell_command.h"
[3930]25
[5944]26#include "parser/tinyxml/tinyxml.h"
[6612]27#include <algorithm>
[4338]28
[6612]29
[6653]30CREATE_FACTORY(DotParticles, CL_DOT_PARTICLES);
[6621]31
[6652]32SHELL_COMMAND(texture, DotParticles, setMaterialTexture)
[7198]33    ->defaultValues("maps/evil-flower.png");
[4725]34
[1856]35using namespace std;
[1853]36
[3245]37/**
[4836]38 *  standard constructor
39 * @param maxCount the Count of particles in the System
[6652]40 * @param type The Type of the DotParticles
[3245]41*/
[6652]42DotParticles::DotParticles (unsigned int maxCount)
[6621]43  : ParticleSystem(maxCount)
[3365]44{
[4602]45  this->init();
[3365]46}
[1853]47
[4677]48/**
[5445]49 * @brief creates a Particle System out of a XML-element
50 * @param root: the XML-element to load from
[4677]51 */
[6652]52DotParticles::DotParticles(const TiXmlElement* root)
[4602]53{
54  this->init();
[6623]55  if (root != NULL)
56    this->loadParams(root);
[4602]57}
[1853]58
[3245]59/**
[4836]60 *  standard deconstructor
[3245]61*/
[6652]62DotParticles::~DotParticles()
[6653]63{ }
[4123]64
[3945]65/**
[6652]66 * @brief initializes the DotParticles with default values
[4602]67*/
[6652]68void DotParticles::init()
[4602]69{
[6653]70  this->setClassID(CL_DOT_PARTICLES, "DotParticles");
[4602]71
[6626]72  this->material.setDiffuseMap("maps/radial-trans-noise.png");
[4602]73}
74
75
76/**
77 * loads Parameters from a TiXmlElement
78 * @param root the XML-element to load from.
79 */
[6652]80void DotParticles::loadParams(const TiXmlElement* root)
[4602]81{
[6623]82  ParticleSystem::loadParams(root);
[4602]83
[6652]84  LoadParam(root, "texture", this, DotParticles, setMaterialTexture);
[4602]85}
[4727]86
[4478]87/**
[6621]88 * @brief draws all the Particles of this System
89 *
90 * The Cases in this Function all do the same:
91 * Drawing all the particles with the appropriate Type.
92 * This is just the fastest Way to do this, but will most likely be changed in the future.
[4338]93 */
[6652]94void DotParticles::draw() const
[4338]95{
[4176]96  glPushAttrib(GL_ENABLE_BIT);
[4338]97
[6628]98  GLboolean checkLight = false;
99  glGetBooleanv(GL_LIGHTING, &checkLight);
[6653]100  if (checkLight == GL_TRUE)
101    glDisable(GL_LIGHTING);
102
[6621]103  glMatrixMode(GL_MODELVIEW);
104  glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
[4863]105
[6652]106  Particle* drawPart = particles;
[6621]107  //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_MODULATE);
[4338]108
[6652]109  glBegin(GL_POINTS);
[6621]110  while (likely(drawPart != NULL))
111  {
112    glColor4fv(drawPart->color);
[6652]113    glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z);
[4338]114
[6621]115    drawPart = drawPart->next;
[4663]116  }
[6652]117  glEnd();
[4176]118  glPopAttrib();
[3932]119}
Note: See TracBrowser for help on using the repository browser.