Added support for copying tex coord data directly from prpgGeometry.

This commit is contained in:
Robert Osfield
2004-01-22 14:24:51 +00:00
parent ea77b1b031
commit d594982dd2
3 changed files with 30 additions and 6 deletions

View File

@@ -123,7 +123,7 @@ void TXPParser::replaceTileLod(osg::Group* group)
}
}
bool TXPParser::StartChildren(void *in)
bool TXPParser::StartChildren(void * /*in*/)
{
bool pushParent = true;
@@ -822,19 +822,23 @@ void* geomRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf)
osg::Geometry *geometry = 0L;
// Get texture coordinates
trpgTexData td;
;
int num_tex;
geom.GetNumTexCoordSets(num_tex);
osg::Vec2Array** tex_coords = new osg::Vec2Array*[num_tex];
for (int texno = 0; texno < num_tex; texno++)
{
tex_coords[texno] = 0L;
if (geom.GetTexCoordSet(texno,&td))
const trpgTexData* td = geom.GetTexCoordSet(texno);
if (td)
{
tex_coords[texno] = new osg::Vec2Array(numVert);
for (int i=0 ;i < numVert; i++)
tex_coords[texno] = new osg::Vec2Array(numVert);
const float* sourcePtr = &(td->floatData[0]);
float* destinationPtr = (float*)&((*tex_coords[texno])[0]);
for (int i=0 ;i < numVert; ++i)
{
(*(tex_coords[texno]))[i].set(td.floatData[2*i+0],td.floatData[2*i+1]);
*destinationPtr++ = *sourcePtr++;
*destinationPtr++ = *sourcePtr++;
}
}
}
@@ -1085,6 +1089,11 @@ void* geomRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf)
}
else
{
std::cout<<"Detected potential memory leak in TXPParerse.cpp"<<std::endl;
}
return (void *) 1;
}

View File

@@ -457,6 +457,14 @@ bool trpgGeometry::GetTexCoordSet(int id,trpgTexData *tx) const
*tx = texData[id];
return true;
}
const trpgTexData *trpgGeometry::GetTexCoordSet(int id) const
{
if (!isValid() || id < 0 || id >= (int)texData.size()) return 0;
return &(texData[id]);
}
bool trpgGeometry::GetNumEdgeFlag(int &n) const
{
if (!isValid()) return false;

View File

@@ -2114,6 +2114,13 @@ public:
coordinate sets.
*/
bool GetTexCoordSet(int id,trpgTexData *) const;
/* This method returns this trpgGeometry's texture coordinate set specified by the given
index. GetNumTexCoordSets determines the total number of texture
coordinate sets.
*/
const trpgTexData *GetTexCoordSet(int id) const;
/* Returns the number of edge flags in this geometry node.
Edge flags are used on certain primitive types, but are rather rare.
*/