• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

Pix3D

Started by Patrice Terrier, December 31, 2014, 06:06:49 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Patrice Terrier

This project computes a grayed intensity for each pixel color, and it turns them into 3D visualization.
This could be used to perform ground topography or any other mathematical computation, or just for fun.

The default representation is using raster point (gl_dPoint) , but it could also use line (gl_dLine) or any other 3D primitive.

To switch between point and line, you have to edit the code shown below:

       glPushMatrix()
          glRotatef(90, 1, 0, 0)  '// ROTATION
          glTranslatef(0, 0, -rH) '// TRANSLATION
          if (nAnimate) then rPenSize = 2 else rPenSize = 1
          glPointSize(rPenSize)
          nPixStep = 2
          for y = 0 to nH - 1 step nPixStep
              for x = 0 to nW -1 step nPixStep
                  zSplitColorARGB(PixColor(x, y), A, R, G, B)
                  if (A) then
                      rSize = rAlpha(x, y) * nMove

                      'gl_dLine(rX1 - rW + x, rY1, rX1 - rW + x, rY1 - rSize, PixColor(x, y), rPenSize)
                      gl_dPoint(rX1 - rW + x, rY1 - rSize, PixColor(x, y))
                  end if
              next
              glTranslatef(0, 0, nPixStep) '// TRANSLATION
          next
        glPopMatrix()



The scene has been setup to render the 3D image to match exactly the pixel resolution of the 2D image, when shown in front of the camera.

Screen shot:



...

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

Patrice Terrier

#1
The first post of this thread has been updated with 2 new versions.

Pix3D_32.zip written in PowerBASIC
Pix3D_64.zip written in C++ (VS2010)

The two SDK versions are almost identical, except that PB's dual array is using row/colum order, while C++ uses colum/row.

What is new in this release:
- Image drag and drop of any type and size from the Explorer.
- Deprecated "gluPerspective" removed and replaced with the new "gl_Perpective" API that is based on direct call to glFrustum.
- Couple of minor bugs have been fixed.

...

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