Search code examples
openglgraphics3dbulletphysics

Drawing a physics body's path?


I've been working on a first-person shooter game with Bullet and OpenGL, and now have it to the point of being able to fire bullets through the scene. I'm now looking to draw the path these bullets take, from starting position to their ending position, with the entire path staying drawn until the next bullet is fired (so that the screen isn't cluttered).

I'm basically just looking for something like a red line that extends to the bullet's new position each frame, or something like that. So, by the time the bullet has gone from the gun to its final stopping place, the red line will show the exact path it took, what it bounced off of, etc.

I've tried looking for examples but I can't find anything useful. I've seen mention of leaving a trail behind an object using an accumulation buffer, but that's not really what I want.

How can this be done? Does everyone know of any examples or tutorials for this?


Solution

  • just make vbo of points and then

    ...
    
    glVertexAttribPointer(.., 1, GL_FLOAT, GL_FALSE, 0, (void*)0);
    
    glDrawArrays(GL_POINTS,0,.. );
    

    Use math you have to assign each. But it's not so easy. I think it can be done with deploy of second pair of shaders /vao. OpenGL multiple draw calls with unique shaders gives blank screen