public ICollisionShape CreateCollisionShape(Actor actor, CollisionShapeConfig config)
 {
     var service = actorCollisionShapeFactoryContext.GetRequiredService<IPhysicsService>();
     var instance = service.CollisionShapeFactory.CreateCollisionShape(CollisionShapeType);
     InitializeProperties(instance, actor, config);
     return instance;
 }
        protected override void InitializeProperties(ICollisionShape instance, Actor actor, CollisionShapeConfig config)
        {
            var concreteShape = instance as ICubeHeightmapCollisionShape;
            concreteShape.Position = actor.Position;

            var concreteActor = actor as TerrainActor;
            var actorModel = concreteActor.ActorModel as CubeTerrainActorModel;
            concreteShape.Heightmap = actorModel.Terrain.Heightmap;

            base.InitializeProperties(instance, actor, config);
        }
Пример #3
0
        public override void UnloadContent()
        {
            if (actor != null)
            {
                actor.UnloadContent();
                actor.ActorContext = null;
                actor = null;
            }

            Invalidate();
        }
Пример #4
0
        public override void LoadContent()
        {
            if (RuntimeContent == null) return;

            actor = RuntimeContent.LoadContent(ContentManager) as Actor;
            if (actor == null) return;

            actor.ActorContext = this;
            actor.LoadContent();

            Invalidate();
        }
 protected virtual void InitializeProperties(ICollisionShape instance, Actor actor, CollisionShapeConfig config)
 {
     instance.StaticFriction = config.StaticFriction;
     instance.DynamicFriction = config.DynamicFriction;
     instance.Restitution = config.Restitution;
 }
Пример #6
0
 /// <summary>
 /// 生成された Actor を ActorConfig の設定に従って初期化します。
 /// </summary>
 /// <param name="config">ActorConfig。</param>
 /// <param name="instance">Actor。</param>
 /// <remarks>
 /// このメソッドでは Actor へのプロパティの設定のみを担い、
 /// コンテンのロードは行いません。
 /// </remarks>
 protected virtual void InitializeActorProperties(Actor instance, ActorConfig config)
 {
     instance.Name = config.Name;
     instance.Position = config.Position;
     Matrix.CreateFromYawPitchRoll(
         config.Orientation.Y,
         config.Orientation.X,
         config.Orientation.Z,
         out instance.Orientation);
     Matrix.CreateScale(ref config.Scale, out instance.Scale);
     instance.Enabled = config.Enabled;
     instance.Visible = config.Visible;
 }