textured line between spheres

BlitzMax Forums/BlitzMax Beginners Area/textured line between spheres

Hi !
Is there a method to drawing this ? (the lines between the sphere) :

A textured poly (or quad) drawing between two spheres ? Don't know how to do this with bmax ! Need your ideas and code tips !!!

Note : the spheres are displayed at random position x,y on the screen.

Either a textured poly or break the connectors into small segments so you can just use rectangular images, add/subtract segments to extend it, and hide and extra behind the balls.

Drag a Shadded sphere along the path.

Drag a Shadded sphere along the path.


Are these lines supposed to be static, or also animate?

Rather than dragging a sphere (which would mean hundreds or thousands of sprites needing to be drawn), it might be the easiest to actually make sprite(s) that just contain a picture of (part of) the wobbly line, and rotate those at the correct angles. That way you can get the same effect with drawing just a couple of sprites which is bound to be significantly faster than dragging a sphere.

which would mean hundreds or thousands of sprites needing to be drawn


No it would mean one sprite drawn hundreds or thousands of times. But point taken. (my intention was to sudjest that it was created by dragging the sphere, and then the grab pasted, but hah, your right, just one "Hump" would be enough

Are these lines supposed to be static, or also animate?

better if animated.

i'm trying a textured poly function by Proger from the code archive. i can't draw a rectangle !
i'm searching a single textured line function (d3d and opengl compatible) ... Is someone know how to draw a textured line with this picture !!!

Thanks !

Hi !
don't understand 'Proger' (code archive) functions. Is there a way to adapt this code to produce only a textured line (with the image from the previous post) ?
Thanks for your help !!!

My try :
Strict

' TexturedPoly by Proger

'SetGraphicsDriver GLMax2DDriver()
Graphics 1024,780

Local Image:TImage = LoadImage("media/onde.png") ' 32x32 256x256 e.t.c

Local x1# = 100
Local y1# = 150
Local Largeur# = 32.00
MoveMouse GraphicsWidth()/2, GraphicsHeight()/2

Local xyuv:Float[] = [ ..
			x1#, y1#, 0.0, 1.0, ..
			Float (MouseX()), Float(MouseY()), 1.0, 1.0,  ..			
			Float(MouseX()) , Float(MouseY()) + Largeur# , 1.0, 0.0, ..
			x1#, y1#+Largeur# , 0.0 , 0.0 ]

While Not KeyDown (KEY_ESCAPE)

	Cls
	xyuv[4] = MouseX() 
	xyuv[5] = MouseY()
	xyuv[8] = MouseX() 	
	xyuv[9] = MouseY() + Largeur#
	SetBlend AlphaBlend
	DrawTexturedPoly Image , xyuv
	Flip
Wend

Function DrawTexturedPoly( image:TImage,xyuv#[],frame=0, vertex = -1)
	Local handle_x#,  handle_y#
	GetHandle handle_x#,  handle_y#
	Local origin_x#,  origin_y#
	GetOrigin origin_x#,  origin_y#	
	
	Local D3DDriver:TD3D7Max2DDriver = TD3D7Max2DDriver(_max2dDriver)
	
	Assert Image, "Image not found"
	
	If D3DDriver Then 
		DrawTexturedPolyD3D ..
			D3DDriver,..
			 TD3D7ImageFrame(image.Frame(frame)), ..
			 xyuv, handle_x, handle_y, origin_x,origin_y, vertex*4
		Return
	End If
	Local  OGLDriver:TGLMax2DDriver = TGLMax2DDriver(_max2dDriver)
	If OGLDriver Then
			DrawTexturedPolyOGL ..
				OGLDriver,..
				 TGLImageFrame(image.Frame(frame)), ..
				 xyuv, handle_x, handle_y, origin_x,origin_y,  vertex*4
		Return
	End If
End Function


Function DrawTexturedPolyD3D( Driver:TD3D7Max2DDriver,  Frame:TD3D7ImageFrame,xyuv#[],handlex#,handley#,tx#,ty# , vertex)
	If Driver.islost Return
	If xyuv.length<6 Return
	Local segs=xyuv.length/4
	Local len_ = Len(xyuv)
	
	If vertex > - 1 Then
		segs = vertex / 4
		len_ = vertex
	End If
	Local uv#[] = New Float[segs*6] ' 6
	

	Local c:Int Ptr=Int Ptr(Float Ptr(uv))
	
	Local ii:Int = 0
	For Local i=0 Until len_ Step 4
		Local x# =  xyuv[i+0]+handlex
		Local y# =  xyuv[i+1]+handley
		uv[ii+0] =  x*Driver.ix+y*Driver.iy+tx
		uv[ii+1] =  x*Driver.jx+y*Driver.jy+ty 
		uv[ii+2] =  0  ' *********** THIS IS THE Z-COORDINATE
		c[ii+3] = Driver.DrawColor
		uv[ii+4] =  xyuv[i+2]
		uv[ii+5] =  xyuv[i+3]
		ii:+6
	Next
	Driver.SetActiveFrame Frame
	Driver.device.DrawPrimitive(D3DPT_TRIANGLEFAN,D3DFVF_XYZ| D3DFVF_DIFFUSE | D3DFVF_TEX1,uv,segs,0)
End Function

Function DrawTexturedPolyOGL (Driver:TGLMax2DDriver, Frame:TGLImageFrame, xy#[],handle_x#,handle_y#,origin_x#,origin_y#, vertex) 
	Private
	Global TmpImage:TImage
	Public
	
	If xy.length<6 Return
	
	Local rot#  = GetRotation()
	Local tform_scale_x#, tform_scale_y#
	GetScale tform_scale_x, tform_scale_y
	
	Local s#=Sin(rot)
	Local c#=Cos(rot)
	Local ix= c*tform_scale_x
	Local iy=-s*tform_scale_y
	Local jx= s*tform_scale_x
	Local jy= c*tform_scale_y
	
	glBindTexture GL_TEXTURE_2D, Frame.name
	glEnable GL_TEXTURE_2D
	
	glBegin GL_POLYGON
	For Local i=0 Until Len xy Step 4
		If vertex > -1 And i >= vertex Then Exit
		Local x#=xy[i+0]+handle_x
		Local y#=xy[i+1]+handle_y
		Local u#=xy[i+2]
		Local v#=xy[i+3]
		glTexCoord2f u,v
		glVertex2f x*ix+y*iy+origin_x,x*jx+y*jy+origin_y
	Next
	glEnd
	If Not tmpImage Then tmpImage = CreateImage(1,1)
	DrawImage tmpImage, -100, - 100 ' Chtob zbit' flag texturi
End Function


is there a method to repeat the pattern of the texture along the line ???

Yup. Set the UV coord of the right side to a multiply of 1

DX UV Wrap

http://modules.indiepath.com/forum/viewtopic.php?t=11

That should do the trick, I think.


Yup. Set the UV coord of the right side to a multiply of 1



Local xyuv:Float[] = [ ..
			x1#, y1#, 0.0, 1.0, ..
			Float (MouseX()), Float(MouseY()), 5.0, 1.0,  ..			
			Float(MouseX()) , Float(MouseY()) + Largeur# , 5.0, 0.0, ..
			x1#, y1#+Largeur# , 0.0 , 0.0 ]

Is it ok ?

results with code from the previous post :


not really what's i want. this not repeat the pattern along the line !!!

DX UV Wrap
?

You have to switch on texture wrapping which is off by default. Not sure how tho

DX BLOOMING UV CHUFFING WRAP

@tonyg. Nice code but is there a solution also with opengl ?

Don't do much OGL but, I thought, extending beyond 1.0 made the texture wrap.
OGL comment