public BulletShapeFileManager(BulletShapeRepository repository, BulletShapeBuilder builder)
     : base(repository, builder)
 {
     ShapeBuilder    = builder;
     ShapeRepository = repository;
     ShapeBuilder.setRepository(ShapeRepository);
 }
        /// <summary>
        /// Add a named shape to a given region, will return a new ReshapeableRigidBodySection if this works correctly.
        /// The returned handles will be owned by this object, so there is no need to dispose them or clean them up (if this
        /// object is disposed). However, you can manually remove a section at any time by calling destroySection.
        /// </summary>
        public ReshapeableRigidBodySection createSection(String shapeName, Vector3 translation, Quaternion rotation, Vector3 scale)
        {
            BulletShapeRepository repository = BulletInterface.Instance.ShapeRepository;

            if (repository.containsValidCollection(shapeName))
            {
                var section = new ReshapeableRigidBodySection(this, repository.getCollection(shapeName).CollisionShape.createClone(), translation, rotation);
                sections.Add(section);

                return(section);
            }

            return(null);
        }
        internal override void createProduct(SimObjectBase instance, BulletScene scene)
        {
            BulletShapeRepository repository = BulletInterface.Instance.ShapeRepository;

            if (repository.containsValidCollection(ShapeName))
            {
                btCollisionShape shape = repository.getCollection(ShapeName).CollisionShape;
                if (constructionInfo.m_mass != 0.0f)
                {
                    shape.calculateLocalInertia(constructionInfo.m_mass, ref constructionInfo.m_localInertia);
                }
                RigidBody rigidBody = new RigidBody(this, scene, shape, instance.Translation, instance.Rotation);
                instance.addElement(rigidBody);
            }
            else
            {
                Log.Default.sendMessage("Could not find collision shape named {0}.", LogLevel.Warning, "BulletPlugin", ShapeName);
            }
        }
Пример #4
0
 internal void setRepository(BulletShapeRepository repository)
 {
     this.repository = repository;
 }