which it is a surface of a model ?

Blitz3D Forums/Blitz3D Programming/which it is a surface of a model ?

Yue(Posted 2016) [#1]
The following code returns me that cube has , besides two surfaces 25 vertices . I'm doing something wrong?

Graphics3D ( 800, 600, 32, 2 )
SetBuffer ( BackBuffer())


Local camara% = CreateCamera()
Local cubo%   = CreateCube()
Local luz%    = CreateLight()

PositionEntity cubo%, 0, 0, 10





While Not KeyDown(1)
	
	For s% = 1 To CountSurfaces(cubo)
	
		For v% = 0 To CountVertices(GetSurface(cubo%,s%))
		
			
		Next 	
			
			
	Next 	
		
		
	UpdateWorld()
	RenderWorld()
	Text 0, 0,s%
	Text 0, 20, v%
	Flip() 
	
Wend 




Rick Nasher(Posted 2016) [#2]
it should be:
For v% = 0 To CountVertices(GetSurface(cubo%,s%))-1

don't ask me why..

To quote Zethrax:
Note that vertex indexes are indexed starting at zero, so you will need to subtract one from the value returned by this function to use it as a For loop delimiter for indexing vertices.

Also note that surface indexes are indexed starting at one.


Also interesting:
CountTriangles(surface)
TrisRendered()




Yue(Posted 2016) [#3]
Thanks You :) , but I fail to understand that it is an area in a cube, also I think a cube has 25 vertices , I think it has less. I am somewhat confused ,.


Matty(Posted 2016) [#4]
Okay...

When you return the value of 'n' after a next statement it is always 1 more than the total number - this is because the value of 'n' in 'for n=1 to 10' has incremented 1 beyond the final value to escape the loop.

Secondly - a cube generated with createcube has 1 surface and 24 vertices because there are 6 sides with 4 vertices each. This is so that uv coordinates can exist for each side independently.

So for n = 1 to 24 will give a n value of 25 after exiting the for loop and for n = 1 to 1 will give an n value of 2 after exiting the for loop.

EDIT - typically it is bad form (or so I was taught in my only ever programming class in 1995) to test the value of a loop counter after exiting a loop as in most programming languages the loop counter has gone out of scope after that point.


Yue(Posted 2016) [#5]
Anyway, I see that the meshes are formed by surfaces , triangles and vertices. Which is a surface that serves several superfices have a model ?

I thought I had the bucket less vertices , the program had on me modeling and resulted eight vertices .


Floyd(Posted 2016) [#6]
The reason there are 24 vertices rather than 8 is that there are three sides meeting at each vertex. Normals, which determine how the mesh reacts to light, are at the vertices. If there was only one vertex at each corner of the cube then there would be only one normal and it would be the same for each side of the cube at that vertex.

So at each corner of the cube there must be three mesh vertices and three normals, one for each side.


Yue(Posted 2016) [#7]
@Floyd Thanks You :)