Issue #216: Allow changing colors for comet tails
parent
9d51cbfad3
commit
a363fc772b
|
@ -1110,6 +1110,15 @@ void Body::setOrbitColor(const Color& c)
|
|||
}
|
||||
|
||||
|
||||
/*! Set the comet tail color
|
||||
*
|
||||
*/
|
||||
void Body::setCometTailColor(const Color& c)
|
||||
{
|
||||
cometTailColor = c;
|
||||
}
|
||||
|
||||
|
||||
/*! Set whether or not the object should be considered when calculating
|
||||
* secondary illumination (e.g. planetshine.)
|
||||
*/
|
||||
|
|
|
@ -327,6 +327,9 @@ class Body : public CatEntry
|
|||
Color getOrbitColor() const { return orbitColor; }
|
||||
void setOrbitColor(const Color&);
|
||||
|
||||
Color getCometTailColor() const { return cometTailColor; }
|
||||
void setCometTailColor(const Color& c);
|
||||
|
||||
int getOrbitClassification() const;
|
||||
|
||||
enum
|
||||
|
@ -402,6 +405,7 @@ class Body : public CatEntry
|
|||
std::list<ReferenceMark*>* referenceMarks{ nullptr };
|
||||
|
||||
Color orbitColor;
|
||||
Color cometTailColor{ 0.5f, 0.5f, 0.75f };
|
||||
|
||||
bool visible{ true };
|
||||
bool clickable{ true };
|
||||
|
|
|
@ -5562,7 +5562,8 @@ struct CometTailVertex
|
|||
|
||||
static CometTailVertex cometTailVertices[CometTailSlices * MaxCometTailPoints];
|
||||
|
||||
static void ProcessCometTailVertex(const CometTailVertex& v,
|
||||
static void ProcessCometTailVertex(const Color& cometTailColor,
|
||||
const CometTailVertex& v,
|
||||
const Vector3f& viewDir,
|
||||
float fadeDistFromSun)
|
||||
{
|
||||
|
@ -5571,7 +5572,8 @@ static void ProcessCometTailVertex(const CometTailVertex& v,
|
|||
|
||||
float fadeFactor = 0.5f - 0.5f * (float) tanh(fadeDistFromSun - 1.0f / fadeDistFromSun);
|
||||
float shade = abs(viewDir.dot(v.normal) * v.brightness * fadeFactor);
|
||||
glColor4f(0.5f, 0.5f, 0.75f, shade);
|
||||
glColor4f(cometTailColor.red(), cometTailColor.green(),
|
||||
cometTailColor.blue(), shade);
|
||||
glVertex(v.point);
|
||||
}
|
||||
|
||||
|
@ -5737,12 +5739,17 @@ void Renderer::renderCometTail(const Body& body,
|
|||
int n = i * nTailSlices;
|
||||
for (int j = 0; j < nTailSlices; j++)
|
||||
{
|
||||
ProcessCometTailVertex(cometTailVertices[n + j], viewDir, fadeDistance);
|
||||
ProcessCometTailVertex(cometTailVertices[n + j + nTailSlices],
|
||||
ProcessCometTailVertex(body.getCometTailColor(),
|
||||
cometTailVertices[n + j], viewDir,
|
||||
fadeDistance);
|
||||
ProcessCometTailVertex(body.getCometTailColor(),
|
||||
cometTailVertices[n + j + nTailSlices],
|
||||
viewDir, fadeDistance);
|
||||
}
|
||||
ProcessCometTailVertex(cometTailVertices[n], viewDir, fadeDistance);
|
||||
ProcessCometTailVertex(cometTailVertices[n + nTailSlices],
|
||||
ProcessCometTailVertex(body.getCometTailColor(),
|
||||
cometTailVertices[n], viewDir, fadeDistance);
|
||||
ProcessCometTailVertex(body.getCometTailColor(),
|
||||
cometTailVertices[n + nTailSlices],
|
||||
viewDir, fadeDistance);
|
||||
glEnd();
|
||||
}
|
||||
|
|
|
@ -999,6 +999,13 @@ static Body* CreateBody(const string& name,
|
|||
}
|
||||
}
|
||||
|
||||
// Read comet tail color
|
||||
Color cometTailColor;
|
||||
if(planetData->getColor("TailColor", cometTailColor))
|
||||
{
|
||||
body->setCometTailColor(cometTailColor);
|
||||
}
|
||||
|
||||
bool clickable = true;
|
||||
if (planetData->getBoolean("Clickable", clickable))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue