Grids in 3d?

Blitz3D Forums/Blitz3D Programming/Grids in 3d?

poopla(Posted 2004) [#1]
Anyone have any ideas for drawing grids in 3d fast?


jhocking(Posted 2004) [#2]
Could you be more specific than "grid?" In 2D that word is fairly self-explanatory (draw lines of pixels into a grid shape,) but in 3D "grid" could be many things.


napole0n(Posted 2004) [#3]
Repeat a masked gridtexture on a plane?


vibe37(Posted 2004) [#4]
Why the hell did I read "Girls in 3d"?


fredborg(Posted 2004) [#5]
Have a look here: http://www.blitzbasic.co.nz/codearcs/codearcs.php?code=839


N(Posted 2004) [#6]
Kungfista: You're not the only one...

Shattered: I'd suggest quads that stretch (and overlap, naturally) setup so that have no culling. You could very easily write a function to do that.. I can post one later maybe.


Magitta(Posted 2004) [#7]
Kungfista: Same here X_X, maybe we red what we would've liked to read..


N(Posted 2004) [#8]
As I said, I could post one.

;;;;;;;;;;;EXAMPLE
Graphics3D 800,600,32,2

C = CreateCamera()
Grid = CreateGrid(8,32,.5)

Repeat
	If KeyHit(1) Then : ClearWorld : End : EndIf
	MoveEntity C,0,0,Float(KeyDown(2)-KeyDown(3))/2
	Pan# = Pan# - Float(MouseXSpeed())/3
	Tilt# = Tilt# + Float(MouseYSpeed())/3
	MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
	RotateEntity C,Tilt,Pan,0
	UpdateWorld
	RenderWorld
	Flip False
Forever


;;;;;;;;;;;;CREATEGRID
Function CreateGrid(GridSize%,Segments%=10,LineWidth#=.1)
	M = CreateMesh()
	Surf = CreateSurface(M)
	GridSize = Abs(GridSize)
	Segments = Abs(Segments)
	N# = -(GridSize*Segments)+GridSize/2
	While N < GridSize*Segments
		V = AddVertex(Surf,N,0,GridSize*Segments)
		AddVertex(Surf,N+LineWidth#,0,GridSize*Segments)
		AddVertex(Surf,N+LineWidth#,0,-GridSize*Segments)
		AddVertex(Surf,N,0,-GridSize*Segments)
		AddTriangle Surf,V,V+1,V+2
		AddTriangle Surf,V+2,V+3,V
		N = N + GridSize
	Wend
	N# = -(GridSize*Segments)+GridSize/2
	While N < GridSize*Segments
		V = AddVertex(Surf,GridSize*Segments,0,N)
		AddVertex(Surf,GridSize*Segments,0,N+LineWidth#)
		AddVertex(Surf,-GridSize*Segments,0,N+LineWidth#)
		AddVertex(Surf,-GridSize*Segments,0,N)
		AddTriangle Surf,V,V+1,V+2
		AddTriangle Surf,V+2,V+3,V
		N = N + GridSize
	Wend
	
	UpdateNormals M
	EntityFX M,16
	Return M
End Function



JoeGr(Posted 2004) [#9]
If you should happen to need a GUI system at the same time, I think you can do 3d grids using Chris Fuller's 'F-UI'.

EDIT: Just realised from another thread that you probably knew that already...