Commit e790458d authored by Carson Brownlee's avatar Carson Brownlee Committed by Carson Brownlee
Browse files

adding scale array support for ospray lines. Fixing color support for lines

parent 9615a2fe
......@@ -184,18 +184,6 @@ OSPGeometricModel RenderAsSpheres(osp::vec3f* vertices, std::vector<unsigned int
for (size_t i = 0; i < indexArray.size(); i++)
{
vdata.emplace_back(vertices[indexArray[i]]);
// mdata[i * width + 0] = static_cast<float>(vertices[indexArray[i]].x);
// mdata[i * width + 1] = static_cast<float>(vertices[indexArray[i]].y);
// mdata[i * width + 2] = static_cast<float>(vertices[indexArray[i]].z);
// int mat = 0;
// if (numCellMaterials)
// {
// mat = rIndexArray[i];
// }
// else if (numPointColors)
// {
// mat = indexArray[i];
// }
if (scaleArray != nullptr)
{
radii.emplace_back(MapThroughPWF(*scaleArray->GetTuple(indexArray[i]), scaleFunction));
......@@ -212,7 +200,17 @@ OSPGeometricModel RenderAsSpheres(osp::vec3f* vertices, std::vector<unsigned int
OSPData positionData = ospNewCopyData1D(vdata.size(), OSP_VEC3F, vdata.data());
ospCommit(positionData);
ospSetObject(ospMesh, "sphere.position", positionData);
ospSetFloat(ospMesh, "radius", pointSize);
if (!radii.empty())
{
OSPData radiiData = ospNewCopyData1D(radii.size(), OSP_FLOAT, radii.data());
ospCommit(radiiData);
ospSetObject(ospMesh, "sphere.radius", radiiData);
}
else
{
std::cout << "pointSize: " << pointSize << std::endl;
ospSetFloat(ospMesh, "radius", pointSize);
}
// send the texture map and texture coordinates over
bool _hastm = false;
......@@ -318,12 +316,42 @@ OSPGeometricModel RenderAsCylinders(std::vector<osp::vec3f>& vertices,
(*scaleArray->GetTuple(indexArray[i]) + *scaleArray->GetTuple(indexArray[i])) * 0.5;
const double r = MapThroughPWF(avg, scaleFunction);
const osp::vec3f& v = vertices[indexArray[i]];
// linear not supported for variable radii, must use curve type with
// 4 instead of 2 control points
mdata.emplace_back(osp::vec4f({ v.x, v.y, v.z, r }));
mdata.emplace_back(osp::vec4f({ v.x, v.y, v.z, r }));
}
OSPData _mdata = ospNewCopyData1D(mdata.size(), OSP_VEC4F, mdata.data());
ospCommit(_mdata);
ospSetObject(ospMesh, "vertex.position_radius", _mdata);
ospRelease(_mdata);
ospSetInt(ospMesh, "type", OSP_ROUND);
ospSetInt(ospMesh, "basis", OSP_BEZIER);
std::vector<unsigned int> indices;
indices.reserve(indexArray.size() / 2);
for (int i = 0; i < indexArray.size(); i += 2)
{
indices.push_back(i * 2);
}
OSPData _idata = ospNewCopyData1D(indices.size(), OSP_UINT, indices.data());
ospCommit(_idata);
ospSetObject(ospMesh, "index", _idata);
ospRelease(_idata);
if (numPointColors)
{
// need to double the number of color points for the indices
std::vector<osp::vec4f> tmpColors(numPointColors * 2);
for (size_t i = 0; i < numPointColors; i++)
{
tmpColors[i * 2 + 0] = PointColors[i];
tmpColors[i * 2 + 1] = PointColors[i];
}
OSPData _PointColors = ospNewCopyData1D(numPointColors * 2, OSP_VEC4F, tmpColors.data());
ospCommit(_PointColors);
ospSetObject(ospGeoModel, "color", _PointColors);
}
}
else
{
......@@ -337,27 +365,31 @@ OSPGeometricModel RenderAsCylinders(std::vector<osp::vec3f>& vertices,
ospCommit(_mdata);
ospSetObject(ospMesh, "vertex.position", _mdata);
ospRelease(_mdata);
}
std::vector<unsigned int> indices;
indices.reserve(indexArray.size() / 2);
for (int i = 0; i < indexArray.size(); i += 2)
{
indices.push_back(i);
}
OSPData _idata = ospNewCopyData1D(indices.size(), OSP_UINT, indices.data());
ospCommit(_idata);
ospSetObject(ospMesh, "index", _idata);
ospRelease(_idata);
ospSetFloat(ospMesh, "radius", lineWidth);
ospSetInt(ospMesh, "type", OSP_ROUND);
ospSetInt(ospMesh, "basis", OSP_LINEAR);
OSPData _PointColors = nullptr;
if (numPointColors)
{
_PointColors = ospNewCopyData1D(numPointColors, OSP_VEC4F, &PointColors[0]);
std::vector<unsigned int> indices;
indices.reserve(indexArray.size() / 2);
for (int i = 0; i < indexArray.size(); i += 2)
{
indices.push_back(i);
}
OSPData _idata = ospNewCopyData1D(indices.size(), OSP_UINT, indices.data());
ospCommit(_idata);
ospSetObject(ospMesh, "index", _idata);
ospRelease(_idata);
if (numPointColors)
{
std::cout << "numPoint colors: " << numPointColors << std::endl;
std::cout << "indexArray size: " << indexArray.size() << std::endl;
OSPData _PointColors = ospNewCopyData1D(numPointColors, OSP_VEC4F, &PointColors[0]);
ospCommit(_PointColors);
ospSetObject(ospGeoModel, "color", _PointColors);
}
}
ospSetFloat(ospMesh, "radius", lineWidth);
ospSetInt(ospMesh, "type", OSP_ROUND);
ospSetInt(ospMesh, "basis", OSP_LINEAR);
// send the texture map and texture coordinates over
bool _hastm = false;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment