THank you very much.

Zeeper.

On Sun, Feb 6, 2011 at 9:13 PM, David Kabala <djkab...@gmail.com> wrote:

>
>
> On Sat, Feb 5, 2011 at 2:42 PM, siper style <siperst...@gmail.com> wrote:
>
>> 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?
>>
>
> There are other ways.  Without more details on whether this may apply, one
> idea would be to put all "Sphere" goemetries as children of a single node,
> and all the "Cylinder" geometries as children of another separate node.
> This way you could determine if a Geometry is a sphere or cylinder by
> checking if it's parent node is the sphere group node, the cylinder group
> node, or neither.
>
> Example:
>
> NodeRecPtr SphereGroupNode;
>
> void createScene()
> {
>
>     SphereGroupNode = makeCoredNode<Group>();
>
>     //Create all the Spheres
>     for(UInt32 i(0) ; i<NumSpheres ; ++i)
>     {
>         NodeRecPtr NewSphereGeoNode = makeSphere(2,1.0);
>         SphereGroupNode->addChild(NewSphereGeoNode);
>     }
>
>     //Similarly for Cylinders
>     //...
>
>     //Create other nodes
>     //...
>
>
>     NodeRecPtr SceneNode = makeCoredNode<Group>();
>     SceneNode->addChild(SphereGroupNode);
>     //Add Cylinder group node
>     //Add all other nodes
> }
>
>
> bool isSphereNode(Node* const NodeToTest)
> {
>     //You may need to change this if you use a more complex hierarchy for
> the the descendent sphere nodes
>     return(NodeToTest != NULL && NodeToTest->getParent() ==
> SphereGroupNode);
> }
>
>
>> 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
>>
>>
>
>
> ------------------------------------------------------------------------------
> 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