Skip to content

Commit 2693cf6

Browse files
committed
Renderer chooses list according to direction
1 parent e93ac86 commit 2693cf6

File tree

3 files changed

+112
-18
lines changed

3 files changed

+112
-18
lines changed

src/Interface/Modules/Render/ES/SRInterface.cc

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,14 +372,14 @@ namespace SCIRun {
372372
primitive = GL_TRIANGLES;
373373
break;
374374
}
375-
375+
/// Create sorted lists of Buffers for transparency in each direction of the axis
376376
//----------------------------------------------------------------
377377
uint32_t* ibo_buffer = reinterpret_cast<uint32_t*>(ibo.data->getBuffer());
378378
size_t num_triangles = ibo.data->getBufferSize() / (sizeof(uint32_t) * 3);
379379
Core::Geometry::Vector dir(0.0, 0.0, 0.0);
380380

381381
std::vector<DepthIndex> rel_depth(num_triangles);
382-
for (int i = 0; i <= 3; ++i)
382+
for (int i = 0; i <= 6; ++i)
383383
{
384384
std::string name = ibo.name;
385385

@@ -399,6 +399,21 @@ namespace SCIRun {
399399
name += "Z";
400400
}
401401
else if (i == 3)
402+
{
403+
dir = Core::Geometry::Vector(-1.0, 0.0, 0.0);
404+
name += "NegX";
405+
}
406+
else if (i == 4)
407+
{
408+
dir = Core::Geometry::Vector(0.0, -1.0, 0.0);
409+
name += "NegY";
410+
}
411+
else if (i == 5)
412+
{
413+
dir = Core::Geometry::Vector(0.0, 0.0, -1.0);
414+
name += "NegZ";
415+
}
416+
else if (i == 6)
402417
{
403418
int numPrimitives = ibo.data->getBufferSize() / ibo.indexSize;
404419
iboMan.addInMemoryIBO(ibo.data->getBuffer(), ibo.data->getBufferSize(), primitive, primType, numPrimitives, name);
@@ -461,7 +476,7 @@ namespace SCIRun {
461476
{
462477
//reorderIBO(pass);
463478
addVBOToEntity(entityID, pass.vboName);
464-
for (int i = 0; i <= 3; ++i)
479+
for (int i = 0; i <= 6; ++i)
465480
{
466481
std::string name = pass.iboName;
467482
if (i == 1)
@@ -470,6 +485,12 @@ namespace SCIRun {
470485
name += "Y";
471486
if (i == 3)
472487
name += "Z";
488+
if (i == 4)
489+
name += "NegX";
490+
if (i == 5)
491+
name += "NegY";
492+
if (i == 6)
493+
name += "NegZ";
473494

474495
addIBOToEntity(entityID, name);
475496
}

src/Interface/Modules/Render/ES/systems/RenderTransBasicSys.cc

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,61 @@ class RenderBasicSysTrans :
105105
{
106106
return;
107107
}
108-
108+
109+
GLuint iboID = ibo.front().glid;
110+
GLuint iboXID = ibo.front().glid;
111+
GLuint iboYID = ibo.front().glid;
112+
GLuint iboZID = ibo.front().glid;
113+
GLuint iboNegXID = ibo.front().glid;
114+
GLuint iboNegYID = ibo.front().glid;
115+
GLuint iboNegZID = ibo.front().glid;
116+
117+
int index = 0;
118+
for (auto it = ibo.begin(); it != ibo.end(); ++it, ++index)
119+
{
120+
if (index == 1)
121+
iboXID = it->glid;
122+
if (index == 2)
123+
iboYID = it->glid;
124+
if (index == 3)
125+
iboZID = it->glid;
126+
if (index == 4)
127+
iboNegXID = it->glid;
128+
if (index == 5)
129+
iboNegYID = it->glid;
130+
if (index == 6)
131+
iboNegZID = it->glid;
132+
}
133+
109134
Core::Geometry::Vector currentDir(camera.front().data.worldToView[0][2],
110-
camera.front().data.worldToView[1][2],
111-
camera.front().data.worldToView[2][2]);
135+
camera.front().data.worldToView[1][2],
136+
camera.front().data.worldToView[2][2]);
137+
138+
Core::Geometry::Vector absDir(abs(camera.front().data.worldToView[0][2]),
139+
abs(camera.front().data.worldToView[1][2]),
140+
abs(camera.front().data.worldToView[2][2]));
141+
142+
double xORy = absDir.x() > absDir.y() ? absDir.x() : absDir.y();
143+
double orZ = absDir.z() > xORy ? absDir.z() : xORy;
144+
145+
if (orZ == absDir.x())
146+
{
147+
iboID = iboXID;
148+
if (currentDir.x() < orZ)
149+
iboID = iboNegXID;
150+
}
151+
if (orZ == absDir.y())
152+
{
153+
iboID = iboYID;
154+
if (currentDir.y() < orZ)
155+
iboID = iboNegYID;
156+
}
157+
if (orZ == absDir.z())
158+
{
159+
iboID = iboZID;
160+
if (currentDir.z() < orZ)
161+
iboID = iboNegZID;
162+
}
112163

113164
// Setup *everything*. We don't want to enter multiple conditional
114165
// statements if we can avoid it. So we assume everything has not been

src/Interface/Modules/Render/ES/systems/RenderTransColorMapSys.cc

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ class RenderColorMapSysTrans :
110110
GLuint iboXID = ibo.front().glid;
111111
GLuint iboYID = ibo.front().glid;
112112
GLuint iboZID = ibo.front().glid;
113+
GLuint iboNegXID = ibo.front().glid;
114+
GLuint iboNegYID = ibo.front().glid;
115+
GLuint iboNegZID = ibo.front().glid;
113116

114117
int index = 0;
115118
for (auto it = ibo.begin(); it != ibo.end(); ++it, ++index)
@@ -120,24 +123,43 @@ class RenderColorMapSysTrans :
120123
iboYID = it->glid;
121124
if (index == 3)
122125
iboZID = it->glid;
126+
if (index == 4)
127+
iboNegXID = it->glid;
128+
if (index == 5)
129+
iboNegYID = it->glid;
130+
if (index == 6)
131+
iboNegZID = it->glid;
123132
}
124-
133+
125134
Core::Geometry::Vector currentDir(camera.front().data.worldToView[0][2],
126135
camera.front().data.worldToView[1][2],
127136
camera.front().data.worldToView[2][2]);
137+
138+
Core::Geometry::Vector absDir(abs(camera.front().data.worldToView[0][2]),
139+
abs(camera.front().data.worldToView[1][2]),
140+
abs(camera.front().data.worldToView[2][2]));
128141

142+
double xORy = absDir.x() > absDir.y() ? absDir.x() : absDir.y();
143+
double orZ = absDir.z() > xORy ? absDir.z() : xORy;
129144

130-
std::cout << "CurrentDir: " << currentDir << std::endl;
131-
132-
currentDir.normalize();
133-
134-
std::cout << "CurrentDirNormalize: " << currentDir << std::endl;
135-
136-
currentDir.safe_normalize();
137-
138-
std::cout << "CurrentDirSafeNormalize: " << currentDir << std::endl;
139-
140-
iboID = iboXID;
145+
if (orZ == absDir.x())
146+
{
147+
iboID = iboXID;
148+
if (currentDir.x() < orZ)
149+
iboID = iboNegXID;
150+
}
151+
if (orZ == absDir.y())
152+
{
153+
iboID = iboYID;
154+
if (currentDir.y() < orZ)
155+
iboID = iboNegYID;
156+
}
157+
if (orZ == absDir.z())
158+
{
159+
iboID = iboZID;
160+
if (currentDir.z() < orZ)
161+
iboID = iboNegZID;
162+
}
141163

142164
// Setup *everything*. We don't want to enter multiple conditional
143165
// statements if we can avoid it. So we assume everything has not been

0 commit comments

Comments
 (0)