Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - mike_g

Pages: [1] 2 3 4 5 6 7 8 ... 18
1
C / C++ /C# / Re: Trying to optimise fadeout
« on: July 18, 2008 »
Cool. I have wanted to learn how to use the MMX registers sometime. Its just something I  havent got around to doing. I'll come back to this later on ;)

2
C / C++ /C# / Re: Trying to optimise fadeout
« on: July 18, 2008 »
Oh yeah,  *256 was the wy to do it. Cheers dude I got > 100fps now :)

3
C / C++ /C# / Trying to optimise fadeout
« on: July 18, 2008 »
Hi, I have a fadeout effect, but its too slow o my eeepc. I get 15fps :/ I have a fast version ,commented out, but it fades out too quickly. The bottleneck seems to be the floating point maths and the type casting. Heres the code:

Code: [Select]
void blit_and_fade(float mod)
{
int i, size = GRAPHICS_W*GRAPHICS_H;
Uint32 *pix = (Uint32*)screen->pixels;
Uint32 *buf = buffer;
Uint32 r_b, g;

for(i=0; i<size; i++, pix++, buf++)
{
*pix = *buf;
r_b = (Uint32)((*buf & 0x00FF00FF) * mod) & 0x00FF00FF;
g   = (Uint32)((*buf & 0x0000FF00) * mod) & 0x0000FF00;
*buf = r_b | g;
//*buf = (*buf >> 1) & 8355711; // <- FAST FADE LOOKS CRAP
}
}
Any suggestion how I coud do this w/o the floating point? Cheers.

4
Well I just found out what my problem was. I was using ints where I needed floats >_<

5
The code posted scaled from the centeriod, but I tried scaling it from the point of origin too (IE: top left of the screen). I dont know whats was wrong with my code, but I'll go over it again later on.

6
Hi, and thanks for the input, links and stuff. I have been playing around with this for a little bit but still no success.

Yeah they are just sequence of quadratic curves. I would have thought that it would be straight forward myself. TBH I don't know why just sacling all the points is not working for me. I'll have a play around with it a bit more and get back to you about it.

Cheers.

7
Blitz / Re: Messy Spline Thing [BB2D]
« on: July 11, 2008 »
cheers, guys.

8
Hi, I'm having some problems zooming and rotating splines.

Basically there are two types of points thats easiest to show this pic:


Even numbered, red, points are for the start and end of a line.
Odd numbered, blue, points set the angle of the curve.

The way I am going about it is to first move all the red points (which I can do). Once the red points have been moved I run through the blue points. I need to place them at the location at which the light blue lines in the pic intersect. I'm a bit confused with the maths tho. Does anyone know how I should go about this?

Heres an example of my unfinished function in Blitz code:
Code: [Select]
Function ZoomSpline(s.spline, zoom)

For i=0 To s\size-1
cx = cx + s\pts[i]\x
cy = cy + s\pts[i]\y
Next
cx = cx / s\size
cy = cy / s\size

For i=0 To s\size-1  Step 2 ;line terminator points
dx# = s\pts[i]\x - cx
dy# = s\pts[i]\y - cy
angle# = ATan2(dy#, dx#)
s\pts[i]\x = s\pts[i]\x + Cos(angle#)*zoom
s\pts[i]\y = s\pts[i]\y + Sin(angle#)*zoom
Next

For i=1 To s\size-2 Step 2 ;angle points

Next
End Function
Cheers. 

9
Nice little intro. The colored text and bars remind me of one I had on an old Amiga disc.

10
Blitz / Re: Messy Spline Thing [BB2D]
« on: July 10, 2008 »
Thanks man, I still have a lot of work to do on the editor, but if I can get that finished I'd like to make a C library that will basically do a load of different kinds of effects and stuff from the splines. This was done in Blitz because its quick and easy :)

11
Blitz / Re: Messy Spline Thing [BB2D]
« on: July 10, 2008 »
Sure dude, here you go: Link

12
Blitz / Re: Messy Spline Thing [BB2D]
« on: July 10, 2008 »
Ok the first one sucked. Heres a prettier version using a spline made in the editor:
Code: [Select]
;******************************************************************;
;----------------------- DATA TYPES REQUIRED ----------------------;
;******************************************************************;
Const MAX_SPLINE_SIZE = 1000
Const CURVE_DETAIL = 50

Type point
Field x, y
End Type

Type spline
Field size
Field pts.point[MAX_SPLINE_SIZE]
End Type

;Temp array for holding points used in spline constructor
Dim temp.point(MAX_SPLINE_SIZE)


Const RUNNER_SIZE = 12

Type runner
Field x, y
Field s.spline
Field pos[RUNNER_SIZE]
Field loc
End Type

;******************************************************************;
;------------------------- FUNCTIONS USED -------------------------;
;******************************************************************;

Function NewPoint.point(x, y)
Local p.point = New point
p\x = x
p\y = y
Return p
End Function

Function NewSpline.spline()
Local s.spline = New spline
Local i = 0
While(temp.point(i) <> Null)
s\pts.point[i] = temp.points(i)
i = i + 1
If(i = MAX_SPLINE_SIZE) Then Exit
Wend
s\size = i
Return s
End Function

Function DrawSpline(s.spline)
i=0
While(s\pts.point[i+2] <> Null)
BezierCurve(s\pts.point[i], s\pts.point[i+1], s\pts.point[i+2])
i=i+2
Wend
End Function

Function BezierCurve(p1.point, p2.point, p3.point)
For i = 0 To CURVE_DETAIL
ptx1 = p1\x+scroll_x: pty1 = p1\y+scroll_y
ptx2 = p2\x+scroll_x: pty2 = p2\y+scroll_y
ptx3 = p3\x+scroll_x: pty3 = p3\y+scroll_y
x1 = QuadraticBezier(i-1, ptx1, ptx2, ptx3)
y1 = QuadraticBezier(i-1, pty1, pty2, pty3)
x2 = QuadraticBezier(i  , ptx1, ptx2, ptx3)
y2 = QuadraticBezier(i  , pty1, pty2, pty3)
Line x1, y1, x2, y2
Next
End Function


Function QuadraticBezier(Perc#,p1#,p2#,p3#)
d1#=(((p2-p1)*perc)/CURVE_DETAIL)+p1
d2#=(((p3-p2)*perc)/CURVE_DETAIL)+p2
d3#=(((d2-d1)*perc)/CURVE_DETAIL)+d1
Return d3
End Function


Function CubicBezier(perc#,p1#,p2#,p3#,p4#)
d1#=(((p2-p1)*perc)/CURVE_DETAIL)+p1
d2#=(((p3-p2)*perc)/CURVE_DETAIL)+p2
d3#=(((p4-p3)*perc)/CURVE_DETAIL)+p3
d4#=QuadraticBezier(perc,d1,d2,d3)
Return d4
End Function



;******************************************************************;
;--------------------------- TEST PROGRAM -------------------------;
;******************************************************************;

Graphics 800,600,32, 1
SetBuffer BackBuffer()
SeedRnd MilliSecs()

Read size
For i=0 To size
Read x
Read y
temp.point(i) = NewPoint(x, y)
Next

s.spline = NewSpline()
For a = 0 To 9
f.runner = CreateRunner(s)
f\loc = a*4
Next
Global hold = -1 ;indicates which point is held
Global scroll_x=0, scroll_y=0

While Not KeyHit(1)
Runner()
Flip
Wend

;********************************************************************;
;--------------------------- EXTRA FUNCTIONS ------------------------;
;********************************************************************;
Function CreateRunner.runner(s.spline)
Local n.runner = New runner
n\x = s\pts.points[0]\x
n\y = s\pts.points[0]\y
n\s = s
n\loc = 0
For i = 0 To RUNNER_SIZE
n\pos[i]=i
Next
Return n
End Function


Function Runner()
For r.runner = Each runner
DrawRunner(r)
RunnerDot(r.runner)

Next
End Function

Function DrawRunner(r.runner)
overlap = False

For i= 0 To RUNNER_SIZE-1
rd = rd+10
gr = gr+8
bl = bl+5
If overlap = False
If r\pos[i] < r\pos[i+1]
ptx1 = r\s\pts[r\loc]\x: pty1 = r\s\pts[r\loc]\y
ptx2 = r\s\pts[r\loc+1]\x: pty2 = r\s\pts[r\loc+1]\y
ptx3 = r\s\pts[r\loc+2]\x: pty3 = r\s\pts[r\loc+2]\y
If i < RUNNER_SIZE-1
x1 = QuadraticBezier(r\pos[i], ptx1, ptx2, ptx3)
y1 = QuadraticBezier(r\pos[i], pty1, pty2, pty3)
x2 = QuadraticBezier(r\pos[i+1] , ptx1, ptx2, ptx3)
y2 = QuadraticBezier(r\pos[i+1] , pty1, pty2, pty3)
Color rd, gr, bl: Line x1, y1, x2, y2
EndIf

Else ; switchover
overlap = True
If r\loc+4 >= r\s\size  ;End of spline
r\loc=0
Return
EndIf
ptx1 = r\s\pts[r\loc]\x: pty1 = r\s\pts[r\loc]\y
ptx2 = r\s\pts[r\loc+1]\x: pty2 = r\s\pts[r\loc+1]\y
ptx3 = r\s\pts[r\loc+2]\x: pty3 = r\s\pts[r\loc+2]\y
x1 = QuadraticBezier(r\pos[i], ptx1, ptx2, ptx3)
y1 = QuadraticBezier(r\pos[i], pty1, pty2, pty3)
x2 = r\s\pts[r\loc+2]\x
y2 = r\s\pts[r\loc+2]\y
Color rd, gr, bl: Line x1, y1, x2, y2
EndIf
Else
If r\loc+4 >= r\s\size  ;End of spline
r\loc=0
Return
EndIf

ptx1 = r\s\pts[r\loc+2]\x: pty1 = r\s\pts[r\loc+2]\y
ptx2 = r\s\pts[r\loc+3]\x: pty2 = r\s\pts[r\loc+3]\y
ptx3 = r\s\pts[r\loc+4]\x: pty3 = r\s\pts[r\loc+4]\y
If i < RUNNER_SIZE-1
x1 = QuadraticBezier(r\pos[i], ptx1, ptx2, ptx3)
y1 = QuadraticBezier(r\pos[i], pty1, pty2, pty3)
x2 = QuadraticBezier(r\pos[i+1] , ptx1, ptx2, ptx3)
y2 = QuadraticBezier(r\pos[i+1] , pty1, pty2, pty3)
Color rd, gr, bl: Line x1, y1, x2, y2
EndIf
EndIf

Next



For i= 0 To RUNNER_SIZE
r\pos[i] = r\pos[i]+1
If r\pos[i] = CURVE_DETAIL Then r\pos[i]=0
Next

If r\pos[0] = 0
r\loc=r\loc+2
EndIf

End Function


Function RunnerDot(r.runner)
overlap = False
For i=0 To RUNNER_SIZE-1
If r\pos[i] > r\pos[i+1] Then overlap = True
Next

If overlap = False
ptx1 = r\s\pts[r\loc]\x: pty1 = r\s\pts[r\loc]\y
ptx2 = r\s\pts[r\loc+1]\x: pty2 = r\s\pts[r\loc+1]\y
ptx3 = r\s\pts[r\loc+2]\x: pty3 = r\s\pts[r\loc+2]\y
Else If r\loc+4 < r\s\size
ptx1 = r\s\pts[r\loc+2]\x: pty1 = r\s\pts[r\loc+2]\y
ptx2 = r\s\pts[r\loc+3]\x: pty2 = r\s\pts[r\loc+3]\y
ptx3 = r\s\pts[r\loc+4]\x: pty3 = r\s\pts[r\loc+4]\y
EndIf

x2 = QuadraticBezier(r\pos[RUNNER_SIZE] , ptx1, ptx2, ptx3)
y2 = QuadraticBezier(r\pos[RUNNER_SIZE] , pty1, pty2, pty3)




Color 255, 0, 0
Oval x2-1, y2-1, 3, 3, 1

End Function


Data 52, 100, 180, 10, 120, 60, 90, 40, 120, 100, 180, 60, 120, 80, 90, 70, 120, 100, 180, 130, 120, 120, 90, 140, 120, 100, 180, 160, 120, 140, 90, 190, 120, 100, 180, 20, 140, 30, 180, 37, 209, 70, 210, 30, 190, 60, 180, 80, 180, 100, 190, 120, 180, 150, 180, 180, 190, 130, 210, 170, 210, 180, 180, 189, 151, 100, 180, 110, 260, 90, 290, 20, 420, 50, 480, 130, 330, 190, 350, 218, 359, 160, 410, 110, 450, 220, 370, 244, 352, 170, 320, 142, 308, 50, 480, 20, 430, 50, 340, 59, 311, 20, 270, 60, 270, -21, 226

13
Blitz / Messy Spline Thing [BB2D]
« on: July 10, 2008 »
I'm working on a spline editor in Java atm. I made an effect with lines following a load of randomly generated lines. Looks like scribbling at the moment. Hopefully It should look better when the paths are laid out in a nice pattern. Cheers.
Code: [Select]
;******************************************************************;
;----------------------- DATA TYPES REQUIRED ----------------------;
;******************************************************************;
Const MAX_SPLINE_SIZE = 100
Const CURVE_DETAIL = 300

Type point
Field x, y
End Type

Type spline
Field size
Field pts.point[MAX_SPLINE_SIZE]
End Type

;Temp array for holding points used in spline constructor
Dim temp.point(MAX_SPLINE_SIZE)


Const RUNNER_SIZE = 12

Type runner
Field x, y
Field s.spline
Field pos[RUNNER_SIZE]
Field loc
End Type

;******************************************************************;
;------------------------- FUNCTIONS USED -------------------------;
;******************************************************************;

Function NewPoint.point(x, y)
Local p.point = New point
p\x = x
p\y = y
Return p
End Function

Function NewSpline.spline()
Local s.spline = New spline
Local i = 0
While(temp.point(i) <> Null)
s\pts.point[i] = temp.points(i)
i = i + 1
If(i = MAX_SPLINE_SIZE) Then Exit
Wend
s\size = i
Return s
End Function

Function DrawSpline(s.spline)
i=0
While(s\pts.point[i+2] <> Null)
BezierCurve(s\pts.point[i], s\pts.point[i+1], s\pts.point[i+2])
i=i+2
Wend
End Function

Function BezierCurve(p1.point, p2.point, p3.point)
For i = 0 To CURVE_DETAIL
ptx1 = p1\x+scroll_x: pty1 = p1\y+scroll_y
ptx2 = p2\x+scroll_x: pty2 = p2\y+scroll_y
ptx3 = p3\x+scroll_x: pty3 = p3\y+scroll_y
x1 = QuadraticBezier(i-1, ptx1, ptx2, ptx3)
y1 = QuadraticBezier(i-1, pty1, pty2, pty3)
x2 = QuadraticBezier(i  , ptx1, ptx2, ptx3)
y2 = QuadraticBezier(i  , pty1, pty2, pty3)
Line x1, y1, x2, y2
Next
End Function


Function QuadraticBezier(Perc#,p1#,p2#,p3#)
d1#=(((p2-p1)*perc)/CURVE_DETAIL)+p1
d2#=(((p3-p2)*perc)/CURVE_DETAIL)+p2
d3#=(((d2-d1)*perc)/CURVE_DETAIL)+d1
Return d3
End Function


Function CubicBezier(perc#,p1#,p2#,p3#,p4#)
d1#=(((p2-p1)*perc)/CURVE_DETAIL)+p1
d2#=(((p3-p2)*perc)/CURVE_DETAIL)+p2
d3#=(((p4-p3)*perc)/CURVE_DETAIL)+p3
d4#=QuadraticBezier(perc,d1,d2,d3)
Return d4
End Function



;******************************************************************;
;--------------------------- TEST PROGRAM -------------------------;
;******************************************************************;
Const VIDEO_MODE = 2
Graphics 1024,768,32, VIDEO_MODE
SetBuffer BackBuffer()
SeedRnd MilliSecs()

Const PALETTE_SIZE = 512
Dim palette(PALETTE_SIZE)
Local rd#, g#, b#
For i=0 To PALETTE_SIZE
rd#=rd#+0.7: If(rd# > 255)r#=255
g#=g#+1.2: If(g# > 255)g#=255
b#=b#+0.1: If(b# > 255)b#=255
palette(i) = Int(rd) Shl 16 + Int(g) Shl 8 + Int(b)
Next


For a = 1 To 10
For b = 0 To 10
temp.point(b) = NewPoint(Rand(0, 1023), Rand(0, 767))
Next
s.spline = NewSpline()
Next
For s.spline = Each spline
f.runner = CreateRunner(s)
f\loc = Rand(0, 8) Mod 2
Next


Global hold = -1 ;indicates which point is held
Global scroll_x=0, scroll_y=0

While Not KeyHit(1)
;Cls
Runner()
Flip
Wend

;********************************************************************;
;--------------------------- EXTRA FUNCTIONS ------------------------;
;********************************************************************;
Function CreateRunner.runner(s.spline)
Local n.runner = New runner
n\x = s\pts.points[0]\x
n\y = s\pts.points[0]\y
n\s = s
n\loc = 0
For i = 0 To RUNNER_SIZE
n\pos[i]=i
Next
Return n
End Function


Function Runner()
For r.runner = Each runner
DrawRunner(r)
Next
End Function

Function DrawRunner(r.runner)
overlap = False

For i= 0 To RUNNER_SIZE-1
rd = rd+10
gr = gr+8
bl = bl+5
If overlap = False
If r\pos[i] < r\pos[i+1]
ptx1 = r\s\pts[r\loc]\x: pty1 = r\s\pts[r\loc]\y
ptx2 = r\s\pts[r\loc+1]\x: pty2 = r\s\pts[r\loc+1]\y
ptx3 = r\s\pts[r\loc+2]\x: pty3 = r\s\pts[r\loc+2]\y
If i < RUNNER_SIZE-1
x1 = QuadraticBezier(r\pos[i], ptx1, ptx2, ptx3)
y1 = QuadraticBezier(r\pos[i], pty1, pty2, pty3)
x2 = QuadraticBezier(r\pos[i+1] , ptx1, ptx2, ptx3)
y2 = QuadraticBezier(r\pos[i+1] , pty1, pty2, pty3)
;col = DrawLine(x1, y1, x2, y2, col)

Color rd, gr, bl: Line x1, y1, x2, y2
EndIf

Else ; switchover
overlap = True
If r\loc+4 >= r\s\size  ;End of spline
r\loc=0
Return
EndIf
ptx1 = r\s\pts[r\loc]\x: pty1 = r\s\pts[r\loc]\y
ptx2 = r\s\pts[r\loc+1]\x: pty2 = r\s\pts[r\loc+1]\y
ptx3 = r\s\pts[r\loc+2]\x: pty3 = r\s\pts[r\loc+2]\y
x1 = QuadraticBezier(r\pos[i], ptx1, ptx2, ptx3)
y1 = QuadraticBezier(r\pos[i], pty1, pty2, pty3)
x2 = r\s\pts[r\loc+2]\x
y2 = r\s\pts[r\loc+2]\y
Color rd, gr, bl: Line x1, y1, x2, y2
;col = DrawLine(x1, y1, x2, y2, col)
EndIf
Else
If r\loc+4 >= r\s\size  ;End of spline
r\loc=0
Return
EndIf

ptx1 = r\s\pts[loc+2]\x: pty1 = r\s\pts[loc+2]\y
ptx2 = r\s\pts[loc+3]\x: pty2 = r\s\pts[loc+3]\y
ptx3 = r\s\pts[loc+4]\x: pty3 = r\s\pts[loc+4]\y
If i < RUNNER_SIZE-1
x1 = QuadraticBezier(r\pos[i], ptx1, ptx2, ptx3)
y1 = QuadraticBezier(r\pos[i], pty1, pty2, pty3)
x2 = QuadraticBezier(r\pos[i+1] , ptx1, ptx2, ptx3)
y2 = QuadraticBezier(r\pos[i+1] , pty1, pty2, pty3)
;col = DrawLine(x1, y1, x2, y2, col)
Color rd, gr, bl: Line x1, y1, x2, y2
EndIf
EndIf



Next

For i= 0 To RUNNER_SIZE
r\pos[i] = r\pos[i]+1
If r\pos[i] = CURVE_DETAIL Then r\pos[i]=0
Next

If r\pos[0] = 0
r\loc=r\loc+2
EndIf

End Function

14
General chat / Re: Many Happy Returns - JIM!
« on: June 24, 2008 »
Happy birthday Jim! Have a good one   ;)

15
Cheers for that. I have wanted to start learning about how to use shaders. Hopefully I'll get around to it soon.

16
Projects / Re: rain by rain_storm
« on: June 17, 2008 »
I tried to run this in vista and dosbox, but it wernt happening. I like the screenie tho :) Would have been nice to see it animated.

17
General chat / Re: Hello again
« on: June 17, 2008 »
Cheers shockwave :)

18
Blitz / Re: A-Star Pathfinding [BB2D]
« on: June 17, 2008 »
Quote
It's a very important subject, especially when you try to apply it to internet traffic routing.
Yeah, I heard that a lot of routing protocols use it.

Quote
A* can also find items without knowing exactly where to look much the same as Dijkstra's meathod. I forget the actual way its done but I think you only have to consider how far you have travelled (since you dont know how far away from the destination you are) and keep going until you find what you are looking. Its not as efficient but when you are using the same code to do different jobs its easy to work with.
Yeah I guess you could find it without a target just ignoring the heuristic. Then it would pretty much be dijkstra's algo.

19
General chat / Re: Hello again
« on: June 16, 2008 »
Thx benny, and rain_storm.

My electronics teacher mixed my last name up and called me grundez. I guess it kinda stuck afer that.

20
General chat / Re: Hello again
« on: June 16, 2008 »
Thanks clyde. Nice to see you too dude ;)

Pages: [1] 2 3 4 5 6 7 8 ... 18