Axiom.Core.Entity.GetSubEntity C# (CSharp) Method

GetSubEntity() public method

Gets the SubEntity at the specified index.
public GetSubEntity ( int index ) : SubEntity
index int
return SubEntity
		public SubEntity GetSubEntity( int index )
		{
			Debug.Assert( index >= 0 && index < this.subEntityList.Count, "index out of range" );

			return this.subEntityList[ index ];
		}

Usage Example

        /// <summary>
        ///   Add the collision data for an object.  This involves looking 
        ///   for a physics file that matches the mesh file's name, and 
        ///   loading the information from that file to build collision 
        ///   volumes.
        /// </summary>
        /// <param name="objNode">the object for which we are adding the collision data</param>
        private void AddCollisionObject(Entity modelEntity, SceneNode modelSceneNode,
                                        long oid, string physicsName)
        {
            // Create a set of collision shapes for the object
            List<CollisionShape> shapes = new List<CollisionShape>();
            PhysicsData pd = new PhysicsData();
            PhysicsSerializer ps = new PhysicsSerializer();

            try {
                Stream stream = ResourceManager.FindCommonResourceData(physicsName);
                ps.ImportPhysics(pd, stream);
                for (int i=0; i<modelEntity.SubEntityCount; i++) {
                    SubEntity subEntity = modelEntity.GetSubEntity(i);
                    if (subEntity.IsVisible) {
                        string submeshName = subEntity.SubMesh.Name;
                        List<CollisionShape> subEntityShapes = pd.GetCollisionShapes(submeshName);
                        foreach (CollisionShape subShape in subEntityShapes) {
                            // static objects will be transformed here, but movable objects
                            // are transformed on the fly
                            subShape.Transform(modelSceneNode.DerivedScale,
                                               modelSceneNode.DerivedOrientation,
                                               modelSceneNode.DerivedPosition);
                            shapes.Add(subShape);
                            log.InfoFormat("Added collision shape: {0} for {1}",
                                           subShape, submeshName);
                        }
                    }
                }
            } catch (Exception e) {
                // Unable to load physics data -- use a sphere or no collision data?
                log.WarnFormat("Unable to load physics data: {0}", e);
            }
            foreach (CollisionShape shape in shapes)
                collisionManager.AddCollisionShape(shape, oid);
        }
All Usage Examples Of Axiom.Core.Entity::GetSubEntity