Пример #1
0
 /// <summary>
 /// Creates a detector volume.
 /// </summary>
 /// <param name="triangleMesh">Arbitrary closed triangle mesh representing the volume.</param>
 /// <param name="queryAccelerator">System used to find nearby objects.</param>
 public DetectorVolume(MeshBoundingBoxTreeData triangleMesh, IQueryAccelerator queryAccelerator)
 {
     TriangleMesh = new TriangleMesh(triangleMesh);
     QueryAccelerator = queryAccelerator;
     collisionRules = new CollisionRules()
     {
          group = new CollisionGroup()
     };
 }
Пример #2
0
 /// <summary>
 /// Creates a detector volume.
 /// </summary>
 /// <param name="triangleMesh">Arbitrary closed triangle mesh representing the volume.</param>
 /// <param name="queryAccelerator">System used to find nearby objects.</param>
 public DetectorVolume(MeshBoundingBoxTreeData triangleMesh, IQueryAccelerator queryAccelerator)
 {
     TriangleMesh     = new TriangleMesh(triangleMesh);
     QueryAccelerator = queryAccelerator;
     collisionRules   = new CollisionRules()
     {
         group = new CollisionGroup()
     };
 }
Пример #3
0
        /// <summary>
        /// Creates a fluid volume.
        /// </summary>
        /// <param name="upVector">Up vector of the fluid volume.</param>
        /// <param name="gravity">Strength of gravity for the purposes of the fluid volume.</param>
        /// <param name="surfaceTriangles">List of triangles composing the surface of the fluid.  Set up as a list of length 3 arrays of Vector3's.</param>
        /// <param name="depth">Depth of the fluid back along the surface normal.</param>
        /// <param name="fluidDensity">Density of the fluid represented in the volume.</param>
        /// <param name="linearDamping">Fraction by which to reduce the linear momentum of floating objects each update, in addition to any of the body's own damping.</param>
        /// <param name="angularDamping">Fraction by which to reduce the angular momentum of floating objects each update, in addition to any of the body's own damping.</param>
        /// <param name="queryAccelerator">System to accelerate queries to find nearby entities.</param>
        /// <param name="threadManager">Thread manager used by the fluid volume.</param>
        public FluidVolume(Vector3 upVector, float gravity, List <Vector3[]> surfaceTriangles, float depth, float fluidDensity, float linearDamping, float angularDamping,
                           IQueryAccelerator queryAccelerator, IThreadManager threadManager)
        {
            Gravity          = gravity;
            SurfaceTriangles = surfaceTriangles;
            MaxDepth         = depth;
            Density          = fluidDensity;
            LinearDamping    = linearDamping;
            AngularDamping   = angularDamping;

            UpVector         = upVector;
            QueryAccelerator = queryAccelerator;
            ThreadManager    = threadManager;

            analyzeCollisionEntryDelegate = AnalyzeCollisionEntry;
        }
Пример #4
0
        /// <summary>
        /// Creates a fluid volume.
        /// </summary>
        /// <param name="upVector">Up vector of the fluid volume.</param>
        /// <param name="gravity">Strength of gravity for the purposes of the fluid volume.</param>
        /// <param name="surfaceTriangles">List of triangles composing the surface of the fluid.  Set up as a list of length 3 arrays of Vector3's.</param>
        /// <param name="depth">Depth of the fluid back along the surface normal.</param>
        /// <param name="fluidDensity">Density of the fluid represented in the volume.</param>
        /// <param name="linearDamping">Fraction by which to reduce the linear momentum of floating objects each update, in addition to any of the body's own damping.</param>
        /// <param name="angularDamping">Fraction by which to reduce the angular momentum of floating objects each update, in addition to any of the body's own damping.</param>
        /// <param name="queryAccelerator">System to accelerate queries to find nearby entities.</param>
        /// <param name="threadManager">Thread manager used by the fluid volume.</param>
        public CustomFluidVolume(Vector3 upVector, float gravity, List<Vector3[]> surfaceTriangles, float depth, float fluidDensity, float linearDamping, float angularDamping,
			IQueryAccelerator queryAccelerator, IThreadManager threadManager)
        {
            Gravity = gravity;
            SurfaceTriangles = surfaceTriangles;
            MaxDepth = depth;
            Density = fluidDensity;
            LinearDamping = linearDamping;
            AngularDamping = angularDamping;

            UpVector = upVector;
            QueryAccelerator = queryAccelerator;
            ThreadManager = threadManager;

            analyzeCollisionEntryDelegate = AnalyzeCollisionEntry;
        }
Пример #5
0
 /// <summary>
 /// Creates a simple, constant force field.
 /// </summary>
 /// <param name="shape">Shape representing the tornado-affected volume.</param>
 /// <param name="position">Position of the tornado.</param>
 /// <param name="axis">Axis of rotation of the tornado.</param>
 /// <param name="height">Height of the tornado; objects above or below the tornado will not be affected by its winds.</param>
 /// <param name="spinClockwise">Whether or not the tornado's rotation is clockwise.</param>
 /// <param name="horizontalWindSpeed">Maximum tangential wind speed; objects will not be accelerated by the wind past this speed sideways.</param>
 /// <param name="upwardSuctionSpeed">Maximum upward pushing wind speed; objects will not be accelerated by the wind past this speed upward.</param>
 /// <param name="inwardSuctionSpeed">Maximum inward sucking wind speed; objects will not be accelerated by the wind past this speed inward.</param>
 /// <param name="horizontalForce">Circular force applied within the tornado.  Force magnitude decreases as distance from axis increases past the radius.</param>
 /// <param name="upwardForce">Magnitude of upward-pushing force within the tornado.  Magnitude decreases as distance from the axis increases past the radius.</param>
 /// <param name="inwardForce">Magnitude of the inward-sucking force within the tornado.  Magnitude decreases as distance from the axis increases past the radius.</param>
 /// <param name="topRadius">Radius of the tornado at the top.</param>
 /// <param name="bottomRadius">Radius of the tornado at the bottom.</param>
 public Tornado(ForceFieldShape shape, Vector3 position, Vector3 axis,
                float height, bool spinClockwise, float horizontalWindSpeed,
                float upwardSuctionSpeed, float inwardSuctionSpeed,
                float horizontalForce, float upwardForce, float inwardForce,
                float topRadius, float bottomRadius, IQueryAccelerator accelerator)
     : base(shape, accelerator)
 {
     Axis                = Vector3.Normalize(axis);
     Position            = position;
     Height              = height;
     SpinClockwise       = spinClockwise;
     HorizontalWindSpeed = horizontalWindSpeed;
     UpwardSuctionSpeed  = upwardSuctionSpeed;
     InwardSuctionSpeed  = inwardSuctionSpeed;
     HorizontalForce     = horizontalForce;
     UpwardForce         = upwardForce;
     InwardForce         = inwardForce;
     BottomRadius        = bottomRadius;
     TopRadius           = topRadius;
 }
Пример #6
0
 public override void OnRemovalFromSpace(Space oldSpace)
 {
     base.OnRemovalFromSpace(oldSpace);
     ParallelLooper = null;
     QueryAccelerator = null;
 }
Пример #7
0
 public override void OnAdditionToSpace(Space newSpace)
 {
     base.OnAdditionToSpace(newSpace);
     ParallelLooper = newSpace.ParallelLooper;
     QueryAccelerator = newSpace.BroadPhase.QueryAccelerator;
 }
Пример #8
0
 protected ForceField(ForceFieldShape shape, IQueryAccelerator queryAccelerator, IThreadManager threadManager)
     : this(shape, queryAccelerator)
 {
     ThreadManager       = threadManager;
     AllowMultithreading = true;
 }
Пример #9
0
 /// <summary>
 /// Constructs a force field.
 /// </summary>
 /// <param name="shape">Shape to use for the force field.</param>
 /// <param name="queryAccelerator">Query accelerator used to find entities.</param>
 protected ForceField(ForceFieldShape shape, IQueryAccelerator queryAccelerator)
 {
     Shape            = shape;
     QueryAccelerator = queryAccelerator;
     subfunction      = new Action <int>(CalculateImpulsesSubfunction);
 }
Пример #10
0
 protected ForceField(ForceFieldShape shape, IQueryAccelerator queryAccelerator, IThreadManager threadManager)
     : this(shape, queryAccelerator)
 {
     ThreadManager = threadManager;
     AllowMultithreading = true;
 }
Пример #11
0
 /// <summary>
 /// Constructs a force field.
 /// </summary>
 /// <param name="shape">Shape to use for the force field.</param>
 /// <param name="queryAccelerator">Query accelerator used to find entities.</param>
 protected ForceField(ForceFieldShape shape, IQueryAccelerator queryAccelerator)
 {
     Shape = shape;
     QueryAccelerator = queryAccelerator;
     subfunction = new Action<int>(CalculateImpulsesSubfunction);
 }
Пример #12
0
 /// <summary>
 /// Creates a detector volume.
 /// </summary>
 /// <param name="triangleMesh">Arbitrary closed triangle mesh representing the volume.</param>
 /// <param name="queryAccelerator">System used to find nearby objects.</param>
 public DetectorVolume(MeshBoundingBoxTreeData triangleMesh, IQueryAccelerator queryAccelerator)
 {
     TriangleMesh     = new TriangleMesh(triangleMesh);
     QueryAccelerator = queryAccelerator;
 }
Пример #13
0
 /// <summary>
 /// Creates a gravitational field.
 /// </summary>
 /// <param name="shape">Shape representing the volume of the force field.</param>
 /// <param name="origin">Location that entities will be pushed toward.</param>
 /// <param name="multiplier">Represents the gravitational constant of the field times the effective mass at the center of the field.</param>
 /// <param name="maxAcceleration">Maximum acceleration the field can apply.</param>
 public GravitationalField(ForceFieldShape shape, Vector3 origin, float multiplier, float maxAcceleration, IQueryAccelerator accelerator)
     : base(shape, accelerator)
 {
     this.Multiplier      = multiplier;
     this.Origin          = origin;
     this.MaxAcceleration = maxAcceleration;
 }
Пример #14
0
 /// <summary>
 /// Creates a simple, constant force field.
 /// </summary>
 /// <param name="shape">Shape representing the volume of the force field.</param>
 /// <param name="forceToApply">Force to apply to entities within the field.  Magnitude of the vector represents the magnitude of the force.</param>
 /// <param name="maxPushSpeed">Maximum speed that the field will accelerate objects to, regardless of force applied. Set to a non-positive for infinite.</param>
 public PushField(ForceFieldShape shape, Vector3 forceToApply, float maxPushSpeed, IQueryAccelerator accelerator)
     : base(shape, accelerator)
 {
     Force            = forceToApply;
     MaximumPushSpeed = maxPushSpeed;
 }