Pom Pom Using Cylinders As Lines.
Blitz3D Forums/Blitz3D Programming/Pom Pom Using Cylinders As Lines.
| ||
Hello there Blitz 3D Fans, nice to see you all again, boy it's been a while since posting a code help topic here. I havent forgotten about good old Blitz! :) Right, here's my problem the formula used for working out the orientation of the Lines aka Cylinders, does not work properly. try altering any of the X / Y / Z Amounts ( Z must equal 1 in my code, or it'll MAV and crash ) And I wondered if anybody around here knew the correct way of putting it right. If you dont get what Im trying to achieve. The to best describe what Im after is to imagine a Dandilion thats got the white stuff you can blow, to make wishes with. Or as I called it, a Pom Pom. Or think of a plotball with lines projecting out. It's supposed to equally spread out the lines so they point in the correct direction. Const XRES=640,YRES=480 Graphics3D XRES,YRES,32 SetBuffer BackBuffer() Const XAMOUNT=4;8 Const YAMOUNT=4;8 Const ZAMOUNt=1;4 Global Cam=CreateCamera() Global Light=CreateLight() PositionEntity Cam,0,0,-5 Const MAX_LINES=(XAMOUNT*YAMOUNT*ZAMOUNT) Dim Cylinder( MAX_LINES ) Global Control=CreatePivot() Global SpaceIncX#=Float(360/XAMOUNT) Global SpaceIncY#=Float(360/YAMOUNT) Global SpaceIncZ#=Float(360/ZAMOUNT) SetupPomPom() Main() End Function Main() Local Angle# While Not KeyHit(1) TurnEntity ( Control, 0.5, 0.7, Sin( Angle# )*1.5 ) Angle#=Angle#+0.45 RenderWorld() Flip Wend End Function Function SetupPomPom() ; ; Setup Cylinder Lines. ; For Z=0 To ZAMOUNT-1 For Y=0 To YAMOUNT-1 For X=0 To XAMOUNT-1 Cylinder( Count )=CreateCylinder(16,True,Control) EntityColor( Cylinder( Count ),Rand(64,255),Rand(64,255),Rand(64,255) ) ScaleEntity ( Cylinder( Count ),0.04,2,0.04 ) ; ; Set Orientation. ; TurnEntity ( Cylinder( Count ), OrientX#, OrientY#, OrientZ# ) Count=Count+1 OrientX#=OrientX#+SpaceIncX# Next OrientY#=OrientY#+SpaceIncY# Next OrientZ#=OrientZ#+SpaceIncZ# Next End Function Cheers and all the very best to you, Clyde. |
| ||
Your using the wrong approach. Only a Geosphere ( isocohedron ) as a starting object will give you uniform spacing. Once you have this, place each cylinder at the vertex and point it back to the center to create the pom pom effect. For example: I'm not sure of the formula to get the number of vertices based on detail but you can see the number created by the child count. Stevie |
| ||
Cheers Stevie :) |
| ||
Is there a way to do this without using fit mesh? Plus say, I want a total of just 32 strands. Thanks a zillion, Clyde. |
| ||
This is the best I can do. Note that if you set the detail to 6 you would normally create 36 strands ( 6 x 6 ) , however, at a pitch of 90 degrees you will have 6 strands which overlap each other, 5 of which are never seen. I have added a condition which removes them so total strands = Detail * Detail - ( Detail - 1 ). Just comment out the 'y = 0 or Angle <> 90' + 'endif' to see what I mean. p.s. What is this for? Stevie Graphics3D 640,480,16,1 Global CAMERA = CreateCamera() PositionEntity CAMERA, 0,0,-5 Global CONTROL = CreatePivot() Dim Cylinder(0) POMPOMcreate( 6 , CONTROL ) While Not KeyHit(1) TurnEntity CONTROL,0.5, 0.7, Sin( Angle# ) * 1.5 Angle#=Angle#+0.45 RenderWorld() Text 0,0,CountChildren( CONTROL ) Flip Wend ;================================================================================ ;================================================================================ ;================================================================================ Function POMPOMcreate( Detail, Parent ) No = Detail * Detail - ( Detail - 1 ) Dim Cylinder( No-1 ) Yaw = CreatePivot() Pitch = CreatePivot( Yaw ) cnt = 0 For y = 0 To Detail-1 Angle# = y * ( 180.0 / Float( Detail ) ) RotateEntity Yaw, 0 , Angle , 0 For p = 0 To Detail-1 Angle# = p * ( 180.0 / Float( Detail ) ) RotateEntity Pitch, Angle , 0 , 0 If y = 0 Or Angle <> 90 Cylinder( cnt ) = CreateCylinder( 16, True , Parent ) RotateMesh Cylinder( cnt ), 90,0,0 ScaleMesh Cylinder( cnt ), .04, .04, 2 EntityColor Cylinder( cnt ),Rand(64,255),Rand(64,255),Rand(64,255) RotateEntity Cylinder( cnt ), EntityPitch( Pitch, 1 ) , EntityYaw( Pitch, 1 ) , 0 , 1 cnt = cnt + 1 EndIf Next Next FreeEntity Yaw End Function |
| ||
Thanks again Stevie. This is for an effect idea for a new Gravity production. If yourself or others reading this are interested in gfx demos, or wonder whats a gfx demo then see the link in my signature. |