Multi Resolution Texturing
|
@ -421,5 +421,5 @@ Code:
|
|||
* Improved the appearance of the corona around stars
|
||||
* Fixed specular lighting for 3DS meshes, but correcting the mapping of 3DS
|
||||
shininess to OpenGL specular exponents.
|
||||
|
||||
|
||||
* Multi Resolution Texturing. (dramsey)
|
||||
|
||||
|
|
4
README
|
@ -140,6 +140,7 @@ Ctrl+L : Toggle night side planet maps (light pollution)
|
|||
W : Toggle wireframe mode
|
||||
Ctrl+P : Toggle per-pixel lighting (if supported)
|
||||
Ctrl+V : Toggle vertex programs (if supported)
|
||||
r R: lower or raise texture resolution
|
||||
|
||||
Spaceflight:
|
||||
F1 : Stop
|
||||
|
@ -317,6 +318,9 @@ The Venus, Saturn, and Saturn's rings textures are from Bjorn Jonsson.
|
|||
His site is http://www.mmedia.is/~bjj/ and is an excellent resource
|
||||
for solar system rendering.
|
||||
|
||||
The lower resolution textures were all converted from their higher resolution
|
||||
Versions using Gimp.
|
||||
|
||||
3D asteroid models of Toutatis, Kleopatra, and Geographos are courtesy of
|
||||
Scott Hudson, Washington State University. His site is:
|
||||
http://www.eecs.wsu.edu/~hudson/Research/Asteroids/4179/index.html
|
||||
|
|
39
configure.in
|
@ -208,24 +208,27 @@ fi
|
|||
AC_MSG_RESULT($enable_hipparcos)
|
||||
AM_CONDITIONAL(ENABLE_HIPPARCOS, test "x$enable_hipparcos" = "xyes")
|
||||
|
||||
AC_OUTPUT( Makefile \
|
||||
src/Makefile \
|
||||
src/celutil/Makefile \
|
||||
src/celmath/Makefile \
|
||||
src/cel3ds/Makefile \
|
||||
src/celtxf/Makefile \
|
||||
src/celengine/Makefile \
|
||||
src/celestia/Makefile \
|
||||
data/Makefile \
|
||||
extras/Makefile \
|
||||
textures/Makefile \
|
||||
models/Makefile \
|
||||
shaders/Makefile \
|
||||
fonts/Makefile \
|
||||
src/celestia/res/Makefile \
|
||||
macros/Makefile \
|
||||
manual/Makefile \
|
||||
)
|
||||
AC_OUTPUT( Makefile \
|
||||
src/Makefile \
|
||||
src/celutil/Makefile \
|
||||
src/celmath/Makefile \
|
||||
src/cel3ds/Makefile \
|
||||
src/celtxf/Makefile \
|
||||
src/celengine/Makefile \
|
||||
src/celestia/Makefile \
|
||||
data/Makefile \
|
||||
extras/Makefile \
|
||||
textures/Makefile \
|
||||
textures/lores/Makefile \
|
||||
textures/medres/Makefile \
|
||||
textures/hires/Makefile \
|
||||
models/Makefile \
|
||||
shaders/Makefile \
|
||||
fonts/Makefile \
|
||||
src/celestia/res/Makefile \
|
||||
macros/Makefile \
|
||||
manual/Makefile \
|
||||
)
|
||||
|
||||
AC_MSG_RESULT()
|
||||
AC_MSG_RESULT()
|
||||
|
|
|
@ -58,6 +58,7 @@ Ctrl+L : Toggle night side planet maps (light pollution)
|
|||
W : Toggle wireframe mode
|
||||
Ctrl+P : Toggle per-pixel lighting (if supported)
|
||||
Ctrl+V : Toggle vertex programs (if supported)
|
||||
r R: lower or raise texture resolution
|
||||
|
||||
Spaceflight:
|
||||
F1 : Stop
|
||||
|
|
|
@ -24,6 +24,7 @@ libcelengine_a_SOURCES = \
|
|||
glext.cpp \
|
||||
lodspheremesh.cpp \
|
||||
meshmanager.cpp \
|
||||
multitexture.cpp \
|
||||
observer.cpp \
|
||||
octree.cpp \
|
||||
orbit.cpp \
|
||||
|
|
|
@ -21,7 +21,7 @@ class Atmosphere
|
|||
height(0.0f),
|
||||
cloudHeight(0.0f),
|
||||
cloudSpeed(0.0f),
|
||||
cloudTex(InvalidResource) {};
|
||||
cloudTexture() {};
|
||||
|
||||
public:
|
||||
float height;
|
||||
|
@ -30,7 +30,7 @@ class Atmosphere
|
|||
Color skyColor;
|
||||
float cloudHeight;
|
||||
float cloudSpeed;
|
||||
ResourceHandle cloudTex;
|
||||
MultiTexture cloudTexture;
|
||||
};
|
||||
|
||||
#endif // _ATMOSPHERE_H_
|
||||
|
|
|
@ -71,13 +71,16 @@ class RingSystem
|
|||
float innerRadius;
|
||||
float outerRadius;
|
||||
Color color;
|
||||
int texture;
|
||||
MultiTexture texture;
|
||||
|
||||
RingSystem(float inner, float outer) :
|
||||
innerRadius(inner), outerRadius(outer), color(1.0f, 1.0f, 1.0f), texture(-1)
|
||||
innerRadius(inner), outerRadius(outer), color(1.0f, 1.0f, 1.0f), texture()
|
||||
{ }
|
||||
RingSystem(float inner, float outer, Color _color, int _texture = -1) :
|
||||
innerRadius(inner), outerRadius(outer), color(_color), texture(_texture)
|
||||
RingSystem(float inner, float outer, Color _color, int _loTexture=-1, int _texture = -1) :
|
||||
innerRadius(inner), outerRadius(outer), color(_color), texture(_loTexture, _texture)
|
||||
{ }
|
||||
RingSystem(float inner, float outer, Color _color, string textureName) :
|
||||
innerRadius(inner), outerRadius(outer), color(_color), texture(textureName)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
// multitexture.cpp
|
||||
//
|
||||
// Copyright (C) 2002 Deon Ramsey <dramsey@sourceforge.net>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
|
||||
#include "multitexture.h"
|
||||
#include "texmanager.h"
|
||||
#include <celutil/debug.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
void MultiTexture::setTexture(const string &source, bool compress)
|
||||
{
|
||||
TextureManager* texMan = GetTextureManager();
|
||||
tex[lores]=texMan->getHandle(TextureInfo(source, compress, lores));
|
||||
tex[medres]=texMan->getHandle(TextureInfo(source, compress, medres));
|
||||
tex[hires]=texMan->getHandle(TextureInfo(source, compress, hires));
|
||||
}
|
||||
|
||||
|
||||
void MultiTexture::setTexture(const string &source, float height)
|
||||
{
|
||||
TextureManager* texMan = GetTextureManager();
|
||||
tex[lores]=texMan->getHandle(TextureInfo(source, height, lores));
|
||||
tex[medres]=texMan->getHandle(TextureInfo(source, height, medres));
|
||||
tex[hires]=texMan->getHandle(TextureInfo(source, height, hires));
|
||||
}
|
||||
|
||||
Texture* MultiTexture::find(unsigned int resolution)
|
||||
{
|
||||
TextureManager* texMan = GetTextureManager();
|
||||
Texture *res=texMan->find(tex[resolution]);
|
||||
if(res||resolution==lores)
|
||||
return res;
|
||||
tex[resolution]=tex[resolution-1];
|
||||
res=texMan->find(tex[resolution]);
|
||||
if(res||resolution==medres)
|
||||
return res;
|
||||
tex[hires]=tex[medres]=tex[lores];
|
||||
return texMan->find(tex[lores]);
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
// multitexture.h
|
||||
//
|
||||
// Copyright (C) 2002, Deon Ramsey
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
|
||||
#ifndef _CELENGINE_MULTITEXTURE_H_
|
||||
#define _CELENGINE_MULTITEXTURE_H_
|
||||
|
||||
#include <string>
|
||||
#include "texture.h"
|
||||
#include <celutil/reshandle.h>
|
||||
|
||||
#define TEXTURE_RESOLUTION 3
|
||||
|
||||
enum {
|
||||
lores = 0,
|
||||
medres = 1,
|
||||
hires = 2
|
||||
};
|
||||
|
||||
|
||||
class MultiTexture
|
||||
{
|
||||
public:
|
||||
MultiTexture() {tex[lores]=tex[medres]=tex[hires]=InvalidResource;};
|
||||
MultiTexture(ResourceHandle loTexture, ResourceHandle medTexture=InvalidResource, ResourceHandle hiTexture=InvalidResource) {tex[lores]=loTexture; tex[medres]=medTexture; tex[hires]=hiTexture;};
|
||||
MultiTexture(string source) {setTexture(source);};
|
||||
~MultiTexture() {};
|
||||
void setTexture(const string &source, bool compressed = false);
|
||||
void setTexture(const string &source, float height);
|
||||
Texture* find(unsigned int resolution);
|
||||
|
||||
public:
|
||||
ResourceHandle tex[3];
|
||||
};
|
||||
|
||||
#endif // _CELENGINE_MULTITEXTURE_H_
|
|
@ -63,10 +63,15 @@ static Texture* glareTex = NULL;
|
|||
static Texture* galaxyTex = NULL;
|
||||
static Texture* shadowTex = NULL;
|
||||
|
||||
static ResourceHandle starTexB = InvalidResource;
|
||||
static ResourceHandle starTexA = InvalidResource;
|
||||
static ResourceHandle starTexG = InvalidResource;
|
||||
static ResourceHandle starTexM = InvalidResource;
|
||||
static Surface starSurfs[StellarClass::Spectral_Unknown+1];
|
||||
|
||||
static char *starTextures[]=
|
||||
{
|
||||
"bstar.jpg",
|
||||
"astar.jpg",
|
||||
"gstar.jpg",
|
||||
"mstar.jpg"
|
||||
};
|
||||
|
||||
static const float CoronaHeight = 0.2f;
|
||||
|
||||
|
@ -107,7 +112,8 @@ Renderer::Renderer() :
|
|||
useRegisterCombiners(false),
|
||||
useCubeMaps(false),
|
||||
useVertexPrograms(false),
|
||||
useRescaleNormal(false)
|
||||
useRescaleNormal(false),
|
||||
textureResolution(medres)
|
||||
{
|
||||
starVertexBuffer = new StarVertexBuffer(2048);
|
||||
}
|
||||
|
@ -173,10 +179,10 @@ static void IllumMapEval(float x, float y, float z,
|
|||
unsigned char* pixel)
|
||||
{
|
||||
Vec3f v(x, y, z);
|
||||
Vec3f n(0, 0, 1);
|
||||
Vec3f u(0, 0, 1);
|
||||
|
||||
#if 0
|
||||
Vec3f n(0, 0, 1);
|
||||
// Experimental illumination function
|
||||
float c = v * n;
|
||||
if (c < 0.0f)
|
||||
|
@ -235,7 +241,7 @@ bool Renderer::init(int winWidth, int winHeight)
|
|||
galaxyTex = CreateProceduralTexture(128, 128, GL_RGBA, GlareTextureEval);
|
||||
galaxyTex->bindName();
|
||||
|
||||
glareTex = CreateJPEGTexture("textures/flare.jpg");
|
||||
glareTex = getJPEGTexture("textures/flare.jpg");
|
||||
if (glareTex == NULL)
|
||||
glareTex = CreateProceduralTexture(64, 64, GL_RGB, GlareTextureEval);
|
||||
glareTex->bindName();
|
||||
|
@ -243,10 +249,23 @@ bool Renderer::init(int winWidth, int winHeight)
|
|||
shadowTex = CreateProceduralTexture(256, 256, GL_RGB, ShadowTextureEval);
|
||||
shadowTex->bindName();
|
||||
|
||||
starTexB = GetTextureManager()->getHandle(TextureInfo("bstar.jpg"));
|
||||
starTexA = GetTextureManager()->getHandle(TextureInfo("astar.jpg"));
|
||||
starTexG = GetTextureManager()->getHandle(TextureInfo("gstar.jpg"));
|
||||
starTexM = GetTextureManager()->getHandle(TextureInfo("mstar.jpg"));
|
||||
StellarClass sc;
|
||||
|
||||
for (unsigned int spectralClass=StellarClass::Spectral_O;
|
||||
spectralClass<=StellarClass::Spectral_Unknown; spectralClass++)
|
||||
{
|
||||
int off=spectralClass/2;
|
||||
if(off>3)
|
||||
--off; // S & N stars have same textures as M & R stars.
|
||||
if(off>3)
|
||||
off=1; // WC, WN and Unknowns get the A class texture.
|
||||
starSurfs[spectralClass].baseTexture.setTexture(starTextures[off]);
|
||||
starSurfs[spectralClass].appearanceFlags |= Surface::ApplyBaseTexture;
|
||||
starSurfs[spectralClass].appearanceFlags |= Surface::Emissive;
|
||||
starSurfs[spectralClass].color =
|
||||
sc.getApparentColor((StellarClass::SpectralClass)spectralClass);
|
||||
}
|
||||
|
||||
|
||||
// Initialize GL extensions
|
||||
if (ExtensionSupported("GL_ARB_multitexture"))
|
||||
|
@ -397,6 +416,19 @@ void Renderer::setFieldOfView(float _fov)
|
|||
}
|
||||
|
||||
|
||||
unsigned int Renderer::getResolution()
|
||||
{
|
||||
return textureResolution;
|
||||
}
|
||||
|
||||
|
||||
void Renderer::setResolution(unsigned int resolution)
|
||||
{
|
||||
if(resolution < TEXTURE_RESOLUTION)
|
||||
textureResolution = resolution;
|
||||
}
|
||||
|
||||
|
||||
TextureFont* Renderer::getFont() const
|
||||
{
|
||||
return font;
|
||||
|
@ -626,7 +658,7 @@ void Renderer::render(const Observer& observer,
|
|||
// limiting magnitude of stars (so stars aren't visible in the daytime
|
||||
// on planets with thick atmospheres.)
|
||||
{
|
||||
vector<RenderListEntry>::iterator notCulled = renderList.begin();
|
||||
//vector<RenderListEntry>::iterator notCulled = renderList.begin();
|
||||
for (vector<RenderListEntry>::iterator iter = renderList.begin();
|
||||
iter != renderList.end(); iter++)
|
||||
{
|
||||
|
@ -1776,16 +1808,15 @@ void Renderer::renderObject(Point3f pos,
|
|||
glDisable(GL_BLEND);
|
||||
|
||||
// Get the textures . . .
|
||||
TextureManager* textureManager = GetTextureManager();
|
||||
if (obj.surface->baseTexture != InvalidResource)
|
||||
ri.baseTex = textureManager->find(obj.surface->baseTexture);
|
||||
if (obj.surface->baseTexture.tex[textureResolution] != InvalidResource)
|
||||
ri.baseTex = obj.surface->baseTexture.find(textureResolution);
|
||||
if ((obj.surface->appearanceFlags & Surface::ApplyBumpMap) != 0 &&
|
||||
(fragmentShaderEnabled && useRegisterCombiners && useCubeMaps) &&
|
||||
obj.surface->bumpTexture != InvalidResource)
|
||||
ri.bumpTex = textureManager->find(obj.surface->bumpTexture);
|
||||
obj.surface->bumpTexture.tex[textureResolution] != InvalidResource)
|
||||
ri.bumpTex = obj.surface->bumpTexture.find(textureResolution);
|
||||
if ((obj.surface->appearanceFlags & Surface::ApplyNightMap) != 0 &&
|
||||
(renderFlags & ShowNightMaps) != 0)
|
||||
ri.nightTex = textureManager->find(obj.surface->nightTexture);
|
||||
ri.nightTex = obj.surface->nightTexture.find(textureResolution);
|
||||
|
||||
// Apply the modelview transform for the object
|
||||
glPushMatrix();
|
||||
|
@ -1932,7 +1963,7 @@ void Renderer::renderObject(Point3f pos,
|
|||
|
||||
if (obj.atmosphere != NULL)
|
||||
{
|
||||
const Atmosphere* atmosphere = obj.atmosphere;
|
||||
Atmosphere* atmosphere = const_cast<Atmosphere *>(obj.atmosphere);
|
||||
|
||||
// Compute the apparent thickness in pixels of the atmosphere.
|
||||
// If it's only one pixel thick, it can look quite unsightly
|
||||
|
@ -1972,8 +2003,8 @@ void Renderer::renderObject(Point3f pos,
|
|||
// If there's a cloud layer, we'll render it now.
|
||||
Texture* cloudTex = NULL;
|
||||
if ((renderFlags & ShowCloudMaps) != 0 &&
|
||||
atmosphere->cloudTex != InvalidResource)
|
||||
cloudTex = textureManager->find(atmosphere->cloudTex);
|
||||
atmosphere->cloudTexture.tex[textureResolution] != InvalidResource)
|
||||
cloudTex = atmosphere->cloudTexture.find(textureResolution);
|
||||
|
||||
if (cloudTex != NULL)
|
||||
{
|
||||
|
@ -2090,7 +2121,7 @@ void Renderer::renderObject(Point3f pos,
|
|||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
Texture* ringsTex = GetTextureManager()->find(rings->texture);
|
||||
Texture* ringsTex = rings->texture.find(textureResolution);
|
||||
|
||||
if (ringsTex != NULL)
|
||||
ringsTex->bind();
|
||||
|
@ -2176,7 +2207,7 @@ void Renderer::renderPlanet(const Body& body,
|
|||
{
|
||||
RenderProperties rp;
|
||||
|
||||
rp.surface = &body.getSurface();
|
||||
rp.surface = const_cast<Surface *>(&body.getSurface());
|
||||
rp.atmosphere = body.getAtmosphere();
|
||||
rp.rings = body.getRings();
|
||||
rp.radius = body.getRadius();
|
||||
|
@ -2258,44 +2289,18 @@ void Renderer::renderStar(const Star& star,
|
|||
|
||||
if (discSizeInPixels > 1)
|
||||
{
|
||||
Surface surface;
|
||||
Surface *surface;
|
||||
Atmosphere atmosphere;
|
||||
RenderProperties rp;
|
||||
|
||||
surface.color = color;
|
||||
switch (star.getStellarClass().getSpectralClass())
|
||||
{
|
||||
case StellarClass::Spectral_O:
|
||||
case StellarClass::Spectral_B:
|
||||
surface.baseTexture = starTexB;
|
||||
break;
|
||||
case StellarClass::Spectral_A:
|
||||
case StellarClass::Spectral_F:
|
||||
surface.baseTexture = starTexA;
|
||||
break;
|
||||
case StellarClass::Spectral_G:
|
||||
case StellarClass::Spectral_K:
|
||||
surface.baseTexture = starTexG;
|
||||
break;
|
||||
case StellarClass::Spectral_M:
|
||||
case StellarClass::Spectral_R:
|
||||
case StellarClass::Spectral_S:
|
||||
case StellarClass::Spectral_N:
|
||||
surface.baseTexture = starTexM;
|
||||
break;
|
||||
default:
|
||||
surface.baseTexture = starTexA;
|
||||
break;
|
||||
}
|
||||
surface.appearanceFlags |= Surface::ApplyBaseTexture;
|
||||
surface.appearanceFlags |= Surface::Emissive;
|
||||
surface=&(starSurfs[star.getStellarClass().getSpectralClass()]);
|
||||
|
||||
atmosphere.height = radius * CoronaHeight;
|
||||
atmosphere.lowerColor = color;
|
||||
atmosphere.upperColor = color;
|
||||
atmosphere.skyColor = color;
|
||||
|
||||
rp.surface = &surface;
|
||||
rp.surface = surface;
|
||||
rp.atmosphere = &atmosphere;
|
||||
rp.rings = NULL;
|
||||
rp.radius = star.getRadius();
|
||||
|
|
|
@ -83,6 +83,8 @@ class Renderer
|
|||
void setSaturationMagnitude(float);
|
||||
float getBrightnessBias() const;
|
||||
void setBrightnessBias(float);
|
||||
void setResolution(unsigned int resolution);
|
||||
unsigned int getResolution();
|
||||
|
||||
typedef struct {
|
||||
std::string text;
|
||||
|
@ -142,7 +144,7 @@ class Renderer
|
|||
orientation(1.0f)
|
||||
{};
|
||||
|
||||
const Surface* surface;
|
||||
Surface* surface;
|
||||
const Atmosphere* atmosphere;
|
||||
RingSystem* rings;
|
||||
RotationElements re;
|
||||
|
@ -272,6 +274,7 @@ class Renderer
|
|||
bool useCompressedTextures;
|
||||
bool useVertexPrograms;
|
||||
bool useRescaleNormal;
|
||||
unsigned int textureResolution;
|
||||
};
|
||||
|
||||
#endif // _RENDER_H_
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "texmanager.h"
|
||||
#include "meshmanager.h"
|
||||
#include "universe.h"
|
||||
#include "multitexture.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -74,15 +75,12 @@ static Surface* CreateSurface(Hash* surfaceData)
|
|||
if (surface->specularColor != Color(0.0f, 0.0f, 0.0f))
|
||||
surface->appearanceFlags |= Surface::SpecularReflection;
|
||||
|
||||
TextureManager* texMan = GetTextureManager();
|
||||
if (applyBaseTexture)
|
||||
surface->baseTexture = texMan->getHandle(TextureInfo(baseTexture,
|
||||
compressTexture));
|
||||
surface->baseTexture.setTexture(baseTexture,compressTexture);
|
||||
if (applyBumpMap)
|
||||
surface->bumpTexture = texMan->getHandle(TextureInfo(bumpTexture,
|
||||
bumpHeight));
|
||||
surface->bumpTexture.setTexture(bumpTexture,bumpHeight);
|
||||
if (applyNightMap)
|
||||
surface->nightTexture = texMan->getHandle(TextureInfo(nightTexture));
|
||||
surface->nightTexture.setTexture(nightTexture);
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
@ -297,8 +295,7 @@ static Body* CreatePlanet(PlanetarySystem* system,
|
|||
string cloudTexture;
|
||||
if (atmosData->getString("CloudMap", cloudTexture))
|
||||
{
|
||||
atmosphere->cloudTex =
|
||||
GetTextureManager()->getHandle(TextureInfo(cloudTexture));
|
||||
atmosphere->cloudTexture.setTexture(cloudTexture);
|
||||
}
|
||||
|
||||
body->setAtmosphere(*atmosphere);
|
||||
|
@ -330,10 +327,9 @@ static Body* CreatePlanet(PlanetarySystem* system,
|
|||
|
||||
string textureName;
|
||||
ringsData->getString("Texture", textureName);
|
||||
ResourceHandle texture = GetTextureManager()->getHandle(TextureInfo(textureName));
|
||||
|
||||
body->setRings(RingSystem((float) inner, (float) outer,
|
||||
color, texture));
|
||||
color, textureName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,13 @@ using namespace std;
|
|||
|
||||
Color StellarClass::getApparentColor() const
|
||||
{
|
||||
switch (getSpectralClass())
|
||||
return getApparentColor(getSpectralClass());
|
||||
}
|
||||
|
||||
|
||||
Color StellarClass::getApparentColor(StellarClass::SpectralClass sc) const
|
||||
{
|
||||
switch (sc)
|
||||
{
|
||||
case Spectral_O:
|
||||
return Color(0.7f, 0.8f, 1.0f);
|
||||
|
|
|
@ -67,6 +67,7 @@ public:
|
|||
inline LuminosityClass getLuminosityClass() const;
|
||||
|
||||
Color getApparentColor() const;
|
||||
Color getApparentColor(StellarClass::SpectralClass sc) const;
|
||||
|
||||
char* str(char* buf, unsigned int buflen) const;
|
||||
std::string str() const;
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <celutil/basictypes.h>
|
||||
#include <celutil/color.h>
|
||||
#include <celutil/reshandle.h>
|
||||
#include "multitexture.h"
|
||||
|
||||
|
||||
class Surface
|
||||
|
@ -21,10 +22,9 @@ class Surface
|
|||
Surface(Color c = Color(0.0f, 0.0f, 0.0f)) :
|
||||
appearanceFlags(0),
|
||||
color(c),
|
||||
baseTexture(InvalidResource),
|
||||
bumpTexture(InvalidResource),
|
||||
nightTexture(InvalidResource),
|
||||
specBaseTexture(InvalidResource),
|
||||
baseTexture(),
|
||||
bumpTexture(),
|
||||
nightTexture(),
|
||||
bumpHeight(0.0f)
|
||||
{};
|
||||
|
||||
|
@ -44,10 +44,9 @@ class Surface
|
|||
Color hazeColor;
|
||||
Color specularColor;
|
||||
float specularPower;
|
||||
ResourceHandle baseTexture; // surface colors
|
||||
ResourceHandle bumpTexture; // normal map based on terrain relief
|
||||
ResourceHandle nightTexture; // artificial lights to show on night side
|
||||
ResourceHandle specBaseTexture; // base tex with specularity in alpha
|
||||
MultiTexture baseTexture; // surface colors
|
||||
MultiTexture bumpTexture; // normal map based on terrain relief
|
||||
MultiTexture nightTexture; // artificial lights to show on night side
|
||||
float bumpHeight; // scale of bump map relief
|
||||
};
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "celestia.h"
|
||||
#include <celutil/debug.h>
|
||||
#include "multitexture.h"
|
||||
#include "texmanager.h"
|
||||
|
||||
using namespace std;
|
||||
|
@ -16,6 +17,13 @@ using namespace std;
|
|||
|
||||
static TextureManager* textureManager = NULL;
|
||||
|
||||
static char *directories[]=
|
||||
{
|
||||
"/lores/",
|
||||
"/medres/",
|
||||
"/hires/"
|
||||
};
|
||||
|
||||
|
||||
TextureManager* GetTextureManager()
|
||||
{
|
||||
|
@ -29,8 +37,8 @@ Texture* TextureInfo::load(const string& baseDir)
|
|||
{
|
||||
if (bumpHeight == 0.0f)
|
||||
{
|
||||
DPRINTF(0, "Loading texture: %s\n", source.c_str());
|
||||
Texture* tex = LoadTextureFromFile(baseDir + "/" + source);
|
||||
DPRINTF(0, "Loading texture: %s%s%s\n", baseDir.c_str(), directories[resolution], source.c_str());
|
||||
Texture* tex = LoadTextureFromFile(baseDir + directories[resolution] + source);
|
||||
|
||||
if (tex != NULL)
|
||||
{
|
||||
|
@ -43,8 +51,8 @@ Texture* TextureInfo::load(const string& baseDir)
|
|||
}
|
||||
else
|
||||
{
|
||||
DPRINTF(0, "Loading bump map: %s\n", source.c_str());
|
||||
Texture* tex = LoadTextureFromFile(baseDir + "/" + source);
|
||||
DPRINTF(0, "Loading bump map: %s%s%s\n", baseDir.c_str(), directories[resolution], source.c_str());
|
||||
Texture* tex = LoadTextureFromFile(baseDir + directories[resolution] + source);
|
||||
|
||||
if (tex != NULL)
|
||||
{
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <map>
|
||||
#include <celutil/resmanager.h>
|
||||
#include <celengine/texture.h>
|
||||
#include "multitexture.h"
|
||||
|
||||
|
||||
class TextureInfo : public ResourceInfo<Texture>
|
||||
|
@ -22,17 +23,20 @@ class TextureInfo : public ResourceInfo<Texture>
|
|||
std::string source;
|
||||
float bumpHeight;
|
||||
bool compressed;
|
||||
unsigned int resolution;
|
||||
|
||||
TextureInfo(const std::string _source, bool _compressed = false) :
|
||||
source(_source), bumpHeight(0.0f), compressed(_compressed) {};
|
||||
TextureInfo(const std::string _source, float _bumpHeight) :
|
||||
source(_source), bumpHeight(_bumpHeight), compressed(false) {};
|
||||
TextureInfo(const std::string _source, bool _compressed = false, unsigned int _resolution=medres) :
|
||||
source(_source), bumpHeight(0.0f), compressed(_compressed), resolution(_resolution) {};
|
||||
TextureInfo(const std::string _source, float _bumpHeight, unsigned int _resolution=medres) :
|
||||
source(_source), bumpHeight(_bumpHeight), compressed(false), resolution(_resolution) {};
|
||||
virtual Texture* load(const std::string&);
|
||||
};
|
||||
|
||||
inline bool operator<(const TextureInfo& ti0, const TextureInfo& ti1)
|
||||
{
|
||||
return ti0.source < ti1.source;
|
||||
if(ti0.resolution == ti1.resolution)
|
||||
return ti0.source < ti1.source;
|
||||
return ti0.resolution < ti1.resolution;
|
||||
}
|
||||
|
||||
typedef ResourceManager<TextureInfo> TextureManager;
|
||||
|
|
|
@ -484,10 +484,7 @@ Texture* CreateJPEGTexture(const char* filename,
|
|||
FILE *in;
|
||||
in = fopen(filename, "rb");
|
||||
if (in == NULL)
|
||||
{
|
||||
printf("Can't open texture file '%s'\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Step 1: allocate and initialize JPEG decompression object
|
||||
// We set up the normal JPEG error routines, then override error_exit.
|
||||
|
@ -598,6 +595,19 @@ Texture* CreateJPEGTexture(const char* filename,
|
|||
}
|
||||
|
||||
|
||||
Texture* getJPEGTexture(const char* filename,
|
||||
int channels)
|
||||
{
|
||||
Texture *res=CreateJPEGTexture(filename, channels);
|
||||
if (res == NULL)
|
||||
{
|
||||
printf("Error trying to read JPEG texture file '%s'\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
#ifdef PNG_SUPPORT
|
||||
void PNGReadData(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
|
|
|
@ -66,6 +66,8 @@ extern Texture* CreateProceduralCubeMap(int size, int format,
|
|||
ProceduralTexEval func);
|
||||
extern Texture* CreateJPEGTexture(const char* filename,
|
||||
int channels = Texture::ColorChannel);
|
||||
extern Texture* getJPEGTexture(const char* filename,
|
||||
int channels = Texture::ColorChannel);
|
||||
extern Texture* CreateBMPTexture(const char* filename);
|
||||
extern Texture* CreatePNGTexture(const std::string& filename);
|
||||
|
||||
|
|
|
@ -31,8 +31,10 @@
|
|||
#include <celengine/overlay.h>
|
||||
#include <celengine/execution.h>
|
||||
#include <celengine/cmdparser.h>
|
||||
#include <celengine/multitexture.h>
|
||||
#include "favorites.h"
|
||||
#include "celestiacore.h"
|
||||
#include <celutil/debug.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
@ -471,8 +473,8 @@ void CelestiaCore::charEntered(char c)
|
|||
return;
|
||||
}
|
||||
|
||||
c = toupper(c);
|
||||
switch (c)
|
||||
char C = toupper(c);
|
||||
switch (C)
|
||||
{
|
||||
case '\001': // Ctrl+A
|
||||
renderer->setRenderFlags(renderer->getRenderFlags() ^ Renderer::ShowAtmospheres);
|
||||
|
@ -641,6 +643,13 @@ void CelestiaCore::charEntered(char c)
|
|||
sim->setTargetSpeed(-sim->getTargetSpeed());
|
||||
break;
|
||||
|
||||
case 'R':
|
||||
if(c=='r') // Doing no rangechecking as setResolution does it allready
|
||||
renderer->setResolution(renderer->getResolution()-1);
|
||||
else
|
||||
renderer->setResolution(renderer->getResolution()+1);
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
sim->setTargetSpeed(0);
|
||||
break;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
pkgdatadir = $(datadir)/@PACKAGE@/textures
|
||||
|
||||
SUBDIRS = lores medres hires
|
||||
|
||||
pkgdata_DATA = $(wildcard *.jpg) $(wildcard *.png)
|
||||
|
||||
EXTRA_DIST = $(pkgdata_DATA)
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
pkgdatadir = $(datadir)/@PACKAGE@/textures/lores
|
||||
|
||||
pkgdata_DATA = $(wildcard *.jpg) $(wildcard *.png)
|
||||
|
||||
EXTRA_DIST = $(pkgdata_DATA)
|
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 5.1 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 8.4 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 5.1 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 4.5 KiB |
After Width: | Height: | Size: 5.2 KiB |
After Width: | Height: | Size: 4.1 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 5.1 KiB |
After Width: | Height: | Size: 5.4 KiB |
After Width: | Height: | Size: 4.1 KiB |
After Width: | Height: | Size: 4.9 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 5.2 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 4.5 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 4.8 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 4.1 KiB |
After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 5.2 KiB |
|
@ -0,0 +1,5 @@
|
|||
pkgdatadir = $(datadir)/@PACKAGE@/textures/medres
|
||||
|
||||
pkgdata_DATA = $(wildcard *.jpg) $(wildcard *.png)
|
||||
|
||||
EXTRA_DIST = $(pkgdata_DATA)
|
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 27 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 147 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 581 KiB |
After Width: | Height: | Size: 330 KiB |
After Width: | Height: | Size: 2.6 MiB |
After Width: | Height: | Size: 43 KiB |
After Width: | Height: | Size: 96 KiB |
After Width: | Height: | Size: 121 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 104 KiB |
After Width: | Height: | Size: 8.6 KiB |
After Width: | Height: | Size: 140 KiB |
After Width: | Height: | Size: 74 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 513 KiB |
After Width: | Height: | Size: 137 KiB |
After Width: | Height: | Size: 186 KiB |
After Width: | Height: | Size: 190 KiB |
After Width: | Height: | Size: 39 KiB |
After Width: | Height: | Size: 85 KiB |
After Width: | Height: | Size: 401 KiB |
After Width: | Height: | Size: 181 KiB |
After Width: | Height: | Size: 27 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 87 KiB |