From 2afd44a7ba2c1d8b9c162ab9c6ccdfbd9f1310c0 Mon Sep 17 00:00:00 2001 From: Ian C Date: Wed, 24 Aug 2005 00:25:34 +0000 Subject: Changed typenames to Blitz standard naming. Added unimplemented TVector. --- glflag.mod/.cvsignore | 3 + glflag.mod/glflag.bmx | 184 ++++++++++++++++++++++++-------------------------- 2 files changed, 91 insertions(+), 96 deletions(-) create mode 100644 glflag.mod/.cvsignore (limited to 'glflag.mod') diff --git a/glflag.mod/.cvsignore b/glflag.mod/.cvsignore new file mode 100644 index 0000000..22829cb --- /dev/null +++ b/glflag.mod/.cvsignore @@ -0,0 +1,3 @@ +glflag.release.win32.i +glflag.debug.win32.i +.bmx \ No newline at end of file diff --git a/glflag.mod/glflag.bmx b/glflag.mod/glflag.bmx index 5b62530..e0993cf 100644 --- a/glflag.mod/glflag.bmx +++ b/glflag.mod/glflag.bmx @@ -12,16 +12,27 @@ Import pub.OpenGL Strict -Type GLFlag +Type TGLFlag + ' These are public and can be used to modify the flag + ' + Field xpos:Float + Field ypos:Float + Field zpos:Float + Field xrot:Float + Field yrot:Float + Field zrot:Float + ' These are considered private ' - Const THRESHOLD:Float=0.0001 - Field v:GLFlagVertex[,] + Global static:Int=False + Global si:Float[]=Null + Field v:TGLFlagVertex[,] + Field cell:Int + Field move:Int Field width:Int Field height:Int Field txt:Int - Field zpos:Float ' Creates a new flag ' @@ -34,20 +45,36 @@ Type GLFlag ' ' Returns null for invalid parameters. ' - Function Create:GLFlag(texture:Int, horiz:Int, vert:Int, size:Float, tile:Int, z:Float) - Local o:GLFlag + Function Create:TGLFlag(texture:Int, horiz:Int, vert:Int, size:Float, tile:Int, z:Float) + Local o:TGLFlag If (horiz<2 Or vert<2) Return Null EndIf - o=New GLFlag + o=New TGLFlag - o.txt=texture + If (Not o.static) + o.si=New Float[3600] + For Local a:Float=0 Until 3600 + o.si[a]=Sin(a/10) + Next + o.static=True + EndIf + + o.xpos=0 + o.ypos=0 o.zpos=z + o.xrot=0 + o.yrot=0 + o.zrot=0 + + o.txt=texture o.width=horiz o.height=vert - o.v=New GLFlagVertex[horiz,vert] + o.cell=size + o.move=size/2 + o.v=New TGLFlagVertex[horiz,vert] Local ox:Float Local oy:Float @@ -57,8 +84,10 @@ Type GLFlag For Local x=0 Until horiz For Local y=0 Until vert - Local v:GLFlagVertex=New GLFlagVertex - v.Set(ox+x*size,oy+y*size,0) + Local v:TGLFlagVertex=New TGLFlagVertex + v.x=ox+x*size + v.y=oy+y*size + v.z=0 If (tile) v.u=(x&1) @@ -77,122 +106,85 @@ Type GLFlag ' Call to render the flag ' - ' dampen - Scale to dampen movements by when bouncing movement - ' friction - Scale to slow down movements - ' - Method Render(dampen:Float=1.0, friction:Float=0.95) + Method Render() glPushMatrix() - glTranslatef(0,0,zpos) + glTranslatef(xpos,ypos,zpos) + glRotatef(xrot,1,0,0) + glRotatef(yrot,0,1,0) + glRotatef(zrot,0,0,1) glBindTexture(GL_TEXTURE_2D,txt) - For Local vert:GLFlagVertex=EachIn v - If (vert.xi<>0 Or vert.yi<>0 Or vert.zi<>0) - Local s:Float - - s=Sgn(vert.xi) - vert.xi:*friction - If (Abs(vert.xi)