From Don Tidrow, spelling fixes

This commit is contained in:
Robert Osfield 2005-05-01 10:34:48 +00:00
parent adba6fa559
commit 7de1265059
4 changed files with 86 additions and 86 deletions

View File

@ -522,91 +522,91 @@ bool TXPArchive::loadLightAttributes()
void trim(std::string& str)
{
while (!str.empty() && isspace(str[str.length()-1]))
str.erase(str.length()-1);
while (!str.empty() && isspace(str[0]))
while (!str.empty() && isspace(str[str.length()-1]))
str.erase(str.length()-1);
while (!str.empty() && isspace(str[0]))
str.erase(0,1);
}
bool TXPArchive::loadTextStyles()
{
const trpgTextStyleTable *textStyleTable = GetTextStyleTable();
if (!textStyleTable) return false;
if (textStyleTable->GetNumStyle() < 1) return true;
const trpgTextStyleTable *textStyleTable = GetTextStyleTable();
if (!textStyleTable) return false;
if (textStyleTable->GetNumStyle() < 1) return true;
// try fontmap.txt
std::map< std::string, std::string > fontmap;
// try fontmap.txt
std::map< std::string, std::string > fontmap;
std::string fmapfname = std::string(getDir())+"\\fontmap.txt";
std::ifstream fmapfile;
fmapfile.open(fmapfname.c_str(),std::ios::in);
std::string fmapfname = std::string(getDir())+"\\fontmap.txt";
std::ifstream fmapfile;
fmapfile.open(fmapfname.c_str(),std::ios::in);
if (fmapfile.is_open())
{
osg::notify(osg::NOTICE) << "txp:: Font map file found: " << fmapfname << std::endl;
std::string line;
while (std::getline(fmapfile,line))
{
unsigned int ix = line.find_first_of('=');
if (ix != std::string::npos)
{
std::string fontname = line.substr(0,ix);
std::string fontfilename = line.substr(ix+1,line.length()-ix+1);
if (fmapfile.is_open())
{
osg::notify(osg::NOTICE) << "txp:: Font map file found: " << fmapfname << std::endl;
std::string line;
while (std::getline(fmapfile,line))
{
unsigned int ix = line.find_first_of('=');
if (ix != std::string::npos)
{
std::string fontname = line.substr(0,ix);
std::string fontfilename = line.substr(ix+1,line.length()-ix+1);
trim(fontname);
trim(fontfilename);
trim(fontname);
trim(fontfilename);
fontmap[fontname] = fontfilename;
fontmap[fontname] = fontfilename;
}
}
fmapfile.close();
}
else
{
osg::notify(osg::NOTICE) << "txp:: No font map file found: " << fmapfname << std::endl;
osg::notify(osg::NOTICE) << "txp:: All fonts defaulted to arial.ttf" << std::endl;
}
}
}
fmapfile.close();
}
else
{
osg::notify(osg::NOTICE) << "txp:: No font map file found: " << fmapfname << std::endl;
osg::notify(osg::NOTICE) << "txp:: All fonts defaulted to arial.ttf" << std::endl;
}
_fonts.resize(textStyleTable->GetNumStyle());
_fcolors.resize(textStyleTable->GetNumStyle());
for (int i = 0; i < textStyleTable->GetNumStyle(); i++)
{
const trpgTextStyle *textStyle = textStyleTable->GetStyleRef(i);
if (!textStyle) continue;
_fonts.resize(textStyleTable->GetNumStyle());
_fcolors.resize(textStyleTable->GetNumStyle());
for (int i = 0; i < textStyleTable->GetNumStyle(); i++)
{
const trpgTextStyle *textStyle = textStyleTable->GetStyleRef(i);
if (!textStyle) continue;
const std::string *fontName = textStyle->GetFont();
if (!fontName) continue;
const std::string *fontName = textStyle->GetFont();
if (!fontName) continue;
std::string fontfilename = fontmap[*fontName];
if (!fontfilename.length()) fontfilename = "arial.ttf";
osg::ref_ptr< osgText::Font > font = osgText::readFontFile(fontfilename);
std::string fontfilename = fontmap[*fontName];
if (!fontfilename.length()) fontfilename = "arial.ttf";
osg::ref_ptr< osgText::Font > font = osgText::readFontFile(fontfilename);
_fonts[i] = font;
_fonts[i] = font;
const trpgMatTable* matTable = GetMaterialTable();
if (matTable)
{
int matId = textStyle->GetMaterial();
const trpgMaterial* mat = matTable->GetMaterialRef(0,matId);
if (mat)
{
trpgColor faceColor;
mat->GetColor(faceColor);
const trpgMatTable* matTable = GetMaterialTable();
if (matTable)
{
int matId = textStyle->GetMaterial();
const trpgMaterial* mat = matTable->GetMaterialRef(0,matId);
if (mat)
{
trpgColor faceColor;
mat->GetColor(faceColor);
float64 alpha;
mat->GetAlpha(alpha);
float64 alpha;
mat->GetAlpha(alpha);
_fcolors[i] = osg::Vec4(faceColor.red, faceColor.green, faceColor.blue, alpha );
}
}
}
_fcolors[i] = osg::Vec4(faceColor.red, faceColor.green, faceColor.blue, alpha );
}
}
}
return true;
return true;
}
void TXPArchive::addLightAttribute(osgSim::LightPointNode* lpn, osg::StateSet* fallback, const osg::Vec3& att)
{
DefferedLightAttribute la;
DeferredLightAttribute la;
la.lightPoint = lpn;
la.fallback = fallback;
la.attitude = att;

View File

@ -51,7 +51,7 @@
namespace txp
{
// this one handles different placement of light direction in osg and terrapage
struct DefferedLightAttribute
struct DeferredLightAttribute
{
// light point at (0,0,0) looking in (0,0,0) direction
osg::ref_ptr<osgSim::LightPointNode> lightPoint;
@ -72,7 +72,7 @@ public:
// Load the materials from the archve
bool loadMaterials();
bool loadMaterial(int ix);
bool loadTexture(int i);
bool loadTexture(int i);
// Load the models from the archive
bool loadModels();
@ -81,16 +81,16 @@ public:
// Load the light attribs from the archive
bool loadLightAttributes();
// Load the text styles from the archive
bool loadTextStyles();
inline std::vector< osg::ref_ptr<osgText::Font> >& getStyles() { return _fonts; }
inline std::vector< osg::Vec4 >& getTextColors() { return _fcolors; }
// Load the text styles from the archive
bool loadTextStyles();
inline std::vector< osg::ref_ptr<osgText::Font> >& getStyles() { return _fonts; }
inline std::vector< osg::Vec4 >& getTextColors() { return _fcolors; }
// Add light attrib
void addLightAttribute(osgSim::LightPointNode* lpn, osg::StateSet* fallback , const osg::Vec3& attitude);
// Get light attrib
inline DefferedLightAttribute& getLightAttribute(unsigned int i)
inline DeferredLightAttribute& getLightAttribute(unsigned int i)
{
return _lights[i];
};
@ -175,7 +175,7 @@ protected:
osg::ref_ptr<TXPParser> _parser;
// Textures
std::vector< osg::ref_ptr<osg::Texture2D> > _textures;
std::vector< osg::ref_ptr<osg::Texture2D> > _textures;
// States
std::vector< osg::ref_ptr<osg::StateSet> > _gstates;
@ -184,13 +184,13 @@ protected:
std::vector< osg::ref_ptr<osg::Node> > _models;
// Light attributes vector
std::vector<DefferedLightAttribute> _lights;
std::vector<DeferredLightAttribute> _lights;
// Text styles / Fonts
std::vector< osg::ref_ptr<osgText::Font> > _fonts;
// Text styles / Fonts
std::vector< osg::ref_ptr<osgText::Font> > _fonts;
// Text colors
std::vector< osg::Vec4 > _fcolors;
// Text colors
std::vector< osg::Vec4 > _fcolors;
//
OpenThreads::Mutex _mutex;

View File

@ -189,7 +189,7 @@ bool TXPParser::EndChildren(void *)
return true;
}
DefferedLightAttribute& TXPParser::getLightAttribute(int ix)
DeferredLightAttribute& TXPParser::getLightAttribute(int ix)
{
return _archive->getLightAttribute(ix);
}
@ -664,13 +664,13 @@ void* lightRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf)
int attr_index;
light.GetAttrIndex(attr_index);
DefferedLightAttribute& dla = _parse->getLightAttribute(attr_index);
DeferredLightAttribute& dla = _parse->getLightAttribute(attr_index);
osgSim::LightPointNode* node = dla.lightPoint.get();
uint32 nvert;
light.GetNumVertices(nvert);
if( node->getLightPoint(0)._sector.valid() ) // osgSim::LigthPoint is a must
if( node->getLightPoint(0)._sector.valid() ) // osgSim::LightPoint is a must
{
for(unsigned int i = 0; i < nvert; i++)
{
@ -1149,7 +1149,7 @@ void* geomRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf)
normals = new osg::Vec3Array(numVert);
geom.GetNormals((float*)&(normals->front()));
}
// Set up the primitive type
switch (primType)
{

View File

@ -103,7 +103,7 @@ protected:
class TXPArchive;
struct DefferedLightAttribute;
struct DeferredLightAttribute;
class TXPParser : public trpgSceneParser, public osg::Referenced
{
@ -116,8 +116,8 @@ public:
_archive = archive;
}
// Gets the archive
inline TXPArchive* getArchive() { return _archive; }
// Gets the archive
inline TXPArchive* getArchive() { return _archive; }
// Scene parser
osg::Group *parseScene(
@ -144,8 +144,8 @@ public:
return _materials;
}
// Ensure material is loaded
inline void loadMaterial(int ix) { _archive->loadMaterial(ix); }
// Ensure material is loaded
inline void loadMaterial(int ix) { _archive->loadMaterial(ix); }
// New to TerraPage 2.0 - local materials
std::vector<osg::ref_ptr<osg::StateSet> >* getLocalMaterials()
@ -206,7 +206,7 @@ public:
}
// Gets light attrib
DefferedLightAttribute& getLightAttribute(int ix);
DeferredLightAttribute& getLightAttribute(int ix);
// Returns if we are under layer subgraph
inline const bool underLayerSubgraph() const