/// <summary>
        /// Read trigger specific parameters from the world parm and add them to the actor parm
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        public static new void ParseParmSet(ref ParameterSet actorParm, ref ParameterSet worldParm)
        {
            if (worldParm.HasParm("TextPosition"))
                actorParm.AddParm("TextPosition", worldParm.GetVector2("TextPosition"));

            if (worldParm.HasParm("Text"))
                actorParm.AddParm("Text", worldParm.GetString("Text"));
        }
Ejemplo n.º 2
0
        public Sun(ParameterSet parm)
        {
            if (parm.HasParm("SunColor"))
                lightColor = parm.GetVector4("SunColor");
            if (parm.HasParm("AmbientLightColor"))
                ambientLightColor = parm.GetVector4("AmbientLightColor");
            Vector2 sunAngles = Vector2.Zero;
            if (parm.HasParm("SunAngles"))
                sunAngles = parm.GetVector2("SunAngles");

            if ( shadowMap == null )
                shadowMap = new RenderTarget2D(Renderer.Instance.GraphicsDevice, SHADOW_MAP_WIDTH_HEIGHT * NUM_CASCADES, SHADOW_MAP_WIDTH_HEIGHT, false, SurfaceFormat.Single, DepthFormat.Depth24);
            SetSunDirectionFromSphericalCoords(sunAngles.X, sunAngles.Y);
        }
Ejemplo n.º 3
0
        // position and rotation come from world parm file, which we dont have access to here
        /*public PhysicsObject(PhysicsType physicsType, Model model, Vector3 position, float mass)
        {
            this.physicsType = physicsType;
            int id = idCounter++;

            if (DisableMass)
                mass = -1.0f;

            switch (physicsType)
            {
                case PhysicsType.Box:
                    spaceObject = PhysicsHelpers.ModelToPhysicsBox(model, position, mass);
                    // boxes contain a broadphase entry which is what shows up in ray casts, so we need to make sure its tag is set to the right id
                    // this will need to be done fore anything that is an ibroadphaseentryowner
                    ((IBroadPhaseEntryOwner)spaceObject).Entry.Tag = id;
                    break;
                case PhysicsType.StaticMesh:
                    spaceObject = PhysicsHelpers.ModelToStaticMesh(model, new BEPUphysics.MathExtensions.AffineTransform(position));
                    //staticmesh's are not ibroadphaseentryowners...they will turn directly on the raycast, so nothing else to set the tag on
                    break;
                case PhysicsType.None:
                    spaceObject = null;
                    this.position = position;
                    return;
            }

            spaceObject.Tag = id;
            Stage.ActiveStage.GetQB<PhysicsQB>().Space.Add(spaceObject);
        }*/
        /// <summary>
        /// Create a physics object
        /// </summary>
        /// <param name="actor">Actor that we are attached to</param>
        /// <param name="Parm">Actor's parm file</param>
        /// <param name="model">Actors model (so we can size the collider)</param>
        /// <param name="position">Position (from world parm)</param>
        /// <param name="rotation">Rotation (from world parm)</param>
        public PhysicsObject(Actor actor, ParameterSet Parm, Model model, Vector3 position, Vector3 rotation, Stage stage)
        {
            // **rotation comes in from file as ( pitch, yaw, roll )**

            this.actor = actor;
            this.physicsType = GameLib.PhysicsObject.PhysicsTypeFromString(Parm.GetString("PhysicsType"));
            this.position = position;
            this.rotation = Matrix.CreateFromYawPitchRoll(rotation.Y, rotation.X, rotation.Z);

            if (ForceStaticMesh)
                this.physicsType = PhysicsType.StaticMesh;

            switch (this.physicsType)
            {
                case PhysicsType.Box:
                    {
                        float mass;
                        if (DisableMass)
                            mass = -1.0f;
                        else
                            mass = Parm.GetFloat("Mass");
                        BEPUphysics.Entities.Entity entity = PhysicsHelpers.ModelToPhysicsBox(model, position, mass, rotation.X, rotation.Y, rotation.Z);
                        entity.CollisionInformation.OwningActor = actor;
                        spaceObject = entity;
                        break;
                    }
                case PhysicsType.StaticMesh:
                    BEPUphysics.Collidables.StaticMesh mesh = PhysicsHelpers.ModelToStaticMesh(model, new BEPUphysics.MathExtensions.AffineTransform(Quaternion.CreateFromRotationMatrix( this.rotation ), position));
                    mesh.OwningActor = actor;
                    spaceObject = mesh;
                    break;
                case PhysicsType.Character:
                    {
                        float mass = Parm.GetFloat("Mass");
                        float scaleRadius = 1.0f;
                        if (Parm.HasParm("ScaleRadius"))
                            scaleRadius = Parm.GetFloat("ScaleRadius");
                        characterController = PhysicsHelpers.ModelToCharacterController(model, position, mass, scaleRadius);
                        spaceObject = characterController.Body;
                        characterController.Body.CollisionInformation.OwningActor = actor;
                        stage.GetQB<PhysicsQB>().AddToSpace(CharacterController);
                        return;
                    }
                case PhysicsType.CylinderCharacter:
                    {
                        float mass = Parm.GetFloat("Mass");
                        float scaleRadius = 1.0f;
                        if (Parm.HasParm("ScaleRadius"))
                            scaleRadius = Parm.GetFloat("ScaleRadius");
                        if (Parm.HasParm("ColliderDims"))
                        {
                            Vector2 v = Parm.GetVector2("ColliderDims");
                            cylinderCharController = new CylinderCharacterController(position, v.Y, v.X, mass);
                        }
                        else
                            cylinderCharController = PhysicsHelpers.ModelToCylinderCharacterController(model, position, mass, scaleRadius);
                        cylinderCharController.Body.Orientation = Quaternion.CreateFromYawPitchRoll(rotation.Y, rotation.X, rotation.Z);
                        spaceObject = cylinderCharController.Body;
                        cylinderCharController.Body.CollisionInformation.OwningActor = actor;
                        stage.GetQB<PhysicsQB>().AddToSpace(cylinderCharController);
                        return;
                    }
                case PhysicsType.TriggerVolume:
                    {
                        DetectorVolume detectorVolume = new DetectorVolume(PhysicsHelpers.ModelToTriangleMesh(model, position));
                        detectorVolume.OwningActor = actor;
                        spaceObject = detectorVolume;
                        detectorVolume.EntityBeganTouching += new EntityBeginsTouchingVolumeEventHandler(detectorVolume_EntityBeganTouching);
                        detectorVolume.EntityStoppedTouching += new EntityStopsTouchingVolumeEventHandler(detectorVolume_EntityStoppedTouching);
                        break;
                    }
                case PhysicsType.None:
                    spaceObject = null;
                    this.position = position;
                    this.rotation = Matrix.CreateFromYawPitchRoll(rotation.Y, rotation.X, rotation.Z);
                    return;
            }

            stage.GetQB<PhysicsQB>().AddToSpace(spaceObject);
        }