News:

Function Finder  Find all the functions within source code files

Main Menu

Sinus Height Map

Started by kevin, August 20, 2010, 05:21:31 PM

Previous topic - Next topic

kevin

 Sinus Height Map

   This is quick port of an old Db demo I wrote some 9 years ago, it's create a rotating vertex array (height map) with a sinus applied to the height..


PlayBASIC Code: [Select]
` *=---------------------------------------------------------------------=*
`
` >> 3D Dot Sine Wave V0.02 <<
`
` By Kevin Picone
`
` Orignal Version Released: 12,June,2001 / Updated 21st,Aug,2010
`
` (c) copyright 2001/2010, By Kevin Picone, All rights reserved.
`
` *=---------------------------------------------------------------------=*
`
` So what does this do ?:
` =======================
`
` This routine rotates and projects a 2d/3d plane of vertex. What's
` interesting is that rather than this being a static plane, the heights
` are created real time sine (plasma) formula. This height data is then
` scrolled across the matrix like table...
`
` To speed up the rotation time, the projection routine uses common
` point rotation along the X and Z axis. This means that to rotate a
` point there's no mult's in the inner loop. It also works just dandy
` for 3D axis rotation also, more so actually.
`
`
` Release Info:
` =============
`
` Your welcome to use this code providing you give credit and add a link
` to www.PlayBASIC.com.
`
`
` Cya,
` Kevin Picone
` www.UnderwareDesign.com
`
` *=---------------------------------------------------------------------=*

; setfps 30

` Constants

i=0

screen_width=GetScreenWidth()
screen_height=GetScreenHeight()

Title$= "3D Sine Wave Matrix"
Version$= "V0.01a"

white=rgb(255,255,255)
red=rgb(255,0,0)



` Projection Plane Value


acc#=400


` Matrix (vertex plane ) Width & Depth (numb of points)


Map_width=180

Map_depth=Map_width


` calc the number of vertex in this matrix

Active_Vertex_Count=Map_width*Map_depth

Dim CommonPointRotSX#(map_width)
Dim CommonPointRotCX#(map_width)
Dim CommonPointRotSZ#(map_Depth)
Dim CommonPointRotCZ#(map_Depth)

Grid_Width#=32
Grid_Depth#=Grid_Width#
Grid_height#=250


` Init the WIDTH & DEPTH of Sine Wave Table

Height_buffer_width=Map_width
Height_buffer_Height=Map_depth
dim buffer(Height_buffer_width,Height_buffer_height)


` starting Position of the dot effect

Screen_Centx=Screen_width*2
Screen_CentY=Screen_Height/2



` Pre- init the Sine Height Buffer
for lp=0 to Map_width
gosub Scroll_Sinewave_Height_buffer
next lp




do

; Clear the screen
cls

` Show Program By Info
text 480,credits_ypos,"Point Count:"+Str$(Active_Vertex_count)


` Inc the Fake Height Maps's (matrixs) Rotation Angle
angle#=wrapangle(angle#,0.12)


` Move the Effects Base position (slide it on from the right)
if Screen_centx>(screen_width/2)
dec Screen_Centx,20
endif


` Rotate and render the Points
gosub _Rotate_Vertex_grid


sync
loop





` *=----------------------------------------------------------------=*
` *=--------------------- Rotate Vertex Grid -----------------------=*
` *=----------------------------------------------------------------=*




_Rotate_Vertex_grid:

` Build Height Tables
gosub Scroll_Sinewave_Height_buffer

Login required to view complete source code