Implement AsterismList class with render() method
parent
8564fa16e7
commit
c2205c7f77
|
@ -13,10 +13,12 @@
|
|||
#endif /* TARGET_OS_MAC */
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#include <GL/glew.h>
|
||||
#include <celutil/util.h>
|
||||
#include <celutil/debug.h>
|
||||
#include "asterism.h"
|
||||
#include "parser.h"
|
||||
#include "vecgl.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -101,6 +103,35 @@ bool Asterism::isColorOverridden() const
|
|||
return useOverrideColor;
|
||||
}
|
||||
|
||||
/*! Draw visible asterisms.
|
||||
*/
|
||||
void AsterismList::render(Color defaultColor)
|
||||
{
|
||||
float opacity = defaultColor.alpha();
|
||||
|
||||
for (const auto ast : *this)
|
||||
{
|
||||
if (!ast->getActive())
|
||||
continue;
|
||||
|
||||
if (ast->isColorOverridden())
|
||||
glColor(ast->getOverrideColor(), opacity);
|
||||
else
|
||||
glColor(defaultColor);
|
||||
|
||||
for (int i = 0; i < ast->getChainCount(); i++)
|
||||
{
|
||||
const Asterism::Chain& chain = ast->getChain(i);
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for (const auto& c : chain)
|
||||
glVertex3fv(c.data());
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
AsterismList* ReadAsterismList(istream& in, const StarDatabase& stardb)
|
||||
{
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <celengine/stardb.h>
|
||||
#include <celutil/color.h>
|
||||
|
||||
class Asterism
|
||||
{
|
||||
|
@ -48,7 +49,11 @@ class Asterism
|
|||
Color color;
|
||||
};
|
||||
|
||||
typedef std::vector<Asterism*> AsterismList;
|
||||
class AsterismList : public std::vector<Asterism*>
|
||||
{
|
||||
public:
|
||||
void render(Color color);
|
||||
};
|
||||
|
||||
AsterismList* ReadAsterismList(std::istream&, const StarDatabase&);
|
||||
|
||||
|
|
|
@ -5791,31 +5791,9 @@ void Renderer::renderAsterisms(const Universe& universe, float dist)
|
|||
(MaxAsterismLinesDist - MaxAsterismLinesConstDist) + 1);
|
||||
}
|
||||
|
||||
glColor(ConstellationColor, opacity);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
enableSmoothLines(renderFlags);
|
||||
|
||||
for (const auto ast : *universe.getAsterisms())
|
||||
{
|
||||
if (!ast->getActive())
|
||||
continue;
|
||||
|
||||
if (ast->isColorOverridden())
|
||||
glColor(ast->getOverrideColor(), opacity);
|
||||
else
|
||||
glColor(ConstellationColor, opacity);
|
||||
|
||||
for (int i = 0; i < ast->getChainCount(); i++)
|
||||
{
|
||||
const Asterism::Chain& chain = ast->getChain(i);
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for (const auto& c : chain)
|
||||
glVertex3fv(c.data());
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
|
||||
universe.getAsterisms()->render(Color(ConstellationColor, opacity));
|
||||
disableSmoothLines(renderFlags);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ class RendererWatcher;
|
|||
class FrameTree;
|
||||
class ReferenceMark;
|
||||
class CurvePlot;
|
||||
class AsterismList;
|
||||
|
||||
struct LightSource
|
||||
{
|
||||
|
@ -525,7 +526,7 @@ class Renderer
|
|||
unsigned int lightIndex,
|
||||
double now);
|
||||
|
||||
void labelConstellations(const std::vector<Asterism*>& asterisms,
|
||||
void labelConstellations(const AsterismList& asterisms,
|
||||
const Observer& observer);
|
||||
void renderParticles(const std::vector<Particle>& particles,
|
||||
const Eigen::Quaternionf& orientation);
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
#include <celengine/deepskyobj.h>
|
||||
#include <celengine/marker.h>
|
||||
#include <celengine/selection.h>
|
||||
#include <celengine/asterism.h>
|
||||
#include <vector>
|
||||
|
||||
|
||||
class ConstellationBoundaries;
|
||||
class Asterism;
|
||||
|
||||
class Universe
|
||||
{
|
||||
|
@ -39,8 +39,8 @@ class Universe
|
|||
DSODatabase* getDSOCatalog() const;
|
||||
void setDSOCatalog(DSODatabase*);
|
||||
|
||||
std::vector<Asterism*>* getAsterisms() const;
|
||||
void setAsterisms(std::vector<Asterism*>*);
|
||||
AsterismList* getAsterisms() const;
|
||||
void setAsterisms(AsterismList*);
|
||||
|
||||
ConstellationBoundaries* getBoundaries() const;
|
||||
void setBoundaries(ConstellationBoundaries*);
|
||||
|
@ -121,7 +121,7 @@ class Universe
|
|||
StarDatabase* starCatalog{nullptr};
|
||||
DSODatabase* dsoCatalog{nullptr};
|
||||
SolarSystemCatalog* solarSystemCatalog{nullptr};
|
||||
std::vector<Asterism*>* asterisms{nullptr};
|
||||
AsterismList* asterisms{nullptr};
|
||||
ConstellationBoundaries* boundaries{nullptr};
|
||||
MarkerList* markers;
|
||||
|
||||
|
|
Loading…
Reference in New Issue