• Welcome to Dark Bit Factory & Gravity.
 

Metaballs :)

Started by Shockwave, May 30, 2006

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

relsoft

I was supposed to post a 3d metaball using the marching cubes algo but someone beat me to it.  I have another approach I haven't tried though.  I think this should be very fast as the calcs are done exclusively by the GPU. :*)

That is if I finish this terrain splatting demo for our kart game. :*)
Challenge Trophies Won:

Clyde

Love to see your spin on the Marching Cubes algo dude too matey.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.


Challenge Trophies Won:

relsoft

Nope I got it to work. :*)

All the raster work done by the GPU for this demo so keep the ballz coming!

BTW, do you see random "red" artifacts on the screen? Or is it just my card acting up again?


'2d metaballs in OpenGL(with 3d translation)
'relsoft 2006
'Richard Eric M. Lope BSN RN
'http://rel.betterwebber.com

Option Explicit
'$Static
'$INCLUDE: "\gl\gl.bi"
'$INCLUDE: "\gl\glu.bi"
'$INCLUDE: "\gl\glfw.bi"
'$INCLUDE: "\gl\glext.bi"



const SCR_WIDTH = 640                   'Width of the screen
const SCR_HEIGHT = 480                  'height of the screen
const BITSPP = 32                       '32 bits per pixel format

const PI = 3.141593
const TWOPI = (2 * PI)

const BLOB_WID = 256
const BLOB_HEI = 256

const MAX_BLOBS = 128



Type DisplayType
    W As Uinteger
    H As Uinteger
    R_BITS As Uinteger
    G_BITS As Uinteger
    B_BITS As Uinteger
    A_BITS As Uinteger
    D_BITS As Uinteger
    S_BITS As Uinteger
    MODE As Uinteger
    GlVer As Zstring Ptr
    As Single FOVy, Aspect, zNear, zFar
End Type


type vector3d
    as single   x
    as single   y
    as single   z
end type

type color_type
    as single   r
    as single   g
    as single   b
    as single   a
end type


Declare Sub Init_GL_Window( Display As DisplayType )
declare SUB Init_GL_SCREEN()
declare sub vector_normalize (v as vector3d)
declare sub glEnable2D()
declare sub glDisable2D()
declare function init_blob_texture(byval wid as integer, byval hei as integer) as GLuint
declare sub draw_blob(byval x as single, byval y as single, byval z as single,_
                      byval r as single, byval g as single, byval b as single,_
                      byval a as single)

Dim Display As DisplayType
Init_GL_Window Display
Init_GL_SCREEN()

dim as GLuint blob_id
blob_id =init_blob_texture(BLOB_WID, BLOB_HEI)
glEnable(GL_TEXTURE_2D)
dim time_start as single

dim blob_col(MAX_BLOBS) as color_type

dim as single demo_time
dim i as integer
dim as single bx, by, bz

for i=0 to MAX_BLOBS
  blob_col(i).r= 1 * (i and 15)
  blob_col(i).g= 1 * (i and 3)
  blob_col(i).b= 1 * (i and 7)
next i

glBindTexture(GL_TEXTURE_2D, blob_id)
glDisable (GL_DEPTH_TEST)
glEnable (GL_BLEND)
glBlendFunc (GL_ONE,GL_ONE)
Do
    demo_time = glfwGetTime() '* 0.01208   
    GlClear GL_COLOR_BUFFER_BIT OR GL_DEPTH_BUFFER_BIT
       
    GlMatrixMode GL_MODELVIEW
    GlLoadIdentity             
    gltranslatef (0.0, 0.0, -15.0)       
   
       
       
        for i = 0 to MAX_BLOBS
            bx = sin(demo_time / 74 * 0.8 * i) * 5 
            by = cos(demo_time / 43 * 0.9 * i) * 3
            bz = sin(demo_time / 53 * 0.9 * i) * 8
            draw_blob(bx, by, bz, blob_col(i).r, blob_col(i).g, blob_col(i).b, 1.0)           
        next i
   
    do
    loop until glfwGetTime() - time_start >= (1/60)
    time_start =  glfwGetTime()
   
    GlfwSwapBuffers
   
   
   
Loop Until glfwGetKey( GLFW_KEY_ESC )

GlDeleteTextures 1, @blob_id

GlfwTerminate()

end

sub draw_blob(byval x as single, byval y as single, byval z as single,_
              byval r as single, byval g as single, byval b as single,_
              byval a as single)
   
    glPushMatrix         
    gltranslatef (x, y, z)
    glColor4f (r, g, b, a)
    glBegin GL_QUADS
glTexCoord2f (0.0, 0.0)
glVertex3f   (-1.0, -1.0,  0.0)
glTexCoord2f (1.0, 0.0)
glVertex3f   (1.0, -1.0,  0.0)
glTexCoord2f (1.0, 1.0)
glVertex3f   (1.0,  1.0,  0.0)
glTexCoord2f (0.0, 1.0)
glVertex3f   (-1.0,  1.0,  0.0)
glEnd
    glPopMatrix
end sub

sub glEnable2D()
   dim vPort(3) as integer

   glGetIntegerv(GL_VIEWPORT, @vPort(0))

   glMatrixMode(GL_PROJECTION)
   glPushMatrix()
   glLoadIdentity()

   glOrtho(0, vPort(2), 0, vPort(3), -1, 1)
   glMatrixMode(GL_MODELVIEW)
   glPushMatrix()
   glLoadIdentity()
end sub

sub glDisable2D()

   glMatrixMode(GL_PROJECTION)
   glPopMatrix()
   glMatrixMode(GL_MODELVIEW)
   glPopMatrix()
   
end sub

function init_blob_texture(byval wid as integer, byval hei as integer) as GLuint
   
    dim as GLuint txtnumber
    dim as unsigned integer ptr texture_data
   

    dim as integer bcol, x, y
    dim as single dist, strength
    dim as integer wid_d2, hei_d2
   
   
    texture_data = callocate((wid * hei)* 1 ,Len(unsigned Integer))
   
    wid_d2 = wid\2
    hei_d2 = hei\2
   
    strength =  wid * 2
   
    for y = 0 to hei - 1
            for x = 0 to wid - 1
                dist = sqr((wid_d2-x) ^ 2 + (hei_d2-y) ^ 2)
                if (wid_d2-x) = 0 and (hei_d2-y) = 0 then
                    bcol = 255
                else
                    bcol = (Strength / (dist^1.4)) * 255                   
                    bcol = bcol - 255
                end if
                if bcol < 0 then bcol = 0
                if bcol > 255 then bcol = 255               
                texture_data[x + y*wid] = bcol shl 16 or bcol shl 8 or bcol
            next x
    next y


glGenTextures(1, @txtnumber)
    glEnable(GL_TEXTURE_2D)
glBindTexture(GL_TEXTURE_2D, txtnumber)
glTexImage2D(GL_TEXTURE_2D, 0, 4, wid, hei, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture_data)   
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR)
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR)


    glDisable(GL_TEXTURE_2D)
   
   
 
    deallocate (texture_data)   
    texture_data = 0
 

return txtnumber
end function


Sub Init_GL_Window( Display As DisplayType )
    Display.W     = SCR_WIDTH
    Display.H     = SCR_HEIGHT
    Display.R_BITS= 8
    Display.G_BITS= 8
    Display.B_BITS= 8
    Display.A_BITS= 8
    Display.D_BITS= BITSPP
    Display.S_BITS= 8
    Display.MODE  = GLFW_WINDOW
    Display.MODE  = GLFW_FULLSCREEN
   
    If glfwInit() Then
        'Successful!
    Else   
        Print "Failed to initialize GLFW!"
        Sleep 1000
        End
    End If
   
   
    If  glfwOpenWindow( _
    Display.W     , _
    Display.H     , _
    Display.R_BITS, _
    Display.G_BITS, _
    Display.B_BITS, _
    Display.A_BITS, _
    Display.D_BITS, _
    Display.S_BITS, _
    Display.MODE  ) _
    Then
    GlfwSwapInterval 1
    Display.GlVer = glGetString(GL_VERSION)
Else
    GlfwTerminate()
    End
End If

End Sub


SUB Init_GL_SCREEN()

   'screen information
   dim w as integer, h as integer
    'OpenGL params for gluerspective
   dim FOVy as double            'Field of view angle in Y
   dim Aspect as double          'Aspect of screen
   dim znear as double           'z-near clip distance
   dim zfar as double            'z-far clip distance

    'using screen info w and h as params
   glViewport 0, 0, SCR_WIDTH,SCR_HEIGHT

   'Set current Mode to projection(ie: 3d)
   glMatrixMode GL_PROJECTION

    'Load identity matrix to projection matrix
   glLoadIdentity

    'Set gluPerspective params
    FOVy = 80/2                                     '45 deg fovy
    Aspect = SCR_WIDTH / SCR_HEIGHT                                  'aspect = x/y
    znear = 1                                       'Near clip
    zfar = 200                                      'far clip

    'use glu Perspective to set our 3d frustum dimension up
   gluPerspective FOVy, aspect, znear, zfar

    'Modelview mode
    'ie. Matrix that does things to anything we draw
    'as in lines, points, tris, etc.
   glMatrixMode GL_MODELVIEW
   'load identity(clean) matrix to modelview
   glLoadIdentity

   glShadeModel GL_SMOOTH                 'set shading to smooth(try GL_FLAT)
   glClearColor 0.0, 0.0, 0.0, 1.0        'set Clear color to BLACK
   glClearDepth 1.0                       'Set Depth buffer to 1(z-Buffer)
   glEnable GL_DEPTH_TEST                 'Enable Depth Testing so that our z-buffer works

   'compare each incoming pixel z value with the z value present in the depth buffer
   'LEQUAL means than pixel is drawn if the incoming z value is less than
    'or equal to the stored z value
   glDepthFunc GL_LEQUAL

    'have one or more material parameters track the current color
    'Material is your 3d model
   glEnable GL_COLOR_MATERIAL


    'Enable Texturing
    'glEnable GL_TEXTURE_2D
   

    'Set blending parameters
    glBlendFunc GL_SRC_ALPHA, GL_ONE


   'Tell openGL that we want the best possible perspective transform
   glHint GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST
   
   'Enable Backface culling
   'GlEnable GL_CULL_FACE
   glPolygonMode(GL_FRONT, GL_FILL)
   
   
        'lighting
  dim as glFloat mat_ambient(0 to 3) =  { 0.5, 0.5, 1.0, 0.15 }
  dim as glFloat mat_specular(0 to 3) = {  1.0, 1.0, 1.0, 0.15 } 
  dim as glFloat mat_shininess = 10.0
  dim as glFloat light_position(0 to 3)= { -7.0, 8.0, -6.0, 1.0  }
  dim as glFloat light_ambient(0 to 3)= { 0.5, 0.5, 0.5, 1.0 }
  dim as glFloat mat_twister(0 to 3) = { 0.75, 0.75, 0.0, 1.0 }
  dim as GLfloat fBrightLight(0 to 3) = { 1.0, 1.0, 1.0, 1.0 }
  glMaterialfv(GL_FRONT, GL_AMBIENT, @mat_ambient(0))
  glMaterialfv(GL_FRONT, GL_SPECULAR, @mat_specular(0))
  glMaterialfv(GL_FRONT, GL_SHININESS, @mat_shininess)
  glMaterialfv(GL_FRONT, GL_DIFFUSE,@mat_twister(0))
  glMaterialfv(GL_FRONT, GL_SPECULAR, @fBrightLight(0))


  glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR)
  glLightfv(GL_LIGHT0,GL_AMBIENT, @light_ambient(0))
  glLightfv(GL_LIGHT0,GL_DIFFUSE, @light_ambient(0))
  glLightfv(GL_LIGHT0, GL_POSITION, @light_position(0))
  'glEnable(GL_LIGHTING)
  'glEnable(GL_LIGHT0)
 
END SUB

sub vector_normalize (v as vector3d)
    'makes v a unit vector
    dim mag as single
    mag = 1/sqr(v.x * v.x + v.y * v.y + v.z * v.z)
    if mag <> 0 then
        v.x = v.x * mag
        v.y = v.y * mag
        v.z = v.z * mag
    else
        v.x = 0
        v.y = 0
        v.z = 1
    end if

end sub

:||
Challenge Trophies Won:

Shockwave

That's so smooth! It sort of reminded me of unlimited bobs effect on the Amiga at first, that was until the screen started filling up.

That looks really smart Rel (as usual!)  O0
Shockwave ^ Codigos
Challenge Trophies Won:

zparticle

Can we get a linky to and exe?

Shockwave

#45
Here you are Zparticle, this is Relsofts Opengl linecube in exe format.

[edit, oops. metaballs now added too! Download the second attachment for both files]
Shockwave ^ Codigos
Challenge Trophies Won:

relsoft

Thanks@Shock.

Ditched the stupid z displacement for a much better lissa movement.  Now with more colors

RGBlobs


'2d metaballs in OpenGL(with 3d translation)
'relsoft 2006
'Richard Eric M. Lope BSN RN
'http://rel.betterwebber.com

Option Explicit
'$Static
'$INCLUDE: "\gl\gl.bi"
'$INCLUDE: "\gl\glu.bi"
'$INCLUDE: "\gl\glfw.bi"
'$INCLUDE: "\gl\glext.bi"



const SCR_WIDTH = 640                   'Width of the screen
const SCR_HEIGHT = 480                  'height of the screen
const BITSPP = 32                       '32 bits per pixel format

const PI = 3.141593
const TWOPI = (2 * PI)

const BLOB_WID = 256
const BLOB_HEI = 256

const MAX_BLOBS = 128



Type DisplayType
    W As Uinteger
    H As Uinteger
    R_BITS As Uinteger
    G_BITS As Uinteger
    B_BITS As Uinteger
    A_BITS As Uinteger
    D_BITS As Uinteger
    S_BITS As Uinteger
    MODE As Uinteger
    GlVer As Zstring Ptr
    As Single FOVy, Aspect, zNear, zFar
End Type


type vector3d
    as single   x
    as single   y
    as single   z
end type

type color_type
    as single   r
    as single   g
    as single   b
    as single   a
end type


Declare Sub Init_GL_Window( Display As DisplayType )
declare SUB Init_GL_SCREEN()
declare sub vector_normalize (v as vector3d)
declare sub glEnable2D()
declare sub glDisable2D()
declare function init_blob_texture(byval wid as integer, byval hei as integer) as GLuint
declare sub draw_blob(byval x as single, byval y as single, byval z as single,_
                      byval r as single, byval g as single, byval b as single,_
                      byval a as single)

Dim Display As DisplayType
Init_GL_Window Display
Init_GL_SCREEN()

dim as GLuint blob_id
blob_id =init_blob_texture(BLOB_WID, BLOB_HEI)
glEnable(GL_TEXTURE_2D)
dim time_start as single

dim blob_col(MAX_BLOBS) as color_type

dim as single demo_time
dim i as integer
dim as single bx, by, bz

for i=0 to MAX_BLOBS
  blob_col(i).r= rnd '1 * (i and 5)
  blob_col(i).g= rnd '1 * (i and 2)
  blob_col(i).b= rnd '1 * (i and 6)
next i

glBindTexture(GL_TEXTURE_2D, blob_id)
glDisable (GL_DEPTH_TEST)
glEnable (GL_BLEND)
glBlendFunc (GL_ONE,GL_ONE)
Do
    demo_time = glfwGetTime() '* 0.01208   
    GlClear GL_COLOR_BUFFER_BIT OR GL_DEPTH_BUFFER_BIT
       
    GlMatrixMode GL_MODELVIEW
    GlLoadIdentity             
    gltranslatef (0.0, 0.0, -15.0)       
   
       
       
        for i = 0 to MAX_BLOBS
            bx = sin(demo_time / 74 * 0.8 * i) * 6 
            by = cos(demo_time / 43 * 0.9 * i) * 4             
            draw_blob(bx, by, 0, blob_col(i).r, blob_col(i).g, blob_col(i).b, 1.0)           
        next i
   
    do
    loop until glfwGetTime() - time_start >= (1/60)
    time_start =  glfwGetTime()
   
    GlfwSwapBuffers
   
   
   
Loop Until glfwGetKey( GLFW_KEY_ESC )

GlDeleteTextures 1, @blob_id

GlfwTerminate()

end

sub draw_blob(byval x as single, byval y as single, byval z as single,_
              byval r as single, byval g as single, byval b as single,_
              byval a as single)
   
    glPushMatrix         
    gltranslatef (x, y, z)
    glColor4f (r, g, b, a)
    glBegin GL_QUADS
glTexCoord2f (0.0, 0.0)
glVertex3f   (-1.0, -1.0,  0.0)
glTexCoord2f (1.0, 0.0)
glVertex3f   (1.0, -1.0,  0.0)
glTexCoord2f (1.0, 1.0)
glVertex3f   (1.0,  1.0,  0.0)
glTexCoord2f (0.0, 1.0)
glVertex3f   (-1.0,  1.0,  0.0)
glEnd
    glPopMatrix
end sub

sub glEnable2D()
   dim vPort(3) as integer

   glGetIntegerv(GL_VIEWPORT, @vPort(0))

   glMatrixMode(GL_PROJECTION)
   glPushMatrix()
   glLoadIdentity()

   glOrtho(0, vPort(2), 0, vPort(3), -1, 1)
   glMatrixMode(GL_MODELVIEW)
   glPushMatrix()
   glLoadIdentity()
end sub

sub glDisable2D()

   glMatrixMode(GL_PROJECTION)
   glPopMatrix()
   glMatrixMode(GL_MODELVIEW)
   glPopMatrix()
   
end sub

function init_blob_texture(byval wid as integer, byval hei as integer) as GLuint
   
    dim as GLuint txtnumber
    dim as unsigned integer ptr texture_data
   

    dim as integer bcol, x, y
    dim as single dist, strength
    dim as integer wid_d2, hei_d2
   
   
    texture_data = callocate((wid * hei)* 1 ,Len(unsigned Integer))
   
    wid_d2 = wid\2
    hei_d2 = hei\2
   
    strength =  wid \ 2
   
    for y = 0 to hei - 1
            for x = 0 to wid - 1
                dist = sqr((wid_d2-x) ^ 2 + (hei_d2-y) ^ 2)
                if (wid_d2-x) = 0 and (hei_d2-y) = 0 then
                    bcol = 255
                else
                    bcol = (Strength / (dist)) * 255                   
                    bcol = bcol - 255
                end if
                if bcol < 0 then bcol = 0
                if bcol > 255 then bcol = 255               
                texture_data[x + y*wid] = bcol shl 16 or bcol shl 8 or bcol
            next x
    next y


glGenTextures(1, @txtnumber)
    glEnable(GL_TEXTURE_2D)
glBindTexture(GL_TEXTURE_2D, txtnumber)
glTexImage2D(GL_TEXTURE_2D, 0, 4, wid, hei, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture_data)   
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR)
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR)


    glDisable(GL_TEXTURE_2D)
   
   
 
    deallocate (texture_data)   
    texture_data = 0
 

return txtnumber
end function


Sub Init_GL_Window( Display As DisplayType )
    Display.W     = SCR_WIDTH
    Display.H     = SCR_HEIGHT
    Display.R_BITS= 8
    Display.G_BITS= 8
    Display.B_BITS= 8
    Display.A_BITS= 8
    Display.D_BITS= BITSPP
    Display.S_BITS= 8
    Display.MODE  = GLFW_WINDOW
    Display.MODE  = GLFW_FULLSCREEN
   
    If glfwInit() Then
        'Successful!
    Else   
        Print "Failed to initialize GLFW!"
        Sleep 1000
        End
    End If
   
   
    If  glfwOpenWindow( _
    Display.W     , _
    Display.H     , _
    Display.R_BITS, _
    Display.G_BITS, _
    Display.B_BITS, _
    Display.A_BITS, _
    Display.D_BITS, _
    Display.S_BITS, _
    Display.MODE  ) _
    Then
    GlfwSwapInterval 1
    Display.GlVer = glGetString(GL_VERSION)
Else
    GlfwTerminate()
    End
End If

End Sub


SUB Init_GL_SCREEN()

   'screen information
   dim w as integer, h as integer
    'OpenGL params for gluerspective
   dim FOVy as double            'Field of view angle in Y
   dim Aspect as double          'Aspect of screen
   dim znear as double           'z-near clip distance
   dim zfar as double            'z-far clip distance

    'using screen info w and h as params
   glViewport 0, 0, SCR_WIDTH,SCR_HEIGHT

   'Set current Mode to projection(ie: 3d)
   glMatrixMode GL_PROJECTION

    'Load identity matrix to projection matrix
   glLoadIdentity

    'Set gluPerspective params
    FOVy = 80/2                                     '45 deg fovy
    Aspect = SCR_WIDTH / SCR_HEIGHT                                  'aspect = x/y
    znear = 1                                       'Near clip
    zfar = 200                                      'far clip

    'use glu Perspective to set our 3d frustum dimension up
   gluPerspective FOVy, aspect, znear, zfar

    'Modelview mode
    'ie. Matrix that does things to anything we draw
    'as in lines, points, tris, etc.
   glMatrixMode GL_MODELVIEW
   'load identity(clean) matrix to modelview
   glLoadIdentity

   glShadeModel GL_SMOOTH                 'set shading to smooth(try GL_FLAT)
   glClearColor 0.0, 0.0, 0.0, 1.0        'set Clear color to BLACK
   glClearDepth 1.0                       'Set Depth buffer to 1(z-Buffer)
   glEnable GL_DEPTH_TEST                 'Enable Depth Testing so that our z-buffer works

   'compare each incoming pixel z value with the z value present in the depth buffer
   'LEQUAL means than pixel is drawn if the incoming z value is less than
    'or equal to the stored z value
   glDepthFunc GL_LEQUAL

    'have one or more material parameters track the current color
    'Material is your 3d model
   glEnable GL_COLOR_MATERIAL


    'Enable Texturing
    'glEnable GL_TEXTURE_2D
   

    'Set blending parameters
    glBlendFunc GL_SRC_ALPHA, GL_ONE


   'Tell openGL that we want the best possible perspective transform
   glHint GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST
   
   'Enable Backface culling
   'GlEnable GL_CULL_FACE
   glPolygonMode(GL_FRONT, GL_FILL)
   
   
        'lighting
  dim as glFloat mat_ambient(0 to 3) =  { 0.5, 0.5, 1.0, 0.15 }
  dim as glFloat mat_specular(0 to 3) = {  1.0, 1.0, 1.0, 0.15 } 
  dim as glFloat mat_shininess = 10.0
  dim as glFloat light_position(0 to 3)= { -7.0, 8.0, -6.0, 1.0  }
  dim as glFloat light_ambient(0 to 3)= { 0.5, 0.5, 0.5, 1.0 }
  dim as glFloat mat_twister(0 to 3) = { 0.75, 0.75, 0.0, 1.0 }
  dim as GLfloat fBrightLight(0 to 3) = { 1.0, 1.0, 1.0, 1.0 }
  glMaterialfv(GL_FRONT, GL_AMBIENT, @mat_ambient(0))
  glMaterialfv(GL_FRONT, GL_SPECULAR, @mat_specular(0))
  glMaterialfv(GL_FRONT, GL_SHININESS, @mat_shininess)
  glMaterialfv(GL_FRONT, GL_DIFFUSE,@mat_twister(0))
  glMaterialfv(GL_FRONT, GL_SPECULAR, @fBrightLight(0))


  glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR)
  glLightfv(GL_LIGHT0,GL_AMBIENT, @light_ambient(0))
  glLightfv(GL_LIGHT0,GL_DIFFUSE, @light_ambient(0))
  glLightfv(GL_LIGHT0, GL_POSITION, @light_position(0))
  'glEnable(GL_LIGHTING)
  'glEnable(GL_LIGHT0)
 
END SUB

sub vector_normalize (v as vector3d)
    'makes v a unit vector
    dim mag as single
    mag = 1/sqr(v.x * v.x + v.y * v.y + v.z * v.z)
    if mag <> 0 then
        v.x = v.x * mag
        v.y = v.y * mag
        v.z = v.z * mag
    else
        v.x = 0
        v.y = 0
        v.z = 1
    end if

end sub
Challenge Trophies Won:

Optimus

#47
Heh,. I was coding these stuff years ago in my quickbasic demo deedlines sax. I didn't have any better inspiration than these moving and zooming 2d star blobs ;P

C code, not particualry optimized, reused stuff, source included with some functions not used in this demo forgotten there (This code was from another project ;).

p.s. I haven't checked the other entries but I'll do soon..
Challenge Trophies Won:

Shockwave

Rel, those metaballs are beautiful! It's the movement pattern that you've used that makes it so pretty I think.

Optimus, actually I was watching Deedsax and I liked the metaballs with the plasma inside so much that I had another idea for them which is similar, Hopefully it'll be hitting your screen soon :) Probably I'll release it over at Pouet too. Great starfield blobs by the way.
I wonder how they'd look in a 3D mental hangover style starfield.
Shockwave ^ Codigos
Challenge Trophies Won:

zparticle

@shockwave: Thanks for the exes. :)

Optimus

Yey,. my initial idea was to do a 3d starfield with the blobs instead of 2d stars, but it was morning and I had to study later so I left the idea for another time ;)

I am curious to see your blob idea. Another idea I had with the effect inside blobs, was blobs inside blobs inside blobs, zooming into blobs were new blobs appearing and all repeating patterns endlessly like in fractals. I think someone did a similar effect looking like this in a C64 demo (a Smash Design demo I can't remember), but I think it wasn't exactly that but some color cycling or something else maybe on the blobs to make that illusion..
Challenge Trophies Won:

Shockwave

I've attached a shot of the effect I'm working on. It's all done now, save for the music.
I wanted to see what the blobs would look like if they were alpha blended over a texture with a transparrent window in the centre, the window in the middle bit came from watching your stuff Optimus.. I just loved the idea of containing an effect inside metaballs.

Anyway, the intro will be out soon :)

Infinately zooming blobs sound much cooler than what I've done!
Shockwave ^ Codigos
Challenge Trophies Won:

TinDragon

Pretty nice looking shot there Shockwave and I like the look of that fps  :)
I have seen a similiar kinf of idea done in 3d were another scene formed the texture over the metaballs, cant remember the demo name as I am crap at that sort of thing  ;D

relsoft

Nice Screenie Shock!!!  You Optimus, I have also a zooming plasma somewhere here n my HD. It zooms by actually zooming the lightmap depending on the scale factor.  Not as good looking as your's though when I scale it really big. :*(

Anhyways here are two old metaballs I made in QB. Exe in the attatchent and source here. :*)  The sonic blob should run on a 233 mhz machine at full speed.

http://rel.betterwebber.com/junk.php?id=17



Challenge Trophies Won:

Optimus

Wow! Quite impressive screenshot. Yey, a 3d scene inside blobs is a must! I can't wait to see that demo of yours!

Rel: Zooming plasmas sounds interesting. I once tried to do one with no success (but it was several years ago), now I know I can try another one also some other ideas I have, I just have more experience to make it work. There was the last effect in "Into The Fight demo" with transparent plasmas (I called them line plasmas), now I am thinking if you were zooming into similar patterns of these plasma with changing colors and new ones arrised, entlessly. Like the zooming squares effect on C64 with several layers, a trip through new squares, that would rock with transparent plasmas, gotta try this!
Challenge Trophies Won:

relsoft

zooming blobs. Not zoomung plasma. Dunno why I wrote plama there. But a zooming plasma wouldn't be hard to make since I laready made a mode7 plasma. :*)
Challenge Trophies Won:

Shockwave

The blobs intro will be out tonight if all goes well, I've had the music from Roly :)
Rel, I loved the QB metaballs, the plasma in the background has a really cool swirly pattern, both run as fast as fuck  O0
Shockwave ^ Codigos
Challenge Trophies Won:

relsoft

I fuck slooooow.  :|| LOL
Challenge Trophies Won:

Shockwave

Intro finished and spread all over the place :)
Shockwave ^ Codigos
Challenge Trophies Won:

Optimus

I would repeat myself here cause I wrote my comments already on Pouet, but I'd say quite impressive mate! Great to see it's in freebasic and it's quite smooth for such a software rendered screen!!!
Challenge Trophies Won: