Hi dirk, hi  Carsten 

I have read your suggestions with much interest. As for now i gave a try
with a small and dirt algo that tryes to spot which triangles cross the seam
and to split them away if needed.

My code for now looks like:

// check if the primitive crossed the seam
if (m_pCylindricGenerator->isPrimitiveOnCrack (verticesCoords))
{
        for (int i=0;i<nVertices;i++)
        {
                // retrieve vertex informations
                int positionInd = it.getPositionIndex(i);
                int normalInd = it.getNormalIndex(i);
                int texCoordInd = it.getTexCoordsIndex(i);
                int indexInd = it.getIndexIndex(i);
                        
                osg::Vec3f norm = normals->getValue (normalInd);
                osg::Pnt3f pos = positions->getValue(positionInd);
                osg::Vec2f texCoord = coords->getValue(texCoordInd); 
                int index = indices->getValue(indexInd);

                // split node
                beginEditCP (positions);
                        positions->addValue (pos+osg::Vec3f (0,0.1,0));
                endEditCP (positions);

                beginEditCP (normals);
                        normals->addValue (norm);
                endEditCP (normals);

                if (texCoord.x()>0.5)
                {
                        beginEditCP (coords);
        
coords->addValue(osg::Vec2f(texCoord.x()-1,texCoord.y()));              
                        endEditCP (coords);
                }
                else
                {
                        beginEditCP (coords);
        
coords->addValue(osg::Vec2f(texCoord.x(),texCoord.y()));                
                        endEditCP (coords);
                }
                                        
                int lastEntry = positions->getSize();

                beginEditCP (indices);
                        indices->setValue(lastEntry-1,indexInd);
                endEditCP (indices);
        }
}

in a few words what i do is appending a copy of the vertex in the
GeoPositions vector and then "correct" the index making it point from the
original node to the newly created one.

Well, the texture melts correctly on the seam (which is an expected thing).
The problem is that some of the triangles preceding those that were splitted
begin messing with their texture coordinates. 

Can u see anything weird in my code?

thanks E.




-----Messaggio originale-----
Da: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Per conto di Dirk
Reiners
Inviato: martedì 20 marzo 2007 7.58
A: [email protected]
Oggetto: Re: [Opensg-users] Geometry manipulation


        Hi Enrico,

Enrico Borrione wrote:
> Hi OpenSG users,
> 
> While working on texture coordinates, i came across a problem:
> using cylindrical and spherical textures i can't find a way to avoid 
> the singularity problem in the texture wrapping area.
> The only solution i could think about was the vertex splitting where 
> the texture starts, so there are a series of vertices with texcoord 0, 
> and a copy of them with texcoord 1 overlapping and making the texture 
> melt correctly where the singularity lays.
> 
> Now I looked at the starting guide where it talks about geometry, 
> indexing, and primitives, but I still can't get a very clear idea on 
> how indexing works in OpenSG.
> 
> Right now i am using a FaceIterator to sweep along the scene and spot 
> which faces cross the singularity area. The next step will be finding 
> the vertices crossing it and splitting them between the two triangles 
> on the opposite sides.
> 
> In pseudo code it would be like:
> 
> 1) find the crossing face (done)
> 2) find the crossing vertex (almost done)
> 3) make a copy of the vertex
> 4) change the index in the faceiterator so that it points to the new 
> vertex
> 5) try to make the process easy to invert (since i would like to 
> update texture coordinates often, i'd like to melt again the vertices 
> before applyng this algo again).
> 
> Keeping aside the multi indexing for the moment (i'd like to get it 
> straight the single indexing first) I don't seem able to find a 
> funcion osg::FaceIterator::setPositionIndex that allows me to change 
> on the fly the topology of the primitives in the geometry core.
> 
> Since the subject is quite difficult to describe in wrote language, 
> i'll look forward to exchange some more messages with u on the subject

Carsten covered it pretty well, I don't really have much to add. The
iterators are not designed to be used for changing anything, as they map the
internal structures into something that's not really there. If you use the
FaceIterator, that's pretty close to what is really there, but all the
others abstract a lot away.

Just that I'd be interested in the result if you get it to work, as it is a
non-trivial problem to solve in general (due to the need for
triangle-splitting in case the crossing is inside a triangle). ;) Especially
the inversion is going to be a challenge.

If you 'only' want to be able to work without splits it's still not totally
trivial, again, the inversion can be tricky. I would probably just ignore
the inversion part and keep a copy of the original data around for that.

Thanks

        Dirk

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's
Techsay panel and you'll get the chance to share your opinions on IT &
business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to