Added user settable BumpHeight parameter for bump maps.

pull/3/head
Chris Laurel 2001-03-16 21:26:29 +00:00
parent 28a960f5df
commit 7f1774054a
5 changed files with 38 additions and 4 deletions

View File

@ -874,7 +874,8 @@ void Renderer::renderPlanet(const Body& body,
surface.bumpTexture != "")
{
if (!textureManager->find(surface.bumpTexture, &bumpTex))
bumpTex = textureManager->loadBumpMap(surface.bumpTexture);
bumpTex = textureManager->loadBumpMap(surface.bumpTexture,
surface.bumpHeight);
}
if (tex == NULL)

View File

@ -52,6 +52,33 @@ Planet SolSystem[] =
};
static Surface* CreateSurface(Hash* surfaceData)
{
Surface* surface = new Surface();
surface->color = Color(1.0f, 1.0f, 1.0f);
surfaceData->getColor("Color", surface->color);
bool applyBaseTexture = surfaceData->getString("Texture", surface->baseTexture);
bool applyBumpMap = surfaceData->getString("BumpMap", surface->bumpTexture);
surface->bumpHeight = 2.5f;
surfaceData->getNumber("BumpHeight", surface->bumpHeight);
bool blendTexture = false;
surfaceData->getBoolean("BlendTexture", blendTexture);
bool compressTexture = false;
surfaceData->getBoolean("CompressTexture", compressTexture);
if (blendTexture)
surface->appearanceFlags |= Surface::BlendTexture;
if (applyBaseTexture)
surface->appearanceFlags |= Surface::ApplyBaseTexture;
if (applyBumpMap)
surface->appearanceFlags |= Surface::ApplyBumpMap;
if (compressTexture)
surface->appearanceFlags |= Surface::CompressBaseTexture;
return surface;
}
static Body* createSatellite(Planet* p)
{
EllipticalOrbit* orbit = new EllipticalOrbit(astro::AUtoKilometers(p->semiMajorAxis),
@ -167,6 +194,7 @@ static Body* CreatePlanet(PlanetarySystem* system,
planetData->getNumber("RotationPeriod", rotationPeriod);
body->setRotationPeriod(rotationPeriod);
#if 0
Surface surface;
surface.color = Color(1.0f, 1.0f, 1.0f);
planetData->getColor("Color", surface.color);
@ -185,6 +213,10 @@ static Body* CreatePlanet(PlanetarySystem* system,
if (compressTexture)
surface.appearanceFlags |= Surface::CompressBaseTexture;
body->setSurface(surface);
#endif
Surface* surface = CreateSurface(planetData);
body->setSurface(*surface);
delete surface;
string mesh("");
planetData->getString("Mesh", mesh);

View File

@ -33,6 +33,7 @@ class Surface
std::string baseTexture;
std::string bumpTexture;
uint32 appearanceFlags;
float bumpHeight;
};
#endif // _SURFACE_H_

View File

@ -43,13 +43,13 @@ CTexture* TextureManager::load(const string& name, bool compress)
}
CTexture* TextureManager::loadBumpMap(const string& name)
CTexture* TextureManager::loadBumpMap(const string& name, float bumpHeight)
{
DPRINTF("Loading bump map: %s\n", name.c_str());
CTexture* tex = LoadTextureFromFile(baseDir + "\\" + name);
if (tex != NULL)
{
tex->normalMap(2.5f, true);
tex->normalMap(bumpHeight, true);
tex->bindName(CTexture::WrapTexture);
}
addResource(name, static_cast<void*>(tex));

View File

@ -26,7 +26,7 @@ class TextureManager : public ResourceManager
bool find(const std::string& name, CTexture**);
CTexture* load(const std::string& name, bool compress = false);
CTexture* loadBumpMap(const std::string& name);
CTexture* loadBumpMap(const std::string& name, float bumpHeight);
};
#endif // _TEXMANAGER_H_