Page Curl Effect...

Blitz3D Forums/Blitz3D Programming/Page Curl Effect...

I posted code a while back ... not exactly what you're looking for but is a start.

Graphics3D 640,480,16,1
Global CAMERA = CreateCamera()
CameraRange CAMERA,0.01,100
WireFrame 0

PositionEntity CAMERA, 0,0,-10 ;1.3

Const Radius# = 1.0

FLAT = MESHflat( Radius * Pi ,2,Radius , 16 ) : HideEntity FLAT
TUBE = MESHtube( Radius,2,Radius , 16 ) : HideEntity TUBE
Texture = LoadTexture("ScreenShot013.bmp")

VISIBLE = MESHflat( 1,1,1 , 16 )
EntityTexture VISIBLE, Texture
Dir# = 1.0 : TimeStep# = 0.0

While Not KeyDown(1)

	TimeStep = TimeStep + .01 * Dir
	If TimeStep >= 1.0 Dir = - 1
	If TimeStep <= 0.0 Dir = 1.0 

	MESHmorph( VISIBLE , TUBE, FLAT , TimeStep )

	RenderWorld()
	Flip

Wend

;====================================================================================
;====================================================================================
;====================================================================================

Function MESHmorph( Source , Initial , Final , T# )

	ss = GetSurface( Source , 1 )
	is = GetSurface( Initial , 1 )
	fs = GetSurface( Final , 1 )
	
	For v = 0 To CountVertices( ss ) - 1
	
		Nx# = VertexX( is, v ) + ( VertexX( fs , v ) - VertexX( is , v ) ) * T
		Ny# = VertexY( is, v ) + ( VertexY( fs , v ) - VertexY( is , v ) ) * T
		Nz# = VertexZ( is, v ) + ( VertexZ( fs , v ) - VertexZ( is , v ) ) * T
		VertexCoords ss, v , Nx, Ny, Nz
		
	Next
	
End Function

;====================================================================================
;====================================================================================
;====================================================================================

Function MESHflat( Sx#, Sy#, Sz#, Segs = 8 )

	Mesh = CreateMesh()
	s = CreateSurface( Mesh )

	For l = 0 To Segs - 1
		a0# = - Sx + 2.0 * Sx * Float( l ) / Float( Segs )  
		a1# = - Sx + 2.0 * Sx * Float ( l + 1 ) / Float( Segs )
		u0# = Float(l) / Float( Segs )
		u1# = Float(l+1) / Float( Segs )
		DebugLog u0
		DebugLog u1
		DebugLog "**************"
		v0 = AddVertex( s , a0 , Sy, Sz , u0,0)
		v1 = AddVertex( s , a1 , Sy, Sz, u1,0)
		v2 = AddVertex( s , a1 , -Sy, Sz, u1,1 )
		v3 = AddVertex( s , a0, -Sy, Sz , u0,1)
		AddTriangle s, v0, v1, v2
		AddTriangle s, v2, v3, v0
	Next
	
	Return Mesh
		
End Function

;====================================================================================
;====================================================================================
;====================================================================================

Function MESHtube( Sx#, Sy#, Sz# , Segs = 8 )

	Mesh = CreateMesh()
	s = CreateSurface( Mesh )

	For l = 0 To Segs - 1
		a0# = 90.0 + l * 360.0 / Float( Segs )	;+90 important so starts at rear
		a1# = 90.0 + ( l + 1 ) * 360.0 / Float( Segs )
		u0# = Float( l/Segs ) 
		u1# = Float( (l+1)/Segs )
		v0 = AddVertex( s , Sx * Cos( a0 ) , Sy , Sz * Sin( a0 ),u0,0 )
		v1 = AddVertex( s , Sx * Cos( a1 ) , Sy , Sz * Sin( a1 ) ,u1,0)
		v2 = AddVertex( s , Sx * Cos( a1 ) , -Sy , Sz * Sin( a1 ),u1,1 )
		v3 = AddVertex( s , Sx * Cos( a0 ) , -Sy , Sz * Sin( a0 ),u0,1 )
		AddTriangle s, v0, v1, v2
		AddTriangle s, v2, v3, v0
	Next
	
	Return Mesh
End Function


Stevie