Commit ee2b8570 authored by Carson Brownlee's avatar Carson Brownlee
Browse files

fixing ospray sphere positions and colors

parent a2279ab2
......@@ -174,38 +174,42 @@ OSPGeometricModel RenderAsSpheres(osp::vec3f* vertices, std::vector<unsigned int
OSPGeometricModel ospGeoModel = ospNewGeometricModel(ospMesh);
int width = 4;
int scaleOffset = -1;
std::vector<osp::vec3f> vdata;
vdata.reserve(indexArray.size());
std::vector<float> radii;
if (scaleArray != nullptr)
{
width = 5;
scaleOffset = 4 * sizeof(float);
radii.reserve(indexArray.size());
}
std::vector<float> mdata(width * indexArray.size());
for (size_t i = 0; i < indexArray.size(); 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];
}
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)
{
mdata[i * width + 4] = MapThroughPWF(*scaleArray->GetTuple(indexArray[i]), scaleFunction);
radii.emplace_back(MapThroughPWF(*scaleArray->GetTuple(indexArray[i]), scaleFunction));
}
}
OSPData _PointColors = nullptr;
if (numPointColors)
{
_PointColors = ospNewCopyData1D(numPointColors, OSP_VEC4F, &PointColors[0]);
ospCommit(_PointColors);
ospSetObject(ospGeoModel, "color", _PointColors);
}
OSPData positionData = ospNewCopyData1D(indexArray.size(), OSP_VEC3F, mdata.data());
OSPData positionData = ospNewCopyData1D(vdata.size(), OSP_VEC3F, vdata.data());
ospCommit(positionData);
ospSetObject(ospMesh, "sphere.position", positionData);
ospSetFloat(ospMesh, "radius", pointSize);
......@@ -252,7 +256,6 @@ OSPGeometricModel RenderAsSpheres(osp::vec3f* vertices, std::vector<unsigned int
if (useCustomMaterial)
{
ospSetMaterial(ospMesh, actorMaterial);
}
else if (vColorTextureMap && _hastm)
{
......@@ -269,7 +272,6 @@ OSPGeometricModel RenderAsSpheres(osp::vec3f* vertices, std::vector<unsigned int
else if (numPointColors)
{
// per point color
ospSetObject(ospGeoModel, "color", _PointColors);
}
else
{
......
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