Author Topic: Animated 3D cube (fake Plasma)  (Read 1604 times)

Offline Paul Smith

  • Mr. Polyvector
  • ***
  • Posts: 105
    • View Profile
Animated 3D cube (fake Plasma)
« on: 2014-Oct-15 »
Fake Plasma Rotating Cube ( Grabsprite abuse )

show.exe in zip shows sides being rendered on the fly
plasmacube.exe normal

not optimized, probably better ways to do this but an easy example.

wobble screen maths may be useful for other project and is quite simple, took me a bit to get it right.
dicecube.ddd made in ac3d.



Code: GLBasic [Select]
SETCURRENTDIR("Media") // go to media files
GLOBAL xxx,a
LOADFONT "smalfont.png", 1
SETFONT 1,1.5
LIMITFPS 40


//LOAD IMAGES
X_LOADOBJ "dicecube.ddd", 0
LOADSPRITE "blue.jpg",9999
LOADSPRITE "orange.jpg", 6000
LOADSPRITE "test.jpg",5000

//------------------------------------------------------------------
// GRAB LOT OF SPRITE LINES
STRETCHSPRITE 6000,0,0,1024,768
FOR t = 1 TO 768
GRABSPRITE t+6001,1,t,1024,1
NEXT

STRETCHSPRITE 5000,0,0,1024,768
FOR t = 1 TO 768
GRABSPRITE t+5001,1,t,1024,1
NEXT

STRETCHSPRITE 9999,0,0,1024,768
FOR t = 1 TO 768
GRABSPRITE t+30,1,t,1024,1
NEXT

//----------------------------------------------------------------------
// SHOW ROTATE TEXTURE CUBE

WHILE TRUE
xxx = xxx + 3
GOSUB side3
//CLEARSCREEN   TURN THIS ON FOR NO BACKGROUND ( SHOW SECRET )
PRINT "X:" + xxx, 100, 10
X_MAKE3D 1, 50, 45
X_CAMERA 4, 0, 0, 0, 0, 0
X_SETTEXTURE 0, -1
X_ROTATION xxx, xxx/ 2, xxx / 2, 0
X_DRAWOBJ 0,0
IF xxx > 360 THEN xxx = 0
SHOWSCREEN
WEND


//-----------------------------------------------------------------------

SUB side3:



            FOR y=1 TO 768
                a=a + 0.005 * 2   // * SPEED
            DRAWSPRITE y, COS( a + y ) * y /4, y      // WOBBLE THE LINES
            NEXT

                GRABSPRITE 9998,200,150,500,500                   // GRAB THE WOBBLED SCREEN
            DRAWSPRITE 0,0,0                                              // DRAW THE TEXTURE
         STRETCHSPRITE 9998,340,170,170,170                       // DRAW 1 SIDE
         STRETCHSPRITE 9998,0,170,170,170                         // DRAW 1 SIDE SAME IMAGE
         GRABSPRITE 0,0,0,512,512                                         // GRAB NEW TEXTURE
  //-----------------------------------------------------------------------

         FOR y=1 TO 768
         a=a + 0.005 * 2
         DRAWSPRITE y+6001, COS( a + y ) * y/4, y
         NEXT
         GRABSPRITE 9997,200,150,500,500
         DRAWSPRITE 0,0,0
         STRETCHSPRITE 9997,170,0,170,170
         STRETCHSPRITE 9997,170,340,170,170
         GRABSPRITE 0,0,0,512,512

 //------------------------------------------------------------------------
            FOR y=1 TO 768
            a=a + 0.005 * 2
            DRAWSPRITE y+5001, COS( a+ y ) *y/4, y
                NEXT
                GRABSPRITE 9998,200,150,500,500
            DRAWSPRITE 0,0,0
            STRETCHSPRITE 9998,340,340,170,170
            STRETCHSPRITE 9998,170,170,170,170
            GRABSPRITE 0,0,0,512,512
                        RETURN
ENDSUB
 
Amstrad CPC 6128, ATARI STE.
Acer  SW5-173 & AMD FX 8350/1050Ti