Implemented detail field for galaxies to cut down on the amount of particles rendered for small galaxies.

This commit is contained in:
Chris Laurel 2001-04-29 03:23:01 +00:00
parent 2f6d7def7c
commit d4bb954ae5
3 changed files with 20 additions and 1 deletions

View file

@ -57,6 +57,7 @@ static GalaxyTypeName GalaxyTypeNames[] =
Galaxy::Galaxy() :
name(""),
position(0, 0, 0), orientation(1), radius(1),
detail(1.0f),
form(NULL)
{
}
@ -102,6 +103,16 @@ void Galaxy::setRadius(float r)
radius = r;
}
float Galaxy::getDetail() const
{
return detail;
}
void Galaxy::setDetail(float d)
{
detail = d;
}
Galaxy::GalaxyType Galaxy::getType() const
{
@ -289,6 +300,10 @@ GalaxyList* ReadGalaxyList(istream& in)
galaxyParams->getNumber("Radius", radius);
galaxy->setRadius((float) radius);
double detail = 1.0;
galaxyParams->getNumber("Detail", detail);
galaxy->setDetail((float) detail);
string typeName;
galaxyParams->getString("Type", typeName);
Galaxy::GalaxyType type = Galaxy::Irr;

View file

@ -58,6 +58,8 @@ class Galaxy
void setRadius(float);
GalaxyType getType() const;
void setType(GalaxyType);
float getDetail() const;
void setDetail(float);
GalacticForm* getForm() const;
@ -66,6 +68,7 @@ class Galaxy
Point3d position;
Quatf orientation;
float radius;
float detail;
GalaxyType type;
GalacticForm* form;
};

View file

@ -1901,9 +1901,10 @@ void Renderer::renderGalaxies(const GalaxyList& galaxies,
int pow2 = 1;
vector<Point3f>* points = form->points;
int nPoints = (int) (points->size() * clamp(galaxy->getDetail()));
glBegin(GL_QUADS);
for (int i = 0; i < points->size(); i++)
for (int i = 0; i < nPoints; i++)
{
Point3f p = (*points)[i] * m;
Vec3f relPos = p - offset;