Added separate render and label flags for the various types of deep sky objects. This will break some scripts and cel:// URLs that relied on the 'show galaxies' flag to also show nebulae, but this is the inescapable cost of moving to a more flexible set of render settings.
parent
f684150e16
commit
57ff878447
|
@ -18,6 +18,10 @@
|
|||
#include <celengine/parser.h>
|
||||
|
||||
|
||||
class Nebula;
|
||||
class Galaxy;
|
||||
class OpenCluster;
|
||||
|
||||
class DeepSkyObject
|
||||
{
|
||||
public:
|
||||
|
@ -46,6 +50,9 @@ class DeepSkyObject
|
|||
float brightness,
|
||||
float pixelSize) = 0;
|
||||
|
||||
virtual unsigned int getRenderMask() { return 0; };
|
||||
virtual unsigned int getLabelMask() { return 0; };
|
||||
|
||||
private:
|
||||
std::string name;
|
||||
Point3d position;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "gl.h"
|
||||
#include "vecgl.h"
|
||||
#include "texture.h"
|
||||
#include "render.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -237,6 +238,18 @@ void Galaxy::render(const Vec3f& offset,
|
|||
}
|
||||
|
||||
|
||||
unsigned int Galaxy::getRenderMask()
|
||||
{
|
||||
return Renderer::ShowGalaxies;
|
||||
}
|
||||
|
||||
|
||||
unsigned int Galaxy::getLabelMask()
|
||||
{
|
||||
return Renderer::GalaxyLabels;
|
||||
}
|
||||
|
||||
|
||||
void InitializeForms()
|
||||
{
|
||||
int galaxySize = 5000;
|
||||
|
|
|
@ -62,6 +62,9 @@ class Galaxy : public DeepSkyObject
|
|||
float brightness,
|
||||
float pixelSize);
|
||||
|
||||
virtual unsigned int getRenderMask();
|
||||
virtual unsigned int getLabelMask();
|
||||
|
||||
GalacticForm* getForm() const;
|
||||
|
||||
private:
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "rendcontext.h"
|
||||
#include "gl.h"
|
||||
#include "vecgl.h"
|
||||
#include "render.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -83,3 +84,15 @@ void Nebula::render(const Vec3f& offset,
|
|||
|
||||
glEnable(GL_BLEND);
|
||||
}
|
||||
|
||||
|
||||
unsigned int Nebula::getRenderMask()
|
||||
{
|
||||
return Renderer::ShowNebulae;
|
||||
}
|
||||
|
||||
|
||||
unsigned int Nebula::getLabelMask()
|
||||
{
|
||||
return Renderer::NebulaLabels;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,9 @@ class Nebula : public DeepSkyObject
|
|||
float brightness,
|
||||
float pixelSize);
|
||||
|
||||
virtual unsigned int getRenderMask();
|
||||
virtual unsigned int getLabelMask();
|
||||
|
||||
void setModel(ResourceHandle);
|
||||
ResourceHandle getModel() const;
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "meshmanager.h"
|
||||
#include "gl.h"
|
||||
#include "vecgl.h"
|
||||
#include "render.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -45,3 +46,15 @@ void OpenCluster::render(const Vec3f& offset,
|
|||
// would be to add an 'sky chart' mode, in which clusters are rendered as
|
||||
// circles.
|
||||
}
|
||||
|
||||
|
||||
unsigned int OpenCluster::getRenderMask()
|
||||
{
|
||||
return Renderer::ShowOpenClusters;
|
||||
}
|
||||
|
||||
|
||||
unsigned int OpenCluster::getLabelMask()
|
||||
{
|
||||
return Renderer::OpenClusterLabels;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,9 @@ class OpenCluster : public DeepSkyObject
|
|||
float brightness,
|
||||
float pixelSize);
|
||||
|
||||
virtual unsigned int getRenderMask();
|
||||
virtual unsigned int getLabelMask();
|
||||
|
||||
private:
|
||||
// TODO: It could be very useful to have a list of stars that are members
|
||||
// of the cluster.
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include "vertexprog.h"
|
||||
#include "texmanager.h"
|
||||
#include "meshmanager.h"
|
||||
#include "rendcontext.h"
|
||||
#include "render.h"
|
||||
|
||||
using namespace std;
|
||||
|
@ -1339,8 +1338,7 @@ void Renderer::render(const Observer& observer,
|
|||
glEnable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
if ((renderFlags & ShowGalaxies) != 0 &&
|
||||
universe.getDeepSkyCatalog() != NULL)
|
||||
if (universe.getDeepSkyCatalog() != NULL)
|
||||
renderDeepSkyObjects(*universe.getDeepSkyCatalog(), observer);
|
||||
|
||||
// Translate the camera before rendering the stars
|
||||
|
@ -1392,8 +1390,8 @@ void Renderer::render(const Observer& observer,
|
|||
disableSmoothLines();
|
||||
}
|
||||
|
||||
if ((labelMode & GalaxyLabels) != 0 && universe.getDeepSkyCatalog() != NULL)
|
||||
labelGalaxies(*universe.getDeepSkyCatalog(), observer);
|
||||
if (universe.getDeepSkyCatalog() != NULL)
|
||||
labelDeepSkyObjects(*universe.getDeepSkyCatalog(), observer);
|
||||
if ((labelMode & StarLabels) != 0 && universe.getStarCatalog() != NULL)
|
||||
labelStars(labelledStars, *universe.getStarCatalog(), observer);
|
||||
if ((labelMode & ConstellationLabels) != 0 &&
|
||||
|
@ -2994,6 +2992,16 @@ static void renderModelDefault(Model* model,
|
|||
}
|
||||
|
||||
|
||||
static void renderModel_GLSL(Model* Model,
|
||||
const LightingState& ls,
|
||||
float radius,
|
||||
const Mat4f& planetMat)
|
||||
{
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void renderSphereDefault(const RenderInfo& ri,
|
||||
const Frustum& frustum,
|
||||
bool lit,
|
||||
|
@ -6361,6 +6369,10 @@ void Renderer::renderDeepSkyObjects(const DeepSkyCatalog& catalog,
|
|||
iter != catalog.end(); iter++)
|
||||
{
|
||||
DeepSkyObject* obj = *iter;
|
||||
|
||||
if ((renderFlags & obj->getRenderMask()) == 0)
|
||||
continue;
|
||||
|
||||
Point3d pos = obj->getPosition();
|
||||
float radius = obj->getRadius();
|
||||
Vec3f offset = Vec3f((float) (pos.x - observerPos.x),
|
||||
|
@ -6468,8 +6480,8 @@ void Renderer::renderCelestialSphere(const Observer& observer)
|
|||
}
|
||||
|
||||
|
||||
void Renderer::labelGalaxies(const DeepSkyCatalog& catalog,
|
||||
const Observer& observer)
|
||||
void Renderer::labelDeepSkyObjects(const DeepSkyCatalog& catalog,
|
||||
const Observer& observer)
|
||||
{
|
||||
Point3f observerPos_ly = (Point3f) observer.getPosition() * ((float)1e-6);
|
||||
|
||||
|
@ -6477,14 +6489,17 @@ void Renderer::labelGalaxies(const DeepSkyCatalog& catalog,
|
|||
iter != catalog.end(); iter++)
|
||||
{
|
||||
DeepSkyObject* obj = *iter;
|
||||
Point3d posd = obj->getPosition();
|
||||
Point3f pos((float) posd.x, (float) posd.y, (float) posd.z);
|
||||
|
||||
Vec3f rpos = pos - observerPos_ly;
|
||||
if ((rpos * conjugate(observer.getOrientation()).toMatrix3()).z < 0)
|
||||
if ((obj->getLabelMask() & labelMode) != 0)
|
||||
{
|
||||
addLabel(obj->getName(), Color(0.7f, 0.7f, 0.0f),
|
||||
Point3f(rpos.x, rpos.y, rpos.z));
|
||||
Point3d posd = obj->getPosition();
|
||||
Point3f pos((float) posd.x, (float) posd.y, (float) posd.z);
|
||||
|
||||
Vec3f rpos = pos - observerPos_ly;
|
||||
if ((rpos * conjugate(observer.getOrientation()).toMatrix3()).z < 0)
|
||||
{
|
||||
addLabel(obj->getName(), Color(0.7f, 0.7f, 0.0f),
|
||||
Point3f(rpos.x, rpos.y, rpos.z));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6501,7 +6516,7 @@ void Renderer::labelStars(const vector<StarLabel>& stars,
|
|||
Star* star = iter->star;
|
||||
Point3f pos = star->getPosition();
|
||||
float distance = pos.distanceTo(observerPos_ly);
|
||||
float appMag = (distance > 0.0f) ?
|
||||
float appMag = (distance > 0.0f) ?
|
||||
astro::absToAppMag(star->getAbsoluteMagnitude(), distance) : -100.0f;
|
||||
|
||||
if (appMag < faintestMag && distance <= distanceLimit)
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <celengine/selection.h>
|
||||
#include <celengine/glcontext.h>
|
||||
#include <celengine/starcolors.h>
|
||||
#include <celengine/rendcontext.h>
|
||||
#include <celtxf/texturefont.h>
|
||||
|
||||
|
||||
|
@ -37,44 +38,8 @@ struct RenderListEntry
|
|||
int solarSysIndex;
|
||||
};
|
||||
|
||||
static const unsigned int MaxLights = 8;
|
||||
static const unsigned int MaxSolarSystems = 16;
|
||||
|
||||
struct DirectionalLight
|
||||
{
|
||||
Color color;
|
||||
float irradiance;
|
||||
Vec3f direction_eye;
|
||||
Vec3f direction_obj;
|
||||
|
||||
// Required for eclipse shadows only--may be able to use
|
||||
// distance instead of position.
|
||||
Point3d position;
|
||||
float apparentSize;
|
||||
};
|
||||
|
||||
struct EclipseShadow
|
||||
{
|
||||
Point3f origin;
|
||||
Vec3f direction;
|
||||
float penumbraRadius;
|
||||
float umbraRadius;
|
||||
};
|
||||
|
||||
struct LightingState
|
||||
{
|
||||
LightingState() : nLights(0),
|
||||
eyeDir_obj(0.0f, 0.0f, -1.0f),
|
||||
eyePos_obj(0.0f, 0.0f, -1.0f)
|
||||
{ shadows[0] = NULL; };
|
||||
|
||||
unsigned int nLights;
|
||||
DirectionalLight lights[MaxLights];
|
||||
vector<EclipseShadow>* shadows[MaxLights];
|
||||
|
||||
Vec3f eyeDir_obj;
|
||||
Point3f eyePos_obj;
|
||||
};
|
||||
|
||||
class Renderer
|
||||
{
|
||||
|
@ -117,6 +82,8 @@ class Renderer
|
|||
SpacecraftLabels = 0x040,
|
||||
LocationLabels = 0x080,
|
||||
CometLabels = 0x100,
|
||||
NebulaLabels = 0x200,
|
||||
OpenClusterLabels = 0x400,
|
||||
BodyLabelMask = (PlanetLabels | MoonLabels | AsteroidLabels | SpacecraftLabels | CometLabels),
|
||||
};
|
||||
|
||||
|
@ -140,6 +107,8 @@ class Renderer
|
|||
ShowCometTails = 0x8000,
|
||||
ShowMarkers = 0x10000,
|
||||
ShowPartialTrajectories = 0x20000,
|
||||
ShowNebulae = 0x40000,
|
||||
ShowOpenClusters = 0x80000,
|
||||
};
|
||||
|
||||
enum StarStyle
|
||||
|
@ -379,8 +348,8 @@ class Renderer
|
|||
double now,
|
||||
vector<EclipseShadow>& shadows);
|
||||
|
||||
void labelGalaxies(const DeepSkyCatalog& catalog,
|
||||
const Observer& observer);
|
||||
void labelDeepSkyObjects(const DeepSkyCatalog& catalog,
|
||||
const Observer& observer);
|
||||
void labelStars(const std::vector<StarLabel>& stars,
|
||||
const StarDatabase& starDB,
|
||||
const Observer& observer);
|
||||
|
|
Loading…
Reference in New Issue