From: Werner Wohlfahrter (wwohlfah@crcg.edu)
Date: 04/13/2000 08:51:28
Hi!
I use Volumizer in combination with OpenInventor. I cutted my Volume
using a SoClipPlane (works great!). Now I try to grab the texture of the
cuttingPlane and map it on an OpenInventor Object.
I think the following should work (please correct me if i'm wrong!):
- create allVertexData
- create aPolygonSetArray
- xfmVox2TexCoords
- polygonizeMPR using the planeEquation of SoClipPlane
- grab the geometry data from the aPolygonSetArray
- grab the texture data from the aPolygonSetArray
- use SoCoordinate3 Object to store geometry
- use SoTextureCoordinate2 to store texture
- use SoNormal
- use SoNormalBinding
- use SoTextureCoordinateBinding
- use So(Indexed)FaceSet
problems:
- The polygonSetArray does not have any vertexData after create
aPolygonSetArray! Why?
I took parts of the code of voglMPR1.cxx which also does the first 3
steps and it works fine there!
- I use an interleavedArrayFormat V3F, which stores the vertexdata but
no texture. Where is the texture stored? I also tried to change the
Format to T3F_V3F which could store texture but it also did not work.
How can I get the data? Where am I wrong?
here is my code and the generated output!
// code -----------------------------
voIndexedFaceSet*** aPolygonSetArray;
voVertexData* allVertexData;
voIndexedTetraSet* aTetraSet = status->getTetraSet();
voBrickSetCollection* aVolume = status->getVolume();
int brickCount =
aVolume->getCurrentBrickSet()->getBrickCount();
int maxSamplesNumber =
status->getMaxSamplesNumber();
int maxBrickCount = status->getMaxBrickCount();
SbPlane cp;
SbVec3f cpNormal;
float eq[4];
/*
// interleavedArrayForamt must include T3F to be able to store
textures!
// V3F = vertex 3 floats (vx, vy, vz)
// T3F = texture 3 floats
voInterleavedArrayType interleavedArrayFormat =
status->getInterleavedArrayFormat();
if (interleavedArrayFormat == voInterleavedArrayTypeScope::V3F) {
interleavedArrayFormat = voInterleavedArrayTypeScope::T3F_V3F;
cout << "snap: interleavedArrayFormat <T3F_V3F>" << endl;
}
*/
voInterleavedArrayType interleavedArrayFormat =
status->getInterleavedArrayFormat();
GLdouble modelMatrix[16], projMatrix[16];
glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix);
glGetDoublev(GL_PROJECTION_MATRIX, projMatrix);
// for interpolationType 2D!!!!
if (aVolume->getInterpolationType() == voInterpolationTypeScope::_2D)
{
cout << "snap: voInterpolationTypeScope::_2D" << endl;
aVolume->setCurrentBrickSet(voGeometryActions::findClosestAxisIndex(
modelMatrix,
projMatrix,
voSamplingModeScope::AXIS_ALIGNED));
}
int valuesPerVtx = getValuesPerVertex(interleavedArrayFormat);
cout << "snap: valuesPerVertex <" << valuesPerVtx << ">" << endl;
if( aTetraSet ) {
valuesPerVtx = aTetraSet->getVertexData()->getValuesPerVertex();
cout << "snap: valuesPerVertex <" << valuesPerVtx << ">" << endl;
}
int samplesNumber = 1;
// Holds all intermediate PER_VERTEX information.
allVertexData = new voVertexData(100000, valuesPerVtx);
aPolygonSetArray = new voIndexedFaceSet**[maxBrickCount];
for (int n1 = 0; n1 < maxBrickCount; n1++) {
aPolygonSetArray[n1] = new voIndexedFaceSet*[samplesNumber];
for (int n2 = 0; n2 < samplesNumber; n2++)
// do not pre-allocate index buffers to save space
aPolygonSetArray[n1][n2] = new voIndexedFaceSet(allVertexData,
0);
}
cp = status->getClipPlane();
cpNormal = cp.getNormal();
cpNormal.getValue(eq[0],eq[1],eq[2]);
eq[3] = cp.getDistanceFromOrigin();
voGeometryActions::polygonizeMPR(
eq,
aVolume->getCurrentBrickSet(),
aPolygonSetArray,
interleavedArrayFormat);
// cout data!
int polyCount = 0;
int vertexCount = 0;
int v = 0;
for (int k1 = 0; k1 < maxBrickCount; k1++) {
for (int k2 = 0; k2 < samplesNumber; k2++) {
v = aPolygonSetArray[k1][k2]->getVertexData()->getMaxCount();
cout << "snap: v count <" << v << ">" << endl;
vertexCount +=
aPolygonSetArray[k1][k2]->getVertexData()->getCount();
++polyCount;
}
}
cout << "snap: polygon count <" << polyCount << ">" << endl;
cout << "snap: vertex count <" << vertexCount << ">" << endl;
// If not using texgen() transform explicitly.
if (hasTextureComponent(interleavedArrayFormat)) {
cout << "snap: xfmVox2TexCoords ..." << endl;
voAppearanceActions::xfmVox2TexCoords(
aVolume->getCurrentBrickSet(),
samplesNumber,
aPolygonSetArray,
interleavedArrayFormat);
cout << "snap: xfmVox2TexCoords done." << endl;
} else {
cout << "snap: NO xfmVox2TexCoords." << endl;
}
// output --------------------------
snap: voInterpolationTypeScope::_2D
snap: valuesPerVertex <3>
snap: valuesPerVertex <3>
snap: eq[0] <0.713388> eq[1] <-0.174725> eq[2] <-0.678637> eq[3]
<-0.298578>
snap: polygonize ...
snap: polygonize done.
snap: v count <100000>
snap: v count <100000>
snap: polygon count <2>
snap: vertex count <0>
snap: NO xfmVox2TexCoords.
Thanks in advance for any help!
ww :)
-- \|/ @ @ ======================================================oOO(_)OOo===== Werner Wohlfahrter Fraunhofer CRCG, Inc. 321 South Main St. Providence, RI 02903, USAphone : (+1) 401 453-6363 x110 email : wwohlfah@crcg.edu, ww@cg.tuwien.ac.at url : http://www.crcg.edu/ww icq : 9611406 =====================================================================
This archive was generated by hypermail 2b29 : Wed Apr 19 2000 - 11:32:42 PDT