|
-
Jul 26th, 2002, 07:46 AM
#1
Thread Starter
Fanatic Member
Starfield
Lately I've been trying to make a 3d program (with Qb) i started out by trying to make a 3d starfield (like the screensaver), I've got most of it down, but i can't seem to get the math for placing a star right... I can get the direction, but not the distance away from the center...
Here's the placement code:
VB Code:
Far = ABS(Dir1)+ABS(Dir2) / 2
'Far is how far from the center
'Dir1 is the angle from you to the star (X and Z axis)
'Dir2 is the angle from you to the star (Y and Z axis)
'Dir3 is the angle from you to the star (X and Y axis)
X = 320 + (((ABS(Far)*SIN(Rad(Dir3))) / 180) * 640)
Y = 210 + (((ABS(Far)*COS(Rad(Dir3))) / 180) * 420)
'Rad is a function that converts degrees to radians
'X is x position, and Y is y position
'320+ and 210+ put the startign point in mid of screen
'/180)*640 and /180)*420 stretch the circle out so it coveres the screen
The problem is with the first line of course, i used the angles... the actual moving forward looks pretty real, but if i tell it to move to the side... well the stars seem to go in a circle
Any ideas?
Don't pay attention to this signature, it's contradictory.
-
Jul 26th, 2002, 10:36 AM
#2
Good Ol' Platypus
I made one like this a while ago, and what I did is create the finishing point and a speed for the star. That speed is how many ticks it should take for the star to get there. I then subtracted the centrex from the endx, same with the y, and divided that by the speed. Then I added that to the star's position and it worked like cake.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|