Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4190 in orxonox.OLD for orxonox/branches/physics/src/lib/graphics


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)

File:
1 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:
Note: See TracChangeset for help on using the changeset viewer.