Ran cleanup to fix tabs
This commit is contained in:
@@ -39,8 +39,8 @@ osgDB::ReaderWriter::ReadResult ReaderWriterTXP::local_readNode(const std::strin
|
||||
if (strncmp(name.c_str(),"archive",7)==0)
|
||||
{
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if ( fileName.empty() )
|
||||
return ReadResult::FILE_NOT_FOUND;
|
||||
if ( fileName.empty() )
|
||||
return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
osg::ref_ptr<TXPNode> txpNode = new TXPNode;
|
||||
txpNode->setArchiveName(fileName);
|
||||
@@ -87,7 +87,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriterTXP::local_readNode(const std::strin
|
||||
archive->ReadSubArchive( 0, 0, endian);
|
||||
archive->ReadSubArchive( y, x, endian);
|
||||
|
||||
// std::cout << "Attempted " << x << " " << y << std::endl;
|
||||
// std::cout << "Attempted " << x << " " << y << std::endl;
|
||||
|
||||
TXPArchive::TileInfo info;
|
||||
if (!archive->getTileInfo(x,y,lod,info))
|
||||
@@ -107,33 +107,33 @@ osgDB::ReaderWriter::ReadResult ReaderWriterTXP::local_readNode(const std::strin
|
||||
archive->GetVersion(majorVersion, minorVersion);
|
||||
if(majorVersion ==2 && minorVersion >=1)
|
||||
{
|
||||
// Version 2.1 and over
|
||||
// The tile table only contains lod 0 and the children
|
||||
// info are stored in its parent. SO if we do not want
|
||||
// to be forced to reparse the parent we need to save that
|
||||
// info. For now we just add it to the node name
|
||||
// Version 2.1 and over
|
||||
// The tile table only contains lod 0 and the children
|
||||
// info are stored in its parent. SO if we do not want
|
||||
// to be forced to reparse the parent we need to save that
|
||||
// info. For now we just add it to the node name
|
||||
|
||||
if(childrenLoc.size() > 0)
|
||||
{
|
||||
asChildren = true;
|
||||
createChildrenLocationString(childrenLoc, childrenInfoStr);
|
||||
}
|
||||
if(childrenLoc.size() > 0)
|
||||
{
|
||||
asChildren = true;
|
||||
createChildrenLocationString(childrenLoc, childrenInfoStr);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lod < (numLods-1))
|
||||
asChildren = true;
|
||||
asChildren = true;
|
||||
}
|
||||
|
||||
if (asChildren)
|
||||
if (asChildren)
|
||||
{
|
||||
char pagedLODfile[1024];
|
||||
sprintf(pagedLODfile,"%s\\subtiles%d_%dx%d_%d",
|
||||
archive->getDir(),
|
||||
lod,
|
||||
x,
|
||||
y,
|
||||
archive->getId());
|
||||
archive->getDir(),
|
||||
lod,
|
||||
x,
|
||||
y,
|
||||
archive->getId());
|
||||
|
||||
strcat(pagedLODfile, childrenInfoStr.c_str());
|
||||
strcat(pagedLODfile, ".txp");
|
||||
@@ -153,7 +153,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriterTXP::local_readNode(const std::strin
|
||||
|
||||
|
||||
osg::ref_ptr<TXPPagedLOD> pagedLOD = new TXPPagedLOD;
|
||||
// note: use maximum(info.maxRange,1e7) as just maxRange would result in some corner tiles from being culled out.
|
||||
// note: use maximum(info.maxRange,1e7) as just maxRange would result in some corner tiles from being culled out.
|
||||
pagedLOD->addChild(tileContent.get(),info.minRange,osg::maximum(info.maxRange,1e7));
|
||||
pagedLOD->setFileName(1,pagedLODfile);
|
||||
pagedLOD->setRange(1,0,info.minRange);
|
||||
@@ -206,64 +206,64 @@ osgDB::ReaderWriter::ReadResult ReaderWriterTXP::local_readNode(const std::strin
|
||||
std::vector<TXPArchive::TileLocationInfo> locs;
|
||||
bool status = true;
|
||||
status = extractChildrenLocations(name, lod, locs, nbChild);
|
||||
if(majorVersion >= TRPG_NOMERGE_VERSION_MAJOR && minorVersion >=TRPG_NOMERGE_VERSION_MINOR && archive->GetHeader()->GetIsMaster())
|
||||
{
|
||||
for(int idx=0;idx<nbChild;idx++)
|
||||
{
|
||||
//figure out the block row/col
|
||||
int blockx,blocky;
|
||||
unsigned int denom = (1 << locs[idx].lod); // this should work up to lod 31
|
||||
blockx = locs[idx].x/denom;
|
||||
blocky = locs[idx].y/denom;
|
||||
locs[idx].addr.col = blockx;
|
||||
locs[idx].addr.row = blocky;
|
||||
}
|
||||
}
|
||||
if(majorVersion >= TRPG_NOMERGE_VERSION_MAJOR && minorVersion >=TRPG_NOMERGE_VERSION_MINOR && archive->GetHeader()->GetIsMaster())
|
||||
{
|
||||
for(int idx=0;idx<nbChild;idx++)
|
||||
{
|
||||
//figure out the block row/col
|
||||
int blockx,blocky;
|
||||
unsigned int denom = (1 << locs[idx].lod); // this should work up to lod 31
|
||||
blockx = locs[idx].x/denom;
|
||||
blocky = locs[idx].y/denom;
|
||||
locs[idx].addr.col = blockx;
|
||||
locs[idx].addr.row = blocky;
|
||||
}
|
||||
}
|
||||
|
||||
if(!status)
|
||||
{
|
||||
ReaderWriterTXPERROR("ReaderWriterTXP::local_readNode()") << "'subtile' filename children parsing failed " << std::endl;
|
||||
return ReadResult::ERROR_IN_READING_FILE;
|
||||
ReaderWriterTXPERROR("ReaderWriterTXP::local_readNode()") << "'subtile' filename children parsing failed " << std::endl;
|
||||
return ReadResult::ERROR_IN_READING_FILE;
|
||||
}
|
||||
|
||||
const trpgHeader* header = archive->GetHeader();
|
||||
trpgHeader::trpgTileType tileType;
|
||||
header->GetTileOriginType(tileType);
|
||||
|
||||
TXPArchive::TileLocationInfo plInfo;
|
||||
plInfo.x = x;
|
||||
plInfo.y = y;
|
||||
plInfo.lod = lod;
|
||||
TXPArchive::TileLocationInfo plInfo;
|
||||
plInfo.x = x;
|
||||
plInfo.y = y;
|
||||
plInfo.lod = lod;
|
||||
TXPArchive::TileInfo parentInfo;
|
||||
archive->getTileInfo(plInfo,parentInfo);
|
||||
|
||||
for(int idx = 0; idx < nbChild; ++idx)
|
||||
{
|
||||
std::vector<TXPArchive::TileLocationInfo> childrenChildLoc;
|
||||
std::vector<TXPArchive::TileLocationInfo> childrenChildLoc;
|
||||
|
||||
TXPArchive::TileLocationInfo& loc = locs[idx];
|
||||
TXPArchive::TileLocationInfo& loc = locs[idx];
|
||||
|
||||
TXPArchive::TileInfo info;
|
||||
if (!archive->getTileInfo(loc,info))
|
||||
continue;
|
||||
TXPArchive::TileInfo info;
|
||||
if (!archive->getTileInfo(loc,info))
|
||||
continue;
|
||||
|
||||
osg::ref_ptr<osg::Node> tileContent = getTileContent(info, loc, archive, childrenChildLoc);
|
||||
osg::ref_ptr<osg::Node> tileContent = getTileContent(info, loc, archive, childrenChildLoc);
|
||||
|
||||
tileContent->setName("TileContent");
|
||||
tileContent->setName("TileContent");
|
||||
|
||||
if(childrenChildLoc.size() > 0)
|
||||
{
|
||||
std::string childInfoStr;
|
||||
createChildrenLocationString(childrenChildLoc, childInfoStr);
|
||||
if(childrenChildLoc.size() > 0)
|
||||
{
|
||||
std::string childInfoStr;
|
||||
createChildrenLocationString(childrenChildLoc, childInfoStr);
|
||||
|
||||
char pagedLODfile[1024];
|
||||
sprintf(pagedLODfile,"%s\\subtiles%d_%dx%d_%d%s.txp",
|
||||
archive->getDir(),
|
||||
loc.lod,
|
||||
loc.x,
|
||||
loc.y,
|
||||
archive->getId(),
|
||||
childInfoStr.c_str());
|
||||
char pagedLODfile[1024];
|
||||
sprintf(pagedLODfile,"%s\\subtiles%d_%dx%d_%d%s.txp",
|
||||
archive->getDir(),
|
||||
loc.lod,
|
||||
loc.x,
|
||||
loc.y,
|
||||
archive->getId(),
|
||||
childInfoStr.c_str());
|
||||
|
||||
// there are tile sets which do not maintain the z extents in
|
||||
// the tile table. This attempt to address the issue by using
|
||||
@@ -277,151 +277,151 @@ osgDB::ReaderWriter::ReadResult ReaderWriterTXP::local_readNode(const std::strin
|
||||
info.radius = bSphere.radius();
|
||||
}
|
||||
|
||||
osg::ref_ptr<TXPPagedLOD> pagedLOD = new TXPPagedLOD;
|
||||
// note: use maximum(info.maxRange,1e7) as just maxRange would result in some corner tiles from being culled out.
|
||||
pagedLOD->addChild(tileContent.get(),info.minRange,osg::maximum(info.maxRange,1e7));
|
||||
pagedLOD->setFileName(1,pagedLODfile);
|
||||
pagedLOD->setRange(1,0,info.minRange);
|
||||
pagedLOD->setCenter(info.center);
|
||||
pagedLOD->setRadius(info.radius);
|
||||
pagedLOD->setPriorityOffset(0,numLods - loc.lod);
|
||||
pagedLOD->setPriorityScale(0,1.0f);
|
||||
pagedLOD->setNumChildrenThatCannotBeExpired(1);
|
||||
pagedLOD->setTileId(loc.x, loc.y, loc.lod);
|
||||
osg::ref_ptr<TXPPagedLOD> pagedLOD = new TXPPagedLOD;
|
||||
// note: use maximum(info.maxRange,1e7) as just maxRange would result in some corner tiles from being culled out.
|
||||
pagedLOD->addChild(tileContent.get(),info.minRange,osg::maximum(info.maxRange,1e7));
|
||||
pagedLOD->setFileName(1,pagedLODfile);
|
||||
pagedLOD->setRange(1,0,info.minRange);
|
||||
pagedLOD->setCenter(info.center);
|
||||
pagedLOD->setRadius(info.radius);
|
||||
pagedLOD->setPriorityOffset(0,numLods - loc.lod);
|
||||
pagedLOD->setPriorityScale(0,1.0f);
|
||||
pagedLOD->setNumChildrenThatCannotBeExpired(1);
|
||||
pagedLOD->setTileId(loc.x, loc.y, loc.lod);
|
||||
|
||||
if(tileType == trpgHeader::TileLocal)
|
||||
{
|
||||
osg::Vec3d center(info.center - parentInfo.bbox._min);
|
||||
osg::Vec3d sw(info.bbox._min - parentInfo.bbox._min);
|
||||
sw[2] = 0.0;
|
||||
pagedLOD->setCenter(center - sw);
|
||||
osg::Matrix offset;
|
||||
offset.setTrans(sw);
|
||||
osg::MatrixTransform *tform = new osg::MatrixTransform(offset);
|
||||
tform->addChild(pagedLOD.get());
|
||||
subtiles->addChild(tform);
|
||||
}
|
||||
else
|
||||
subtiles->addChild(pagedLOD.get());
|
||||
subtiles->setUserData(new TileIdentifier(loc.x, loc.y, loc.lod)); // is this really needed?
|
||||
}
|
||||
else
|
||||
{
|
||||
subtiles->setUserData(new TileIdentifier(loc.x, loc.y, loc.lod));
|
||||
if(tileType == trpgHeader::TileLocal)
|
||||
{
|
||||
osg::Vec3d center(info.center - parentInfo.bbox._min);
|
||||
osg::Vec3d sw(info.bbox._min - parentInfo.bbox._min);
|
||||
sw[2] = 0.0;
|
||||
osg::Matrix offset;
|
||||
offset.setTrans(sw);
|
||||
osg::MatrixTransform *tform = new osg::MatrixTransform(offset);
|
||||
tform->addChild(tileContent.get());
|
||||
subtiles->addChild(tform);
|
||||
}
|
||||
else
|
||||
subtiles->addChild(tileContent.get());
|
||||
}
|
||||
if(tileType == trpgHeader::TileLocal)
|
||||
{
|
||||
osg::Vec3d center(info.center - parentInfo.bbox._min);
|
||||
osg::Vec3d sw(info.bbox._min - parentInfo.bbox._min);
|
||||
sw[2] = 0.0;
|
||||
pagedLOD->setCenter(center - sw);
|
||||
osg::Matrix offset;
|
||||
offset.setTrans(sw);
|
||||
osg::MatrixTransform *tform = new osg::MatrixTransform(offset);
|
||||
tform->addChild(pagedLOD.get());
|
||||
subtiles->addChild(tform);
|
||||
}
|
||||
else
|
||||
subtiles->addChild(pagedLOD.get());
|
||||
subtiles->setUserData(new TileIdentifier(loc.x, loc.y, loc.lod)); // is this really needed?
|
||||
}
|
||||
else
|
||||
{
|
||||
subtiles->setUserData(new TileIdentifier(loc.x, loc.y, loc.lod));
|
||||
if(tileType == trpgHeader::TileLocal)
|
||||
{
|
||||
osg::Vec3d center(info.center - parentInfo.bbox._min);
|
||||
osg::Vec3d sw(info.bbox._min - parentInfo.bbox._min);
|
||||
sw[2] = 0.0;
|
||||
osg::Matrix offset;
|
||||
offset.setTrans(sw);
|
||||
osg::MatrixTransform *tform = new osg::MatrixTransform(offset);
|
||||
tform->addChild(tileContent.get());
|
||||
subtiles->addChild(tform);
|
||||
}
|
||||
else
|
||||
subtiles->addChild(tileContent.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
int sizeX, sizeY;
|
||||
archive->getLODSize(lod+1,sizeX,sizeY);
|
||||
int sizeX, sizeY;
|
||||
archive->getLODSize(lod+1,sizeX,sizeY);
|
||||
|
||||
const trpgHeader* header = archive->GetHeader();
|
||||
trpgHeader::trpgTileType tileType;
|
||||
header->GetTileOriginType(tileType);
|
||||
const trpgHeader* header = archive->GetHeader();
|
||||
trpgHeader::trpgTileType tileType;
|
||||
header->GetTileOriginType(tileType);
|
||||
|
||||
TXPArchive::TileInfo parentInfo;
|
||||
archive->getTileInfo(x,y,lod,parentInfo);
|
||||
TXPArchive::TileInfo parentInfo;
|
||||
archive->getTileInfo(x,y,lod,parentInfo);
|
||||
|
||||
for (int ix = 0; ix < 2; ix++)
|
||||
{
|
||||
for (int iy = 0; iy < 2; iy++)
|
||||
{
|
||||
int tileX = x*2+ix;
|
||||
int tileY = y*2+iy;
|
||||
int tileLOD = lod+1;
|
||||
for (int ix = 0; ix < 2; ix++)
|
||||
{
|
||||
for (int iy = 0; iy < 2; iy++)
|
||||
{
|
||||
int tileX = x*2+ix;
|
||||
int tileY = y*2+iy;
|
||||
int tileLOD = lod+1;
|
||||
|
||||
TXPArchive::TileInfo info;
|
||||
if (!archive->getTileInfo(tileX,tileY,tileLOD,info))
|
||||
continue;
|
||||
TXPArchive::TileInfo info;
|
||||
if (!archive->getTileInfo(tileX,tileY,tileLOD,info))
|
||||
continue;
|
||||
|
||||
osg::ref_ptr<osg::Node> tileContent = getTileContent(info,tileX,tileY,tileLOD,archive, childrenLoc);
|
||||
osg::ref_ptr<osg::Node> tileContent = getTileContent(info,tileX,tileY,tileLOD,archive, childrenLoc);
|
||||
|
||||
tileContent->setName("TileContent");
|
||||
tileContent->setName("TileContent");
|
||||
|
||||
if (tileLOD < (numLods-1))
|
||||
{
|
||||
char pagedLODfile[1024];
|
||||
sprintf(pagedLODfile,"%s\\subtiles%d_%dx%d_%d.txp",
|
||||
archive->getDir(),
|
||||
tileLOD,
|
||||
tileX,
|
||||
tileY,
|
||||
archive->getId());
|
||||
if (tileLOD < (numLods-1))
|
||||
{
|
||||
char pagedLODfile[1024];
|
||||
sprintf(pagedLODfile,"%s\\subtiles%d_%dx%d_%d.txp",
|
||||
archive->getDir(),
|
||||
tileLOD,
|
||||
tileX,
|
||||
tileY,
|
||||
archive->getId());
|
||||
|
||||
// there are tile sets which do not maintain the z extents in
|
||||
// the tile table. This attempt to address the issue by using
|
||||
// the geometry bounding sphere. The downside is that this is
|
||||
// not coupled to the generation and may result in runtime cracks
|
||||
if (info.center.z() == 0)
|
||||
{
|
||||
osg::BoundingSphere bSphere = tileContent->getBound();
|
||||
// there are tile sets which do not maintain the z extents in
|
||||
// the tile table. This attempt to address the issue by using
|
||||
// the geometry bounding sphere. The downside is that this is
|
||||
// not coupled to the generation and may result in runtime cracks
|
||||
if (info.center.z() == 0)
|
||||
{
|
||||
osg::BoundingSphere bSphere = tileContent->getBound();
|
||||
|
||||
info.center.z() = bSphere.center().z();
|
||||
info.radius = bSphere.radius();
|
||||
}
|
||||
info.center.z() = bSphere.center().z();
|
||||
info.radius = bSphere.radius();
|
||||
}
|
||||
|
||||
osg::ref_ptr<TXPPagedLOD> pagedLOD = new TXPPagedLOD;
|
||||
// note: use maximum(info.maxRange,1e7) as just maxRange would result in some corner tiles from being culled out.
|
||||
pagedLOD->addChild(tileContent.get(),info.minRange,osg::maximum(info.maxRange,1e7));
|
||||
pagedLOD->setFileName(1,pagedLODfile);
|
||||
pagedLOD->setRange(1,0,info.minRange);
|
||||
pagedLOD->setCenter(info.center);
|
||||
pagedLOD->setRadius(info.radius);
|
||||
pagedLOD->setPriorityOffset(0,numLods-lod);
|
||||
pagedLOD->setPriorityScale(0,1.0f);
|
||||
pagedLOD->setNumChildrenThatCannotBeExpired(1);
|
||||
pagedLOD->setTileId(tileX,tileY,tileLOD);
|
||||
osg::ref_ptr<TXPPagedLOD> pagedLOD = new TXPPagedLOD;
|
||||
// note: use maximum(info.maxRange,1e7) as just maxRange would result in some corner tiles from being culled out.
|
||||
pagedLOD->addChild(tileContent.get(),info.minRange,osg::maximum(info.maxRange,1e7));
|
||||
pagedLOD->setFileName(1,pagedLODfile);
|
||||
pagedLOD->setRange(1,0,info.minRange);
|
||||
pagedLOD->setCenter(info.center);
|
||||
pagedLOD->setRadius(info.radius);
|
||||
pagedLOD->setPriorityOffset(0,numLods-lod);
|
||||
pagedLOD->setPriorityScale(0,1.0f);
|
||||
pagedLOD->setNumChildrenThatCannotBeExpired(1);
|
||||
pagedLOD->setTileId(tileX,tileY,tileLOD);
|
||||
|
||||
if(tileType == trpgHeader::TileLocal)
|
||||
{
|
||||
osg::Vec3d center(info.center - parentInfo.bbox._min);
|
||||
osg::Vec3d sw(info.bbox._min - parentInfo.bbox._min);
|
||||
sw[2] = 0.0;
|
||||
pagedLOD->setCenter(center - sw);
|
||||
osg::Matrix offset;
|
||||
offset.setTrans(sw);
|
||||
osg::MatrixTransform *tform = new osg::MatrixTransform(offset);
|
||||
tform->addChild(pagedLOD.get());
|
||||
subtiles->addChild(tform);
|
||||
}
|
||||
else
|
||||
subtiles->addChild(pagedLOD.get());
|
||||
}
|
||||
else
|
||||
{
|
||||
subtiles->setUserData(new TileIdentifier(tileX,tileY,tileLOD));
|
||||
if(tileType == trpgHeader::TileLocal)
|
||||
{
|
||||
osg::Vec3d center(info.center - parentInfo.bbox._min);
|
||||
osg::Vec3d sw(info.bbox._min - parentInfo.bbox._min);
|
||||
sw[2] = 0.0;
|
||||
osg::Matrix offset;
|
||||
offset.setTrans(sw);
|
||||
osg::MatrixTransform *tform = new osg::MatrixTransform(offset);
|
||||
tform->addChild(tileContent.get());
|
||||
subtiles->addChild(tform);
|
||||
}
|
||||
else
|
||||
subtiles->addChild(tileContent.get());
|
||||
}
|
||||
if(tileType == trpgHeader::TileLocal)
|
||||
{
|
||||
osg::Vec3d center(info.center - parentInfo.bbox._min);
|
||||
osg::Vec3d sw(info.bbox._min - parentInfo.bbox._min);
|
||||
sw[2] = 0.0;
|
||||
pagedLOD->setCenter(center - sw);
|
||||
osg::Matrix offset;
|
||||
offset.setTrans(sw);
|
||||
osg::MatrixTransform *tform = new osg::MatrixTransform(offset);
|
||||
tform->addChild(pagedLOD.get());
|
||||
subtiles->addChild(tform);
|
||||
}
|
||||
else
|
||||
subtiles->addChild(pagedLOD.get());
|
||||
}
|
||||
else
|
||||
{
|
||||
subtiles->setUserData(new TileIdentifier(tileX,tileY,tileLOD));
|
||||
if(tileType == trpgHeader::TileLocal)
|
||||
{
|
||||
osg::Vec3d center(info.center - parentInfo.bbox._min);
|
||||
osg::Vec3d sw(info.bbox._min - parentInfo.bbox._min);
|
||||
sw[2] = 0.0;
|
||||
osg::Matrix offset;
|
||||
offset.setTrans(sw);
|
||||
osg::MatrixTransform *tform = new osg::MatrixTransform(offset);
|
||||
tform->addChild(tileContent.get());
|
||||
subtiles->addChild(tform);
|
||||
}
|
||||
else
|
||||
subtiles->addChild(tileContent.get());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//osg::notify(osg::NOTICE) << "Subtiles for " << x << " " << y << " " << lod << " lodaded" << std::endl;
|
||||
@@ -539,7 +539,7 @@ bool ReaderWriterTXP::extractChildrenLocations(const std::string& name, int pare
|
||||
|
||||
locs[idx].lod = parentLod+1;
|
||||
|
||||
|
||||
|
||||
|
||||
token = strtok(0, "_");
|
||||
}
|
||||
@@ -617,26 +617,26 @@ class SeamFinder: public osg::NodeVisitor
|
||||
{
|
||||
public:
|
||||
SeamFinder(int x, int y, int lod, const TXPArchive::TileInfo& info, TXPArchive *archive ):
|
||||
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
|
||||
_x(x), _y(y), _lod(lod), _info(info), _archive(archive)
|
||||
{}
|
||||
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
|
||||
_x(x), _y(y), _lod(lod), _info(info), _archive(archive)
|
||||
{}
|
||||
|
||||
virtual void apply(osg::Group& group)
|
||||
{
|
||||
for (unsigned int i = 0; i < group.getNumChildren(); i++)
|
||||
{
|
||||
osg::Node* child = group.getChild(i);
|
||||
osg::Node* seam = seamReplacement(child);
|
||||
if (child != seam)
|
||||
{
|
||||
group.replaceChild(child,seam);
|
||||
}
|
||||
else
|
||||
{
|
||||
child->accept(*this);
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
for (unsigned int i = 0; i < group.getNumChildren(); i++)
|
||||
{
|
||||
osg::Node* child = group.getChild(i);
|
||||
osg::Node* seam = seamReplacement(child);
|
||||
if (child != seam)
|
||||
{
|
||||
group.replaceChild(child,seam);
|
||||
}
|
||||
else
|
||||
{
|
||||
child->accept(*this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
osg::Node* seamReplacement(osg::Node* node);
|
||||
@@ -649,8 +649,8 @@ protected:
|
||||
osg::Node* SeamFinder::seamReplacement(osg::Node* node)
|
||||
{
|
||||
osg::Group* group = node->asGroup();
|
||||
if ( group == 0 )
|
||||
return node;
|
||||
if ( group == 0 )
|
||||
return node;
|
||||
|
||||
std::vector<osg::Node*> nonSeamChildren;
|
||||
osg::LOD* hiRes = 0;
|
||||
@@ -671,10 +671,10 @@ osg::Node* SeamFinder::seamReplacement(osg::Node* node)
|
||||
|
||||
bool nonSeamChild = true;
|
||||
|
||||
// looks like the problem is in here - likely due to seamLOD info
|
||||
// not being adjusted properly in tiled databases
|
||||
// looks like the problem is in here - likely due to seamLOD info
|
||||
// not being adjusted properly in tiled databases
|
||||
// seam center is outside the bounding box of the tile
|
||||
osg::Vec3 lodCenter = lod->getCenter();
|
||||
osg::Vec3 lodCenter = lod->getCenter();
|
||||
|
||||
if(tileType == trpgHeader::TileLocal)
|
||||
{
|
||||
@@ -690,7 +690,7 @@ osg::Node* SeamFinder::seamReplacement(osg::Node* node)
|
||||
tileExtents.y /= divider;
|
||||
offset[0] = _x*tileExtents.x;// + tileExtents.x*0.5;
|
||||
offset[1] = _y*tileExtents.y;// + tileExtents.y*0.5;
|
||||
lodCenter += offset;
|
||||
lodCenter += offset;
|
||||
}
|
||||
|
||||
if (!_info.bbox.contains(lodCenter))
|
||||
@@ -735,7 +735,7 @@ osg::Node* SeamFinder::seamReplacement(osg::Node* node)
|
||||
int dx = 0;
|
||||
int dy = 0;
|
||||
int lod = _lod;
|
||||
osg::Vec3 lodCenter = loRes->getCenter();
|
||||
osg::Vec3 lodCenter = loRes->getCenter();
|
||||
|
||||
if(tileType == trpgHeader::TileLocal)
|
||||
{
|
||||
@@ -751,27 +751,27 @@ osg::Node* SeamFinder::seamReplacement(osg::Node* node)
|
||||
tileExtents.y /= divider;
|
||||
offset[0] = _x*tileExtents.x;// + tileExtents.x*0.5;
|
||||
offset[1] = _y*tileExtents.y;// + tileExtents.y*0.5;
|
||||
lodCenter += offset;
|
||||
lodCenter += offset;
|
||||
}
|
||||
|
||||
osg::Vec3 delta = lodCenter-_info.center;
|
||||
if (fabs(delta.x())>fabs(delta.y()))
|
||||
{
|
||||
if ( delta.x() < 0.0 )
|
||||
--dx; // west
|
||||
else
|
||||
dx++; // east
|
||||
if ( delta.x() < 0.0 )
|
||||
--dx; // west
|
||||
else
|
||||
dx++; // east
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( delta.y() < 0.0 )
|
||||
--dy; // south
|
||||
else
|
||||
++dy; // north
|
||||
if ( delta.y() < 0.0 )
|
||||
--dy; // south
|
||||
else
|
||||
++dy; // north
|
||||
}
|
||||
|
||||
TXPSeamLOD* seam = new TXPSeamLOD(_x, _y, lod, dx, dy);
|
||||
seam->setCenter(loRes->getCenter());
|
||||
seam->setCenter(loRes->getCenter());
|
||||
seam->addChild(loRes->getChild(0)); // low res
|
||||
if (hiRes)
|
||||
{
|
||||
@@ -800,8 +800,8 @@ osg::Node* SeamFinder::seamReplacement(osg::Node* node)
|
||||
|
||||
osg::Node* ReaderWriterTXP::getTileContent(const TXPArchive::TileInfo &info, int x, int y, int lod, TXPArchive* archive, std::vector<TXPArchive::TileLocationInfo>& childrenLoc)
|
||||
{
|
||||
if ( archive == 0 )
|
||||
return false;
|
||||
if ( archive == 0 )
|
||||
return false;
|
||||
|
||||
int majorVersion, minorVersion;
|
||||
archive->GetVersion(majorVersion, minorVersion);
|
||||
@@ -837,8 +837,8 @@ osg::Node* ReaderWriterTXP::getTileContent(const TXPArchive::TileInfo &info, int
|
||||
// this version only gets called if the TXP version is >= than 2.1
|
||||
osg::Node* ReaderWriterTXP::getTileContent(const TXPArchive::TileInfo &info, const TXPArchive::TileLocationInfo& loc, TXPArchive* archive, std::vector<TXPArchive::TileLocationInfo>& childrenLoc)
|
||||
{
|
||||
if ( archive == 0 )
|
||||
return false;
|
||||
if ( archive == 0 )
|
||||
return false;
|
||||
|
||||
// int numLods = archive->getNumLODs();
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ bool TXPArchive::openFile(const std::string& archiveName)
|
||||
header->GetNumLods(_numLODs);
|
||||
header->GetExtents(_swExtents,_neExtents);
|
||||
header->GetVersion(_majorVersion, _minorVersion);
|
||||
_isMaster = header->GetIsMaster();
|
||||
_isMaster = header->GetIsMaster();
|
||||
}
|
||||
|
||||
int numTextures;
|
||||
@@ -149,7 +149,7 @@ bool TXPArchive::loadMaterial(int ix)
|
||||
|
||||
|
||||
if (GetStatesMapEntry(ix).get())
|
||||
return true;
|
||||
return true;
|
||||
|
||||
osg::StateSet* osg_state_set = new osg::StateSet;
|
||||
|
||||
@@ -175,17 +175,17 @@ bool TXPArchive::loadMaterial(int ix)
|
||||
trpgColor color;
|
||||
mat->GetAmbient(color);
|
||||
osg_material->setAmbient( osg::Material::FRONT_AND_BACK ,
|
||||
osg::Vec4(color.red, color.green, color.blue, alpha));
|
||||
osg::Vec4(color.red, color.green, color.blue, alpha));
|
||||
mat->GetDiffuse(color);
|
||||
osg_material->setDiffuse(osg::Material::FRONT_AND_BACK ,
|
||||
osg::Vec4(color.red, color.green, color.blue, alpha));
|
||||
osg::Vec4(color.red, color.green, color.blue, alpha));
|
||||
|
||||
mat->GetSpecular(color);
|
||||
osg_material->setSpecular(osg::Material::FRONT_AND_BACK ,
|
||||
osg::Vec4(color.red, color.green, color.blue, alpha));
|
||||
osg::Vec4(color.red, color.green, color.blue, alpha));
|
||||
mat->GetEmission(color);
|
||||
osg_material->setEmission(osg::Material::FRONT_AND_BACK ,
|
||||
osg::Vec4(color.red, color.green, color.blue, alpha));
|
||||
osg::Vec4(color.red, color.green, color.blue, alpha));
|
||||
|
||||
float64 shinines;
|
||||
mat->GetShininess(shinines);
|
||||
@@ -342,28 +342,28 @@ bool TXPArchive::loadMaterials()
|
||||
bool TXPArchive::loadTexture(int i)
|
||||
{
|
||||
if (GetTexMapEntry(i).get())
|
||||
return true;
|
||||
|
||||
return true;
|
||||
|
||||
bool separateGeo = false;
|
||||
int majorVer,minorVer;
|
||||
GetVersion(majorVer,minorVer);
|
||||
if((majorVer >= TRPG_NOMERGE_VERSION_MAJOR) && (minorVer>=TRPG_NOMERGE_VERSION_MINOR))
|
||||
{
|
||||
separateGeo = true;
|
||||
separateGeo = true;
|
||||
}
|
||||
trpgrImageHelper image_helper(this->GetEndian(),getDir(),materialTable,texTable,separateGeo);
|
||||
|
||||
const trpgTexture *tex;
|
||||
tex = texTable.GetTextureRef(i);
|
||||
if (!tex)
|
||||
return false;
|
||||
return false;
|
||||
|
||||
trpgTexture::ImageMode mode;
|
||||
tex->GetImageMode(mode);
|
||||
if(mode == trpgTexture::External)
|
||||
{
|
||||
char texName[ 1024 ];
|
||||
texName[ 0 ] = 0;
|
||||
char texName[ 1024 ];
|
||||
texName[ 0 ] = 0;
|
||||
tex->GetName(texName,1023);
|
||||
|
||||
// Create a texture by name.
|
||||
@@ -396,21 +396,21 @@ bool TXPArchive::loadTexture(int i)
|
||||
else
|
||||
{
|
||||
osg::notify(osg::WARN) << "TrPageArchive::LoadMaterials() error: "
|
||||
<< "couldn't open image: " << filename << std::endl;
|
||||
<< "couldn't open image: " << filename << std::endl;
|
||||
}
|
||||
SetTexMap(i,osg_texture);
|
||||
SetTexMap(i,osg_texture);
|
||||
}
|
||||
else if( mode == trpgTexture::Local )
|
||||
{
|
||||
SetTexMap(i,getLocalTexture(image_helper,tex));
|
||||
SetTexMap(i,getLocalTexture(image_helper,tex));
|
||||
}
|
||||
else if( mode == trpgTexture::Template )
|
||||
{
|
||||
SetTexMap(i,0L);
|
||||
SetTexMap(i,0L);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetTexMap(i,0L);
|
||||
SetTexMap(i,0L);
|
||||
}
|
||||
|
||||
return (GetTexMapEntry(i).get() != 0);
|
||||
@@ -421,7 +421,7 @@ bool TXPArchive::loadModel(int ix)
|
||||
trpgModel *mod = modelTable.GetModelRef(ix);
|
||||
int type;
|
||||
if(!mod)
|
||||
return false;
|
||||
return false;
|
||||
mod->GetType(type);
|
||||
|
||||
// Only dealing with external models currently
|
||||
@@ -431,15 +431,15 @@ bool TXPArchive::loadModel(int ix)
|
||||
mod->GetName(name,1023);
|
||||
|
||||
// Load the model. It's probably not TerraPage
|
||||
osg::Node *osg_model = osgDB::readNodeFile( name );
|
||||
if ( !osg_model )
|
||||
osg::Node *osg_model = osgDB::readNodeFile( name );
|
||||
if ( !osg_model )
|
||||
{
|
||||
osg::notify(osg::WARN) << "TrPageArchive::LoadModels() error: "
|
||||
<< "failed to load model: "
|
||||
<< name << std::endl;
|
||||
<< "failed to load model: "
|
||||
<< name << std::endl;
|
||||
}
|
||||
// Do this even if it's NULL
|
||||
_models[ ix ] = osg_model;
|
||||
// Do this even if it's NULL
|
||||
_models[ ix ] = osg_model;
|
||||
}
|
||||
/*
|
||||
else
|
||||
@@ -465,7 +465,7 @@ bool TXPArchive::loadModels()
|
||||
trpgModelTable::ModelMapType::iterator itr = mt->begin();
|
||||
for ( ; itr != mt->end( ); itr++)
|
||||
{
|
||||
loadModel(itr->first);
|
||||
loadModel(itr->first);
|
||||
}
|
||||
osg::notify(osg::NOTICE) << "txp:: ... done." << std::endl;
|
||||
return true;
|
||||
@@ -479,7 +479,7 @@ bool TXPArchive::loadLightAttributes()
|
||||
trpgLightTable::LightMapType::iterator itr = lm->begin();
|
||||
for ( ; itr != lm->end() ; itr++)
|
||||
{
|
||||
trpgLightAttr* ref = &itr->second;
|
||||
trpgLightAttr* ref = &itr->second;
|
||||
|
||||
osgSim::LightPointNode* osgLight = new osgSim::LightPointNode();
|
||||
|
||||
@@ -565,12 +565,12 @@ bool TXPArchive::loadLightAttributes()
|
||||
lp._sector = back;
|
||||
osgLight->addLightPoint(lp);
|
||||
}
|
||||
else
|
||||
{
|
||||
else
|
||||
{
|
||||
osgLight->addLightPoint(lp);
|
||||
}
|
||||
|
||||
addLightAttribute(osgLight, stateSet, osg::Vec3(normal.x,normal.y,normal.z),itr->first);
|
||||
addLightAttribute(osgLight, stateSet, osg::Vec3(normal.x,normal.y,normal.z),itr->first);
|
||||
}
|
||||
|
||||
osg::notify(osg::NOTICE) << "txp:: ... done." << std::endl;
|
||||
@@ -580,7 +580,7 @@ bool TXPArchive::loadLightAttributes()
|
||||
void trim(std::string& str)
|
||||
{
|
||||
while (!str.empty() && isspace(str[str.length()-1]))
|
||||
str.erase(str.length()-1);
|
||||
str.erase(str.length()-1);
|
||||
while (!str.empty() && isspace(str[0]))
|
||||
str.erase(0,1);
|
||||
}
|
||||
@@ -588,9 +588,9 @@ bool TXPArchive::loadTextStyles()
|
||||
{
|
||||
const trpgTextStyleTable *textStyleTable = GetTextStyleTable();
|
||||
if ( !textStyleTable )
|
||||
return false;
|
||||
return false;
|
||||
if ( textStyleTable->GetNumStyle() < 1 )
|
||||
return true;
|
||||
return true;
|
||||
|
||||
// try fontmap.txt
|
||||
std::map< std::string, std::string > fontmap;
|
||||
@@ -601,66 +601,66 @@ bool TXPArchive::loadTextStyles()
|
||||
|
||||
if (fmapfile.is_open())
|
||||
{
|
||||
osg::notify(osg::NOTICE) << "txp:: Font map file found: " << fmapfname << std::endl;
|
||||
std::string line;
|
||||
while (std::getline(fmapfile,line))
|
||||
{
|
||||
std::string::size_type 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);
|
||||
osg::notify(osg::NOTICE) << "txp:: Font map file found: " << fmapfname << std::endl;
|
||||
std::string line;
|
||||
while (std::getline(fmapfile,line))
|
||||
{
|
||||
std::string::size_type 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();
|
||||
}
|
||||
}
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
const trpgTextStyleTable::StyleMapType *smap = textStyleTable->getStyleMap();
|
||||
trpgTextStyleTable::StyleMapType::const_iterator itr = smap->begin();
|
||||
for ( ; itr != smap->end(); itr++)
|
||||
{
|
||||
const trpgTextStyle *textStyle = &itr->second;
|
||||
if ( !textStyle )
|
||||
continue;
|
||||
const trpgTextStyle *textStyle = &itr->second;
|
||||
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[itr->first] = font;
|
||||
_fonts[itr->first] = 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[itr->first] = osg::Vec4(faceColor.red, faceColor.green, faceColor.blue, alpha );
|
||||
}
|
||||
}
|
||||
_fcolors[itr->first] = osg::Vec4(faceColor.red, faceColor.green, faceColor.blue, alpha );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -703,19 +703,19 @@ bool TXPArchive::getTileInfo(const TileLocationInfo& loc, TileInfo& info)
|
||||
sw.x+(loc.x*size.x)+(size.x/2.f),
|
||||
sw.y+(loc.y*size.y)+(size.y/2.f),
|
||||
(loc.zmin + loc.zmax)/2.f
|
||||
);
|
||||
);
|
||||
info.bbox.set(
|
||||
osg::Vec3(
|
||||
info.center.x()-(size.x/2.f),
|
||||
info.center.y()-(size.y/2.f),
|
||||
loc.zmin
|
||||
),
|
||||
),
|
||||
osg::Vec3(
|
||||
info.center.x()+(size.x/2.f),
|
||||
info.center.y()+(size.y/2.f),
|
||||
loc.zmax
|
||||
)
|
||||
);
|
||||
)
|
||||
);
|
||||
info.radius = osg::Vec3(size.x/2.f, size.y/2.f,0.f).length() * 1.3;
|
||||
|
||||
return true;
|
||||
@@ -727,10 +727,10 @@ bool TXPArchive::getTileInfo(int x, int y, int lod, TileInfo& info)
|
||||
|
||||
if(_majorVersion == 2 && _minorVersion >=1)
|
||||
{
|
||||
// Version 2.1
|
||||
// Tile table contain only lod 0
|
||||
if(lod > 0)
|
||||
return false;
|
||||
// Version 2.1
|
||||
// Tile table contain only lod 0
|
||||
if(lod > 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
trpgwAppAddress addr;
|
||||
@@ -753,10 +753,10 @@ osg::Group* TXPArchive::getTileContent(
|
||||
{
|
||||
if(_majorVersion == 2 && _minorVersion >= 1)
|
||||
{
|
||||
// Version 2.1
|
||||
// This call is valid only for lod = 0
|
||||
if(lod != 0)
|
||||
return new osg::Group;
|
||||
// Version 2.1
|
||||
// This call is valid only for lod = 0
|
||||
if(lod != 0)
|
||||
return new osg::Group;
|
||||
}
|
||||
|
||||
trpgwAppAddress addr;
|
||||
@@ -781,42 +781,42 @@ public:
|
||||
ModelVisitor(TXPArchive* archive, const TXPArchive::TileLocationInfo& loc):
|
||||
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
|
||||
_archive(archive), _tileInfo(loc)
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
virtual void apply(osg::MatrixTransform& xform)
|
||||
{
|
||||
const trpgHeader* header = _archive->GetHeader();
|
||||
trpgHeader::trpgTileType tileType;
|
||||
header->GetTileOriginType(tileType);
|
||||
const osg::Referenced* ref = xform.getUserData();
|
||||
const TileIdentifier* tileID = dynamic_cast<const txp::TileIdentifier*>(ref);
|
||||
{
|
||||
const trpgHeader* header = _archive->GetHeader();
|
||||
trpgHeader::trpgTileType tileType;
|
||||
header->GetTileOriginType(tileType);
|
||||
const osg::Referenced* ref = xform.getUserData();
|
||||
const TileIdentifier* tileID = dynamic_cast<const txp::TileIdentifier*>(ref);
|
||||
|
||||
if(!tileID) return; // bail early - this isn't a loaded model
|
||||
if(!tileID) return; // bail early - this isn't a loaded model
|
||||
|
||||
if(tileType == trpgHeader::TileLocal && tileID->lod == 9999)
|
||||
{
|
||||
trpg2dPoint tileExtents;
|
||||
header->GetTileSize(0, tileExtents);
|
||||
osg::BoundingBox bbox;
|
||||
_archive->getExtents(bbox);
|
||||
osg::Vec3 offset(xform.getMatrix().getTrans());
|
||||
offset[0] -= bbox._min[0];
|
||||
offset[1] -= bbox._min[1];
|
||||
if(tileType == trpgHeader::TileLocal && tileID->lod == 9999)
|
||||
{
|
||||
trpg2dPoint tileExtents;
|
||||
header->GetTileSize(0, tileExtents);
|
||||
osg::BoundingBox bbox;
|
||||
_archive->getExtents(bbox);
|
||||
osg::Vec3 offset(xform.getMatrix().getTrans());
|
||||
offset[0] -= bbox._min[0];
|
||||
offset[1] -= bbox._min[1];
|
||||
|
||||
trpg2dPoint offsetXY, tileID(_tileInfo.x,_tileInfo.y);
|
||||
int divider = (0x01 << _tileInfo.lod);
|
||||
// calculate which tile model is located in
|
||||
tileExtents.x /= divider;
|
||||
tileExtents.y /= divider;
|
||||
offset[0] -= tileID.x*tileExtents.x;
|
||||
offset[1] -= tileID.y*tileExtents.y;
|
||||
trpg2dPoint offsetXY, tileID(_tileInfo.x,_tileInfo.y);
|
||||
int divider = (0x01 << _tileInfo.lod);
|
||||
// calculate which tile model is located in
|
||||
tileExtents.x /= divider;
|
||||
tileExtents.y /= divider;
|
||||
offset[0] -= tileID.x*tileExtents.x;
|
||||
offset[1] -= tileID.y*tileExtents.y;
|
||||
|
||||
osg::Matrix mat(xform.getMatrix());
|
||||
mat.setTrans(offset);
|
||||
xform.setMatrix(mat);
|
||||
}
|
||||
}
|
||||
osg::Matrix mat(xform.getMatrix());
|
||||
mat.setTrans(offset);
|
||||
xform.setMatrix(mat);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -840,12 +840,12 @@ osg::Group* TXPArchive::getTileContent(
|
||||
trpgTileTable::TileMode tileMode;
|
||||
tileTable.GetMode(tileMode);
|
||||
if(tileMode == trpgTileTable::External)
|
||||
readStatus = ReadExternalTile(loc.x, loc.y, loc.lod, buf);
|
||||
readStatus = ReadExternalTile(loc.x, loc.y, loc.lod, buf);
|
||||
else
|
||||
readStatus = ReadTile(loc.addr, buf);
|
||||
readStatus = ReadTile(loc.addr, buf);
|
||||
|
||||
if(!readStatus)
|
||||
return new osg::Group;
|
||||
return new osg::Group;
|
||||
trpgTileHeader *tilehdr = _parser->getTileHeaderRef();
|
||||
|
||||
int majVersion,minVersion;
|
||||
@@ -853,14 +853,14 @@ osg::Group* TXPArchive::getTileContent(
|
||||
// only compute block # if we are a master archive.
|
||||
if((majVersion >= TRPG_NOMERGE_VERSION_MAJOR) && (minVersion >= TRPG_NOMERGE_VERSION_MINOR) && (_isMaster))
|
||||
{
|
||||
if(tilehdr)
|
||||
{
|
||||
int x,y;
|
||||
unsigned int denom = (1 << loc.lod); // this should work up to lod 31
|
||||
x = loc.x/denom;
|
||||
y = loc.y/denom;
|
||||
tilehdr->SetBlockNo(y,x);
|
||||
}
|
||||
if(tilehdr)
|
||||
{
|
||||
int x,y;
|
||||
unsigned int denom = (1 << loc.lod); // this should work up to lod 31
|
||||
x = loc.x/denom;
|
||||
y = loc.y/denom;
|
||||
tilehdr->SetBlockNo(y,x);
|
||||
}
|
||||
}
|
||||
|
||||
osg::Group *tileGroup = _parser->parseScene(buf,_statesMap,_models,realMinRange,realMaxRange,usedMaxRange);
|
||||
@@ -871,17 +871,17 @@ osg::Group* TXPArchive::getTileContent(
|
||||
childInfoList.clear();
|
||||
for(int idx = 0; idx < nbChild; idx++)
|
||||
{
|
||||
const trpgChildRef *childRef = _parser->GetChildRef(idx);
|
||||
const trpgChildRef *childRef = _parser->GetChildRef(idx);
|
||||
|
||||
if(childRef)
|
||||
{
|
||||
TileLocationInfo loc;
|
||||
childRef->GetTileLoc(loc.x, loc.y, loc.lod);
|
||||
childRef->GetTileZValue(loc.zmin, loc.zmax);
|
||||
childRef->GetTileAddress(loc.addr);
|
||||
childInfoList.push_back(loc);
|
||||
if(childRef)
|
||||
{
|
||||
TileLocationInfo loc;
|
||||
childRef->GetTileLoc(loc.x, loc.y, loc.lod);
|
||||
childRef->GetTileZValue(loc.zmin, loc.zmax);
|
||||
childRef->GetTileAddress(loc.addr);
|
||||
childInfoList.push_back(loc);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fix up model MatrixTransform
|
||||
@@ -892,16 +892,16 @@ osg::Group* TXPArchive::getTileContent(
|
||||
OSGStatesMapType::iterator itr = _statesMap.begin();
|
||||
while( itr != _statesMap.end( ) )
|
||||
{
|
||||
if(itr->second.valid() &&
|
||||
(itr->second->referenceCount()==1))
|
||||
{
|
||||
// unreference it.
|
||||
if(itr->second.valid() &&
|
||||
(itr->second->referenceCount()==1))
|
||||
{
|
||||
// unreference it.
|
||||
itr->second = NULL;
|
||||
|
||||
|
||||
OSGStatesMapType::iterator toRemove = itr;
|
||||
++itr;
|
||||
|
||||
// remove it from the map
|
||||
|
||||
// remove it from the map
|
||||
_statesMap.erase( toRemove );
|
||||
}
|
||||
else
|
||||
@@ -913,18 +913,18 @@ osg::Group* TXPArchive::getTileContent(
|
||||
OSGTexMapType::iterator mitr = _texmap.begin();
|
||||
while( mitr != _texmap.end( ) )
|
||||
{
|
||||
if(mitr->second.valid() &&
|
||||
(mitr->second->referenceCount()==1))
|
||||
{
|
||||
// unreference it.
|
||||
if(mitr->second.valid() &&
|
||||
(mitr->second->referenceCount()==1))
|
||||
{
|
||||
// unreference it.
|
||||
mitr->second = NULL;
|
||||
|
||||
|
||||
OSGTexMapType::iterator toRemove = mitr;
|
||||
++mitr;
|
||||
|
||||
// remove it from the map
|
||||
|
||||
// remove it from the map
|
||||
_texmap.erase( toRemove );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
++mitr;
|
||||
|
||||
@@ -53,125 +53,125 @@ namespace txp
|
||||
// this one handles different placement of light direction in osg and terrapage
|
||||
struct DeferredLightAttribute
|
||||
{
|
||||
// light point at (0,0,0) looking in (0,0,0) direction
|
||||
osg::ref_ptr<osgSim::LightPointNode> lightPoint;
|
||||
osg::ref_ptr<osg::StateSet> fallback;
|
||||
osg::Vec3 attitude;
|
||||
// light point at (0,0,0) looking in (0,0,0) direction
|
||||
osg::ref_ptr<osgSim::LightPointNode> lightPoint;
|
||||
osg::ref_ptr<osg::StateSet> fallback;
|
||||
osg::Vec3 attitude;
|
||||
};
|
||||
|
||||
class TXPParser;
|
||||
class TXPArchive : public trpgr_Archive, public osg::Referenced
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
TXPArchive();
|
||||
// Constructor
|
||||
TXPArchive();
|
||||
|
||||
// Opens the archive file and reads the header
|
||||
bool openFile(const std::string& archiveName);
|
||||
// Load the materials from the archve
|
||||
bool loadMaterials();
|
||||
bool loadMaterial(int ix);
|
||||
bool loadTexture(int i);
|
||||
// Opens the archive file and reads the header
|
||||
bool openFile(const std::string& archiveName);
|
||||
// Load the materials from the archve
|
||||
bool loadMaterials();
|
||||
bool loadMaterial(int ix);
|
||||
bool loadTexture(int i);
|
||||
|
||||
// Load the models from the archive
|
||||
bool loadModels();
|
||||
bool loadModel(int ix);
|
||||
// Load the models from the archive
|
||||
bool loadModels();
|
||||
bool loadModel(int ix);
|
||||
|
||||
// Load the light attribs from the archive
|
||||
bool loadLightAttributes();
|
||||
// Load the light attribs from the archive
|
||||
bool loadLightAttributes();
|
||||
|
||||
// Load the text styles from the archive
|
||||
bool loadTextStyles();
|
||||
inline std::map<int, osg::ref_ptr<osgText::Font> >& getStyles()
|
||||
{
|
||||
return _fonts;
|
||||
}
|
||||
inline std::map<int, osg::Vec4 >& getTextColors()
|
||||
{
|
||||
return _fcolors;
|
||||
}
|
||||
// Load the text styles from the archive
|
||||
bool loadTextStyles();
|
||||
inline std::map<int, osg::ref_ptr<osgText::Font> >& getStyles()
|
||||
{
|
||||
return _fonts;
|
||||
}
|
||||
inline std::map<int, osg::Vec4 >& getTextColors()
|
||||
{
|
||||
return _fcolors;
|
||||
}
|
||||
|
||||
// Add light attrib
|
||||
void addLightAttribute(osgSim::LightPointNode* lpn, osg::StateSet* fallback , const osg::Vec3& attitude,int handle);
|
||||
// Add light attrib
|
||||
void addLightAttribute(osgSim::LightPointNode* lpn, osg::StateSet* fallback , const osg::Vec3& attitude,int handle);
|
||||
|
||||
int getNumLightAttributes()
|
||||
{
|
||||
return _lights.size();
|
||||
}
|
||||
int getNumLightAttributes()
|
||||
{
|
||||
return _lights.size();
|
||||
}
|
||||
|
||||
// Get light attrib
|
||||
inline DeferredLightAttribute& getLightAttribute(unsigned int i)
|
||||
{
|
||||
return _lights[i];
|
||||
};
|
||||
// Get light attrib
|
||||
inline DeferredLightAttribute& getLightAttribute(unsigned int i)
|
||||
{
|
||||
return _lights[i];
|
||||
};
|
||||
|
||||
// Gets some informations for a given tile
|
||||
struct TileInfo
|
||||
{
|
||||
osg::Vec3 center;
|
||||
double minRange;
|
||||
double maxRange;
|
||||
double lod0Range;
|
||||
float radius;
|
||||
osg::Vec3 size;
|
||||
osg::BoundingBox bbox;
|
||||
};
|
||||
struct TileLocationInfo
|
||||
{
|
||||
TileLocationInfo() : x( -1 ), y( -1 ), lod( -1 )
|
||||
{}
|
||||
TileLocationInfo(int gx, int gy, int glod, const trpgwAppAddress& gaddr, float gzmin = 0.0f, float gzmax = 0.0f):
|
||||
x( gx ), y( gy ), lod( glod ), addr( gaddr ), zmin( gzmin ), zmax( gzmax )
|
||||
{}
|
||||
int x, y, lod;
|
||||
trpgwAppAddress addr;
|
||||
float zmin, zmax;
|
||||
};
|
||||
// Gets some informations for a given tile
|
||||
struct TileInfo
|
||||
{
|
||||
osg::Vec3 center;
|
||||
double minRange;
|
||||
double maxRange;
|
||||
double lod0Range;
|
||||
float radius;
|
||||
osg::Vec3 size;
|
||||
osg::BoundingBox bbox;
|
||||
};
|
||||
struct TileLocationInfo
|
||||
{
|
||||
TileLocationInfo() : x( -1 ), y( -1 ), lod( -1 )
|
||||
{}
|
||||
TileLocationInfo(int gx, int gy, int glod, const trpgwAppAddress& gaddr, float gzmin = 0.0f, float gzmax = 0.0f):
|
||||
x( gx ), y( gy ), lod( glod ), addr( gaddr ), zmin( gzmin ), zmax( gzmax )
|
||||
{}
|
||||
int x, y, lod;
|
||||
trpgwAppAddress addr;
|
||||
float zmin, zmax;
|
||||
};
|
||||
|
||||
bool getTileInfo(int x, int y, int lod, TileInfo& info);
|
||||
bool getTileInfo(const TileLocationInfo& loc, TileInfo& info);
|
||||
bool getTileInfo(int x, int y, int lod, TileInfo& info);
|
||||
bool getTileInfo(const TileLocationInfo& loc, TileInfo& info);
|
||||
|
||||
// Set/Get the archive id
|
||||
inline void setId(int id)
|
||||
{
|
||||
_id = id;
|
||||
}
|
||||
inline const int& getId() const
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
// Set/Get the archive id
|
||||
inline void setId(int id)
|
||||
{
|
||||
_id = id;
|
||||
}
|
||||
inline const int& getId() const
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
// Returns the number of LODs for this archive
|
||||
inline const int& getNumLODs() const
|
||||
{
|
||||
return _numLODs;
|
||||
}
|
||||
// Returns the number of LODs for this archive
|
||||
inline const int& getNumLODs() const
|
||||
{
|
||||
return _numLODs;
|
||||
}
|
||||
|
||||
// Returns the extents of the archive
|
||||
// Returns the extents of the archive
|
||||
// FIXME - Needs to change for databases that aren't flat-earth
|
||||
void getExtents(osg::BoundingBox& extents);
|
||||
// {
|
||||
// extents.set(_swExtents.x,_swExtents.y,0.0f,_neExtents.x,_neExtents.y,0.0f);
|
||||
// }
|
||||
|
||||
// Returns the origin of the archive
|
||||
inline void getOrigin(double& x, double& y)
|
||||
{
|
||||
x=_swExtents.x;
|
||||
y=_swExtents.y;
|
||||
}
|
||||
// Returns the origin of the archive
|
||||
inline void getOrigin(double& x, double& y)
|
||||
{
|
||||
x=_swExtents.x;
|
||||
y=_swExtents.y;
|
||||
}
|
||||
|
||||
// Returns global texture
|
||||
inline osg::Texture2D* getGlobalTexture(int id)
|
||||
{
|
||||
return GetTexMapEntry(id).get();
|
||||
}
|
||||
// Returns global texture
|
||||
inline osg::Texture2D* getGlobalTexture(int id)
|
||||
{
|
||||
return GetTexMapEntry(id).get();
|
||||
}
|
||||
|
||||
// Returns scenegraph representing the Tile.
|
||||
// For version 2.1 and over this function can only be call
|
||||
// with lod = 0, since the archive tile table will contain
|
||||
// only tiles with lod = 0
|
||||
osg::Group* getTileContent(
|
||||
// Returns scenegraph representing the Tile.
|
||||
// For version 2.1 and over this function can only be call
|
||||
// with lod = 0, since the archive tile table will contain
|
||||
// only tiles with lod = 0
|
||||
osg::Group* getTileContent(
|
||||
int x,
|
||||
int y,
|
||||
int lod,
|
||||
@@ -181,8 +181,8 @@ namespace txp
|
||||
osg::Vec3& tileCenter,
|
||||
std::vector<TileLocationInfo>& childInfoList);
|
||||
|
||||
// To be used for Version 2.1 with lod > 0
|
||||
osg::Group* getTileContent(
|
||||
// To be used for Version 2.1 with lod > 0
|
||||
osg::Group* getTileContent(
|
||||
const TileLocationInfo& loc,
|
||||
double realMinRange,
|
||||
double realMaxRange,
|
||||
@@ -190,68 +190,68 @@ namespace txp
|
||||
osg::Vec3& tileCenter,
|
||||
std::vector<TileLocationInfo>& childInfoList);
|
||||
|
||||
// Get the number of tiles for given LOD
|
||||
bool getLODSize(int lod, int& x, int& y);
|
||||
// Get the number of tiles for given LOD
|
||||
bool getLODSize(int lod, int& x, int& y);
|
||||
|
||||
void GetVersion(int& majorVer, int& minorVer) const
|
||||
{
|
||||
majorVer = _majorVersion;
|
||||
minorVer = _minorVersion;
|
||||
}
|
||||
void GetVersion(int& majorVer, int& minorVer) const
|
||||
{
|
||||
majorVer = _majorVersion;
|
||||
minorVer = _minorVersion;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
// Destructor
|
||||
virtual ~TXPArchive();
|
||||
// Destructor
|
||||
virtual ~TXPArchive();
|
||||
|
||||
// Id of the archive
|
||||
int _id;
|
||||
// Id of the archive
|
||||
int _id;
|
||||
|
||||
// Number of the LODs
|
||||
int _numLODs;
|
||||
// Number of the LODs
|
||||
int _numLODs;
|
||||
|
||||
// Archive extents
|
||||
trpg2dPoint _swExtents;
|
||||
trpg2dPoint _neExtents;
|
||||
// Archive extents
|
||||
trpg2dPoint _swExtents;
|
||||
trpg2dPoint _neExtents;
|
||||
|
||||
// Terra Page Parser
|
||||
osg::ref_ptr<TXPParser> _parser;
|
||||
// Terra Page Parser
|
||||
osg::ref_ptr<TXPParser> _parser;
|
||||
|
||||
// Textures
|
||||
typedef std::map<int,osg::ref_ptr<osg::Texture2D> > OSGTexMapType;
|
||||
OSGTexMapType _texmap;
|
||||
// Textures
|
||||
typedef std::map<int,osg::ref_ptr<osg::Texture2D> > OSGTexMapType;
|
||||
OSGTexMapType _texmap;
|
||||
|
||||
void SetTexMap(int key,osg::ref_ptr<osg::Texture2D> ref);
|
||||
osg::ref_ptr<osg::Texture2D> GetTexMapEntry(int key);
|
||||
void SetTexMap(int key,osg::ref_ptr<osg::Texture2D> ref);
|
||||
osg::ref_ptr<osg::Texture2D> GetTexMapEntry(int key);
|
||||
|
||||
|
||||
// States
|
||||
typedef std::map<int,osg::ref_ptr<osg::StateSet> > OSGStatesMapType;
|
||||
OSGStatesMapType _statesMap;
|
||||
// States
|
||||
typedef std::map<int,osg::ref_ptr<osg::StateSet> > OSGStatesMapType;
|
||||
OSGStatesMapType _statesMap;
|
||||
|
||||
void SetStatesMap(int key,osg::ref_ptr<osg::StateSet> ref);
|
||||
osg::ref_ptr<osg::StateSet> GetStatesMapEntry(int key);
|
||||
void SetStatesMap(int key,osg::ref_ptr<osg::StateSet> ref);
|
||||
osg::ref_ptr<osg::StateSet> GetStatesMapEntry(int key);
|
||||
|
||||
// Models
|
||||
typedef std::map<int,osg::ref_ptr<osg::Node> > OSGModelsMapType;
|
||||
OSGModelsMapType _models;
|
||||
// Models
|
||||
typedef std::map<int,osg::ref_ptr<osg::Node> > OSGModelsMapType;
|
||||
OSGModelsMapType _models;
|
||||
|
||||
// Light attributes vector
|
||||
std::map<int, DeferredLightAttribute> _lights;
|
||||
// Light attributes vector
|
||||
std::map<int, DeferredLightAttribute> _lights;
|
||||
|
||||
// Text styles / Fonts
|
||||
std::map<int, osg::ref_ptr<osgText::Font> > _fonts;
|
||||
// Text styles / Fonts
|
||||
std::map<int, osg::ref_ptr<osgText::Font> > _fonts;
|
||||
|
||||
// Text colors
|
||||
std::map<int, osg::Vec4 > _fcolors;
|
||||
// Text colors
|
||||
std::map<int, osg::Vec4 > _fcolors;
|
||||
|
||||
//
|
||||
OpenThreads::Mutex _mutex;
|
||||
//
|
||||
OpenThreads::Mutex _mutex;
|
||||
|
||||
// Cache those: TerraPage version
|
||||
int _majorVersion, _minorVersion;
|
||||
// Cache those: TerraPage version
|
||||
int _majorVersion, _minorVersion;
|
||||
|
||||
bool _isMaster;
|
||||
bool _isMaster;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -148,8 +148,8 @@ osg::Group *TXPParser::parseScene(
|
||||
}
|
||||
_tileGroups.clear();
|
||||
|
||||
LayerVisitor lv;
|
||||
_root->accept(lv);
|
||||
LayerVisitor lv;
|
||||
_root->accept(lv);
|
||||
|
||||
return _root.get();
|
||||
}
|
||||
@@ -357,7 +357,7 @@ void TXPParser::loadLocalMaterials()
|
||||
int majorVer,minorVer;
|
||||
this->getArchive()->GetVersion(majorVer,minorVer);
|
||||
if((majorVer >= TRPG_NOMERGE_VERSION_MAJOR) && (minorVer>=TRPG_NOMERGE_VERSION_MINOR)) {
|
||||
separateGeo = true;
|
||||
separateGeo = true;
|
||||
}
|
||||
// new to 2.0 LOCAL materials
|
||||
trpgrImageHelper image_helper(
|
||||
@@ -365,7 +365,7 @@ void TXPParser::loadLocalMaterials()
|
||||
_archive->getDir(),
|
||||
*_archive->GetMaterialTable(),
|
||||
*_archive->GetTexTable(),
|
||||
separateGeo
|
||||
separateGeo
|
||||
);
|
||||
trpgTileHeader* tile_head = getTileHeaderRef();
|
||||
|
||||
@@ -407,7 +407,7 @@ void TXPParser::loadLocalMaterials()
|
||||
{
|
||||
case trpgTextureEnv::Alpha :
|
||||
osg_texenv->setMode(osg::TexEnv::REPLACE);
|
||||
break;
|
||||
break;
|
||||
case trpgTextureEnv::Decal:
|
||||
osg_texenv->setMode(osg::TexEnv::DECAL);
|
||||
break;
|
||||
@@ -498,10 +498,10 @@ void TXPParser::loadLocalMaterials()
|
||||
}
|
||||
|
||||
|
||||
/* This controls what alpha values in a texture mean. It can take the values:
|
||||
None,Always,Equal,GreaterThanOrEqual,GreaterThan,
|
||||
LessThanOrEqual,LessThan,Never,NotEqual
|
||||
*/
|
||||
/* This controls what alpha values in a texture mean. It can take the values:
|
||||
None,Always,Equal,GreaterThanOrEqual,GreaterThan,
|
||||
LessThanOrEqual,LessThan,Never,NotEqual
|
||||
*/
|
||||
int alphaFunc;
|
||||
mat->GetAlphaFunc(alphaFunc);
|
||||
if( alphaFunc>=GL_NEVER && alphaFunc<=GL_ALWAYS)
|
||||
@@ -758,18 +758,18 @@ void* lightRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf)
|
||||
int attr_index;
|
||||
light.GetAttrIndex(attr_index);
|
||||
|
||||
uint32 nvert;
|
||||
uint32 nvert;
|
||||
light.GetNumVertices(nvert);
|
||||
|
||||
const trpgLightTable *lt = _parse->getArchive()->GetLightTable();
|
||||
trpgLightAttr *ref = const_cast<trpgLightAttr*>(lt->GetLightAttrRef(attr_index));
|
||||
if (!ref)
|
||||
{
|
||||
osg::notify(osg::NOTICE) << "NULL LightAttr " << attr_index << std::endl;
|
||||
return (void*)1;
|
||||
}
|
||||
const trpgLightTable *lt = _parse->getArchive()->GetLightTable();
|
||||
trpgLightAttr *ref = const_cast<trpgLightAttr*>(lt->GetLightAttrRef(attr_index));
|
||||
if (!ref)
|
||||
{
|
||||
osg::notify(osg::NOTICE) << "NULL LightAttr " << attr_index << std::endl;
|
||||
return (void*)1;
|
||||
}
|
||||
|
||||
osgSim::LightPointNode *lpNode = new osgSim::LightPointNode();
|
||||
osgSim::LightPointNode *lpNode = new osgSim::LightPointNode();
|
||||
|
||||
trpgColor col;
|
||||
ref->GetFrontColor(col);
|
||||
@@ -780,88 +780,88 @@ void* lightRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf)
|
||||
trpgLightAttr::PerformerAttr perfAttr;
|
||||
ref->GetPerformerAttr(perfAttr);
|
||||
|
||||
lpNode->setMaxPixelSize(perfAttr.maxPixelSize);
|
||||
lpNode->setMaxPixelSize(perfAttr.maxPixelSize);
|
||||
lpNode->setMinPixelSize(perfAttr.minPixelSize);
|
||||
|
||||
trpg3dPoint norm;
|
||||
ref->GetNormal(norm);
|
||||
trpg3dPoint norm;
|
||||
ref->GetNormal(norm);
|
||||
|
||||
trpgLightAttr::LightDirectionality direc;
|
||||
trpgLightAttr::LightDirectionality direc;
|
||||
ref->GetDirectionality(direc);
|
||||
|
||||
for ( unsigned i=0; i < nvert; i++ )
|
||||
{
|
||||
trpg3dPoint pt;
|
||||
for ( unsigned i=0; i < nvert; i++ )
|
||||
{
|
||||
trpg3dPoint pt;
|
||||
light.GetVertex(i, pt);
|
||||
|
||||
osgSim::LightPoint lp(
|
||||
true,
|
||||
osg::Vec3(pt.x,pt.y,pt.z),
|
||||
osg::Vec4(col.red, col.green,col.blue, 1.0),
|
||||
inten
|
||||
);
|
||||
osgSim::LightPoint lp(
|
||||
true,
|
||||
osg::Vec3(pt.x,pt.y,pt.z),
|
||||
osg::Vec4(col.red, col.green,col.blue, 1.0),
|
||||
inten
|
||||
);
|
||||
|
||||
switch (direc)
|
||||
{
|
||||
case trpgLightAttr::trpg_Unidirectional:
|
||||
{
|
||||
float lobeVert=0.f, lobeHorz=0.f, lobeRoll=0.f;
|
||||
float64 tmp;
|
||||
switch (direc)
|
||||
{
|
||||
case trpgLightAttr::trpg_Unidirectional:
|
||||
{
|
||||
float lobeVert=0.f, lobeHorz=0.f, lobeRoll=0.f;
|
||||
float64 tmp;
|
||||
|
||||
ref->GetHLobeAngle(tmp);
|
||||
lobeHorz = osg::DegreesToRadians( tmp );
|
||||
|
||||
ref->GetVLobeAngle(tmp);
|
||||
lobeVert = osg::DegreesToRadians( tmp );
|
||||
|
||||
ref->GetLobeRollAngle(tmp);
|
||||
lobeRoll = osg::DegreesToRadians( tmp );
|
||||
ref->GetHLobeAngle(tmp);
|
||||
lobeHorz = osg::DegreesToRadians( tmp );
|
||||
|
||||
ref->GetVLobeAngle(tmp);
|
||||
lobeVert = osg::DegreesToRadians( tmp );
|
||||
|
||||
ref->GetLobeRollAngle(tmp);
|
||||
lobeRoll = osg::DegreesToRadians( tmp );
|
||||
|
||||
osg::Vec3 normal(norm.x,norm.y,norm.z);
|
||||
lp._sector = new osgSim::DirectionalSector( normal, lobeHorz, lobeVert, lobeRoll );
|
||||
}
|
||||
break;
|
||||
case trpgLightAttr::trpg_Bidirectional:
|
||||
{
|
||||
float lobeVert=0.f, lobeHorz=0.f, lobeRoll=0.f;
|
||||
float64 tmp;
|
||||
osg::Vec3 normal(norm.x,norm.y,norm.z);
|
||||
lp._sector = new osgSim::DirectionalSector( normal, lobeHorz, lobeVert, lobeRoll );
|
||||
}
|
||||
break;
|
||||
case trpgLightAttr::trpg_Bidirectional:
|
||||
{
|
||||
float lobeVert=0.f, lobeHorz=0.f, lobeRoll=0.f;
|
||||
float64 tmp;
|
||||
|
||||
ref->GetHLobeAngle(tmp);
|
||||
lobeHorz = osg::DegreesToRadians( tmp );
|
||||
|
||||
ref->GetVLobeAngle(tmp);
|
||||
lobeVert = osg::DegreesToRadians( tmp );
|
||||
|
||||
ref->GetLobeRollAngle(tmp);
|
||||
lobeRoll = osg::DegreesToRadians( tmp );
|
||||
ref->GetHLobeAngle(tmp);
|
||||
lobeHorz = osg::DegreesToRadians( tmp );
|
||||
|
||||
ref->GetVLobeAngle(tmp);
|
||||
lobeVert = osg::DegreesToRadians( tmp );
|
||||
|
||||
ref->GetLobeRollAngle(tmp);
|
||||
lobeRoll = osg::DegreesToRadians( tmp );
|
||||
|
||||
osg::Vec3 normal(norm.x,norm.y,norm.z);
|
||||
lp._sector = new osgSim::DirectionalSector( normal, lobeHorz, lobeVert, lobeRoll );
|
||||
osg::Vec3 normal(norm.x,norm.y,norm.z);
|
||||
lp._sector = new osgSim::DirectionalSector( normal, lobeHorz, lobeVert, lobeRoll );
|
||||
|
||||
ref->GetBackColor(col);
|
||||
ref->GetBackIntensity(inten);
|
||||
ref->GetBackColor(col);
|
||||
ref->GetBackIntensity(inten);
|
||||
|
||||
osgSim::LightPoint lp2(
|
||||
true,
|
||||
osg::Vec3(pt.x,pt.y,pt.z),
|
||||
osg::Vec4(col.red, col.green,col.blue, 1.0),
|
||||
inten
|
||||
);
|
||||
osgSim::LightPoint lp2(
|
||||
true,
|
||||
osg::Vec3(pt.x,pt.y,pt.z),
|
||||
osg::Vec4(col.red, col.green,col.blue, 1.0),
|
||||
inten
|
||||
);
|
||||
|
||||
lp2._sector = new osgSim::DirectionalSector( -normal, lobeHorz, lobeVert, lobeRoll );
|
||||
lpNode->addLightPoint( lp2 );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
lp2._sector = new osgSim::DirectionalSector( -normal, lobeHorz, lobeVert, lobeRoll );
|
||||
lpNode->addLightPoint( lp2 );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
lpNode->addLightPoint( lp);
|
||||
lpNode->addLightPoint( lp);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
_parse->setCurrentNode(lpNode);
|
||||
_parse->getCurrTop()->addChild(lpNode);
|
||||
_parse->setCurrentNode(lpNode);
|
||||
_parse->getCurrTop()->addChild(lpNode);
|
||||
|
||||
#if 0
|
||||
|
||||
@@ -878,7 +878,7 @@ void* lightRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf)
|
||||
trpg3dPoint pt;
|
||||
light.GetVertex(i, pt);
|
||||
osg::Matrix matrix;
|
||||
// matrix.makeTranslate(pt.x,pt.y,pt.z);
|
||||
// matrix.makeTranslate(pt.x,pt.y,pt.z);
|
||||
matrix.makeRotate(osg::Quat(0.0,dla.attitude));
|
||||
matrix.setTrans(pt.x,pt.y,pt.z);
|
||||
osg::ref_ptr<osg::MatrixTransform> trans = new osg::MatrixTransform();
|
||||
@@ -931,7 +931,7 @@ void* layerRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf)
|
||||
trpgLayer group;
|
||||
if (!group.Read(buf)) return NULL;
|
||||
|
||||
osg::ref_ptr<LayerGroup> osgGroup = new LayerGroup();
|
||||
osg::ref_ptr<LayerGroup> osgGroup = new LayerGroup();
|
||||
_parse->setCurrentNode(osgGroup.get());
|
||||
_parse->getCurrTop()->addChild(osgGroup.get());
|
||||
return (void*)1;
|
||||
@@ -1362,58 +1362,58 @@ void* geomRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf)
|
||||
{
|
||||
case trpgGeometry::Triangles:
|
||||
{
|
||||
geometry = new osg::Geometry;
|
||||
geometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::TRIANGLES,0,numPrims*3));
|
||||
geometry = new osg::Geometry;
|
||||
geometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::TRIANGLES,0,numPrims*3));
|
||||
}
|
||||
break;
|
||||
case trpgGeometry::Quads:
|
||||
{
|
||||
geometry = new osg::Geometry;
|
||||
geometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,numPrims*4));
|
||||
geometry = new osg::Geometry;
|
||||
geometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,numPrims*4));
|
||||
}
|
||||
break;
|
||||
case trpgGeometry::TriStrips:
|
||||
{
|
||||
geometry = new osg::Geometry;
|
||||
osg::DrawArrayLengths* dal = new osg::DrawArrayLengths(osg::PrimitiveSet::TRIANGLE_STRIP,0,numPrims);
|
||||
geom.GetPrimLengths(reinterpret_cast<int*>(&(dal->front())));
|
||||
geometry->addPrimitiveSet(dal);
|
||||
geometry = new osg::Geometry;
|
||||
osg::DrawArrayLengths* dal = new osg::DrawArrayLengths(osg::PrimitiveSet::TRIANGLE_STRIP,0,numPrims);
|
||||
geom.GetPrimLengths(reinterpret_cast<int*>(&(dal->front())));
|
||||
geometry->addPrimitiveSet(dal);
|
||||
}
|
||||
break;
|
||||
case trpgGeometry::TriFans:
|
||||
{
|
||||
geometry = new osg::Geometry;
|
||||
osg::DrawArrayLengths* dal = new osg::DrawArrayLengths(osg::PrimitiveSet::TRIANGLE_FAN,0,numPrims);
|
||||
geom.GetPrimLengths(reinterpret_cast<int*>(&(dal->front())));
|
||||
geometry->addPrimitiveSet(dal);
|
||||
geometry = new osg::Geometry;
|
||||
osg::DrawArrayLengths* dal = new osg::DrawArrayLengths(osg::PrimitiveSet::TRIANGLE_FAN,0,numPrims);
|
||||
geom.GetPrimLengths(reinterpret_cast<int*>(&(dal->front())));
|
||||
geometry->addPrimitiveSet(dal);
|
||||
|
||||
// Need to flip the fans coords.
|
||||
int ind = 0;
|
||||
int i;
|
||||
for (i=0;i<numPrims;++i)
|
||||
{
|
||||
int length = (*dal)[i];
|
||||
int start=ind+1;
|
||||
int end=ind+length-1;
|
||||
// Swap from start+1 to end
|
||||
// Swap vertices, texture coords & normals
|
||||
for (; start < end; ++start, --end )
|
||||
{
|
||||
std::swap((*vertices)[start], (*vertices)[end]);
|
||||
for(int texno = 0; texno < num_tex; texno ++ )
|
||||
{
|
||||
if( tex_coords[texno].valid() )
|
||||
{
|
||||
std::swap((*tex_coords[texno])[start], (*tex_coords[texno])[end]);
|
||||
}
|
||||
}
|
||||
if(normals.valid())
|
||||
{
|
||||
std::swap((*normals)[start], (*normals)[end]);
|
||||
}
|
||||
}
|
||||
ind += length;
|
||||
}
|
||||
// Need to flip the fans coords.
|
||||
int ind = 0;
|
||||
int i;
|
||||
for (i=0;i<numPrims;++i)
|
||||
{
|
||||
int length = (*dal)[i];
|
||||
int start=ind+1;
|
||||
int end=ind+length-1;
|
||||
// Swap from start+1 to end
|
||||
// Swap vertices, texture coords & normals
|
||||
for (; start < end; ++start, --end )
|
||||
{
|
||||
std::swap((*vertices)[start], (*vertices)[end]);
|
||||
for(int texno = 0; texno < num_tex; texno ++ )
|
||||
{
|
||||
if( tex_coords[texno].valid() )
|
||||
{
|
||||
std::swap((*tex_coords[texno])[start], (*tex_coords[texno])[end]);
|
||||
}
|
||||
}
|
||||
if(normals.valid())
|
||||
{
|
||||
std::swap((*normals)[start], (*normals)[end]);
|
||||
}
|
||||
}
|
||||
ind += length;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -1460,7 +1460,7 @@ void* geomRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf)
|
||||
if((sset!=0L) && sset.valid())
|
||||
{
|
||||
if(tmp_ss.valid())
|
||||
{
|
||||
{
|
||||
osg::StateAttribute* texenv0 = tmp_ss->getTextureAttribute(0,osg::StateAttribute::TEXENV);
|
||||
if(texenv0)
|
||||
sset->setTextureAttribute(n_mat,texenv0);
|
||||
|
||||
Reference in New Issue
Block a user