A billowing flag?

Blitz3D Forums/Blitz3D Programming/A billowing flag?

Chroma(Posted 2007) [#1]
Guys, is anyone handy with code to make a flag billow. I have to have a flag flapping in the wind for tomorrow morning. I only have milkshape. Can someone bail me out? Think state or national flag.


caff_(Posted 2007) [#2]
Perhaps use a sine wave.

Something like:

http://www.blitzbasic.com/codearcs/codearcs.php?code=851


Stevie G(Posted 2007) [#3]
From the Blitz 3d samples folder .. ( Marks samples himself )

Global info1$="Flag demo"
Global info2$="Features mesh deformation"

Include "../start.bb"

Const segs=128,width#=4,depth#=.125

mesh=CreateMesh()
surf=CreateSurface( mesh )

For k=0 To segs
	x#=Float(k)*width/segs-width/2
	u#=Float(k)/segs
	AddVertex surf,x,1,0,u,0
	AddVertex surf,x,-1,0,u,1
Next

For k=0 To segs-1
	AddTriangle surf,k*2,k*2+2,k*2+3
	AddTriangle surf,k*2,k*2+3,k*2+1
Next

b=LoadBrush( "b3dlogo.jpg" )
PaintSurface surf,b

camera=CreateCamera()
PositionEntity camera,0,0,-5

light=CreateLight()
TurnEntity light,45,45,0

While Not KeyHit(1)

	ph#=MilliSecs()/4
	cnt=CountVertices(surf)-1
	For k=0 To cnt
		x#=VertexX(surf,k)
		y#=VertexY(surf,k)
		z#=Sin(ph+x*300)*depth
		VertexCoords surf,k,x,y,z
	Next
	UpdateNormals mesh
	
	If KeyDown(26) TurnEntity camera,0,1,0
	If KeyDown(27) TurnEntity camera,0,-1,0
	If KeyDown(30) MoveEntity camera,0,0,.1
	If KeyDown(44) MoveEntity camera,0,0,-.1
	
	If KeyDown(203) TurnEntity mesh,0,1,0,True
	If KeyDown(205) TurnEntity mesh,0,-1,0,True
	If KeyDown(200) TurnEntity mesh,1,0,0,True
	If KeyDown(208) TurnEntity mesh,-1,0,0,True
	
	UpdateWorld
	RenderWorld
	Flip
Wend
End



Chroma(Posted 2007) [#4]
Thx for the tips. I went with animating a segmented plane in milkshape. It looks quite sad but it'll do I guess.


sonokong(Posted 2007) [#5]
right