Getting Wireframe to be both on and off

Blitz3D Forums/Blitz3D Beginners Area/Getting Wireframe to be both on and off

fox95871(Posted 2009) [#1]
Okay, I know that's not possible. But does anyone know of someone ever trying to achieve the same effect? I was thinking maybe, with Wireframe off, draw a 2D line between the 3D screen positions of the different vertexes and continually update it with Cls and Line. I don't know quite where to start though, specifically what commands to use to get the coordinates to begin with, or how to convert them to 2D exactly.

I do have a good reason for this project, I'm going to make some Maya mode 5 type effects if that motivates anyone to help.


Kryzon(Posted 2009) [#2]
You can create lines that would represent the edges of your model. There are some nice "3D lines" examples at the Code Archives:

http://blitzbasic.com/codearcs/codearcs.php?code=839

http://blitzbasic.com/codearcs/codearcs.php?code=1184

Run the first one, it shows very easily how to use it.
Make sure to thank the authors of whatever code you might use!


puki(Posted 2009) [#3]
The FastExtension lib will allow you to actually have wireframe both on and off at the same time:



http://fastlibs.com


GfK(Posted 2009) [#4]
Okay, I know that's not possible.
Sure it is. Do a 2-pass render. The first 'normal' render, and the second render in wireframe mode with colour/z-buffer clearing disabled (ref: CameraClsMode).


_PJ_(Posted 2009) [#5]
Sure it is. Do a 2-pass render. The first 'normal' render, and the second render in wireframe mode with colour/z-buffer clearing disabled (ref: CameraClsMode).


This is a technique I've used, it's nowhere near as slow as I imagined it would be, and gives a very pleasing result.


GIB3D(Posted 2009) [#6]
Wow Malice that didn't sound right...
gives a very pleasing result

Handcuffed to a keyboard.


I just HAD to say something.


fox95871(Posted 2009) [#7]
Will that fastlibs thing mess up my copy of Blitz3D or make it so I can't use Blitz media linker for final exes?


puki(Posted 2009) [#8]
If your Blitz3D version is lower than V1.101 then you should be fine (certainly with recent versions, other than the most recent). Having said that, we expect the new version of FastExtension to work with Blitz3D V1.101.

I have no idea as to Blitz Media Linker - although, I would expect no problems at all with it.


AJ00200(Posted 2009) [#9]
Okay, I know that's not possible


It is on a quantum computer!


_PJ_(Posted 2009) [#10]

Wow Malice that didn't sound right...

gives a very pleasing result



Handcuffed to a keyboard.



I just HAD to say something.


HAhahah!

What can I say? I like programming :D


Matty(Posted 2009) [#11]
Listen to GfK and ignore the 'noise' results in this thread.


fox95871(Posted 2009) [#12]
I'm not having any luck with any of them. They're all floating code you have to paste together and hope it works, and then they don't. Thanks for trying to help, but could someone just make me a small complete program of a CreateMesh cube with solid polygons and lines please? I'm so busy!


_PJ_(Posted 2009) [#13]
Now ythat you mention it, I have tried doing what I know I've done before, and what Gfk suggested, and it doesn't seem to work now :S - strange. Unless Gfk (or someone else maybe) has a different method?

Anyway, how's trhis for memory? As I thought back to when I wanted something similar, there was anotgher topic around at the time.

Skidracer posted this which I hope is helpful:

; 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



fox95871(Posted 2009) [#14]
I just got around to trying all these. Gfk, your suggesion in post 4 is the one I ended up using. Seeing the lines go diagonally across the faces of the cube would be my one gripe, but it's better than it was, which was no lines at all! Thanks for the help.