コード例 #1
0
ファイル: StepManager.cs プロジェクト: thormme/Chimera
        float upStepMargin = 0.1f; //There's a little extra space above the maximum step height to start the obstruction and downcast test rays.  Helps when a step is very close to the max step height.

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Constructs a new step manager for a character.
        /// </summary>
        /// <param name="character">Character governed by the manager.</param>
        public StepManager(CharacterController character)
        {
            this.character = character;
            //The minimum step height is just barely above where the character would generally find the ground.
            //This helps avoid excess tests.
            minimumUpStepHeight = CollisionDetectionSettings.AllowedPenetration * 1.1f;// Math.Max(0, -.01f + character.Body.CollisionInformation.Shape.CollisionMargin * (1 - character.SupportFinder.sinMaximumSlope));
        }
コード例 #2
0
ファイル: StanceManager.cs プロジェクト: thormme/Chimera
 /// <summary>
 /// Constructs a stance manager for a character.
 /// </summary>
 /// <param name="character">Character governed by the manager.</param>
 /// <param name="crouchingHeight">Crouching height of the character.</param>
 public StanceManager(CharacterController character, float crouchingHeight)
 {
     this.character = character;
     standingHeight = character.Body.Height;
     //if (crouchingHeight < standingHeight)
         //this.crouchingHeight = StandingHeight * .7f;
     //else
         //throw new Exception("Crouching height must be less than standing height.");
 }
コード例 #3
0
ファイル: QueryManager.cs プロジェクト: thormme/Chimera
        /// <summary>
        /// Constructs the query manager for a character.
        /// </summary>
        /// <param name="character">Character to manage queries for.</param>
        public QueryManager(CharacterController character)
        {
            this.character = character;
            //We can share the real shape with the 'current' query object.
            currentQueryObject = new ConvexCollidable<CylinderShape>(character.Body.CollisionInformation.Shape);
            standingQueryObject = new ConvexCollidable<CylinderShape>(new CylinderShape(character.StanceManager.StandingHeight, character.Body.Radius));
            crouchingQueryObject = new ConvexCollidable<CylinderShape>(new CylinderShape(character.StanceManager.CrouchingHeight, character.Body.Radius));
            //Share the collision rules between the main body and its query objects.  That way, the character's queries return valid results.
            currentQueryObject.CollisionRules = character.Body.CollisionInformation.CollisionRules;
            standingQueryObject.CollisionRules = character.Body.CollisionInformation.CollisionRules;
            crouchingQueryObject.CollisionRules = character.Body.CollisionInformation.CollisionRules;

            SupportRayFilter = SupportRayFilterFunction;
        }
コード例 #4
0
 /// <summary>
 /// Constructs a new horizontal motion constraint.
 /// </summary>
 /// <param name="characterController">Character to be governed by this constraint.</param>
 public HorizontalMotionConstraint(CharacterController characterController)
 {
     this.character = characterController;
     CollectInvolvedEntities();
 }
コード例 #5
0
ファイル: Creature.cs プロジェクト: thormme/Chimera
        /// <summary>
        /// Construct a new Creature.
        /// </summary>
        /// <param name="position">The position of the Creature.</param>
        /// <param name="height">The height of the collision object.</param>
        /// <param name="radius">The radius of the collision object.</param>
        /// <param name="mass">The mass of the Creature.</param>
        /// <param name="renderable">The Creaure's renderable.</param>
        /// <param name="visionSensor">A sensor defining the Creature's field of view.</param>
        /// <param name="controller">The controller for this Creature, its brain.</param>
        /// <param name="numParts">The number of parts this Creature supports.</param>
        public Creature(Vector3 position, float height, float radius, float mass, Renderable renderable, VisionSensor visionSensor, Controller controller, int numParts)
            : base(renderable, new Cylinder(position, height, radius, mass))
        {
            mHeight = height;

            Sensor = visionSensor;
            CollisionRules.AddRule(Entity, Sensor.Entity, CollisionRule.NoBroadPhase);
            Forward = new Vector3(0.0f, 0.0f, -1.0f);
            mPartAttachments = new List<PartAttachment>(numParts);
            for (int i = 0; i < numParts; ++i)
            {
                mPartAttachments.Add(null);
            }

            mUnusedPartBones = GetUsablePartBones();

            CharacterController = new CharacterController(Entity, 1.0f);
            SlideSlope = CharacterController.SupportFinder.MaximumSlope;

            Controller = controller;
            controller.SetCreature(this);

            mBoneIndex = 0;

            //mTrailParticles = new ParticleSystem("puff", Position);
        }
コード例 #6
0
 /// <summary>
 /// Constructs a new vertical motion constraint.
 /// </summary>
 /// <param name="characterController">Character governed by the constraint.</param>
 public VerticalMotionConstraint(CharacterController characterController)
 {
     this.character = characterController;
 }