Wireframe and Solid

Blitz3D Forums/Blitz3D Programming/Wireframe and Solid

Just a little demo I knocked up, inspired by a demo called 'Half and Half'
Decided to call it 'X Ray'


;Written by Colonel
;Copyright NRG STUDIO 2005

Const GW=800 GH=600

Graphics3D GW,GH,32,2
HidePointer

AppTitle "NRG Studio 2005 - XRay"

obj=CreateMesh()
s=CreateSurface(obj)

For m=-3 To 3 Step 3
	For n=-3 To 3 Step 3
		For o=-3 To 3 Step 3
			v0=AddVertex(s,m-1,n+1,o-1)
			v1=AddVertex(s,m+1,n+1,o-1)
			v2=AddVertex(s,m+1,n-1,o-1)
			v3=AddVertex(s,m-1,n-1,o-1)
			
			v4=AddVertex(s,m-1,n+1,o+1)
			v5=AddVertex(s,m+1,n+1,o+1)
			v6=AddVertex(s,m+1,n-1,o+1)
			v7=AddVertex(s,m-1,n-1,o+1)

			AddTriangle(s,v0,v1,v2)
			AddTriangle(s,v0,v2,v3)
			AddTriangle(s,v4,v6,v5)
			AddTriangle(s,v4,v7,v6)
			AddTriangle(s,v4,v0,v3)
			AddTriangle(s,v4,v3,v7)
			AddTriangle(s,v1,v5,v6)
			AddTriangle(s,v1,v6,v2)
			AddTriangle(s,v0,v4,v5)
			AddTriangle(s,v0,v5,v1)
			AddTriangle(s,v3,v2,v6)
			AddTriangle(s,v3,v6,v7)

		Next
	Next
Next
UpdateNormals obj

s=CreateSphere(8,obj)

c1=CreateCamera()

light=CreateLight()
RotateEntity light,45,45,45

PositionEntity c1,0,0,-15

i1=CreateImage(200,150) ;used for wireframe rendering

While Not KeyDown(1)	
	ang=ang+2
	PositionEntity s,8*Cos(ang),8*Sin(ang),0
	
	RotateEntity obj,ang/2,ang/2,ang/4
	
	x=300+299*Cos(ang/3)
	y=225+100*Sin(ang/3)
	
        ;Render and capture the wireframe image
	WireFrame True
	RenderWorld
	CopyRect x,y,200,150,0,0,BackBuffer(),ImageBuffer(i1)

	;Render the solid image
	WireFrame False
	RenderWorld
	
	DrawBlock i1,x,y
	
	;Draw an outline of the 'see through' window
	Line x,y,x+200,y
	Line x+200,y,x+200,y+150
	Line x+200,y+150,x,y+150
	Line x,y+150,x,y
	
	Flip
Wend
End


May be useful. More than likely not.

Well I liked it - I'm sure someone will find a use for it !

Yes this effect deos look good, but when used on many s at once it really slows down the whole programme

Nice to see that my work inspires others(well if it was my demo that you speak of), it helps me staying motivated to work on :)
(btw. my demo was made with B+ in case someone wanted to know)

The demo and others I have done can be found here:

http://democoders.zac-interactive.dk/

Thats pretty neat zarwan, col!

The 'Multi-Pass' Rendering Method can be applied to any entity effect or control. (ie EntityAlpha, EntityBlend, EntityColor, EntityTexture, etc)

Const GW=800 GH=600

Graphics3D GW,GH,32,2
HidePointer

AppTitle "Multi-Pass Rendering for Effects"

obj=CreateMesh()
s=CreateSurface(obj)

For m=-3 To 3 Step 3
	For n=-3 To 3 Step 3
		For o=-3 To 3 Step 3
			v0=AddVertex(s,m-1,n+1,o-1)
			v1=AddVertex(s,m+1,n+1,o-1)
			v2=AddVertex(s,m+1,n-1,o-1)
			v3=AddVertex(s,m-1,n-1,o-1)
			
			v4=AddVertex(s,m-1,n+1,o+1)
			v5=AddVertex(s,m+1,n+1,o+1)
			v6=AddVertex(s,m+1,n-1,o+1)
			v7=AddVertex(s,m-1,n-1,o+1)

			AddTriangle(s,v0,v1,v2)
			AddTriangle(s,v0,v2,v3)
			AddTriangle(s,v4,v6,v5)
			AddTriangle(s,v4,v7,v6)
			AddTriangle(s,v4,v0,v3)
			AddTriangle(s,v4,v3,v7)
			AddTriangle(s,v1,v5,v6)
			AddTriangle(s,v1,v6,v2)
			AddTriangle(s,v0,v4,v5)
			AddTriangle(s,v0,v5,v1)
			AddTriangle(s,v3,v2,v6)
			AddTriangle(s,v3,v6,v7)

		Next
	Next
Next
UpdateNormals obj

s=CreateSphere(8,obj)

c1=CreateCamera()

light=CreateLight()
RotateEntity light,45,45,45

PositionEntity c1,0,0,-15

i1=CreateImage(200,150) ;used for multi-pass rendering

While Not KeyDown(1)	
	ang=ang+2
	PositionEntity s,8*Cos(ang),8*Sin(ang),0
	RotateEntity obj,ang/2,ang/2,ang/4
	
	;Rect coords
	x=300+299*Cos(ang/3)
	y=225+100*Sin(ang/3)
	
    ;Effect State 1 ===================
	EntityColor(obj,255,0,0)
	;==================================
	
	RenderWorld() ;#1
	
	CopyRect x,y,200,150,0,0,0,ImageBuffer(i1)

	;Effect State 2 ===================
	EntityColor(obj,0,0,255)
	;==================================
	
	RenderWorld() ;#2
	
	DrawBlock i1,x,y
	
	Rect x,y,200,150,0
	
	Flip
Wend
End

I believe this is one of the principles behind shaders... not sure.

zawran:
It was your demo, yes. I tried to email this demo to you so you could use it for something, but the address on the website got returned as not a valid address! Never mind, it's in here now :)

The next demo, I feel people will like ;) watch this space...
Thanks to everyone else ;)


Cheers.

Sorry about the email being down, I am working on a completely new website, and I forgot all about keeping that email up. Sometime around the end of the month everything should be ready and people can start emailing me again :)

Looking forward to see what you bring out next :)