I'm a little rusty, please help with....

Blitz3D Forums/Blitz3D Beginners Area/I'm a little rusty, please help with....

Blitzplotter(Posted June) [#1]
I'm using the following code within a loop to create a number of cylinders:


pillarheight=CreateCylinder()
	
	PositionEntity pillarheight,20,xx,yy
	
	ScaleEntity pillarheight,3,mod_height,3
	
	RotateEntity pillarheight,0,0,90



However, I want to hide /show them dependent upon a button being depressed on the UI.

I'm suspecting I need to create an array of cylinders, rather than just numerous cylinders in order to hide each cylinder after being created.

[EDIT]

Tried modifying the above code to name the entitys:

	
	pillarheight=CreateCylinder()
	
	pillarname$(location_and_height)="1"
	
	NameEntity pillarheight,pillarname$(location_and_height)
	
	PositionEntity pillarheight,20,xx,yy
	
	ScaleEntity pillarheight,3,mod_height,3
	
	RotateEntity pillarheight,0,0,90
	
	
	


However trying to hide the named entitys using the following syntax causes a memory violation:

	
		
			If HeightBlahOn=0
				
				For x=1 To 1000
				
					HideEntity pillarname$(x)
					
				Next	
					
			EndIf



I'm beginning to suspect that the main.bb does not have visibility of the pillar created in the included.bb which creates the cylinders.....


Any ideas how? Thanks.


RemiD(Posted June) [#2]
i see 2 ways :
store the reference of each entity in an array list or in a customtype list and then browse the list to show/hide them.
or
create a parent pivot and set each cylinder as a child of this parent pivot then show/hide the parent pivot to show/hide all cylinders (all child entities)

you will probably need a variable to store the state of the parent of all cylinders (shown or hidden) or the state of each cylinder (shown or hidden) depending on what you want to achieve...


Blitzplotter(Posted June) [#3]
@RemiD - thanks for the feedback. I suspect I need to create my array of cylinders within my main.bb.

Then 'manipulate' each cylinder accordingly within my include file, terrain_geny.bb.

Then, back within main, I can show / hide them accordingly.

Hmmm, tried modifying my code to reference each pillar indirectly via its 'name, however getting a MAV:


	pillarheight=CreateCylinder()
	
	pillarname$(location_and_height)="1"
	
	NameEntity pillarheight,pillarname$(location_and_height)
	
	;PositionEntity pillarheight,20,xx,yy
	
	PositionEntity pillarname$(location_and_height),20,xx,yy
	
	ScaleEntity pillarheight,3,mod_height,3
	
	RotateEntity pillarheight,0,0,90
	
	






I hear you here:



you will probably need a variable to store the state of the parent of all cylinders (shown or hidden) or the state of each cylinder (shown or hidden) depending on what you want to achieve...




tried the following, but getting a MAV still:


	;pillarheight=CreateCylinder()
	ARYpillarheight(location_and_height,0)=CreateCylinder()
	
	;pillarname$(location_and_height)="1"
	
	;NameEntity pillarheight,pillarname$(location_and_height)
	
	;PositionEntity pillarheight,20,xx,yy
	
	;PositionEntity pillarname$(location_and_height),20,xx,yy
	PositionEntity ARYpillarheight(location_and_height,0),20,xx,yy
	
	;ScaleEntity pillarheight,3,mod_height,3
	ScaleEntity ARYpillarheight(location_and_height,0),3,mod_height,3
	
	;RotateEntity pillarheight,0,0,90
	RotateEntity ARYpillarheight(location_and_height,0),0,0,90
	



Blitzplotter(Posted June) [#4]
Sorted it - thanks for your inspiration RemiD, and all before dinner, here is the code within main to declare and turn on and off:

Its been 3 years since I played around with this project, B3D is ace ;)


Global HeightBlahOn=1

Dim ARYpillarheight(1000,1)

For location_and_height=1 To 1000; Step 100
	
	ARYpillarheight(location_and_height,0)=CreateCylinder()
	
Next

;.....................

			If HeightBlahOn=0
				
				For x=1 To 1000
				
					HideEntity ARYpillarheight(x,0)
					
				Next	
					
			EndIf






Within terraingeny.bb:



	PositionEntity ARYpillarheight(location_and_height,0),20,xx,yy

	ScaleEntity ARYpillarheight(location_and_height,0),3,mod_height,3

	RotateEntity ARYpillarheight(location_and_height,0),0,0,90








Blitzplotter(Posted June) [#5]
Does anyone know why this code fails to store the relative co-ordinates of all the individual cylinders in the first screen grab above when I attempt to execute a ParentEntity command - its almost as if just the parent entity is being saved, or all cylinders are being parented using the same co-ords as the parent cylinder.

For location_and_height=1 To 1000

        xx=xx+3

        yy=yy+3

        ARYpillarheight(location_and_height,0)=CreateCylinder()
	
	
	PositionEntity ARYpillarheight(location_and_height,0),20,xx,yy
	
	
	ScaleEntity ARYpillarheight(location_and_height,0),3,mod_height,3
	
	
	RotateEntity ARYpillarheight(location_and_height,0),0,0,90
	

	;Parent Entity to 3DROUTE
	ParentEntity ARYpillarheight(location_and_height,0),RelieftHeightMap


next