Many thanks.
But what if I have thousands of geometries?
Do I still need to name them to be able to find their shape later on?

Zeeper

On Sat, Feb 5, 2011 at 5:51 PM, David Kabala <djkab...@gmail.com> wrote:

> Hi Zeeper,
>
> There is no way to do this unless you add additional information to your
> "sphere" and "cylinder" Geometry instances.  A Geometry in OpenSG holds
> generic geometric data(positions, normals, texCoords, etc).  It does not
> know if the underlying geometric data represents a sphere or cylinder.
> However, you can add attachments to a Geometry that you could use to
> distinguish between different shapes.
>
> As an example using OpenSG 2:
>
> #include <OpenSG/OSGSimpleGeometry.h>
> #include <OpenSG/OSGNameAttachment.h>
>
> ...
> OSG_USING_NAMESPACE
> ...
>
> //Create a Sphere Geoemtry
> GeometryRecPtr ExampleSphereGeo = 
> makeSphereGeo<http://www.opensg.org/doxygen/namespaceOSG.html#aabcd434346baf44743d93a61c5b889ab>(2,
> 1.0);
>
> //Add a name attachment to the goemetry
> setName<http://www.opensg.org/doxygen/namespaceOSG.html#afc7762df3d105a1915f08614cb5a41f8>(ExampleSphereGeo,
> "Sphere_Shape");
>
> //Create a Cylinder Geometry
> GeometryRecPtr ExampleCylinderGeo = 
> makeCylinderGeo<http://www.opensg.org/doxygen/namespaceOSG.html#a6099339ee81a34f95e792c6f976a6577>(2.0,
> 1.0, 24, true, true, true);
>
> //Add a name attachment to the geometry
> setName<http://www.opensg.org/doxygen/namespaceOSG.html#afc7762df3d105a1915f08614cb5a41f8>
> (ExampleCylinderGeo,"Cylinder_Shape");
>
> ...
>
> //At some other location
> NodeRecPtr SomeNodeToTest = ...;
>
>
> if(SomeNodeToTest->getCore()->getType().isDerivedFrom(Geometry::getClassType()))
> {
>      Char8* GeoName = getName(SomeNodeToTest->getCore());
>
>      if(GeoName != NULL)
>     {
>         if(strcmp(GeoName,"Sphere_Shape") == 0)
>         {
>              //Do Sphere stuff
>         }
>         else if(strcmp(GeoName,"Cylinder_Shape") == 0)
>         {
>              //Do Cylinder stuff
>         }
>     }
> }
>
> On Sat, Feb 5, 2011 at 11:33 AM, siper style <siperst...@gmail.com> wrote:
>
>> Hello,
>>
>> I want to get the shape of a geometry.
>> I have many geometries, I did
>> node->getCore->getTypeName() to check if it is a geometry,
>>
>
> You will want to use
> node->getCore()->getType().isDerivedFrom(Geometry::getClassType()) instead.
>
>
>> Now I am not able to know if the geometry is a sphere or a cylinder.
>> I only want to do something to the spheres and not the cylinders
>>
>> Zeeper
>>
>>
>> ------------------------------------------------------------------------------
>> The modern datacenter depends on network connectivity to access resources
>> and provide services. The best practices for maximizing a physical
>> server's
>> connectivity to a physical network are well understood - see how these
>> rules translate into the virtual world?
>> http://p.sf.net/sfu/oracle-sfdevnlfb
>> _______________________________________________
>> Opensg-users mailing list
>> Opensg-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/opensg-users
>>
>>
>
>
> ------------------------------------------------------------------------------
> The modern datacenter depends on network connectivity to access resources
> and provide services. The best practices for maximizing a physical server's
> connectivity to a physical network are well understood - see how these
> rules translate into the virtual world?
> http://p.sf.net/sfu/oracle-sfdevnlfb
> _______________________________________________
> Opensg-users mailing list
> Opensg-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/opensg-users
>
>
------------------------------------------------------------------------------
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to