wireframe mode reliability

Blitz3D Forums/Blitz3D Programming/wireframe mode reliability

Rob(Posted 2003) [#1]
Reakon its reliable enough to use in a commercial game yet lads? if not, what alternatives?


_PJ_(Posted 2003) [#2]
I have only ever heard (or read) it said that it is only worth using it for test-purposes etc. as it is unsupported by most video cards. I hae had no problems with either of my computers though. Only a few small points:

Why would you want to use it in a game?

I am adding an option for wireframe in my spaceship game, but only cos it reminds me of Elite so much

Some tips if you really are gonna use it:

Hide skybox/sphere in wireframe mode, or render separately
Sprites also may need separate rendering.

Some darker textures look almost invisible in wireframe mode, so maybe a blank/white texture could be used...


Perturbatio(Posted 2003) [#3]
I had thought about it, and my best workaround was to manually draw the wireframe (with hidden surface removal). But that would mean learning how to do it (for me at least).


Rob(Posted 2003) [#4]
Drawing with line is too slow since you need to tformpoint each vert. I am thinking of a proxy.

Tron style edge lines are what I have in mind.


Perturbatio(Posted 2003) [#5]
Care to elaborate? I am unsure of what you mean.

*Edit*

maybe get a simple primitive (like a triangular tube) and stretch it from vertex to vertex?


Ross C(Posted 2003) [#6]
Use a wireframe texture. There must be a way from inside blitz to apply a texture and draw white lines from each vertex, whilst keeping the rest of the texture black and using the black as the mask color.


Ross C(Posted 2003) [#7]
Use a wireframe texture. There must be a way from inside blitz to apply a texture and draw white lines from each vertex, whilst keeping the rest of the texture black and using the black as the mask color.

Even if it's not all the vertexs, you might be able to cheat. It looks not bad either. Some one done it a while back on here.


Perturbatio(Posted 2003) [#8]
someone clicked back to edit their post didn't they? :)


Rob(Posted 2003) [#9]
They did :) but I am now thinking of using clearsurface every second frame and using that time to build a single surface flat overlay mesh from point to point...


Perturbatio(Posted 2003) [#10]
Uhuh... hmmm... *nods knowingly*


_PJ_(Posted 2003) [#11]
There was an excellent example of wireframe texture technique (fairly certain it was in code archives too) - this would be a good idea to get those 'tron-like' effects, as you can blur/fade-out the lines to give a more light-like appearance.

--------------

Whilst thinking about it, would it be too slow to render twice with wireframe camera and a normal camera?


Perturbatio(Posted 2003) [#12]
Presumabley a wireframe texture technique is only useful if you know what the geometry will look like and have it correctly UV mapped?

Unless you can generate such textures on the fly?
My guess would be that it's too slow for realtime use.


podperson(Posted 2003) [#13]
I'm thinking a wireframe texture will not look all that great. Frankly, I see no reason to expect wireframe NOT to be supported on a large majority of graphics cards and I'd do some testing before resorting to a complex, low performance, and quite possibly pointless alternative.

Are you willing to run on "just" all TNT and later nVidia cards and all Rage128 and later ATI cards? If so, I suspect the point is moot.

(Rage128 and TNT were, I believe, the first nVidia and ATI cards, respectively, that could go head-to-head with the 3dfx Voodoo 1. I may be wrong about the TNT, but the TNT2 certainly could.)


smilertoo(Posted 2003) [#14]
I dont know but geforce cards do better with shaded views than they do with wireframe.


Shambler(Posted 2003) [#15]
In 10 years I've not had a card that didn't support wireframe, albeit sometimes meaning a slower frame rate.


BlitzSupport(Posted 2003) [#16]
The wireframe mode comes from your graphics card's drivers, so you can't really trust that it's going to work as intended...


WolRon(Posted 2003) [#17]
My last machine would occasionally crash in wireframe so I avoided it.


ChrML(Posted 2003) [#18]
I have GeForce 2 MX and wireframe works for me...


podperson(Posted 2003) [#19]
" The wireframe mode comes from your graphics card's drivers, so you can't really trust that it's going to work as intended... "

Um... so do all the other graphics modes ;)


Neochrome(Posted 2003) [#20]
couldn't you just simply go through the Vertex index's and DRAW lines from those points? using CameraProject of something?

it'll be complicated, But the result would be (almost) the same as if your using WireFrame (only for that mesh tho)


skidracer(Posted 2003) [#21]
With cylinders you can easily setup your line segments with a single pointentity, scaleentity command pair. To efficiently face quads towards a camera needs some tricky maths, this code is not quite right as you will see wire thickeness is not accurate at all angles.

; wired2.bb

; 3d wire frame system
; wires are lines in 3D space with start and end widths
; CreateWireMesh creates single surface mesh with quad per wire type
; UpdateWireMesh positions wire quad so as to face the camera

Type wire
	Field x0#,y0#,z0#,w0#
	Field x1#,y1#,z1#,w1#
End Type

Function CreateWire.wire(x0#,y0#,z0#,w0#,x1#,y1#,z1#,w1#)
	w.wire=New wire
	w\x0=x0
	w\y0=y0
	w\z0=z0
	w\w0=w0
	w\x1=x1
	w\y1=y1
	w\z1=z1
	w\w1=w1
End Function

Function CreateWireMesh()
	m=CreateMesh()
	EntityFX m,16 ;double sided flag so no tricky flip testing required
	s=CreateSurface(m,b)	
	For w.wire=Each wire
		AddVertex s,0,0,0,0,0
		AddVertex s,0,0,0,1,0
		AddVertex s,0,0,0,1,1
		AddVertex s,0,0,0,0,1
		AddTriangle s,v+0,v+1,v+2
		AddTriangle s,v+0,v+2,v+3
		v=v+4
	Next
	Return m
End Function

Function UpdateWireMesh(cam,mesh)
	s=GetSurface(mesh,1)
	camx#=EntityX(cam)
	camy#=EntityY(cam)
	camz#=EntityZ(cam)
			
	For w.wire=Each wire

		px#=w\x1-w\x0
		py#=w\y1-w\y0
		pz#=w\z1-w\z0
		l#=1.0/Sqr(px*px+py*py+pz*pz)
		px=px*l
		py=py*l
		pz=pz*l

		cx#=w\x0-camx
		cy#=w\y0-camy
		cz#=w\z0-camz
		l#=1.0/Sqr(cx*cx+cy*cy+cz*cz)
		cx=cx*l
		cy=cy*l
		cz=cz*l
		
		l=w\w0
		ex#=l*(-py*cz+pz*cy)
		ey#=l*(+px*cz-pz*cx)
		ez#=l*(py*cx+px*cy)
	
		VertexCoords s,v+0,w\x0+ex,w\y0+ey,w\z0+ez
		VertexCoords s,v+3,w\x0-ex,w\y0-ey,w\z0-ez

		cx#=w\x1-camx
		cy#=w\y1-camy
		cz#=w\z1-camz
		l#=1.0/Sqr(cx*cx+cy*cy+cz*cz)
		cx=cx*l
		cy=cy*l
		cz=cz*l

		l=w\w1
		ex=l*(-py*cz+pz*cy)
		ey=l*(+px*cz-pz*cx)
		ez=l*(py*cx+px*cy)

		VertexCoords s,v+1,w\x1+ex,w\y1+ey,w\z1+ez
		VertexCoords s,v+2,w\x1-ex,w\y1-ey,w\z1-ez
		v=v+4
	Next
End Function

Graphics3D 1024,768



Function CreateBox(x#,y#,z#,w#,h#,d#)
; front square
	CreateWire(x-w,y+h,z+d,2, x+w,y+h,z+d,2)
	CreateWire(x-w,y-h,z+d,2, x+w,y-h,z+d,2)
	CreateWire(x-w,y-h,z+d,2, x-w,y+h,z+d,2)
	CreateWire(x+w,y+h,z+d,2, x+w,y-h,z+d,2)
; side lines
	CreateWire(x-w,y-h,z+d,2, x-w,y-h,z-d,2)
	CreateWire(x+w,y-h,z+d,2, x+w,y-h,z-d,2)
	CreateWire(x+w,y+h,z+d,2, x+w,y+h,z-d,2)
	CreateWire(x-w,y+h,z+d,2, x-w,y+h,z-d,2)
; back square
	CreateWire(x-w,y+h,z-d,2, x+w,y+h,z-d,2)
	CreateWire(x-w,y-h,z-d,2, x+w,y-h,z-d,2)
	CreateWire(x-w,y-h,z-d,2, x-w,y+h,z-d,2)
	CreateWire(x+w,y+h,z-d,2, x+w,y-h,z-d,2)
End Function

For i=1 To 1000
	CreateBox(Rnd(-1000,1000),Rnd(-1000,1000),Rnd(-1000,1000),Rnd(100),Rnd(100),Rnd(100))
Next

mesh=CreateWireMesh()
cam=CreateCamera()
;CameraClsColor cam,20,60,80
CameraRange cam,1,10000

tube=CreateTexture(1,4,4)
brush=CreateBrush()
BrushTexture brush,tube
t=TextureBuffer(tube)
WritePixel 0,0,0,t
WritePixel 0,1,-1,t
WritePixel 0,2,-1,t
WritePixel 0,3,0,t
PaintMesh mesh,brush

While Not KeyHit(1)
	RotateEntity cam,0,MouseX(),.3
	PositionEntity cam,0,0,0
	MoveEntity cam,0,0,-MouseY()*10.0
	UpdateWireMesh(cam,mesh)
	UpdateWorld
	RenderWorld
	Flip
Wend

End



Andy(Posted 2003) [#22]
My Geforce 256 DDR generally works with WF, but sometimes there are weird artifacts...

Andy