Metropoli BBS
VIEWER: gridxz.vxr MODE: TEXT (ASCII)
#VRML V1.0 ascii

#
#	This program generates a x-z grid for X equal fromX to X equal toX and
#	from Z equal fromZ to Z equal toZ with grid spacing equal to gridSpacing
#
# 	To use this file include the following code (uncommented) in your file
#  and define the values for your grid 
#

#PARAMETERS {
#	fields [SFLong fromX, SFLong toX, SFLong fromZ, SFLong toZ, SFFloat gridSpacing]
#	fromX 0
#	toX 10
#	fromZ 0
#	toZ 10
#	gridSpacing 1
#	
#	INCLUDE gridXZ.vxr
#}

Separator {
	
	# Create the grid lines crossing the x axis

	DEF gridDataX Coordinate3 {
		point [] # MFVec3f
	}
	
	DEF gridX IndexedLineSet {
		coordIndex [] # MFLong
	}
	
	DEF loop1 LOOP {
		fields [ SFLong start, SFLong end, SFLong step, SFLong position, SFLong index ]
		start fromX
		end toX+gridSpacing
		step gridSpacing
		index 0																# This is the initial value of index
		
		APPEND gridDataX:point (position,0,fromZ)			# Each line will go from fromZ to toZ parallel to the z-axis 
		APPEND gridDataX:point (position,0,toZ)

		APPEND gridX:coordIndex index      					# Get the index to begining point
		APPEND gridX:coordIndex index+1    					# Get the index to ending point
		APPEND gridX:coordIndex -1							 		# Terminate the polyline	
	
		SET loop1:index loop1:index+2 							# Increase index by 2 each time through the loop
	}

	# Create the z grid lines
	
	DEF gridDataZ Coordinate3 {
		point [] # MFVec3f
	}
	
	DEF gridZ IndexedLineSet {
		coordIndex [] # MFLong
	}

	DEF loop2 LOOP {
		fields [ SFLong start, SFLong end, SFLong step, SFLong position, SFLong index ]
		start fromZ
		end toZ+gridSpacing
		step gridSpacing
		index 0 															# This is the initial value of index
		
		APPEND gridDataZ:point (fromX,0,position)			# Each line will go from fromX to toX parallel to the X-axis 
		APPEND gridDataZ:point (toX,0,position)

		APPEND gridZ:coordIndex index      					# Get the index to begining point
		APPEND gridZ:coordIndex index+1    					# Get the index to ending point
		APPEND gridZ:coordIndex -1							 		# Terminate the polyline	
	
		SET loop2:index loop2:index+2 							# Increase index by 2 each time through the loop
	}
}
[ RETURN TO DIRECTORY ]