Quote:
I can't do calculus, so to be completely honest I have again no idea what you're talking about. The way I did it was calculate F, get the acceleration using f=m/a, get velocity using v=a [delta]t, where [delta]t is a fixed constant. After that I calculate the displacement using s=v [delta]t.
This is correct except in a simulation you have to integrate the forces over time. High school math falls short in that they assume you are working with constants. Unfortunately in simulations you don't have constant time and you have variable acceleration over time which is normally your frame delta and/or your accumulated time due to the time delta. Please understand...what you are trying to do requires more than high school math.
Also, there was no mention of 2D or 3D.
Quote:
Anyway, I decided that a stars mass would be generated, followed by it's density. From that, the radius would arise. And the number of particles the star was made up would be determined by the number of pixels it would occupy when drawn to the screen. In other words, one pixel=one particle. Here I encountered the first big problem. When a circle is drawn to the screen, it's made up of a bunch of squares. It's not a perfect circle. What I needed to find out was how to calculate the number of pixels set when drawing a circle with a radius of n pixels to the screen. And I had no idea how to do that.
Radius arises out of density? Ok.
One pixel = one particle = a ton of particles for just 1 object. Not probable.
Quote:
When a circle is drawn to the screen, it's made up of a bunch of squares. It's not a perfect circle.
Because you are using particles instead of primitives. If you follow the equation of a circle which I assume you know since you seem to know everything now anyways then your circle will be a circle. Again I would show you how to create a 'sphere or circle' of particles using the equation but you probably already know how to do it. r^2 = x^2 + y^2. That is all you need.
Quote:
What I needed to find out was how to calculate the number of pixels set when drawing a circle with a radius of n pixels to the screen. And I had no idea how to do that.
You just said that radius is determined by density. This is absurd but hey it is your simulation and not mine. If radius is determined by density and you know density then you know the radius. I'm lost here.
If you say your max particle density of any one star is 10000 pixels then the number of pixels for any star in your system with density expressed as a normalized float is:
num_particles = density * max_particles
When density is 1.0f you get max particles. When density is 0.5f you get half of max_particles and so on. You just need to decide on a theoretical maximum of particles. If you are going to render these particles like this:
Code:
for (unsigned int i = 0;i < m_NumParticles; ++i)
{
//Draw particle
}
This would be a very bad idea. A better idea would be to transform a portion of the particles and then draw. After that you are always drawing what you just transformed. This way you don't get graphics pipeline stalls. If you just transform and then render the entire buffer of particles then the video card is locked out at several points thus causing stalls.
And, BTW, density has nothing to do with the size of an object. You can take a teaspoon of material from a white dwarf and it will have a mass of a million newtons and you can take a teaspoon of material from our own sun and it will have a very small mass.
A huge boulder of granite hass less mass than a small boulder of solid steel.
Quote:
And anyway, not that I want to sound rude, but I was asking about something else...
Not to be rude but I don't think you know exactly what you are asking.
If you want to render your 'stars' as empty circles then you can use the circle drawing algo. The angle increment for a circle is:
angle_incr = PI / number_of_facets
Where the number of facets is the desired approximation of a circle that you want. If you want to draw perfect circles you will have to use another algo but I do not recommend it. Circles with 32 facets are usually a good approximation.