Re: Grafik-"Superformel" als BB Quelltext
Geschrieben von Markus am 05. September 2004 03:18:50:
Als Antwort auf: Grafik-"Superformel" geschrieben von Hyronimus am 21. März 2004 18:12:05:
BlitzBasic3D für den PC :-)
;Super Formel !!!
;http://astronomy.swin.edu.au/~pbourke/surfaces/supershape3d/
;http://astronomy.swin.edu.au/~pbourke/curves/supershape/
;http://www.heise.de/newsticker/meldung/45863Graphics3D 800,600,16,2
WireFrame 1SetBuffer BackBuffer()
camera%=CreateCamera()AmbientLight 10,10,10
li=CreateLight()
PositionEntity li,-4,-4,0
LightRange li,10superobjekt%=CreateSuper%(8,60,100,30,1,1, 2,10,10,10, 1,1 , 36)
PositionEntity superobjekt%,0,0,4
UpdateNormals superobjektWhile Not KeyHit(1)
;Ich weiß, dass die Steuerung scheiße ist!!!
RotateEntity superobjekt%,MouseX(),MouseY(),0
RenderWorld
Flip
Wend
EndFunction CreateSuper%(m_1#,n1_1#,n2_1#,n3_1#,a_1#,b_1#,m_2#,n1_2#,n2_2#,n3_2#,a_2#,b_2#,detail%=40)
Local r1#,r2#,phi#,theta#,alpha#,i%,j%
Local mesh%=CreateMesh()
Local surface%=CreateSurface(mesh%)alpha#=360/detail%
phi#=-90
r2#=super#(m_2#,n1_2#,n2_2#,n3_2#,a_2#,b_2#,phi#)
For j%=0 To detail%-1
theta#=j%*alpha#-180
r1#=super#(m_1#,n1_1#,n2_1#,n3_1#,a_1#,b_1#,theta#)
AddVertex(surface%,r1*Cos(theta#)*r2*Cos(phi#),r1*Sin(theta#)*r2*Cos(phi#),r2*Sin(phi#))
NextFor i%=1 To detail%/2
phi#=i%*alpha#-90
r2#=super#(m_2#,n1_2#,n2_2#,n3_2#,a_2#,b_2#,phi#)
For j%=0 To detail%-1
theta#=j%*alpha#-180
r1#=super#(m_1#,n1_1#,n2_1#,n3_1#,a_1#,b_1#,theta#)
AddVertex(surface%,r1*Cos(theta#)*r2*Cos(phi#),r1*Sin(theta#)*r2*Cos(phi#),r2*Sin(phi#))
Next
For j%=0 To detail%-1
AddTriangle(surface%,(i%-1)*detail+j,(i%-1)*detail%+((j+1)Mod detail%),(i%)*detail%+((j+1)Mod detail%))
AddTriangle(surface%,(i%-1)*detail+j,(i%)*detail%+((j+1)Mod detail%),i%*detail+j)
Next
Next
Return mesh%
End FunctionFunction super#(m#,n1#,n2#,n3#,a#,b#,phi#)
Return((Abs(Cos(m#*phi#/4)/a#))^n2#+(Abs(Sin(m#*phi#/4)/b#))^n3#)^(1/-n1#)
End Function