Countvertices()=-2?

Blitz3D Forums/Blitz3D Beginners Area/Countvertices()=-2?

Chaps,

I've been trying to make a buckyball. When I check the number of vertices in my risible mesh it says -2. Is that because I have put more than 1 triangle per vertex - or is that nothing to do with it?

Never had countvertices return a negative count. I think you must be doing something wrong. It should make no difference if triangles share vertices or not.

What's a buckyball btw?

Are you creating the mesh in code .. if so, can show an example?

Stevie

The number of vertices is more to do with a surface than a mesh (and I think Blitz3d has a limit of 65536 vertices per surface).

http://en.wikipedia.org/wiki/Buckyball

Woah! Having just seen what a buckyball is from octo's link, I'm guessing the problem is indeed that you've exceeded the vert limit. :P

That's bizarre, a molecule EXACTLY the same shape as a soccer ball that produces free radicals when it hits water, the football hooliganism parallels are scary to say the least.

Am I mistaken or have some replies been lost? Has the website been restored very recently?

It has been moved. There was an announcement on the front page that warned some posts would be lost in the process. At least it happened without a long downtime.

Ahh. I saw a coded solution here from a genius and got the gist. I found also a list of vertices on the net. Phi - indeedy!

Thanks. I got tears in my eyes. I wanna create a star stype object. Something that looks like its happenning. I'm one hell of a long way from achieving that but it's a step. 1 step. The buckyball.

I also found some very interesting information concerning relationships between the planets in our solar system when using the distance between Sol and Mercury as 1 astronomical unit instead Earth to Sol as is normal. All from searching google with Phi and Buckyball.

I'm not quite sure about shaving the donkey - It's the only valuable posession my family has but I'll try anything!

Funny really '-2 vertices'. Never mind - probably it's more like minus 2 braincells concerning my cretinous construction methods.

That was probably octothorpe. You might find this interesting. Not my code, I am not sure who wrote it, other than it was on the old blitzcoder forums, but it creates a geosphere of varying detail by subdivision of an Icosahedron. It may help you achieve your star. Change global detail to suit. I suspect the texturing bit needs some work. There is a paper by Gernot Hoffman on the subject which explains the process. He seems to know his onions.
http://www.fho-emden.de/~hoffmann/ikos27042002.pdf


Graphics3D 800,600,0,2

texture=CreateTexture(128,128)
SetBuffer TextureBuffer(texture)
inc=1
For i=0 To 128
c=c+inc If c=64 Then inc=-inc
Color 100+c*2,c*2,255-c*2
Rect i,0,1,128
Next
SetBuffer  BackBuffer()


Global planet=CreateMesh()
EntityTexture planet,texture
Global surf=CreateSurface(planet)

;setup isocahedron
v01=AddVertex(surf,0,-1,0):settexcoords(v01)	;top
v12=AddVertex(surf,0, 1,0):settexcoords(v12)	;bottom

h#=Sqr(5)/5
r#=2*h

v02=AddVertex(surf,Cos(72*0.0)*r,-h,Sin(72*0.0)*r):settexcoords(v02)
v03=AddVertex(surf,Cos(72*1.0)*r,-h,Sin(72*1.0)*r):settexcoords(v03)
v04=AddVertex(surf,Cos(72*2.0)*r,-h,Sin(72*2.0)*r):settexcoords(v04)
v05=AddVertex(surf,Cos(72*3.0)*r,-h,Sin(72*3.0)*r):settexcoords(v05)
v06=AddVertex(surf,Cos(72*4.0)*r,-h,Sin(72*4.0)*r):settexcoords(v06)

v07=AddVertex(surf,Cos(72*0.5)*r, h,Sin(72*0.5)*r):settexcoords(v07)
v08=AddVertex(surf,Cos(72*1.5)*r, h,Sin(72*1.5)*r):settexcoords(v08)
v09=AddVertex(surf,Cos(72*2.5)*r, h,Sin(72*2.5)*r):settexcoords(v09)
v10=AddVertex(surf,Cos(72*3.5)*r, h,Sin(72*3.5)*r):settexcoords(v10)
v11=AddVertex(surf,Cos(72*4.5)*r, h,Sin(72*4.5)*r):settexcoords(v11)


Global detail=1

;top
sub(v01,v02,v03,detail)
sub(v01,v03,v04,detail)
sub(v01,v04,v05,detail)
sub(v01,v05,v06,detail)
sub(v01,v06,v02,detail)

sub(v02,v07,v03,detail)
sub(v03,v08,v04,detail)
sub(v04,v09,v05,detail)
sub(v05,v10,v06,detail)
sub(v06,v11,v02,detail)

;bottom
sub(v12,v11,v10,detail)
sub(v12,v10,v09,detail)
sub(v12,v09,v08,detail)
sub(v12,v08,v07,detail)
sub(v12,v07,v11,detail)

sub(v08,v03,v07,detail)
sub(v09,v04,v08,detail)
sub(v10,v05,v09,detail)
sub(v11,v06,v10,detail)
sub(v07,v02,v11,detail)


Function sub(v1,v2,v3,layer)

	If layer>0 Then
		nx#=(VertexX(surf,v1)+VertexX(surf,v2))/2
		ny#=(VertexY(surf,v1)+VertexY(surf,v2))/2
		nz#=(VertexZ(surf,v1)+VertexZ(surf,v2))/2
		l#=Sqr(nx*nx+ny*ny+nz*nz)
		nx=nx/l:ny=ny/l:nz=nz/l
		n1=AddVertex(surf,nx,ny,nz):settexcoords(n1)

		nx#=(VertexX(surf,v2)+VertexX(surf,v3))/2
		ny#=(VertexY(surf,v2)+VertexY(surf,v3))/2
		nz#=(VertexZ(surf,v2)+VertexZ(surf,v3))/2
		l#=Sqr(nx*nx+ny*ny+nz*nz)
		nx=nx/l:ny=ny/l:nz=nz/l
		n2=AddVertex(surf,nx,ny,nz):settexcoords(n2)

		nx#=(VertexX(surf,v3)+VertexX(surf,v1))/2
		ny#=(VertexY(surf,v3)+VertexY(surf,v1))/2
		nz#=(VertexZ(surf,v3)+VertexZ(surf,v1))/2
		l#=Sqr(nx*nx+ny*ny+nz*nz)
		nx=nx/l:ny=ny/l:nz=nz/l
		n3=AddVertex(surf,nx,ny,nz):settexcoords(n3)

		sub(v1,n3,n1,layer-1)
		sub(v2,n1,n2,layer-1)
		sub(v3,n2,n3,layer-1)
		sub(n3,n2,n1,layer-1)
	Else
		AddTriangle(surf,v1,v2,v3)
	End If

End Function


camp1=CreatePivot()
camp2=CreatePivot(camp1)
camera=CreateCamera(camp2)
CameraRange camera,.1,3100
PositionEntity camera,0,1001,-30
PositionEntity camera,0,0,-2000
cdist=-2000
light=CreateLight(1):LightColor light ,255,240,230:AmbientLight 50,50,50
;LightMesh planet,255,255,255
EntityShininess planet,.1
RotateEntity planet,0,180,0

;RotateEntity light,5.234,54,456
ScaleEntity planet,1000,1000,1000
;If (detail Mod 2) Then FlipMesh planet
UpdateNormals planet
;HideEntity planet
;sphere=CreateSphere(18):ScaleEntity sphere,1000,1000,1000 	;+- equals detail lvl 3
;np=CreateSphere(4) :positionEntity np,0,-1000,0:ScaleEntity np,10,10,10	;poles
;sp=CreateSphere(4) :positionEntity sp,0,1000,0:ScaleEntity sp,10,10,10

SetBuffer BackBuffer()
While Not KeyHit(1)
	TurnEntity camp2,Float(MouseYSpeed())/10,0,0
	TurnEntity camp1,0,Float(MouseXSpeed())/10,0
	MoveMouse 400,300

	TurnEntity light,0,-.1,0

	cdist=cdist+MouseZSpeed()*10
	PositionEntity camera,0,0,cdist
	
	If KeyHit(57) Then w=Not w	WireFrame w
	time=MilliSecs()
	RenderWorld()
	time=MilliSecs()-time
	Text 10,10,CountVertices(surf)
	Text 10,20,CountTriangles(surf)
	;Text 10,20,CountTriangles(GetSurface(sphere,1))
	Text 10,30,(4^detail)*20
	Text 10,40,time
	Flip
	Cls
Wend
End

;	If layer=detail Then 
;		DebugLog(length(v1,v2))
;		DebugLog(length(v2,v3))
;		DebugLog(length(v3,v1))
;	End If
;Function length#(v1,v2)
;	Return Sqr((VertexX(surf,v1)-VertexX(surf,v2))^2+(VertexY(surf,v1)-VertexY(surf,v2))^2+(VertexZ(surf,v1)-VertexZ(surf,v2))^2)
;End Function

Function settexcoords(v)
	nx#=VertexX(surf,v):ny#=VertexY(surf,v):nz#=VertexZ(surf,v)
	theta#=ATan2(ny,Sqr(nx*nx+nz*nz))
	phi#=ATan2(nx,nz)
	VertexTexCoords(surf,v,-(phi+180)/360,-(theta+90)/180)	
End Function


Hmmm..... very tasty! Thanks again DJ. I may be some time...