far imagination, but everything is possible .
here is another stolen code about pine cone, i think if every call to position a sphere (seed) replaced by a call to make a tiny pine cone we will see a Fractal Broccoli, i can't now to make this recursive change i am just stuck.
in fact it is the same sunflower code but stretched in 3D, if we play with the fourth parameter in these lines:
we will get funny shapes.
Code: Select all
Structure coor
x.f
y.f
z.f
EndStructure
Global z.coor
Global seeds = 1
#golden_angle = 137.508
Global golden.f = Radian(#golden_angle); = 2.3999 also = golden_angle*PI/180
Procedure floret(n.i)
r.f : ang.f : xc.f : yc.f
r =Sqr(n*golden)
ang = (n*golden)
xc = r*Cos(ang)/20
yc = r*Sin(ang)/20
z\x=xc : z\y=yc
EndProcedure
Enumeration
#sphere
#camera
EndEnumeration
#cameraSpeed = 0.2
Define.f KeyX, KeyY, MouseX, MouseY
Declare PineCone()
InitEngine3D()
InitMouse()
InitKeyboard()
InitSprite()
ExamineDesktops()
OpenWindow(0, 0, 0, DesktopWidth(0), DesktopHeight(0), "'Space': toggle rotation/stop .... .. arrow keys+mouse: move/rotate camera...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, DesktopWidth(0), DesktopHeight(0), 0, 0, 0)
Add3DArchive(".",#PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home+"Examples\3D\Data\Textures\",#PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home+"Examples\3D\Data\GUI",#PB_3DArchive_FileSystem)
Parse3DScripts()
CreateLight(0,RGB(255, 255, 95),-50,50,100)
;;============================================
OpenWindow3D(0,0,0,200,120,"Engine Stats")
TextGadget3D(0,2,0,200,30,"")
TextGadget3D(1,2,0,200,60,"")
ShowGUI(255,0)
;=============================================
CreateCamera(#camera, 0, 0, 100, 100)
MoveCamera(#camera, 0, 2, 5, #PB_Absolute)
CameraBackColor(#camera, RGB(255,200,200))
CameraLookAt(#camera,0,-1,0)
CreateLight(0, RGB(255,255,255), 0, 20, 30)
AmbientColor(RGB(250, 100, 20))
CreateMaterial(1, LoadTexture(1, "clouds.jpg"))
MaterialCullingMode(1, #PB_Material_NoCulling)
SetMaterialColor(1, #PB_Material_AmbientColor, RGB(250, 255, 255))
SetMaterialColor(1, #PB_Material_SpecularColor, RGB(255, 255, 255))
Global Compound = CreateEntity(#PB_Any,0,0)
PineCone() ;call the pine cone construction procedure
RotateEntity(Compound, 90.0,0.0,0,#PB_Absolute)
rot = 1
Repeat
Repeat
Event = WindowEvent()
Until Event = 0
If ExamineMouse()
MouseX = -MouseDeltaX()/20
MouseY = -MouseDeltaY()/20
EndIf
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Left)
KeyX = -#cameraSpeed
ElseIf KeyboardPushed(#PB_Key_Right)
KeyX = #cameraSpeed
Else
KeyX = 0
EndIf
If KeyboardPushed(#PB_Key_Up)
KeyY = -#cameraSpeed
ElseIf KeyboardPushed(#PB_Key_Down)
KeyY = #cameraSpeed
Else
KeyY = 0
EndIf
If KeyboardReleased(#PB_Key_Space)
rot ! 1
EndIf
EndIf
RotateEntity(Compound, 0.5*rot,0.5*rot,0.5*rot,#PB_Relative)
RotateCamera(#Camera, MouseY, MouseX, 0, #PB_Relative)
MoveCamera(#Camera, KeyX, 0, KeyY)
RenderWorld()
FlipBuffers()
;;==============================================
SetGadgetText3D(0,"FPS: "+StrF(Engine3DStatus(#PB_Engine3D_CurrentFPS )))
SetGadgetText3D(1,"Tris: "+StrF(Engine3DStatus(#PB_Engine3D_NbRenderedTriangles)))
;;================================================
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
End
Procedure PineCone()
CreateSphere(#sphere,1, 16,16)
CreateEntity(#sphere, MeshID(#sphere),MaterialID(1),0,0,0)
For count =1 To 140
floret(count) ; calling the procedure to find the one sphere (seed) position
CopyEntity(#sphere,count+#sphere)
ScaleEntity(count+#sphere, (0.11+count/900),(0.11+count/900),(0.11+count/900))
MoveEntity(count+#sphere, z\x , z\y , count/100)
AddSubEntity(Compound, count+#sphere, #PB_Entity_SphereBody)
Next
For count =144 To 1 Step -1
floret(count) ;calling the procedure to find the one sphere (seed) position
CopyEntity(#sphere,count+144)
ScaleEntity(count+144, (0.11+count/900),(0.11+count/900),(0.11+count/900))
MoveEntity(count+144, -z\x , -z\y , 2.2-count/200)
AddSubEntity(Compound, count+144, #PB_Entity_SphereBody)
Next
HideEntity(#sphere,1)
EndProcedure