Hi Carsten,

thanks for your answer. I'm trying your piece of code right now, but somehow I 
can't find the
osg::GeoPnt3fPropertyRefPtr  as well as the osg::GeoPnt3fProperty  function. 
Are these OpenSG 2.0 features only? 

Unfortunately I have to use the 1.8 version. Is there a usable equivalent? 
Maybe the GeoPositions3fPtr?

thanks, greets Andy

--- Carsten Neumann <carsten_neum...@gmx.net> schrieb am Mi, 21.7.2010:

Von: Carsten Neumann <carsten_neum...@gmx.net>
Betreff: Re: [Opensg-users] Copy triangles into a new geometry
An: opensg-users@lists.sourceforge.net
Datum: Mittwoch, 21. Juli, 2010 14:27 Uhr

    Hello Andy,

Andy Bartz wrote:
> I have a virtual model consisting of different .obj gometries using 
> openSG. I already managed to find out the hit triangle Index and it's 
> related obj Object, by clicking in my virtual scene.
> 
> What I'm trying to do is let the user select a number of connected 
> triangles of one .obj Object. After that I want to create a new geometry 
> object consisting only of the selected triangles, without changing the 
> original geometry.

the triangle index from the IntersectAction can be used together with a 
TriangleIterator to get all relevant properties of the triangle 
(positions, normals, colors, texcoords, ...).

> Therefore I kind of need to "copy" the selected triangles somehow.

since the TriangleIterator gives you access to all the information about 
the triangles you can create a new Geometry and add the needed 
positions, normals, etc. to it.

> Is there an easy way to achieve that?

hm, there is no helper function to make partial copies of geometry in 
the way you need it - such a use case has not come up yet. The basic 
steps would look somewhat like this:

// triIdx is the triangle index from the IntersectAction

TriangleIterator triIt = geo->beginTriangles();
triIt.seek(triIdx);

// triIt 'points' at the hit triangle

GeometryRefPtr geoCopy = Geometry::create();
GeoPnt3fPropertyRefPtr pnts  = GeoPnt3fProperty::create();

pnts->addValue(triIt.getPosition(0));
pnts->addValue(triIt.getPosition(1));
pnts->addValue(triIt.getPosition(2));

// similar for normals, etc.

// you also need to set lengths and types on the geometry (please see
// the tutorial <http://www.opensg.org/wiki/Tutorial/OpenSG2/Geometry>
// for details on the geometries workings).

// add the new geometry to the scene graph
NodeRefPtr geoCopyN = makeNodeFor(geoCopy);
rootNode->addChild(geoCopyN);

    Cheers,
        Carsten

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users


------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to