Enabled new star rendering path as an option--uses point sprite extension, new glare textures (gaussian), and dynamic star labeling.
parent
b3b51e51d2
commit
4fa5c3475f
|
@ -522,12 +522,6 @@ CommandSetVisibilityLimit::CommandSetVisibilityLimit(double mag) :
|
|||
|
||||
void CommandSetVisibilityLimit::process(ExecutionEnvironment& env)
|
||||
{
|
||||
Renderer* r = env.getRenderer();
|
||||
if (r != NULL)
|
||||
{
|
||||
r->setBrightnessBias(0.05f);
|
||||
r->setSaturationMagnitude(1.0f);
|
||||
}
|
||||
env.getSimulation()->setFaintestVisible((float) magnitude);
|
||||
}
|
||||
////////////////
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -82,8 +82,8 @@ class Renderer
|
|||
SpacecraftLabels = 0x040,
|
||||
LocationLabels = 0x080,
|
||||
CometLabels = 0x100,
|
||||
NebulaLabels = 0x200,
|
||||
OpenClusterLabels = 0x400,
|
||||
NebulaLabels = 0x200,
|
||||
OpenClusterLabels = 0x400,
|
||||
I18nConstellationLabels = 0x800,
|
||||
BodyLabelMask = (PlanetLabels | MoonLabels | AsteroidLabels | SpacecraftLabels | CometLabels),
|
||||
};
|
||||
|
@ -108,8 +108,9 @@ class Renderer
|
|||
ShowCometTails = 0x8000,
|
||||
ShowMarkers = 0x10000,
|
||||
ShowPartialTrajectories = 0x20000,
|
||||
ShowNebulae = 0x40000,
|
||||
ShowOpenClusters = 0x80000,
|
||||
ShowNebulae = 0x40000,
|
||||
ShowOpenClusters = 0x80000,
|
||||
ShowNewStars = 0x100000,
|
||||
};
|
||||
|
||||
enum StarStyle
|
||||
|
@ -124,8 +125,6 @@ class Renderer
|
|||
void setRenderFlags(int);
|
||||
int getLabelMode() const;
|
||||
void setLabelMode(int);
|
||||
void addLabelledStar(Star*, const std::string&);
|
||||
void clearLabelledStars();
|
||||
float getAmbientLightLevel() const;
|
||||
void setAmbientLightLevel(float);
|
||||
float getMinimumOrbitSize() const;
|
||||
|
@ -150,10 +149,6 @@ class Renderer
|
|||
|
||||
GLContext* getGLContext() { return context; }
|
||||
|
||||
float getSaturationMagnitude() const;
|
||||
void setSaturationMagnitude(float);
|
||||
float getBrightnessBias() const;
|
||||
void setBrightnessBias(float);
|
||||
void setStarStyle(StarStyle);
|
||||
StarStyle getStarStyle() const;
|
||||
void setResolution(unsigned int resolution);
|
||||
|
@ -161,18 +156,28 @@ class Renderer
|
|||
|
||||
void loadTextures(Body*);
|
||||
|
||||
static const int MaxLabelLength = 32;
|
||||
typedef struct {
|
||||
std::string text;
|
||||
char text[MaxLabelLength];
|
||||
Color color;
|
||||
Point3f position;
|
||||
} Label;
|
||||
|
||||
void addLabel(std::string, Color, const Point3f&, float depth = -1);
|
||||
void addSortedLabel(std::string, Color, const Point3f&);
|
||||
void addLabel(const char* text, Color, const Point3f&, float depth = -1);
|
||||
void addLabel(const std::string&, Color, const Point3f&, float depth = -1);
|
||||
void addSortedLabel(const std::string&, Color, const Point3f&);
|
||||
void clearLabels();
|
||||
void clearSortedLabels();
|
||||
|
||||
void setFont(TextureFont*);
|
||||
TextureFont* getFont() const;
|
||||
enum FontStyle
|
||||
{
|
||||
FontNormal = 0,
|
||||
FontLarge = 1,
|
||||
FontCount = 2,
|
||||
};
|
||||
|
||||
void setFont(FontStyle, TextureFont*);
|
||||
TextureFont* getFont(FontStyle) const;
|
||||
|
||||
public:
|
||||
// Internal types
|
||||
|
@ -215,7 +220,7 @@ class Renderer
|
|||
public:
|
||||
StarVertexBuffer(unsigned int _capacity);
|
||||
~StarVertexBuffer();
|
||||
void start(bool _usePoints);
|
||||
void start();
|
||||
void render();
|
||||
void finish();
|
||||
void addStar(const Point3f&, const Color&, float);
|
||||
|
@ -228,7 +233,6 @@ class Renderer
|
|||
float* texCoords;
|
||||
unsigned char* colors;
|
||||
Vec3f v0, v1, v2, v3;
|
||||
bool usePoints;
|
||||
};
|
||||
|
||||
struct LightSource
|
||||
|
@ -245,10 +249,12 @@ class Renderer
|
|||
public:
|
||||
PointStarVertexBuffer(unsigned int _capacity);
|
||||
~PointStarVertexBuffer();
|
||||
void start(const GLContext&);
|
||||
void startPoints(const GLContext&);
|
||||
void startSprites(const GLContext&);
|
||||
void render();
|
||||
void finish();
|
||||
void addStar(const Point3f& f, const Color&, float);
|
||||
void setTexture(Texture*);
|
||||
|
||||
private:
|
||||
struct StarVertex
|
||||
|
@ -263,6 +269,8 @@ class Renderer
|
|||
unsigned int nStars;
|
||||
StarVertex* vertices;
|
||||
const GLContext* context;
|
||||
bool useSprites;
|
||||
Texture* texture;
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -317,6 +325,9 @@ class Renderer
|
|||
void renderStars(const StarDatabase& starDB,
|
||||
float faintestVisible,
|
||||
const Observer& observer);
|
||||
void renderPointStars(const StarDatabase& starDB,
|
||||
float faintestVisible,
|
||||
const Observer& observer);
|
||||
void renderDeepSkyObjects(const Universe&,
|
||||
const Observer&,
|
||||
float faintestMagNight);
|
||||
|
@ -371,6 +382,14 @@ class Renderer
|
|||
const Quatf& orientation,
|
||||
float renderDistance,
|
||||
bool useHaloes);
|
||||
void renderObjectAsPoint(Point3f center,
|
||||
float appMag,
|
||||
float _faintestMag,
|
||||
float discSizeInPixels,
|
||||
Color color,
|
||||
const Quatf& orientation,
|
||||
float renderDistance,
|
||||
bool useHaloes);
|
||||
|
||||
void renderEllipsoidAtmosphere(const Atmosphere& atmosphere,
|
||||
Point3f center,
|
||||
|
@ -393,16 +412,14 @@ class Renderer
|
|||
double now,
|
||||
vector<EclipseShadow>& shadows);
|
||||
|
||||
void labelStars(const std::vector<StarLabel>& labelledStars,
|
||||
const StarDatabase&,
|
||||
const Observer&);
|
||||
void labelConstellations(const AsterismList& asterisms,
|
||||
const Observer& observer);
|
||||
void renderParticles(const std::vector<Particle>& particles,
|
||||
Quatf orientation);
|
||||
void renderLabels();
|
||||
void renderLabels(FontStyle fs);
|
||||
std::vector<Label>::iterator renderSortedLabels(std::vector<Label>::iterator,
|
||||
float depth);
|
||||
float depth,
|
||||
FontStyle fs);
|
||||
void renderMarkers(const MarkerList&,
|
||||
const UniversalCoord& position,
|
||||
const Quatf& orientation,
|
||||
|
@ -428,7 +445,7 @@ class Renderer
|
|||
float corrFac;
|
||||
float pixelSize;
|
||||
float faintestAutoMag45deg;
|
||||
TextureFont* font;
|
||||
TextureFont* font[FontCount];
|
||||
|
||||
int renderMode;
|
||||
int labelMode;
|
||||
|
@ -450,6 +467,8 @@ class Renderer
|
|||
std::string displayedSurface;
|
||||
|
||||
StarVertexBuffer* starVertexBuffer;
|
||||
PointStarVertexBuffer* pointStarVertexBuffer;
|
||||
PointStarVertexBuffer* glareVertexBuffer;
|
||||
std::vector<RenderListEntry> renderList;
|
||||
std::vector<Particle> glareParticles;
|
||||
std::vector<Label> labels;
|
||||
|
@ -459,9 +478,6 @@ class Renderer
|
|||
|
||||
std::vector<LightSource> lightSourceLists[MaxSolarSystems];
|
||||
|
||||
std::vector<StarLabel> labelledStars;
|
||||
std::vector<DSOLabel> labelledDSOs;
|
||||
|
||||
double modelMatrix[16];
|
||||
double projMatrix[16];
|
||||
|
||||
|
@ -473,6 +489,8 @@ class Renderer
|
|||
unsigned int textureResolution;
|
||||
|
||||
DetailOptions detailOptions;
|
||||
|
||||
bool useNewStarRendering;
|
||||
|
||||
public:
|
||||
struct OrbitSample
|
||||
|
|
|
@ -311,6 +311,30 @@ vector<string> StarDatabase::getCompletion(const string& name) const
|
|||
}
|
||||
|
||||
|
||||
static void catalogNumberToString(uint32 catalogNumber, char* buf, unsigned int bufSize)
|
||||
{
|
||||
// Just return an empty string if there's any chance that the buffer is too small
|
||||
if (bufSize < 20 && bufSize > 0)
|
||||
{
|
||||
buf[0] = '\0';
|
||||
}
|
||||
|
||||
if (catalogNumber < 1000000)
|
||||
{
|
||||
sprintf(buf, "HIP %d", catalogNumber);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 tyc3 = catalogNumber / 1000000000;
|
||||
catalogNumber -= tyc3 * 1000000000;
|
||||
uint32 tyc2 = catalogNumber / 10000;
|
||||
catalogNumber -= tyc2 * 10000;
|
||||
uint32 tyc1 = catalogNumber;
|
||||
sprintf(buf, "TYC %d-%d-%d", tyc1, tyc2, tyc3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Return the name for the star with specified catalog number. The returned
|
||||
// string will be:
|
||||
// the common name if it exists, otherwise
|
||||
|
@ -344,22 +368,32 @@ string StarDatabase::getStarName(const Star& star) const
|
|||
sprintf(buf, "HD %d", star.getCatalogNumber(Star::HDCatalog));
|
||||
else
|
||||
*/
|
||||
catalogNumberToString(catalogNumber, buf, sizeof(buf));
|
||||
|
||||
return string(buf);
|
||||
}
|
||||
|
||||
// A less convenient version of getStarName that writes to a char
|
||||
// array instead of a string. The advantage is that no memory allocation
|
||||
// will every occur.
|
||||
void StarDatabase::getStarName(const Star& star, char* nameBuffer, unsigned int bufferSize) const
|
||||
{
|
||||
assert(bufferSize != 0);
|
||||
|
||||
uint32 catalogNumber = star.getCatalogNumber();
|
||||
|
||||
if (namesDB != NULL)
|
||||
{
|
||||
if (catalogNumber < 1000000)
|
||||
StarNameDatabase::NumberIndex::const_iterator iter = namesDB->getFirstNameIter(catalogNumber);
|
||||
if (iter != namesDB->getFinalNameIter() && iter->first == catalogNumber)
|
||||
{
|
||||
sprintf(buf, "HIP %d", catalogNumber);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 tyc3 = catalogNumber / 1000000000;
|
||||
catalogNumber -= tyc3 * 1000000000;
|
||||
uint32 tyc2 = catalogNumber / 10000;
|
||||
catalogNumber -= tyc2 * 10000;
|
||||
uint32 tyc1 = catalogNumber;
|
||||
sprintf(buf, "TYC %d-%d-%d", tyc1, tyc2, tyc3);
|
||||
strncpy(nameBuffer, iter->second.c_str(), bufferSize);
|
||||
nameBuffer[bufferSize - 1] = '\0';
|
||||
return;
|
||||
}
|
||||
}
|
||||
return string(buf);
|
||||
|
||||
catalogNumberToString(catalogNumber, nameBuffer, bufferSize);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ class StarDatabase
|
|||
float radius) const;
|
||||
|
||||
std::string getStarName (const Star&) const;
|
||||
void getStarName(const Star& star, char* nameBuffer, unsigned int bufferSize) const;
|
||||
std::string getStarNameList(const Star&, const unsigned int maxNames = MAX_STAR_NAMES) const;
|
||||
|
||||
StarNameDatabase* getNameDatabase() const;
|
||||
|
|
|
@ -40,6 +40,7 @@ unsigned int vp::diffuseTexOffset_2light = 0;
|
|||
unsigned int vp::specular_2light = 0;
|
||||
unsigned int vp::nightLights_2light = 0;
|
||||
unsigned int vp::ellipticalGalaxy = 0;
|
||||
unsigned int vp::starDisc = 0;
|
||||
|
||||
|
||||
class VertexProcessorNV : public VertexProcessor
|
||||
|
@ -276,6 +277,8 @@ VertexProcessor* vp::initARB()
|
|||
return NULL;
|
||||
if (!LoadARBVertexProgram("shaders/night2_arb.vp", nightLights_2light))
|
||||
return NULL;
|
||||
if (!LoadARBVertexProgram("shaders/star_arb.vp", starDisc))
|
||||
return NULL;
|
||||
|
||||
// Load vertex programs that are only required with fragment programs
|
||||
if (ExtensionSupported("GL_NV_fragment_program") ||
|
||||
|
|
|
@ -76,6 +76,7 @@ namespace vp
|
|||
extern unsigned int specular_2light;
|
||||
extern unsigned int nightLights_2light;
|
||||
extern unsigned int ellipticalGalaxy;
|
||||
extern unsigned int starDisc;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1397,12 +1397,14 @@ void CelestiaCore::charEntered(const char *c_p, int modifiers)
|
|||
case '\031': // Ctrl+Y
|
||||
renderer->setRenderFlags(renderer->getRenderFlags() ^ Renderer::ShowAutoMag);
|
||||
if (renderer->getRenderFlags() & Renderer::ShowAutoMag)
|
||||
{
|
||||
{
|
||||
flash(_("Auto-magnitude enabled"));
|
||||
setFaintestAutoMag();
|
||||
}
|
||||
setFaintestAutoMag();
|
||||
}
|
||||
else
|
||||
{
|
||||
flash(_("Auto-magnitude disabled"));
|
||||
}
|
||||
notifyWatchers(RenderFlagsChanged);
|
||||
break;
|
||||
|
||||
|
@ -1924,7 +1926,10 @@ void CelestiaCore::charEntered(const char *c_p, int modifiers)
|
|||
break;
|
||||
|
||||
case '@':
|
||||
editMode = !editMode;
|
||||
// Obsolete?
|
||||
//editMode = !editMode;
|
||||
renderer->setRenderFlags(renderer->getRenderFlags() ^ Renderer::ShowNewStars);
|
||||
notifyWatchers(RenderFlagsChanged);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -3811,26 +3816,11 @@ bool CelestiaCore::initRenderer()
|
|||
return false;
|
||||
}
|
||||
|
||||
// Set up the star labels
|
||||
for (vector<string>::const_iterator iter = config->labelledStars.begin();
|
||||
iter != config->labelledStars.end();
|
||||
iter++)
|
||||
if ((renderer->getRenderFlags() & Renderer::ShowAutoMag) != 0)
|
||||
{
|
||||
Star* star = universe->getStarCatalog()->find(*iter);
|
||||
if (star != NULL)
|
||||
renderer->addLabelledStar(star, *iter);
|
||||
}
|
||||
|
||||
if((renderer->getRenderFlags() & Renderer::ShowAutoMag) != 0)
|
||||
{
|
||||
renderer->setFaintestAM45deg(renderer->getFaintestAM45deg());
|
||||
renderer->setFaintestAM45deg(renderer->getFaintestAM45deg());
|
||||
setFaintestAutoMag();
|
||||
}
|
||||
else
|
||||
{
|
||||
renderer->setBrightnessBias(0.1f);
|
||||
renderer->setSaturationMagnitude(1.0f);
|
||||
}
|
||||
|
||||
if (config->mainFont == "")
|
||||
font = LoadTextureFont("fonts/default.txf");
|
||||
|
@ -3855,21 +3845,23 @@ bool CelestiaCore::initRenderer()
|
|||
|
||||
if (config->labelFont == "")
|
||||
{
|
||||
renderer->setFont(font);
|
||||
renderer->setFont(Renderer::FontNormal, font);
|
||||
}
|
||||
else
|
||||
{
|
||||
TextureFont* labelFont = LoadTextureFont(string("fonts") + "/" + config->labelFont);
|
||||
if (labelFont == NULL)
|
||||
{
|
||||
renderer->setFont(font);
|
||||
renderer->setFont(Renderer::FontNormal, font);
|
||||
}
|
||||
else
|
||||
{
|
||||
labelFont->buildTexture();
|
||||
renderer->setFont(labelFont);
|
||||
renderer->setFont(Renderer::FontNormal, labelFont);
|
||||
}
|
||||
}
|
||||
|
||||
renderer->setFont(Renderer::FontLarge, titleFont);
|
||||
|
||||
if (config->logoTextureFile != "")
|
||||
{
|
||||
|
@ -3998,8 +3990,6 @@ bool CelestiaCore::readStars(const CelestiaConfig& cfg,
|
|||
/// brightness parameters appropriately.
|
||||
void CelestiaCore::setFaintest(float magnitude)
|
||||
{
|
||||
renderer->setBrightnessBias(0.1f);
|
||||
renderer->setSaturationMagnitude(1.0f);
|
||||
sim->setFaintestVisible(magnitude);
|
||||
}
|
||||
|
||||
|
@ -4009,7 +3999,6 @@ void CelestiaCore::setFaintest(float magnitude)
|
|||
void CelestiaCore::setFaintestAutoMag()
|
||||
{
|
||||
float faintestMag;
|
||||
renderer->setBrightnessBias(0.1f);
|
||||
renderer->autoMag(faintestMag);
|
||||
sim->setFaintestVisible(faintestMag);
|
||||
}
|
||||
|
@ -4215,7 +4204,8 @@ void CelestiaCore::goToUrl(const string& urlStr)
|
|||
Url url(urlStr, this);
|
||||
url.goTo();
|
||||
timeScale = sim->getTimeScale();
|
||||
notifyWatchers(RenderFlagsChanged|LabelFlagsChanged);
|
||||
clog << "goToUrl: " << timeScale << endl;
|
||||
notifyWatchers(RenderFlagsChanged | LabelFlagsChanged);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -762,7 +762,7 @@ const std::string& Greek::canonicalAbbreviation(const std::string& letter)
|
|||
//! of a string by the UTF-8 representation of that letter.
|
||||
//! Also, replace digits following Greek letters with UTF-8
|
||||
//! superscripts.
|
||||
std::string ReplaceGreekLetterAbbr(std::string str)
|
||||
std::string ReplaceGreekLetterAbbr(const std::string& str)
|
||||
{
|
||||
std::string ret = str;
|
||||
|
||||
|
@ -803,3 +803,102 @@ std::string ReplaceGreekLetterAbbr(std::string str)
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
//! Replaces the Greek letter abbreviation at the beginning
|
||||
//! of a string by the UTF-8 representation of that letter.
|
||||
//! Also, replace digits following Greek letters with UTF-8
|
||||
//! superscripts. Operates on char* instead of strings--less
|
||||
//! convenient, but more efficient. Return the number of
|
||||
//! characters copied to the destination string, not
|
||||
//! including the zero terminator.
|
||||
unsigned int
|
||||
ReplaceGreekLetterAbbr(char *dst, unsigned int dstSize, const char* src, unsigned int srcLength)
|
||||
{
|
||||
if (src[0] >= 'A' && src[0] <= 'Z' &&
|
||||
src[1] >= 'A' && src[1] <= 'Z')
|
||||
{
|
||||
// Linear search through all letter abbreviations
|
||||
for (unsigned int i = 0; i < (unsigned int) Greek::instance->nLetters; i++)
|
||||
{
|
||||
const char* abbr = canonicalAbbrevs[i];
|
||||
unsigned int j = 0;
|
||||
while (abbr[j] == src[j] && abbr[j] != '\0' && src[j] != '\0')
|
||||
j++;
|
||||
|
||||
// It's a match if we reached the end of the abbreviation string
|
||||
if (abbr[j] == '\0')
|
||||
{
|
||||
unsigned int abbrevLength = j;
|
||||
unsigned int srcIndex = j;
|
||||
char* superscript = NULL;
|
||||
if (src[abbrevLength] == '1')
|
||||
superscript = UTF8_SUPERSCRIPT_1;
|
||||
else if (src[abbrevLength] == '2')
|
||||
superscript = UTF8_SUPERSCRIPT_2;
|
||||
else if (src[abbrevLength] == '3')
|
||||
superscript = UTF8_SUPERSCRIPT_3;
|
||||
|
||||
const char* utfGreek = greekAlphabetUTF8[i];
|
||||
unsigned int utfGreekLength = strlen(utfGreek);
|
||||
|
||||
unsigned int requiredLength = (int) srcLength;
|
||||
if (utfGreekLength > abbrevLength)
|
||||
requiredLength += utfGreekLength - abbrevLength;
|
||||
if (superscript != NULL)
|
||||
{
|
||||
requiredLength += strlen(superscript) - 1;
|
||||
srcIndex++;
|
||||
}
|
||||
|
||||
// If there's not enough room, give up translating and just copy as much as possible
|
||||
if (requiredLength + 1 > dstSize)
|
||||
break;
|
||||
|
||||
unsigned int dstIndex = 0;
|
||||
j = 0;
|
||||
while (utfGreek[j])
|
||||
{
|
||||
dst[dstIndex++] = utfGreek[j];
|
||||
j++;
|
||||
}
|
||||
|
||||
if (superscript != NULL)
|
||||
{
|
||||
j = 0;
|
||||
while (superscript[j])
|
||||
{
|
||||
dst[dstIndex++] = superscript[j];
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
while (src[srcIndex])
|
||||
{
|
||||
dst[dstIndex++] = src[srcIndex++];
|
||||
}
|
||||
dst[dstIndex] = '\0';
|
||||
|
||||
return dstIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
strncpy(dst, src, dstSize);
|
||||
if (dstSize > srcLength)
|
||||
{
|
||||
return srcLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dstSize > 0)
|
||||
{
|
||||
dst[dstSize - 1] = '\0';
|
||||
return dstSize - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,8 @@ inline int UTF8EncodedSizeFromFirstByte(unsigned int ch)
|
|||
return charlen;
|
||||
}
|
||||
|
||||
std::string ReplaceGreekLetterAbbr(std::string);
|
||||
std::string ReplaceGreekLetterAbbr(const std::string&);
|
||||
unsigned int ReplaceGreekLetterAbbr(char* dst, unsigned int dstSize, const char* src, unsigned int srcLength);
|
||||
|
||||
class Greek
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue