Example #1
0
        public void RecalculateCollision()
        {
            Vector3    pos    = Position;
            Quaternion orient = Orientation;

            Node.DetachAllObjects();
            Engine.Singleton.SceneManager.DestroySceneNode(Node);
            Engine.Singleton.SceneManager.DestroyEntity(Entity);
            Body.Dispose();
            Body = null;

            Entity = Engine.Singleton.SceneManager.CreateEntity(Profile.MeshName);
            Node   = Engine.Singleton.SceneManager.RootSceneNode.CreateChildSceneNode();
            Node.AttachObject(Entity);

            ConvexCollision collision = new MogreNewt.CollisionPrimitives.ConvexHull(Engine.Singleton.NewtonWorld,
                                                                                     Node,
                                                                                     Quaternion.IDENTITY,
                                                                                     0.1f,
                                                                                     Engine.Singleton.GetUniqueBodyId());

            Vector3 inertia, offset;

            collision.CalculateInertialMatrix(out inertia, out offset);

            inertia *= Profile.BodyMass;

            Body = new Body(Engine.Singleton.NewtonWorld, collision, true);
            Body.AttachNode(Node);
            Body.SetMassMatrix(Profile.BodyMass, inertia);
            Body.AutoSleep = false;

            Body.Transformed    += BodyTransformCallback;
            Body.ForceCallback  += BodyForceCallback;
            Orientation          = orient;
            Position             = pos;
            Body.UserData        = this;
            Body.MaterialGroupID = Engine.Singleton.MaterialManager.EnemyMaterialID;

            Joint upVector = new MogreNewt.BasicJoints.UpVector(
                Engine.Singleton.NewtonWorld, Body, Vector3.UNIT_Y);

            collision.Dispose();
        }
Example #2
0
        public Character(CharacterProfile profile)
        {
            m_Profile = profile.Clone();

            m_Orientation = Quaternion.IDENTITY;

            m_Entity = Core.Singleton.m_SceneManager.CreateEntity(m_Profile.m_MeshName);
            m_Node = Core.Singleton.m_SceneManager.RootSceneNode.CreateChildSceneNode();
            m_Node.AttachObject(m_Entity);

            Vector3 scaledSize = m_Entity.BoundingBox.HalfSize * m_Profile.m_BodyScaleFactor;

            ConvexCollision collision = new MogreNewt.CollisionPrimitives.Capsule(
                Core.Singleton.m_NewtonWorld,
                System.Math.Min(scaledSize.x, scaledSize.z),
                scaledSize.y * 2,
                Vector3.UNIT_X.GetRotationTo(Vector3.UNIT_Y),
                Core.Singleton.GetUniqueBodyId());

            Vector3 inertia, offset;
            collision.CalculateInertialMatrix(out inertia, out offset);
            inertia *= m_Profile.m_BodyMass;

            m_Body = new Body(Core.Singleton.m_NewtonWorld, collision, true);
            m_Body.AttachNode(m_Node);
            m_Body.SetMassMatrix(m_Profile.m_BodyMass, inertia);
            m_Body.AutoSleep = false;

            m_Body.Transformed += BodyTransformCallback;
            m_Body.ForceCallback += BodyForceCallback;

            Joint upVector = new MogreNewt.BasicJoints.UpVector(
            Core.Singleton.m_NewtonWorld, m_Body, Vector3.UNIT_Y);

            collision.Dispose();
        }
Example #3
0
        public Enemy(CharacterProfile profile, bool czyPojemnik, float zasiegWzr, float zasiegOgl)
        {
            Profile = profile.Clone();

            _Orientation = Quaternion.IDENTITY;

            Entity = Engine.Singleton.SceneManager.CreateEntity(Profile.MeshName);
            Node = Engine.Singleton.SceneManager.RootSceneNode.CreateChildSceneNode();
            Node.AttachObject(Entity);

            Vector3 scaledSize = Entity.BoundingBox.HalfSize * Profile.BodyScaleFactor;

            ConvexCollision collision = new MogreNewt.CollisionPrimitives.ConvexHull(Engine.Singleton.NewtonWorld,
                Node,
                Quaternion.IDENTITY,
                0.1f,
                Engine.Singleton.GetUniqueBodyId());

            Vector3 inertia, offset;
            collision.CalculateInertialMatrix(out inertia, out offset);

            inertia *= Profile.BodyMass;

            Body = new Body(Engine.Singleton.NewtonWorld, collision, true);
            Body.AttachNode(Node);
            Body.SetMassMatrix(Profile.BodyMass, inertia);
            Body.AutoSleep = false;

            Body.Transformed += BodyTransformCallback;
            Body.ForceCallback += BodyForceCallback;

            Body.UserData = this;
            Body.MaterialGroupID = Engine.Singleton.MaterialManager.EnemyMaterialID;

            Joint upVector = new MogreNewt.BasicJoints.UpVector(
            Engine.Singleton.NewtonWorld, Body, Vector3.UNIT_Y);

            collision.Dispose();

            isContainer = czyPojemnik;
            isSeen = false;
            isReachable = false;
            _ZasiegWzroku = zasiegWzr;
            _ZasiegOgolny = zasiegOgl;
            _Statistics = Profile.Statistics.statistics_Clone();
            State = StateTypes.IDLE;

            //DROPPRIZE KUFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

            if (Profile.DropPrizeID == "")
                Profile.DropPrizeID = "pPusty";

            DropPrize = PrizeManager.P[Profile.DropPrizeID].prize_Clone();
            List<DescribedProfile> lista_tym = new List<DescribedProfile>();
            List<DescribedProfile> lista_tym2 = new List<DescribedProfile>(DropPrize.ItemsList);

            if (DropPrize.ItemsList.Count > 2)
            {
                for (int i = 0; i < 2; i++)
                {
                    int Los = Engine.Singleton.Random.Next(lista_tym2.Count);
                    lista_tym.Add(lista_tym2[Los]);
                    lista_tym2.RemoveAt(Los);
                    DropPrize.ItemsList = new List<DescribedProfile>(lista_tym);
                }
            }

            else
                DropPrize.ItemsList = new List<DescribedProfile>(DropPrize.ItemsList);

            DropPrize.AmountGold = Engine.Singleton.Random.Next(DropPrize.AmountGold / 2, DropPrize.AmountGold + 1);
            DropExp = DropPrize.AmountExp;

            //PO DROPPRIZIE KUFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

            walkAnim = Entity.GetAnimationState("WALK");
            idleAnim = Entity.GetAnimationState("IDLE");
            attackAnim = Entity.GetAnimationState("ATTACK");
            deadAnim = Entity.GetAnimationState("DEAD");

            //Animation("IdleLegs").Enabled = true;
            //Animation("IdleLegs").Loop = true;
            FriendlyType = Profile.FriendlyType;
            ProfName = Profile.ProfileName;
        }
Example #4
0
        public void RecalculateCollision()
        {
            Vector3 pos = Position;
            Quaternion orient = Orientation;
            Node.DetachAllObjects();
            Engine.Singleton.SceneManager.DestroySceneNode(Node);
            Engine.Singleton.SceneManager.DestroyEntity(Entity);
            Body.Dispose();
            Body = null;

            Entity = Engine.Singleton.SceneManager.CreateEntity(Profile.MeshName);
            Node = Engine.Singleton.SceneManager.RootSceneNode.CreateChildSceneNode();
            Node.AttachObject(Entity);

            ConvexCollision collision = new MogreNewt.CollisionPrimitives.ConvexHull(Engine.Singleton.NewtonWorld,
                Node,
                Quaternion.IDENTITY,
                0.1f,
                Engine.Singleton.GetUniqueBodyId());

            Vector3 inertia, offset;
            collision.CalculateInertialMatrix(out inertia, out offset);

            inertia *= Profile.BodyMass;

            Body = new Body(Engine.Singleton.NewtonWorld, collision, true);
            Body.AttachNode(Node);
            Body.SetMassMatrix(Profile.BodyMass, inertia);
            Body.AutoSleep = false;

            Body.Transformed += BodyTransformCallback;
            Body.ForceCallback += BodyForceCallback;
            Orientation = orient;
            Position = pos;
            Body.UserData = this;
            Body.MaterialGroupID = Engine.Singleton.MaterialManager.EnemyMaterialID;

            Joint upVector = new MogreNewt.BasicJoints.UpVector(
            Engine.Singleton.NewtonWorld, Body, Vector3.UNIT_Y);

            collision.Dispose();
        }
Example #5
0
        public Character(CharacterProfile profile)
        {
            Profile = profile.Clone();

            _Orientation = Quaternion.IDENTITY;

            Entity = Engine.Singleton.SceneManager.CreateEntity(Profile.MeshName);
            Node   = Engine.Singleton.SceneManager.RootSceneNode.CreateChildSceneNode();
            Node.AttachObject(Entity);

            Vector3 scaledSize = Entity.BoundingBox.HalfSize * Profile.BodyScaleFactor;

            ConvexCollision collision = new MogreNewt.CollisionPrimitives.Capsule(
                Engine.Singleton.NewtonWorld,
                System.Math.Min(scaledSize.x, scaledSize.z),
                scaledSize.y * 2,
                Vector3.UNIT_X.GetRotationTo(Vector3.UNIT_Y),
                Engine.Singleton.GetUniqueBodyId());



            Vector3 inertia, offset;

            collision.CalculateInertialMatrix(out inertia, out offset);

            inertia *= Profile.BodyMass;

            Body = new Body(Engine.Singleton.NewtonWorld, collision, true);
            Body.AttachNode(Node);
            Body.SetMassMatrix(Profile.BodyMass, inertia);
            Body.AutoSleep = false;

            Body.Transformed   += BodyTransformCallback;
            Body.ForceCallback += BodyForceCallback;

            Body.UserData        = this;
            Body.MaterialGroupID = Engine.Singleton.MaterialManager.CharacterMaterialID;

            Joint upVector = new MogreNewt.BasicJoints.UpVector(
                Engine.Singleton.NewtonWorld, Body, Vector3.UNIT_Y);

            collision.Dispose();

            SensorNode = Node.CreateChildSceneNode(new Vector3(0, 0, System.Math.Min(scaledSize.x, scaledSize.z) * 1.5f));

            collision = new MogreNewt.CollisionPrimitives.Cylinder(
                Engine.Singleton.NewtonWorld,
                System.Math.Min(scaledSize.x, scaledSize.z) * 1.5f,
                scaledSize.y * 1,
                Vector3.UNIT_X.GetRotationTo(Vector3.UNIT_Y),
                Engine.Singleton.GetUniqueBodyId());
            ObjectSensor = new Body(Engine.Singleton.NewtonWorld, collision, true);
            ObjectSensor.SetMassMatrix(1, new Vector3(1, 1, 1));

            ObjectSensor.UserData        = this;
            ObjectSensor.MaterialGroupID = Engine.Singleton.MaterialManager.CharacterSensorMaterialID;

            Contacts = new List <GameObject>();

            Inventory = new List <DescribedProfile>();
            Inventory = Profile.Inventory;

            AnimBlender = new CharacterAnimBlender();
            AnimBlender.SetEntity(Entity);

            ActiveQuests = new QuestManager();

            _Statistics = Profile.Statistics.statistics_Clone();

            FriendlyType = Profile.FriendlyType;

            State = Enemy.StateTypes.IDLE;

            DropExp  = 0;
            ProfName = Profile.ProfileName;

            if (Profile.DialogRoot != null && Profile.DialogRoot != "")
            {
                TalkRoot = Conversations.D[Profile.DialogRoot].Reactions.Values.ElementAt(0);
            }

            Activities = new ActivityManager();
            Waiting    = false;
        }
Example #6
0
        public Enemy(CharacterProfile profile, bool czyPojemnik, float zasiegWzr, float zasiegOgl)
        {
            Profile = profile.Clone();

            _Orientation = Quaternion.IDENTITY;

            Entity = Engine.Singleton.SceneManager.CreateEntity(Profile.MeshName);
            Node   = Engine.Singleton.SceneManager.RootSceneNode.CreateChildSceneNode();
            Node.AttachObject(Entity);

            Vector3 scaledSize = Entity.BoundingBox.HalfSize * Profile.BodyScaleFactor;

            ConvexCollision collision = new MogreNewt.CollisionPrimitives.ConvexHull(Engine.Singleton.NewtonWorld,
                                                                                     Node,
                                                                                     Quaternion.IDENTITY,
                                                                                     0.1f,
                                                                                     Engine.Singleton.GetUniqueBodyId());

            Vector3 inertia, offset;

            collision.CalculateInertialMatrix(out inertia, out offset);

            inertia *= Profile.BodyMass;

            Body = new Body(Engine.Singleton.NewtonWorld, collision, true);
            Body.AttachNode(Node);
            Body.SetMassMatrix(Profile.BodyMass, inertia);
            Body.AutoSleep = false;

            Body.Transformed   += BodyTransformCallback;
            Body.ForceCallback += BodyForceCallback;

            Body.UserData        = this;
            Body.MaterialGroupID = Engine.Singleton.MaterialManager.EnemyMaterialID;

            Joint upVector = new MogreNewt.BasicJoints.UpVector(
                Engine.Singleton.NewtonWorld, Body, Vector3.UNIT_Y);

            collision.Dispose();

            isContainer   = czyPojemnik;
            isSeen        = false;
            isReachable   = false;
            _ZasiegWzroku = zasiegWzr;
            _ZasiegOgolny = zasiegOgl;
            _Statistics   = Profile.Statistics.statistics_Clone();
            State         = StateTypes.IDLE;

            //DROPPRIZE KUFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

            if (Profile.DropPrizeID == "")
            {
                Profile.DropPrizeID = "pPusty";
            }

            DropPrize = PrizeManager.P[Profile.DropPrizeID].prize_Clone();
            List <DescribedProfile> lista_tym  = new List <DescribedProfile>();
            List <DescribedProfile> lista_tym2 = new List <DescribedProfile>(DropPrize.ItemsList);

            if (DropPrize.ItemsList.Count > 2)
            {
                for (int i = 0; i < 2; i++)
                {
                    int Los = Engine.Singleton.Random.Next(lista_tym2.Count);
                    lista_tym.Add(lista_tym2[Los]);
                    lista_tym2.RemoveAt(Los);
                    DropPrize.ItemsList = new List <DescribedProfile>(lista_tym);
                }
            }

            else
            {
                DropPrize.ItemsList = new List <DescribedProfile>(DropPrize.ItemsList);
            }

            DropPrize.AmountGold = Engine.Singleton.Random.Next(DropPrize.AmountGold / 2, DropPrize.AmountGold + 1);
            DropExp = DropPrize.AmountExp;

            //PO DROPPRIZIE KUFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

            walkAnim   = Entity.GetAnimationState("WALK");
            idleAnim   = Entity.GetAnimationState("IDLE");
            attackAnim = Entity.GetAnimationState("ATTACK");
            deadAnim   = Entity.GetAnimationState("DEAD");

            //Animation("IdleLegs").Enabled = true;
            //Animation("IdleLegs").Loop = true;
            FriendlyType = Profile.FriendlyType;
            ProfName     = Profile.ProfileName;
        }
Example #7
0
        public PlayerController(Mogre.Node node, Mogre.Entity entity, float mass)
        {
            //init logic states for controler
            initLogicStates();
            //force direction
            m_GoTo = Mogre.Quaternion.IDENTITY;
            //node to update
            m_PlayerNode = node;
            //Ball
            MogreNewt.ConvexCollision collision = new MogreNewt.CollisionPrimitives.Ellipsoid(
                    Core.Singleton.NewtonWorld,
                    new Mogre.Vector3(0.25f, 0.25f, 0.25f),
                    new Mogre.Quaternion(new Mogre.Radian(1.57f), new Mogre.Vector3(0, 1, 0)),
                    Core.Singleton.GetUniqueBodyId());
            Mogre.Vector3 inertia, offset;

            collision.CalculateInertialMatrix(out inertia, out offset);
            inertia *= mass;//mass

            m_MainBody = new MogreNewt.Body(Core.Singleton.NewtonWorld, collision, true);
            m_MainBody.SetMassMatrix(mass, inertia);
            m_MainBody.AutoSleep = false;

            m_MainBody.LinearDamping = 1.0f;
            m_MainBody.Transformed += BodyTransformCallback;
            m_MainBody.ForceCallback += BodyForceCallback;
            m_MainBody.UserData = this;
            m_MainBody.Type = (int)PhysicsManager.BodyTypes.PLAYER;

            collision.Dispose();

            m_MainBody.MaterialGroupID = Core.Singleton.PhysicsManager.getMaterialID("Player");
            //Ball end

            m_Pose = m_myPoses["normal"];
            ///Second helper body
            Mogre.Vector3 inertia2, offset2;

            m_Pose.m_collision.CalculateInertialMatrix(out inertia2, out offset2);
            inertia2 *= 1;
            m_SecondBody = new MogreNewt.Body(Core.Singleton.NewtonWorld, m_Pose.m_collision, true);
            m_SecondBody.SetMassMatrix(1, inertia2);
            m_SecondBody.AutoSleep = false;
            m_SecondBody.IsGravityEnabled = false;
            m_SecondBody.SetPositionOrientation(new Mogre.Vector3(0, 1f, 0), Mogre.Quaternion.IDENTITY);
            m_SecondBody.MaterialGroupID = Core.Singleton.PhysicsManager.getMaterialID("Player");
            m_SecondBody.UserData = null;

            //set Y joint for second body
            MogreNewt.Joint upVector = new MogreNewt.BasicJoints.UpVector(
            Core.Singleton.NewtonWorld, m_SecondBody, Mogre.Vector3.UNIT_Y);

            //connections between player bodies!
            player_join = new MogreNewt.BasicJoints.BallAndSocket(Core.Singleton.NewtonWorld, m_MainBody, m_SecondBody, new Mogre.Vector3(0, 0, 0));
        }