Cast Cylinder from node child

Aug 19, 2011 at 4:27 PM

Hi Adept,

I created a Cylinder and add it  to a loaded Mesh.

When i tried to retrive it back i did like:

cyl=(Cylinder) mshSphere.Children[0] 

 

But then i got Unable to cast Cylinder from Balder.Objects.Geometries.Geometry exception...

 

Maybe is dumb question, but help would be apreciated :)

Thanks in advance...

Coordinator
Aug 19, 2011 at 4:41 PM

A Mesh is a container for Geometries. So when you load a Mesh it will add any geometries in the file as Children. When you then add a Cylinder to the Sphere mesh, it will not be the first, so it is probably the last geometry in the Children collection.

Aug 20, 2011 at 12:38 PM

I'm afraid it doesn't work that way...

When i first add two Cylinder to mshSphere1 i got:

 

mshSphere.Children[0] = Cylinder1

mshSphere.Children[1] = Cylinder2

and mshSphere.Children.Count=2;

(here the casting to Cylinder works)

That is correct and no other children exists...

 

After applying several animations to mshSphere1 i got:

mshSphere.Children[0] =(Geometry) anyGeometry

and mshSphere.Children.Count=1;

 

Which is odd!

I'm using release version 0.8.8.9, and mshSphere1 is a loaded sphere ASE.

Thanks

Coordinator
Aug 22, 2011 at 1:34 PM

Is it possible for you to try and compile the latest version on the default branch - a lot of changes has been applied since the official 0.8.8.9 release.