Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4190 in orxonox.OLD for orxonox


Ignore:
Timestamp:
May 15, 2005, 11:20:53 PM (20 years ago)
Author:
bensch
Message:

orxonox/branches/physics: particles get rendered with facing toward Camera (in PARTICLE_SPRITE-mode)

Location:
orxonox/branches/physics/src
Files:
3 edited

Legend:

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

    r4186 r4190  
    2424
    2525#include "field.h"
     26
     27// needed to find the Position of the Camera
     28#include "world.h"
     29#include "camera.h"
    2630
    2731using namespace std;
     
    273277    {
    274278    case PARTICLE_SPRITE:
     279      GLdouble projMat[16];
     280      GLfloat drawPartPos[4];
     281      glGetDoublev(GL_PROJECTION_MATRIX, projMat);
     282     
    275283      glMatrixMode(GL_MODELVIEW);
    276       //  glDisable(GL_LIGHTING);
    277       material->select();
    278284      glDisable(GL_DEPTH_TEST);
     285      glDisable(GL_LIGHTING);
     286           material->select();
     287     
     288
    279289      while (likely(drawPart != NULL))
    280290        {
    281           glPushMatrix();
    282           glTranslatef(drawPart->position.x, drawPart->position.y, drawPart->position.z);
    283           glScalef(drawPart->radius, drawPart->radius, drawPart->radius);
    284           glCallList(*this->glID);
    285          
    286           //glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z);
     291          //! \todo implement a faster code for the look-at Camera algorithm.
     292
     293          Camera* camera = WorldInterface::getInstance()->getCurrentWorld()->getLocalCamera();
     294          Vector cameraPos = camera->getAbsCoor();
     295          Vector cameraTargetPos = camera->getTarget()->getAbsCoor();
     296          Vector view = cameraTargetPos - cameraPos;
     297          Vector up = Vector(0, 1, 0);
     298          up = camera->getAbsDir().apply(up);
     299          Vector h = up.cross(view);
     300          Vector v = h.cross(view);
     301          h.normalize();
     302          v.normalize();
     303          v *= .5 * drawPart->radius;
     304          h *= .5 * drawPart->radius;
     305
     306          glBegin(GL_TRIANGLE_STRIP);
     307          glTexCoord2i(1, 1);
     308          glVertex3f(drawPart->position.x - h.x - v.x,
     309                     drawPart->position.y - h.y - v.y,
     310                     drawPart->position.z - h.z - v.z);
     311          glTexCoord2i(0, 1);
     312          glVertex3f(drawPart->position.x - h.x + v.x,
     313                     drawPart->position.y - h.y + v.y,
     314                     drawPart->position.z - h.z + v.z);
     315          glTexCoord2i(1, 0);
     316          glVertex3f(drawPart->position.x + h.x - v.x,
     317                     drawPart->position.y + h.y - v.y,
     318                     drawPart->position.z + h.z - v.z);
     319          glTexCoord2i(0, 0);
     320          glVertex3f(drawPart->position.x + h.x + v.x,
     321                     drawPart->position.y + h.y + v.y,
     322                     drawPart->position.z + h.z + v.z);
     323
     324          glEnd();
     325 
    287326          drawPart = drawPart->next;
    288           glPopMatrix();
    289         }
    290       //      glEnd();
    291      
    292       //  glEnable(GL_LIGHTING);
    293      
     327        }
     328      glEnable(GL_LIGHTING);
    294329      glEnable(GL_DEPTH_TEST);
     330
     331     
    295332      break;
    296333    default:
  • orxonox/branches/physics/src/story_entities/world.cc

    r4186 r4190  
    492492
    493493
    494   ParticleSystem* system = new ParticleSystem(10000, PARTICLE_SPARK);
    495   system->setLifeSpan(5);
     494  ParticleSystem* system = new ParticleSystem(100000, PARTICLE_SPRITE);
     495  system->setLifeSpan(3);
    496496  system->setConserve(.9);
    497497  system->setRadius(2, 0, 2, 0);
    498498
    499   ParticleEmitter* emitter = new ParticleEmitter(Vector(-1, 0, 0), M_PI_4, 1000, 0);
     499  ParticleEmitter* emitter = new ParticleEmitter(Vector(-1, 0, 0), M_PI_4, 400, .5);
    500500  emitter->setParent(this->localPlayer);
    501501 
    502502  Field* twirl = new Twirl();
    503   twirl->setMagnitude(-.1);
     503  twirl->setMagnitude(.1);
    504504  Field* gravity = new PointGravity();
    505   gravity->setMagnitude(0);
    506   new PhysicsConnection(system, twirl);
    507   //  new PhysicsConnection(system, gravity);
    508   twirl->setParent(this->localCamera->getTarget());
    509   gravity->setParent(this->localCamera->getTarget());
    510   particleEngine->addConnection(emitter, system);
     505  gravity->setMagnitude(.5);
     506    new PhysicsConnection(system, twirl);
     507    //    new PhysicsConnection(system, gravity);
     508    twirl->setParent(this->localCamera->getTarget());
     509    gravity->setParent(this->localCamera->getTarget());
     510    particleEngine->addConnection(emitter, system);
    511511}
    512512
  • orxonox/branches/physics/src/story_entities/world.h

    r4178 r4190  
    3636  static WorldInterface* getInstance();
    3737  void init(World* world);
     38  inline World* getCurrentWorld(void) {return this->worldReference;}
    3839  tList<WorldEntity>* getEntityList();
    3940
     
    9091  void setPath( const char* name);
    9192
     93  inline Camera* getLocalCamera(void) {return this->localCamera;}
     94
    9295 private:
    9396  void constuctorInit(char* name, int worldID);
Note: See TracChangeset for help on using the changeset viewer.