/// <summary>
        /// Fires an octahedron.
        /// </summary>
        private void FireOctahedron()
        {
            // Get model
            DaggerfallModelComponent model = new DaggerfallModelComponent(core, (int)PhysicsObjects.Octahedron);

            // Get camera facing
            Vector3 cameraFacing = core.ActiveScene.Camera.TransformedReference;

            // Get start position
            Vector3 position = core.ActiveScene.Camera.Position;

            position += cameraFacing * (model.BoundingSphere.Radius * 3);

            // Create entity
            DynamicEntity entity = new DynamicEntity(core.ActiveScene);

            entity.Matrix = Matrix.CreateRotationY(MathHelper.ToRadians(scene.Camera.Yaw)) * Matrix.CreateTranslation(position);

            // Attach geometry
            entity.Components.Add(model);

            // Attach physics
            PhysicsColliderComponent physics = new PhysicsColliderComponent(core, core.ActiveScene, entity.Matrix, model.ModelData.GetPointList(), 2f);

            //physics.PhysicsEntity.LinearVelocity = cameraFacing * 15f;
            physics.PhysicsEntity.AngularMomentum     = new Vector3(0.0001f, 10, 0.0001f);
            physics.PhysicsEntity.Material.Bounciness = 0.1f;
            entity.Components.Add(physics);

            // Set entity to expire after 5 minutes
            entity.Components.Add(new ReaperComponent(core, entity, 300000));
        }
Example #2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="document">Scene document.</param>
        /// <param name="entity">Entity owning this proxy.</param>
        /// <param name="model">Model to proxy.</param>
        public DaggerfallModelProxy(SceneDocument document, EntityProxy entity, DaggerfallModelComponent model)
            : base(document, entity)
        {
            base.name  = defaultName;
            this.model = model;

            // Add to parent entity
            base.Entity.Components.Add(model);
        }
        /// <summary>
        /// Creates a new model component proxy.
        /// </summary>
        private DaggerfallModelProxy AddModelProxy(EntityProxy parent, uint id)
        {
            // Create new model
            DaggerfallModelComponent model = new DaggerfallModelComponent(worldControl.Core, id);

            // Create proxy for component
            DaggerfallModelProxy modelProxy = new DaggerfallModelProxy(sceneDocument, parent, model);

            // Add new proxy to tree view
            TreeNode node = AddTreeNode(parent.TreeNode, modelProxy);

            return(modelProxy);
        }
        /// <summary>
        /// Fires an arrow projectile.
        /// </summary>
        private void FireArrow()
        {
            // Get arrow model
            DaggerfallModelComponent arrowModel = new DaggerfallModelComponent(core, (int)PhysicsObjects.Arrow);

            arrowModel.Matrix = Matrix.CreateScale(1.0f);

            // Get camera facing
            Vector3 cameraFacing = core.ActiveScene.Camera.TransformedReference;

            // Get start position
            Vector3 position = core.ActiveScene.Camera.Position;

            position += cameraFacing * (arrowModel.BoundingSphere.Radius * 2);

            // Create arrow entity
            DynamicEntity arrowEntity = new DynamicEntity(core.ActiveScene);

            arrowEntity.Matrix = Matrix.CreateFromYawPitchRoll(
                MathHelper.ToRadians(scene.Camera.Yaw),
                MathHelper.ToRadians(scene.Camera.Pitch),
                0) * Matrix.CreateTranslation(position);

            // Attach arrow geometry
            arrowEntity.Components.Add(arrowModel);

            // Attach arrow physics
            BoundingBox box    = arrowModel.BoundingBox;
            float       width  = box.Max.X - box.Min.X;
            float       height = box.Max.Y - box.Min.Y;
            float       depth  = box.Max.Z - box.Min.Z;
            PhysicsColliderComponent arrowPhysics = new PhysicsColliderComponent(core, core.ActiveScene, arrowEntity.Matrix, width, height, depth, 1f);

            arrowPhysics.PhysicsEntity.LinearVelocity      = cameraFacing * 30f;
            arrowPhysics.PhysicsEntity.Material.Bounciness = 0.2f;
            arrowEntity.Components.Add(arrowPhysics);

            // Set entity to expire after 2 seconds
            arrowEntity.Components.Add(new ReaperComponent(core, arrowEntity, 2000));
        }
        /// <summary>
        /// Drops a heavy anvil.
        /// </summary>
        private void FireAnvil()
        {
            // Get anvil model
            DaggerfallModelComponent anvilModel = new DaggerfallModelComponent(core, (int)PhysicsObjects.Anvil);

            anvilModel.Matrix = Matrix.CreateScale(0.04f);

            // Get camera facing
            Vector3 cameraFacing = core.ActiveScene.Camera.TransformedReference;

            // Get start position
            Vector3 position = core.ActiveScene.Camera.Position;

            position += cameraFacing * (anvilModel.BoundingSphere.Radius * 2);

            // Create anvil entity
            DynamicEntity anvilEntity = new DynamicEntity(core.ActiveScene);

            anvilEntity.Matrix = Matrix.CreateRotationY(MathHelper.ToRadians(scene.Camera.Yaw)) * Matrix.CreateTranslation(position);

            // Attach anvil geometry
            anvilEntity.Components.Add(anvilModel);

            // Attach anvil physics
            BoundingBox box    = anvilModel.BoundingBox;
            float       width  = box.Max.X - box.Min.X;
            float       height = box.Max.Y - box.Min.Y;
            float       depth  = box.Max.Z - box.Min.Z;
            PhysicsColliderComponent anvilPhysics = new PhysicsColliderComponent(core, core.ActiveScene, anvilEntity.Matrix, width, height, depth, 200f);

            anvilPhysics.PhysicsEntity.Material.Bounciness = 0.0f;
            anvilEntity.Components.Add(anvilPhysics);

            // Set entity to expire after 5 minutes
            anvilEntity.Components.Add(new ReaperComponent(core, anvilEntity, 300000));
        }