Create a vertex

Blitz3D Forums/Blitz3D Beginners Area/Create a vertex

Ben(t)(Posted 2007) [#1]
Hi I'm still new to this even though I've been programming for almost 2 years, I want to create a circular entity that only has one side, like what the portal game is doing, how do I create a half sphere object?


big10p(Posted 2007) [#2]
http://www.blitzbasic.com/codearcs/codearcs.php?code=639


Ben(t)(Posted 2007) [#3]
that does not help much though, it sill gives me a full sphere but it has been flattened, I only want one side of the sphere at all


Stevie G(Posted 2007) [#4]
Probably not perfect for all segment levels but works with the default of 8 ...

Stevie

Graphics3D 640,480,16,1

light = CreateLight() : RotateEntity light, 30,-45,0
camera = CreateCamera() : PositionEntity camera, 0,0,-3

ss = SEMI_SPHERE() : EntityFX ss, 4

While Not KeyDown(1)

	TurnEntity ss, 1,0,-1
	RenderWorld()
	
	Flip

Wend

End

;==============================================================

Function SEMI_SPHERE()

	temp = CreateSphere()
	ts = GetSurface( temp, 1 )

	mesh = CreateMesh()
	s = CreateSurface( mesh )
	
	For t = 0 To CountTriangles( ts ) - 1
	
		v0 = TriangleVertex( ts, t , 0 )
		v1 = TriangleVertex( ts, t , 1 )
		v2 = TriangleVertex( ts, t , 2 )
		 
		If VertexY( ts, v0 ) > 0 Or VertexY( ts, v1) > 0 Or VertexY( ts, v2 ) > 0
			nv0 = AddVertex( s, VertexX( ts, v0 ) , VertexY( ts, v0 ) , VertexZ( ts, v0 ) )
			nv1 = AddVertex( s, VertexX( ts, v1 ) , VertexY( ts, v1 ) , VertexZ( ts, v1 ) )
			nv2 = AddVertex( s, VertexX( ts, v2 ) , VertexY( ts, v2 ) , VertexZ( ts, v2 ) )
			VertexNormal s, nv0, VertexNX( ts, v0 ) , VertexNY( ts, v0 ), VertexNZ( ts, v0 )
			VertexNormal s, nv1, VertexNX( ts, v1 ) , VertexNY( ts, v1 ), VertexNZ( ts, v1 )
			VertexNormal s, nv2, VertexNX( ts, v2 ) , VertexNY( ts, v2 ), VertexNZ( ts, v2 )
			AddTriangle ( s, nv0, nv1, nv2 )
		EndIf
		
	Next
	
	FreeEntity temp
	
	Return mesh
	
End Function 



big10p(Posted 2007) [#5]
that does not help much though, it sill gives me a full sphere but it has been flattened, I only want one side of the sphere at all
Eh? No it doesn't - it creates a hemisphere, which is what I thought you wanted.


chwaga(Posted 2007) [#6]
I think he means he wants a stretched out circle shape... or stretched out semi-circle


Stevie G(Posted 2007) [#7]
You could explain yourself a bit better with a picture ..


chwaga(Posted 2007) [#8]
if you mean what I think you mean, It's be most productive to use a sprite with a masked texture


Ben(t)(Posted 2007) [#9]
okay so I want a round one sided shape, that link you gave me to that code big10p takes half of the vertexes and places them on the reverse side of the other half of the sphere. but the sphere still has all it's vertexes

I need a oval shape which is one sided, so if I was behind it it would be invisible.


Stevie G(Posted 2007) [#10]
Try this ...

This example creates a filled circle of radius 100 :

SUN = MESHring( 0 , 100 , 7.5,7.5, 15 )

This example creates a hollow circle with inner radius of 4 and outer radius of 5 :

CURSOR = MESHring( 4,5,15,15, 30 )

Try this also ..

POINTER = MESHring( 20 , 25 , 0,5,90 )

Function MESHring( Min# , Max#, MinA#, MaxA#, Segs = 30 )

	mesh = CreateMesh()
	s = CreateSurface( mesh )

	Closed = ( MinA = MaxA And MinA = Segs * .5 )
	For a = 1 To 360 
		If ( a Mod segs ) = 0
			If ( Not Closed )
				v0 = AddVertex( s, Max * Cos( a - MaxA ) , Max * Sin( a - MaxA ) , 0 )
				v1 = AddVertex( s, Max * Cos( a + MaxA ) , Max * Sin( a + MaxA ) , 0 )
				v2 = AddVertex( s, Min * Cos( a + MinA ) , Min * Sin( a + MinA ) , 0 )
				v3 = AddVertex( s, Min * Cos( a - MinA ) , Min * Sin( a - MinA ) , 0 )
				AddTriangle s, v2, v1, v0
				AddTriangle s, v0, v3, v2
			Else
				AddVertex( s, Max * Cos( a ) , Max * Sin( a ) , 0 )
				AddVertex( s, Min * Cos( a ) , Min * Sin( a ) , 0 )
			EndIf
		EndIf				
	Next	

	If Closed
		Points = 360.0 / Segs
		For l = 0 To Points - 1
			n = ( l + 1 ) Mod Points
			V0 = l * 2
			V1 = V0+1
			V3 = n * 2
			V2 = v3 + 1	
			AddTriangle s, v0, v1, v2
			AddTriangle s, v2, v3, v0
		Next
	EndIf	

	Return Mesh	

End Function