Author Topic: Parallax Starfield - a different way . . .  (Read 10341 times)

0 Members and 1 Guest are viewing this topic.

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Re: Parallax Starfield - a different way . . .
« Reply #20 on: April 15, 2009 »
I think I may have done it . . .

Code: [Select]
#include once "tinyptc_ext.bi"
const xres = 640 : const yres = 480:Dim shared as integer sf,a,x1,y1:sf=255
Dim shared as double x(sf),y(sf),z(sf),col:Declare Sub Stars:Dim Shared as Integer sb(xres*yres)
for a=0 to sf-1:x(a)=((rnd(1)*10000)-5000):y(a)=((rnd(1)*10000)-5000):z(a)=((rnd(1)*30)):next
ptc_allowclose(0):ptc_setdialog(1,"Fullscreen?",0,1)
If( ptc_open( "3D Starfield Test", XRES, YRES ) = 0 ) Then End -1:End If
WHILE(GETASYNCKEYSTATE(VK_ESCAPE)<> -32767 and PTC_GETLEFTBUTTON=FALSE)
Stars:ptc_update @sb(0):erase sb:Wend:ptc_close():end
Sub Stars:for a=0 to sf-1: z(a)=z(a)-0.1 :x1=320+(x(a)/z(a)):y1=240+(y(a)/z(a)):col=((-z(a))+30)*7
if int(col)>255 then col=255:col=int(col)
if x1>0  and x1<640 and y1>0 and y1<yres then sb(x1+(y1*xres))=rgb(col,col,col) else z(a)=30 end if
next a:End Sub
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17412
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Parallax Starfield - a different way . . .
« Reply #21 on: April 15, 2009 »
That looks great :)

+5 Karma to you. Definately more interesting than the 2D one.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Re: Parallax Starfield - a different way . . .
« Reply #22 on: April 15, 2009 »
Thanks Shockwave - couldnt really have done it without you!  :'(
I now understand exactly how it all works which is cool!
I can now take it further by spinning the stars etc . . .

DrewPee


DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Re: Parallax Starfield - a different way . . .
« Reply #23 on: April 15, 2009 »
I have now started using a SINE wave to create movement of the stars . . . I can honestly say I am now very proud of this! ;)
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Parallax Starfield - a different way . . .
« Reply #24 on: April 16, 2009 »
That is very good indeed dude, welldone.

Sorry DrewPee for seeming to Hijack your topic, didnt mean for that to happen, this is a tad Off Topic:
@Shockwave: Do you remember way back when you used to use Windows / Microsoft Messenger ( now known as Windows Live Messenger) . After saying hello to me on the very first conversation, the second thing you said to me, was do I know anything about 3D Starfields in 2D, and it was one of the very first routines I ever learnt and from you. I remember it like it was only yesterday. But thinking back it's got to be at least 5 years ago, it was when Dark Bit Factory was concieved I cant remember the exact date.

Back To Topic. :)
Havent forgotten about the K*5 challenge offer, will knock something up soon. Mr DrewPee's on a roll with this now.
« Last Edit: April 17, 2009 by Clyde »
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17412
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Parallax Starfield - a different way . . .
« Reply #25 on: April 17, 2009 »
Drewpee, that's really nice that you are adding some more dynamic stuff to the starfield, you're close to getting it similar to the way that the bob starfield worked in the classic amiga demos like mental hangover and hysteresis, one observation though, you seem to have applied the movement to the points after you do the perspective transformation to them which means that they all move around at the same rate, realistically on a 3D starfield, the distant ones would move more slowly.

To achieve this you can do the same as you are doing now but apply the transformation to the points before you transform them and the result will be much more satisfying. It's already nice though so keep on improving it :)

@Shockwave: Do you remember way back when you used to use Windows / Microsoft Messenger ( now known as Windows Live Messenger) . After saying hello to me on the very first conversation, the second thing you said to me, was do I know anything about 3D Starfields in 2D, and it was one of the very first routines I ever learnt and from you. I remember it like it was only yesterday. But thinking back it's got to be at least 5 years ago, it was when Dark Bit Factory was concieved I cant remember the exact date.

It rings a vague bell with me to be honest Clyde but a lot of water has gone under the bridge since then mate. It's great that you remember that though and kind of scary too to think that 5 years have already gone by since then.
Shockwave ^ Codigos
Challenge Trophies Won: