Hi Carten

Thank you for you reply.  I have some more questions.

Bascially i want to do some 3D boolean operation and then want render input 
and output. So basically i am using library which taking vertices and 
indices list as input and returns same.

So when so input seems cleared now but how do create NodePtrRef from indices 
and vertice from scratch ? I tried to do that but it doesnot showing 
anything in render screen.

Here is the conversion code

NodeRefPtr ConverNodetoMesh(AMesh* mesh)

{

NodeTransitPtr root (NULL);

GeometryUnrecPtr geo = NULL;

GeoPnt3fPropertyUnrecPtr points = NULL;

GeoUInt32PropertyUnrecPtr index = NULL;

GeoUInt32PropertyUnrecPtr lens = NULL;

GeoUInt8PropertyUnrecPtr type = NULL;

SimpleMaterialUnrecPtr mat = NULL;

Pnt3f point;





root = Node ::create();

geo = Geometry ::create();

points = GeoPnt3fProperty ::create();

index = GeoUInt32Property::create();

lens = GeoUInt32Property::create();

type = GeoUInt8Property ::create();

mat = SimpleMaterial ::create();

mat->setDiffuse(Color3f(0.42, 0.42, 0.52));

mat->setSpecular(Color3f(1, 1, 1));

mat->setShininess(20);

root->setCore(geo);

geo->setProperty(points, Geometry::PositionsIndex);

geo->setIndex (index, Geometry::PositionsIndex);

geo->setLengths(lens);

geo->setTypes (type);

geo->setMaterial(mat);



AMesh::VLIST verts = mesh->Verts();



int n=0;

for (UInt32 i=0; i<verts.size(); ++i)

{

AMesh::Vertex aVertex = verts[i];


point.setValues(aVertex.Pos().x(),aVertex.Pos().y(),aVertex.Pos().z());

points->addValue(point);

}



AMesh::PLIST faces = mesh->Polys();

for (int i=0; i<faces.size(); i++ )

{

int idx = 0;

AMesh::Polygon aPolygon = faces[i];


idx = aPolygon.Verts()[0].Data().m_vertexIndex;

index->editFieldPtr()->push_back(idx);

idx = aPolygon.Verts()[1].Data().m_vertexIndex;

index->editFieldPtr()->push_back(idx);

idx = aPolygon.Verts()[2].Data().m_vertexIndex;

index->editFieldPtr()->push_back(idx);

}

calcVertexNormals(geo);


createSharedIndex(geo);


return root;

}



Did i missed anything in this code ?


----- Original Message ----- 
From: "Carsten Neumann" <[email protected]>
To: <[email protected]>
Sent: Friday, June 12, 2009 7:44 PM
Subject: Re: [Opensg-users] How to acccess indices in Geometry


> Hello Alex,
>
> alex wrote:
>>> ok, I'm a little confused. If I load the image0.off file I get 92 faces
>>> with 276 pos indices, which is 3 indices per triangle so it makes sense.
>>>
>>> After striping I get 121 pos indices.
>>>
>>> But I don't get the 290 you report. If I dump the pos index after
>>> loading it looks ok. The only difference is the vertex order inside
>>> the triangle, as it is reversed. E.g. if the file contains 1 2 3 the
>>> loader will generate 3 2 1.
>>
>> You are right :)  It is not 290 it is 276 pos indices and After striping 
>> 121
>> pos indices.
>
> yes, they are numbered from 0 to 120, 121 is one past the end of the
> array (actually a std::vector<>).
>
>> But actually when i am accessing indices because triangle made from 3
>> indices so for 121 pos i will get access voliation
>> BTW. what actually stripping is doing interanally ?  Are you talking 
>> about
>> createSharedIndex function ?
>
> createOptimizedPrimitives() - it generates triangle strips and fans
> which render faster, because a triangle in a strip/fan reuses two
> vertices from the previous triangle so they don't have to be transformed
> twice by the hardware.
>
> Cheers,
> Carsten
>
> ------------------------------------------------------------------------------
> Crystal Reports - New Free Runtime and 30 Day Trial
> Check out the new simplified licensing option that enables unlimited
> royalty-free distribution of the report engine for externally facing
> server and web deployment.
> http://p.sf.net/sfu/businessobjects
> _______________________________________________
> Opensg-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/opensg-users
> 


------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to