Procedural Programming Competition Final Rules

Blitz3D Forums/Blitz3D Programming/Procedural Programming Competition Final Rules

Yeah, this a great open source contest. They should make a special section in the code archives for it, seeing there's no external content.

I'm think about seeing if I can find some sponsers for another compition like this one. This has been a lot of fun! Maybe next time we can have some actual prizes!

Here's a code donation from my project. Had to make some extended primitives.

Function CreateWedge(ParentEntity=0)
	wedge=CreateMesh()
	surf=CreateSurface(wedge)
	;Sides
	v1=AddVertex(surf,-1,-1,1,0,1)
	v2=AddVertex(surf,-1,1,-1,1,0)
	v3=AddVertex(surf,-1,-1,-1,1,1)
	AddTriangle(surf,v1,v2,v3)
	v4=AddVertex(surf,1,-1,1,1,1)
	v5=AddVertex(surf,1,1,-1,0,5)
	v6=AddVertex(surf,1,-1,-1,0,1)
	AddTriangle(surf,v6,v5,v4)

	;back
	v1=AddVertex(surf,-1,1,-1,0,0)
	v2=AddVertex(surf,1,1,-1,1,0)
	v3=AddVertex(surf,1,-1,-1,1,1)
	v4=AddVertex(surf,-1,-1,-1,0,1)
	AddTriangle(surf,v1,v2,v3)
	AddTriangle(surf,v1,v3,v4)

	;Wedge
	v1=AddVertex(surf,-1,-1,1,1,1)
	v2=AddVertex(surf,1,-1,1,0,1)
	v3=AddVertex(surf,1,1,-1,0,0)
	v4=AddVertex(surf,-1,1,-1,1,0)
	AddTriangle(surf,v1,v2,v3)
	AddTriangle(surf,v1,v3,v4)

	;Bottom
	v1=AddVertex(surf,-1,-1,1,0,1)
	v2=AddVertex(surf,1,-1,1,1,1)
	v3=AddVertex(surf,1,-1,-1,1,0)
	v4=AddVertex(surf,-1,-1,-1,0,0)
	AddTriangle(surf,v3,v2,v1)
	AddTriangle(surf,v3,v1,v4)

	UpdateNormals wedge
	EntityFX wedge,4
	If ParentEntity > 0 Then EntityParent(wedge,ParentEntity)
	Return wedge
End Function

Function CreateSquare(Axis=3,ParentEntity = 0)
;Axis X =1 , Y=2, Z=3
	Square=CreateMesh()
	surf=CreateSurface(Square)
	;Bottom
	v1=AddVertex(surf,-1,0,-1,0,0)
	v2=AddVertex(surf,1,0,-1,1,0)
	v3=AddVertex(surf,1,0,1,1,1)
	v4=AddVertex(surf,-1,0,1,0,1)
	If Axis = 1 Then
		RotateMesh Square,0,0,90
	Else If Axis = 3 Then
		RotateMesh Square,-90,0,0
	End If
	AddTriangle(surf,v3,v2,v1)
	AddTriangle(surf,v3,v1,v4)
	UpdateNormals Square
	EntityFX Square,4
	If ParentEntity > 0 Then EntityParent(Square,ParentEntity)
	Return Square
End Function

Dim Prim_Circle(0)

Function CreateCircle(Segments = 12,Axis=3,ParentEntity = 0)
;Axis X =1 , Y=2,  Z=3
	Circle=CreateMesh()
	surf=CreateSurface(Circle)
	;Bottom
	Dim Prim_Circle(Segments)
	Prim_Circle(0) = AddVertex(surf,0,0,0,.5,.5)
	For S = 1 To Segments
		Angle# = (360/Segments) * (S-1)
		U# = Sin(Angle#)/2 + .5
		V# = Cos(Angle#+180)/2 + .5
		Prim_Circle(S)=AddVertex(surf,Sin(Angle#),0,Cos(Angle#),U,V)
		If s>1 Then
			AddTriangle(surf,Prim_Circle(0),Prim_Circle(s-1),Prim_Circle(s))
		End If 
	Next
	AddTriangle(surf,Prim_Circle(0),Prim_Circle(Segments),Prim_Circle(1))
	
	If Axis = 1 Then
		RotateMesh Circle,0,0,90
	Else If Axis = 3 Then
		RotateMesh Circle,-90,0,0
	End If

	UpdateNormals Circle
	EntityFX Circle,4
	If ParentEntity > 0 Then EntityParent(Circle,ParentEntity)
	Return Circle
End Function