Fixes for Win32 build.
This commit is contained in:
@@ -136,12 +136,12 @@ Lwo2::ReadFile( const string& filename )
|
||||
unsigned char
|
||||
Lwo2::_read_char()
|
||||
{
|
||||
unsigned char c;
|
||||
char c;
|
||||
if (_fin.is_open())
|
||||
{
|
||||
_fin.read(&c, 1);
|
||||
}
|
||||
return c;
|
||||
return static_cast<unsigned char>(c);
|
||||
}
|
||||
|
||||
unsigned long
|
||||
@@ -391,7 +391,7 @@ Lwo2::_read_polygons_mapping(unsigned long size)
|
||||
u = _read_float();
|
||||
v = _read_float();
|
||||
|
||||
Lwo2PolygonMapping pm = {polygon_index, Vec2(u, v)};
|
||||
Lwo2PolygonMapping pm(polygon_index, Vec2(u, v));
|
||||
_current_layer->_polygons_map.insert(PairVMAD(point_index, pm));
|
||||
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@ Lwo2Layer::~Lwo2Layer()
|
||||
// deleting points lists
|
||||
IteratorPointsList pol_itr;
|
||||
for (pol_itr = _polygons.begin(); pol_itr != _polygons.end(); pol_itr++)
|
||||
{
|
||||
{
|
||||
delete (*pol_itr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,111 +30,111 @@ Lwo2Layer::notify(NotifySeverity severity)
|
||||
osg::notify(severity) << " points:\t" << _points.size() << endl;
|
||||
IteratorVec3 itr;
|
||||
for (itr = _points.begin(); itr != _points.end(); itr++)
|
||||
{
|
||||
{
|
||||
osg::notify(severity) << " \t" << (*itr) << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// points mappings
|
||||
osg::notify(severity) << " points mappings:\t" << _points_map.size() << endl;
|
||||
IteratorVec2 itr_vec2;
|
||||
for (itr_vec2 = _points_map.begin(); itr_vec2 != _points_map.end(); itr_vec2++)
|
||||
{
|
||||
{
|
||||
osg::notify(severity) << " \t" << (*itr_vec2) << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// polygons
|
||||
osg::notify(severity) << " polygons:\t" << _polygons.size() << endl;
|
||||
IteratorPointsList pol_itr;
|
||||
IteratorShort short_itr;
|
||||
for (pol_itr = _polygons.begin(); pol_itr != _polygons.end(); pol_itr++)
|
||||
{
|
||||
{
|
||||
osg::notify(severity) << " " << (*pol_itr)->size() << ":";
|
||||
for (short_itr = (*pol_itr)->begin(); short_itr != (*pol_itr)->end(); short_itr++)
|
||||
{
|
||||
osg::notify(severity) << "\t" << (*short_itr);
|
||||
}
|
||||
{
|
||||
osg::notify(severity) << "\t" << (*short_itr);
|
||||
}
|
||||
osg::notify(severity) << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// polygons tags
|
||||
osg::notify(severity) << " polygons tags:\t" << _polygons_tag.size() << endl;
|
||||
for (short_itr = _polygons_tag.begin(); short_itr != _polygons_tag.end(); short_itr++)
|
||||
{
|
||||
{
|
||||
osg::notify(severity) << "\t" << (*short_itr) << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Lwo2Layer::GenerateGeometry( Geometry& geometry )
|
||||
{
|
||||
notify(DEBUG_INFO);
|
||||
|
||||
IteratorPointsList pol_itr;
|
||||
Vec3Array* coords = new Vec3Array;
|
||||
notify(DEBUG_INFO);
|
||||
|
||||
// create texture array
|
||||
Vec2Array* texcoords;
|
||||
if (_points_map.size() > 0)
|
||||
{
|
||||
texcoords = new Vec2Array;
|
||||
}
|
||||
IteratorPointsList pol_itr;
|
||||
Vec3Array* coords = new Vec3Array;
|
||||
|
||||
// variables for VMAD data processing
|
||||
pair<multimap< short, Lwo2PolygonMapping >::iterator,
|
||||
multimap< short, Lwo2PolygonMapping >::iterator> range;
|
||||
multimap< short, Lwo2PolygonMapping >::iterator itr;
|
||||
// create texture array
|
||||
Vec2Array* texcoords = 0;
|
||||
if (_points_map.size() > 0)
|
||||
{
|
||||
texcoords = new Vec2Array;
|
||||
}
|
||||
|
||||
// all polygons
|
||||
int polygon_index = 0;
|
||||
for (pol_itr = _polygons.begin(); pol_itr != _polygons.end(); pol_itr++, polygon_index++)
|
||||
{
|
||||
vector< short >::reverse_iterator short_itr;
|
||||
for (short_itr = (*pol_itr)->rbegin(); short_itr != (*pol_itr)->rend(); short_itr++)
|
||||
{
|
||||
// variables for VMAD data processing
|
||||
pair<multimap< short, Lwo2PolygonMapping >::iterator,
|
||||
multimap< short, Lwo2PolygonMapping >::iterator> range;
|
||||
multimap< short, Lwo2PolygonMapping >::iterator itr;
|
||||
|
||||
// polygons coords
|
||||
(*coords).push_back(_points[*short_itr]);
|
||||
// all polygons
|
||||
int polygon_index = 0;
|
||||
for (pol_itr = _polygons.begin(); pol_itr != _polygons.end(); pol_itr++, polygon_index++)
|
||||
{
|
||||
vector< short >::reverse_iterator short_itr;
|
||||
for (short_itr = (*pol_itr)->rbegin(); short_itr != (*pol_itr)->rend(); short_itr++)
|
||||
{
|
||||
|
||||
// point texture coords
|
||||
if (_points_map.size() > 0)
|
||||
{
|
||||
// VMAP data
|
||||
Vec2 uv = _points_map[*short_itr];
|
||||
// polygons coords
|
||||
(*coords).push_back(_points[*short_itr]);
|
||||
|
||||
// chech if present VMAD data
|
||||
if (_polygons_map.size() > 0)
|
||||
{
|
||||
// point texture coords
|
||||
if (_points_map.size() > 0)
|
||||
{
|
||||
// VMAP data
|
||||
Vec2 uv = _points_map[*short_itr];
|
||||
|
||||
// select data for current point
|
||||
range = _polygons_map.equal_range(*short_itr);
|
||||
// chech if present VMAD data
|
||||
if (_polygons_map.size() > 0)
|
||||
{
|
||||
|
||||
for (itr = range.first; itr != range.second; itr++)
|
||||
{
|
||||
// select data for current point
|
||||
range = _polygons_map.equal_range(*short_itr);
|
||||
|
||||
// found current polygon
|
||||
if ((*itr).second.polygon_index == polygon_index)
|
||||
{
|
||||
uv = (*itr).second.uv;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (itr = range.first; itr != range.second; itr++)
|
||||
{
|
||||
|
||||
(*texcoords).push_back(uv);
|
||||
}
|
||||
}
|
||||
geometry.addPrimitive(new DrawArrays(Primitive::POLYGON,
|
||||
(*coords).size() - (*pol_itr)->size(),
|
||||
(*pol_itr)->size()));
|
||||
}
|
||||
geometry.setVertexArray(coords);
|
||||
// found current polygon
|
||||
if ((*itr).second.polygon_index == polygon_index)
|
||||
{
|
||||
uv = (*itr).second.uv;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// assign texture array
|
||||
if (_points_map.size() > 0)
|
||||
{
|
||||
geometry.setTexCoordArray(0, texcoords);
|
||||
}
|
||||
(*texcoords).push_back(uv);
|
||||
}
|
||||
}
|
||||
geometry.addPrimitive(new DrawArrays(Primitive::POLYGON,
|
||||
(*coords).size() - (*pol_itr)->size(),
|
||||
(*pol_itr)->size()));
|
||||
}
|
||||
geometry.setVertexArray(coords);
|
||||
|
||||
// generate normals
|
||||
osgUtil::SmoothingVisitor smoother;
|
||||
smoother.smooth(geometry);
|
||||
// assign texture array
|
||||
if (_points_map.size() > 0)
|
||||
{
|
||||
geometry.setTexCoordArray(0, texcoords);
|
||||
}
|
||||
|
||||
// generate normals
|
||||
osgUtil::SmoothingVisitor smoother;
|
||||
smoother.smooth(geometry);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,11 @@ struct Lwo2Surface
|
||||
|
||||
struct Lwo2PolygonMapping
|
||||
{
|
||||
|
||||
Lwo2PolygonMapping(short s,const Vec2& v2):
|
||||
polygon_index(s),
|
||||
uv(v2) {}
|
||||
|
||||
short polygon_index;
|
||||
Vec2 uv;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user