Results 1 to 5 of 5

Thread: Draw 2d shock-wave using OpenGL?

  1. #1

    Draw 2d shock-wave using OpenGL?

    Hi all,
    I am drawing some 2d explosions using OpenGL triangle strips.

    http://2.bp.blogspot.com/_vMC6A9wL7B...Screenshot.png

    I would like to make the explosions look more like this (with shock-wave ring, ignore rest of explosion):



    Here is the code I currently use:

    [pascal]Procedure TExplosion.Draw;
    Const
    cSegments = 20;

    Var
    p : Integer;
    t : Single;
    a : Single;
    r2 : Single;
    r1 : Single;
    ex : Single;
    ey : Single;
    Begin
    If Time < 0 Then Exit;
    t := Time / TTL;
    r2 := MinRadius + MaxRadius * (1 - t);
    r1 := r2 - 25;
    If r1 < 0 Then r1 := 0;

    glPushMatrix;
    glTranslatef(x,y,0);
    glBegin(GL_TRIANGLE_STRIP);
    For p := 0 To cSegments Do
    Begin
    a := p * 2 * PI / cSegments;
    ex := Cos(a);
    ey := Sin(a);
    // outer ring edge
    glColor4f(1,0.2,0,t);
    glVertex3f(r2 * ex,r2 * ey,0);
    // inner ring edge
    glColor4f(1,1,0,t / 2);
    glVertex3f(r1 * ex,r1 * ey,0);
    End;
    glEnd;
    glPopMatrix;
    End;
    [/pascal]

    Any ideas?

    I'm sure I could make a nice texture, but I am not sure what U,V coordinates I would use inside the code when doing the triangle strip...

    cheers,
    Paul

  2. #2

    Re: Draw 2d shock-wave using OpenGL?

    Well, i've done that using a single, alpha blended quad in my particle demo here:

    http://www.pascalgamedevelopment.com...p?topic=5781.0 (press the LMB)

    There i just use a quad with the texture coordinates {0,0} and {1,1} where i move the corner verticies outward over time, its a easy "hack" to achive the same effect.


    Amnoxx

    Oh, and this code appears to be an approximate replacement for return(random() & 0x01);

    Phoenix Wiki
    http://www.phoenixlib.net/

    Phoenix Forum
    http://www.pascalgamedevelopment.com/viewforum.php?f=71

  3. #3

    Re: Draw 2d shock-wave using OpenGL?

    Quote Originally Posted by Andreaz
    Well, i've done that using a single, alpha blended quad in my particle demo here:

    http://www.pascalgamedevelopment.com...p?topic=5781.0 (press the LMB)

    There i just use a quad with the texture coordinates {0,0} and {1,1} where i move the corner verticies outward over time, its a easy "hack" to achive the same effect.


    Thanks Andreaz, I will take a look
    Thanks all for your replies
    cheers,
    Paul

  4. #4

    Re: Draw 2d shock-wave using OpenGL?

    Andreaz,
    would it be ok if I maybe tried using the shockwave.bmp (slightly edited), and maybe 1 or more of the bullet 'sprites' (bullets.png) from your particles demo in my competition entry?

    I would understand if you said no

    cheers,
    Paul

  5. #5

    Re: Draw 2d shock-wave using OpenGL?

    Thank You!

    Your ring render is the missing link in my glvg unit on making radial fill possible with more then 2 colors.

    [EDIT]It is not entirely wat i want because with larger radiuses the lines become visible. e.g. if an inner ring has 40 segment and another ring has 80 holes will apear.
    Is is solveable with just using lots of segment always, but that probeably is not efficient.

    Is it possibel to make the inner part of the ring use less segement than the outer part?
    How would one triangulate such going from 2 points on the inside to many more on the outsie. Btw sorry for breaking on your thread.
    [/EDIT]
    http://3das.noeska.com - create adventure games without programming

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •