• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

OpenGL "Asleep"

Started by Patrice Terrier, December 10, 2010, 06:21:07 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Patrice Terrier

Asleep

The native OpenGL source code of this project, shows you what to do, to create a demoscene mixing 3D and audio altogether.


  • Culling technic based on z-order sorting.
  • Bilboarding.
  • Particle effect.
  • Pulsating effect.
  • Smooth shading.
  • Mousing support.
  • Bass.dll audio integration.


Note: Turn your loudspeakers on, before to run "Asleep".


Screen shot:




Culling technic based on z-order sorting:

SUB Quad_Draw(BYVAL Pulse AS LONG)

    LOCAL K AS LONG, x, y, z, sSize, sPulseSize AS SINGLE


'   // The culling section.
    DIM A1(g_nAttracters - 1) AS SINGLE, A2(g_nAttracters - 1) AS LONG
    FOR K = 0 TO g_nAttracters - 1
        A1(K) = alist(K).X * billboardMat(2) + alist(K).Y * billboardMat(6) + alist(K).Z * billboardMat(10)
        A2(K) = K
    NEXT
'   // Sort bazed on the Z-order location.
    ARRAY SORT A1(), TAGARRAY A2()


    FOR K = 0 TO g_nAttracters - 1

        glPushMatrix()
           x = alist(A2(K)).X * billboardMat(0) + alist(A2(K)).Y * billboardMat(4) + alist(A2(K)).Z * billboardMat( 8 )
           y = alist(A2(K)).X * billboardMat(1) + alist(A2(K)).Y * billboardMat(5) + alist(A2(K)).Z * billboardMat( 9 )
           z = A1(K)
           glTranslatef(x, y, z)

           CALL glColor4f(0.95, 0.95, 0.95, 0.5)
           sSize = 200

           IF K = g_nAttracters -1 THEN
              IF (A2(K)+1) <> 6 THEN
                 sPulseSize = sSize + (Pulse * 5)
              ELSE
                 sPulseSize = sSize
              END IF
              DrawQuad(sPulseSize, sPulseSize, 0, mt(A2(K)+1).Texture)
              DrawQuad(sSize, sSize, 0, mt(7).Texture)
           ELSE
              IF (A2(K)+1) <> 6 THEN
                 sPulseSize = sSize + (Pulse * 5)
              ELSE
                 sPulseSize = sSize
              END IF
              DrawQuad(sPulseSize, sPulseSize, 0, mt(A2(K)+1).Texture)

           END IF
        glPopMatrix()
    NEXT

END SUB


...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Patrice Terrier

The first post of this thread has been updated, to fix the ZIP file corruption caused by the "Server Collapse".

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com