|
|
@ -184,8 +184,7 @@ namespace ESMTerrain
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Storage::fillVertexBuffers(int lodLevel, float size, const osg::Vec2f& center, ESM::RefId worldspace,
|
|
|
|
void Storage::fillVertexBuffers(int lodLevel, float size, const osg::Vec2f& center, ESM::RefId worldspace,
|
|
|
|
osg::ref_ptr<osg::Vec3Array> positions, osg::ref_ptr<osg::Vec3Array> normals,
|
|
|
|
osg::Vec3Array& positions, osg::Vec3Array& normals, osg::Vec4ubArray& colours)
|
|
|
|
osg::ref_ptr<osg::Vec4ubArray> colours)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// LOD level n means every 2^n-th vertex is kept
|
|
|
|
// LOD level n means every 2^n-th vertex is kept
|
|
|
|
size_t increment = static_cast<size_t>(1) << lodLevel;
|
|
|
|
size_t increment = static_cast<size_t>(1) << lodLevel;
|
|
|
@ -199,9 +198,9 @@ namespace ESMTerrain
|
|
|
|
|
|
|
|
|
|
|
|
size_t numVerts = static_cast<size_t>(size * (landSize - 1) / increment + 1);
|
|
|
|
size_t numVerts = static_cast<size_t>(size * (landSize - 1) / increment + 1);
|
|
|
|
|
|
|
|
|
|
|
|
positions->resize(numVerts * numVerts);
|
|
|
|
positions.resize(numVerts * numVerts);
|
|
|
|
normals->resize(numVerts * numVerts);
|
|
|
|
normals.resize(numVerts * numVerts);
|
|
|
|
colours->resize(numVerts * numVerts);
|
|
|
|
colours.resize(numVerts * numVerts);
|
|
|
|
|
|
|
|
|
|
|
|
osg::Vec3f normal;
|
|
|
|
osg::Vec3f normal;
|
|
|
|
osg::Vec4ub color;
|
|
|
|
osg::Vec4ub color;
|
|
|
@ -269,7 +268,7 @@ namespace ESMTerrain
|
|
|
|
height = heightData->getHeights()[col * landSize + row];
|
|
|
|
height = heightData->getHeights()[col * landSize + row];
|
|
|
|
if (alteration)
|
|
|
|
if (alteration)
|
|
|
|
height += getAlteredHeight(col, row);
|
|
|
|
height += getAlteredHeight(col, row);
|
|
|
|
(*positions)[static_cast<unsigned int>(vertX * numVerts + vertY)]
|
|
|
|
positions[static_cast<unsigned int>(vertX * numVerts + vertY)]
|
|
|
|
= osg::Vec3f((vertX / float(numVerts - 1) - 0.5f) * size * LandSizeInUnits,
|
|
|
|
= osg::Vec3f((vertX / float(numVerts - 1) - 0.5f) * size * LandSizeInUnits,
|
|
|
|
(vertY / float(numVerts - 1) - 0.5f) * size * LandSizeInUnits, height);
|
|
|
|
(vertY / float(numVerts - 1) - 0.5f) * size * LandSizeInUnits, height);
|
|
|
|
|
|
|
|
|
|
|
@ -293,7 +292,7 @@ namespace ESMTerrain
|
|
|
|
|
|
|
|
|
|
|
|
assert(normal.z() > 0);
|
|
|
|
assert(normal.z() > 0);
|
|
|
|
|
|
|
|
|
|
|
|
(*normals)[static_cast<unsigned int>(vertX * numVerts + vertY)] = normal;
|
|
|
|
normals[static_cast<unsigned int>(vertX * numVerts + vertY)] = normal;
|
|
|
|
|
|
|
|
|
|
|
|
if (colourData)
|
|
|
|
if (colourData)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -315,7 +314,7 @@ namespace ESMTerrain
|
|
|
|
|
|
|
|
|
|
|
|
color.a() = 255;
|
|
|
|
color.a() = 255;
|
|
|
|
|
|
|
|
|
|
|
|
(*colours)[static_cast<unsigned int>(vertX * numVerts + vertY)] = color;
|
|
|
|
colours[static_cast<unsigned int>(vertX * numVerts + vertY)] = color;
|
|
|
|
|
|
|
|
|
|
|
|
++vertX;
|
|
|
|
++vertX;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -333,7 +332,7 @@ namespace ESMTerrain
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (unsigned int iVert = 0; iVert < numVerts * numVerts; iVert++)
|
|
|
|
for (unsigned int iVert = 0; iVert < numVerts * numVerts; iVert++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
(*positions)[static_cast<unsigned int>(iVert)] = osg::Vec3f(0.f, 0.f, 0.f);
|
|
|
|
positions[static_cast<unsigned int>(iVert)] = osg::Vec3f(0.f, 0.f, 0.f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|