Mesh2=MP_CreateCylinder(10,4, 0.4, 2) ; new Cylinder with options
will make a sharp tip cone because it decipher 0.4 as zero
i am still looking how to parallel between
;glRotatef_( openangle,0,0,1)
MP_RotateMesh(cyl, 0,0,openangle)
;glRotatef_(twist,0,1,0)
MP_RotateMesh(cyl, 0,twist,0)
i will adopt the strategy of using MP_AddMesh , this is the easiest approach, but needs to accommodate rotations correctly
here is the very crude approximate which show only the very general strategy, and not a correct version:
Code: Select all
Declare DrawBranch( startRadius.f, startlength.f, levels.l, openangle.f, twist.f)
ExamineDesktops()
Global bitplanes.b=DesktopDepth(0),RX.w=DesktopWidth(0),RY.w=DesktopHeight(0),s_bg.i
MP_Graphics3D(RX,RY,0,1);MP_VSync(0)
SetWindowTitle(0, "press '1' or '2' to change Camera view position")
camera = MP_CreateCamera() ; Kamera erstellen
light= MP_CreateLight(2) ; Es werde Licht
MP_PositionEntity(light, -10, 10, 0)
MP_AmbientSetLight (RGB(0,100,200))
cam = MP_CreateCamera()
MP_PositionEntity(cam, 0, 3, -7)
MP_EntityLookAt(cam, 0, 0, 0)
tex0 = MP_CreateTextureColor(128, 128, RGBA(0, 255, 0, 0))
MP_MaterialEmissiveColor(tex0, 0, 122, 132, 132)
tex1 = MP_CreateTextureColor(128, 128, RGBA(25, 255, 255, 0))
MP_MaterialEmissiveColor(tex1, 0, 122, 132, 132)
;mp_wireframe(1)
Global tree = MP_CreateCylinder(8,3,1, 2)
MP_ResizeMesh(tree,0.1,0.1,0.1)
DrawBranch(1, 2, 6, 30,30)
MP_EntitySetTexture(sphere, tex1)
MP_EntitySetNormals (sphere)
MP_MaterialDiffuseColor (sphere,255,255,255,50)
MP_MaterialSpecularColor (sphere, 255, 255 ,255, 155,5)
;;oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow; Esc abfrage oder Windows Schliessen
If MP_KeyHit(#PB_Key_1)
MP_PositionEntity(cam, 0, 10, -3)
MP_EntityLookAt(cam, 0, 0, 0)
ElseIf MP_KeyHit(#PB_Key_2)
MP_PositionEntity(cam, 0, 3, -7)
MP_EntityLookAt(cam, 0, 0, 0)
EndIf
MP_TurnEntity (tree,-2,-1,1) ; mee too
MP_RenderWorld() ; Erstelle die Welt
MP_Flip () ; Stelle Sie dar
Wend
End
Procedure DrawBranch( startRadius.f, startlength.f, levels.l, openangle.f, twist.f)
baseRadius.f = startRadius
topRadius.f = baseRadius - startRadius/levels
length.f = startlength
;glPushMatrix_()
For i = 1 To levels
cyl=MP_CreateCylinder(8,length,baseRadius, topRadius)
MP_RotateMesh(cyl, -90,0,0)
MP_TranslateMesh(cyl, 0, length, 0)
;glRotatef_( openangle,0,0,1)
MP_RotateMesh(cyl, 0,0,openangle)
;glRotatef_(twist,0,1,0)
MP_RotateMesh(cyl, 0,twist,0)
;glPushMatrix_();
;glRotatef_(-openangle*2,0,0,1)
MP_RotateMesh(cyl, 0,0,-openangle*2)
MP_AddMesh(cyl , tree) : MP_FreeEntity(cyl)
If i = 1
DrawBranch(topRadius, length, levels-1, -openangle, twist)
Else
DrawBranch(topRadius, length, levels-i, openangle, twist)
EndIf
;glPopMatrix_()
baseRadius = topRadius
topRadius = baseRadius - startRadius/levels
length = length - startlength/levels
Next
;glPopMatrix_()
EndProcedure