Hello there!

Does anybody know how to create 3d starfield like StarTrek movie ?
i c ant find that effect in the board..
no direct x only gdi

Thanks in advance!

mob posted a nice starfield but only 2d. aka horizontal starfield.

i read that to make that effect i must do a 3d to 2d conversion
but i dont knew how

VLA Intro To Starfields:
< A star field is just a series of 3d point plotted onto a 2d plane (your
screen). The movement effect is achieved by simply decreasing the Z
cordinate and redisplaying the results. The formula for the 3d to 2d
conversion is:

????????????????
ScreenX = ScreenDist * Xpos / Zpos
ScreenY = ScreenDist * Ypos / Zpos
????????????????
>

my non working code:

if eax==WM_INITDIALOG
invoke SetTimer,hWnd,555,120,0
invoke nrandom,200;640
mov x,eax
invoke nrandom,200;480
mov y,eax
mov z,256;256

.ELSEIF eax==WM_TIMER
dec z

.elseif eax == WM_PAINT
invoke BeginPaint,hWnd,addr ps
mov hDc,eax
; lloop:
mov eax,x
shl eax,8; ; eax = x * 256
mov ecx,z ;256
cdq
idiv ecx
mov x,eax


shl eax,8 ; eax = x * 256
mov ecx,z ;256
cdq
idiv ecx
mov y,eax
invoke SetPixelV,hDc,y,x,00FFFFFFh
Posted on 2002-08-04 22:02:08 by vilik
Well, basically 3D starfield is a collection of 3D points and I believe what you have pasted correctly outlines their projection onto the 3D screen. For a more realistic effect, you can use particles for the actual stars. I have attached an example that does a basic job of projecting 3D particles.
Posted on 2002-08-04 22:36:18 by comrade
Very nice piece of work Comrade !

Regs,
Posted on 2002-08-05 01:41:20 by James_Ladd
On my PC it displays the flares with normal (reddish) colors in the center and a fading green border. Assuming this isn't supposed to happen, maybe something with the palette?
Posted on 2002-08-05 11:23:54 by Qweerdy
It works in 16-bit 5-6-5 mode. Older video cards use 5-5-5, so that might be the case with your PC.
Posted on 2002-08-05 13:41:25 by comrade
Great job ... Comrade!

You just give us some more ideas for HE spells :)
Posted on 2002-08-05 14:11:21 by BogdanOntanu
Oooh... like what?
Posted on 2002-08-11 22:37:40 by AmkG
writing a 3d starfield is as esay as writing a 2d one... you already posted
the important formula for it...

ScreenX = ScreenDist * Xpos / Zpos
ScreenY = ScreenDist * Ypos / Zpos

where ScreenDist is the distance of the viever from the screen, the best
value for it would be 256 but you can play around with it... but to do all
this stuff you've have to do this:

create a struc that is definded like this: X,Y,Z,OLDPOS,COLOR,SPEED
then you create an array of say 500 of these structures...
run through it and pass random values to it... limit Z to a value, say 1000
in your drawing loop you plot star for star and decrease the Z value, if
Z is <=1 you set it back to your limit (1000)... convert these values to
2d and print them to the screen... then you have to save the current
screen position in OLDPOS... you need that value to delete the previous
star (with a black pixel!), you can do it with doublebuffering also but
it's slower. there are also formulas for the color so that it looks like the
stars are coming from out of something like a nebula...

i like thos good old dos effects...
Posted on 2002-08-12 04:37:10 by mob
I'm working on a 640x480 starfield in 32 Bit DirectDraw and I somehow encountered a problem with my UpdateStars Routine. Could you please check it?

It keeps crashing. I guess I am calculating the Screenpos wrong...

The Init Code just setups random Values from 0 - 640 into Stars.x and Values from 0 - 480 into Stars.y ...

Help me



mov [dwStack],esp
mov ecx, 250
@@update: push ecx
mov eax, [esi][Stars.y]
mov ebx, 256
shl eax, 8
sub ebx, [esi][Stars.z]
cdq
idiv ebx
mov ecx, dxScanline
mul ecx
mov ecx, eax
mov eax, [esi][Stars.x]
mov ebx,256
shl eax, 8
sub ebx,[esi][Stars.z]
cdq
idiv ebx
imul eax,4
add ecx,eax
mov edi, [hStars]
add edi, ecx
mov eax,0ffffffffh
mov [edi],eax
pop esi
pop ecx
add esi, sizeof Star_3d
loopd @@update
mov esp,[dwStack]
ret


:) :)
Posted on 2003-06-20 07:10:57 by stylus

Well, basically 3D starfield is a collection of 3D points and I believe what you have pasted correctly outlines their projection onto the 3D screen. For a more realistic effect, you can use particles for the actual stars. I have attached an example that does a basic job of projecting 3D particles.



funny result while circle state when u specify dotWidth equ 100 instead of 32
Posted on 2003-06-20 08:40:57 by AceEmbler
Can anybody help me with my problem? Still not solved ... :confused:
Posted on 2003-07-04 04:18:59 by stylus
It's just sugestion cuz i'm not using directdraw stuff


But if u random x 0-640 and Random y 0-480 so youre resoultion is 641x481 not 640x480

when u use just block of memory like DIB section program will crush only when u try to write in (640,480) since 0,0 is the first pixel. But i do not know how is it about DirectDraw maby it crushes when u try write something in (x,480) or (640,y)
Posted on 2003-07-04 04:47:00 by AceEmbler
I would suggest that the perspective transform (x/z and y/z) is not NEARLY as important as how he performed the rotation (trig rotation) - but notably, this method is not suited to a Framed environment, and furthermore, the rotation formula is inaccurate, as 2d rotations in 3d rotate axes as well !!! I won't go into this further other than to say neat job for a lil demo, reminds me of my 8 bit days, but its major redeeming point is that its the basis of a cheap particle system, and someone here may explore that. Pity you based it all in the 2D DirectDraw renderer instead of under D3D !!!
Posted on 2003-07-06 10:01:04 by Homer
How is that pity? I choose not to use Direct3D. Rotation formula is fine as well.
Posted on 2003-07-06 21:20:35 by comrade