Added diffuse and minormoon classes.

ver1_6_1
Chris Laurel 2008-04-14 18:48:13 +00:00
parent 2d5c71a91f
commit 7e117ee0fd
2 changed files with 112 additions and 45 deletions

View File

@ -102,21 +102,68 @@ class Body
Body(PlanetarySystem*, const std::string& name);
~Body();
// Object class enumeration:
// All of these values must be powers of two so that they can
// be used in an object type bit mask.
//
// The values of object class enumerants cannot be modified
// without consequence. The object orbit mask is a stored user
// setting, so there will be unexpected results when the user
// upgrades if the orbit mask values mean something different
// in the new version.
//
// * Planet, Moon, Asteroid, DwarfPlanet, and MinorMoon all behave
// essentially the same. They're distinguished from each other for
// user convenience, so that it's possible to assign them different
// orbit and label colors, and to categorize them in the solar
// system browser.
//
// * Comet is identical to the asteroid class except that comets may
// be rendered with dust and ion tails.
//
// Other classes have different default settings for the properties
// Clickable, VisibleAsPoint, Visible, and SecondaryIlluminator. These
// defaults are assigned in the ssc file parser and may be overridden
// for a particular body.
//
// * Invisible is used for barycenters and other reference points.
// An invisible object is not clickable, visibleAsPoint, visible, or
// a secondary illuminator.
//
// * SurfaceFeature is meant to be used for buildings and landscape.
// SurfaceFeatures is clickable and visible, but not visibleAsPoint or
// a secondary illuminator.
//
// * Component should be used for parts of spacecraft or buildings that
// are separate ssc objects. A component is clickable and visible, but
// not visibleAsPoint or a secondary illuminator.
//
// * Diffuse is used for gas clouds, dust plumes, and the like. They are
// visible, but other properties are false by default. It is expected
// that an observer will move through a diffuse object, so there's no
// need for any sort of collision detection to be applied.
//
// * Stellar is a pseudo-class used only for orbit rendering.
//
// * Barycenter and SmallBody are not used currently. Invisible is used
// instead of barycenter.
enum
{
Planet = 0x01,
Moon = 0x02,
Asteroid = 0x04,
Comet = 0x08,
Spacecraft = 0x10,
Invisible = 0x20,
Barycenter = 0x40,
SmallBody = 0x80,
DwarfPlanet = 0x100,
Stellar = 0x200, // only used for orbit mask
SurfaceFeature = 0x400,
Component = 0x800,
Unknown = 0x10000,
Planet = 0x01,
Moon = 0x02,
Asteroid = 0x04,
Comet = 0x08,
Spacecraft = 0x10,
Invisible = 0x20,
Barycenter = 0x40, // Not used (invisible is used instead)
SmallBody = 0x80, // Not used
DwarfPlanet = 0x100,
Stellar = 0x200, // only used for orbit mask
SurfaceFeature = 0x400,
Component = 0x800,
MinorMoon = 0x1000,
Diffuse = 0x2000,
Unknown = 0x10000,
};
enum VisibilityPolicy

View File

@ -92,6 +92,52 @@ static void sscError(const Tokenizer& tok,
}
// Object class properties
static const int CLASSES_UNCLICKABLE = Body::Invisible |
Body::Diffuse;
static const int CLASSES_INVISIBLE_AS_POINT = Body::Invisible |
Body::SurfaceFeature |
Body::Component |
Body::Diffuse;
static const int CLASSES_SECONDARY_ILLUMINATOR = Body::Planet |
Body::Moon |
Body::MinorMoon |
Body::DwarfPlanet |
Body::Asteroid |
Body::Comet;
typedef map<std::string, int, CompareIgnoringCasePredicate> ClassificationTable;
static ClassificationTable Classifications;
void InitializeClassifications()
{
Classifications["planet"] = Body::Planet;
Classifications["dwarfplanet"] = Body::DwarfPlanet;
Classifications["moon"] = Body::Moon;
Classifications["minormoon"] = Body::MinorMoon;
Classifications["comet"] = Body::Comet;
Classifications["asteroid"] = Body::Asteroid;
Classifications["spacecraft"] = Body::Spacecraft;
Classifications["invisible"] = Body::Invisible;
Classifications["surfacefeature"] = Body::SurfaceFeature;
Classifications["component"] = Body::Component;
Classifications["diffuse"] = Body::Diffuse;
}
int GetClassificationId(const string& className)
{
if (Classifications.empty())
InitializeClassifications();
ClassificationTable::iterator iter = Classifications.find(className);
if (iter == Classifications.end())
return Body::Unknown;
else
return iter->second;
}
//! Maximum depth permitted for nested frames.
static unsigned int MaxFrameDepth = 50;
@ -704,24 +750,7 @@ static Body* CreatePlanet(const string& name,
int classification = body->getClassification();
string classificationName;
if (planetData->getString("Class", classificationName))
{
if (compareIgnoringCase(classificationName, "planet") == 0)
classification = Body::Planet;
else if (compareIgnoringCase(classificationName, "moon") == 0)
classification = Body::Moon;
else if (compareIgnoringCase(classificationName, "comet") == 0)
classification = Body::Comet;
else if (compareIgnoringCase(classificationName, "asteroid") == 0)
classification = Body::Asteroid;
else if (compareIgnoringCase(classificationName, "spacecraft") == 0)
classification = Body::Spacecraft;
else if (compareIgnoringCase(classificationName, "invisible") == 0)
classification = Body::Invisible;
else if (compareIgnoringCase(classificationName, "surfacefeature") == 0)
classification = Body::SurfaceFeature;
else if (compareIgnoringCase(classificationName, "component") == 0)
classification = Body::Component;
}
classification = GetClassificationId(classificationName);
if (classification == Body::Unknown)
{
@ -746,22 +775,13 @@ static Body* CreatePlanet(const string& name,
if (classification == Body::Invisible)
body->setVisible(false);
// Surface features and component objects are by default not
// visible as points at a distance.
if (classification == Body::Invisible ||
classification == Body::SurfaceFeature ||
classification == Body::Component)
{
// Set default properties for the object based on its classification
if (classification & CLASSES_INVISIBLE_AS_POINT)
body->setVisibleAsPoint(false);
}
if (classification == Body::Invisible ||
classification == Body::SurfaceFeature ||
classification == Body::Component ||
classification == Body::Spacecraft)
{
if ((classification & CLASSES_SECONDARY_ILLUMINATOR) == 0)
body->setSecondaryIlluminator(false);
}
if (classification & CLASSES_UNCLICKABLE)
body->setClickable(false);
string infoURL;
if (planetData->getString("InfoURL", infoURL))