Exemplo n.º 1
0
        /// <summary>
        /// Checks if owner team has enough of the materials. If team has enough, so the game action
        /// creates new object and send it to a position (Vector3(100, 0, 100) + gameObject.Position) and returns
        /// text that the creation was successful. Else returns text that the creation failed.
        /// </summary>
        /// <returns>Returns text about the creation.</returns>
        public string OnMouseClick()
        {
            if (gameObject.Team.CheckMaterials(neededMaterials))
            {
                // Removes team material
                gameObject.Team.UseMaterials(neededMaterials);

                // Creates arguments of the creation
                var args = new List <object>();
                args.Add(Game.IGameObjectCreator.GetUnusedName("Wolen"));
                args.Add(gameObject.Team);

                string objectPosToString = gameObject.Position.x.ToString() + ';' + gameObject.Position.z.ToString();
                args.Add(new object[] { objectPosToString });

                var solSyst = Game.SolarSystemManager.GetSolarSystem(gameObject);

                // Creates new object.
                var createdGameObject = Game.IGameObjectCreator.CreateImgo(creatingObject, args.ToArray(), solSyst);

                // Sends new object to its position.
                var position = new Mogre.Vector3(100, 0, 100) + gameObject.Position;
                Game.IMoveManager.GoToLocation(createdGameObject, position);
                gameObject.Team.AddIMGO(createdGameObject);

                return(creatingObject + " created.");
            }
            else
            {
                return(creatingObject + " cannot be created, you don't have enough materials.");
            }
        }
Exemplo n.º 2
0
        /** Returns a list with positions
         */
        public Mogre.Vector3[] GetTextureCoords()
        {
            try
            {
                int bufSize = PositionEmitter_GetPositionsCount(nativePtr);
                if (bufSize == 0)
                {
                    return(null);
                }
                IntPtr[]        floats   = new IntPtr[bufSize];
                Mogre.Vector3[] toReturn = new Mogre.Vector3[bufSize];

                PositionEmitter_GetPositionsCoords(nativePtr, floats, bufSize);

                for (int i = 0; i < floats.Length; i++)
                {
                    IntPtr        scalePtr = floats[i];
                    Type          type     = typeof(Mogre.Vector3);
                    Mogre.Vector3 retVal   = (Mogre.Vector3)(Marshal.PtrToStructure(scalePtr, type));

                    toReturn[i] = retVal;
                }
                return(toReturn);
            }
            catch (Exception e) { Console.WriteLine(e.Message + "@" + e.Source); }
            return(null);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Sends object to the given position.
        /// </summary>
        /// <param name="imgo">The moving game object.</param>
        /// <param name="to">The point of the moving.</param>
        public void GoToLocation(IMovableGameObject imgo, Mogre.Vector3 to)
        {
            var a = new LinkedList <Mogre.Vector3>();

            a.AddLast(to);
            imgo.SetNextLocation(a);
        }
Exemplo n.º 4
0
        public override void ProcessParameters(Mogre.NameValuePairList parameters)
        {
            Mogre.NameValuePairList.Iterator ni;

            if ((ni = parameters.Find("Name")) != parameters.End())
            {
                this.name = ni.Value;
            }

            if ((ni = parameters.Find("Position")) != parameters.End())
            {
                this.position = Mogre.StringConverter.ParseVector3(ni.Value);
            }

            if ((ni = parameters.Find("Orientation")) != parameters.End())
            {
                this.orientation = Mogre.StringConverter.ParseQuaternion(ni.Value);
            }

            if ((ni = parameters.Find("ClipDistance")) != parameters.End())
            {
                this.clipDistance = MogreX.StringConverter.ParseVector2(ni.Value);
            }

            if ((ni = parameters.Find("FOV")) != parameters.End())
            {
                this.fov = Mogre.StringConverter.ParseReal(ni.Value);
            }
        }
Exemplo n.º 5
0
        public override void ProcessParameters(Mogre.NameValuePairList parameters)
        {
            Mogre.NameValuePairList.Iterator ni;

            if ((ni = parameters.Find("Name")) != parameters.End())
            {
                this.name = ni.Value;
            }

            if ((ni = parameters.Find("Position")) != parameters.End())
            {
                this.position = Mogre.StringConverter.ParseVector3(ni.Value);
            }

            if ((ni = parameters.Find("Orientation")) != parameters.End())
            {
                this.orientation = Mogre.StringConverter.ParseQuaternion(ni.Value);
            }

            if ((ni = parameters.Find("Scale")) != parameters.End())
            {
                this.scale = Mogre.StringConverter.ParseVector3(ni.Value);
            }

            if ((ni = parameters.Find("AutoTrackTarget")) != parameters.End())
            {
                this.autoTrackTarget = ni.Value;
            }
        }
Exemplo n.º 6
0
        void MogitorsRoot.IDragDropHandler.OnDragWheel(DragData dragData, Mogre.Viewport vp, float delta)
        {
            if (dragData.Object == null)
            {
                return;
            }

            Mogre.Vector3 vPos = Mogre.Vector3.ZERO;

            PropertyInfo prop = dragData.Object.GetType().GetProperty("Position");

            if (prop != null)
            {
                vPos = (Mogre.Vector3)prop.GetValue(dragData.Object, null);
            }
            float distance = (vPos - vp.Camera.DerivedPosition).Length + (delta / 120.0f);

            if (vPos.x == 999999 && vPos.y == 999999 && vPos.z == 999999)
            {
                return;
            }
            else
            {
                vPos = vp.Camera.DerivedPosition + ((vPos - vp.Camera.DerivedPosition).NormalisedCopy * distance);
            }

            prop.SetValue(dragData.ObjectType, vPos, null);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Sets new positions to members in the collision group.
        /// </summary>
        /// <param name="groupInCollistion">The group with members in collision.</param>
        private void RepairHidenCollision(Dictionary <string, IMovableGameObject> groupInCollistion)
        {
            Dictionary <Mogre.Vector3, IMovableGameObject> collision = new Dictionary <Mogre.Vector3, IMovableGameObject>();

            // Checks all members in collision and sets them new position.
            foreach (var imgoPair in groupInCollistion)
            {
                if (collision.ContainsKey(imgoPair.Value.Position))
                {
                    bool          isTaken = true;
                    Mogre.Vector3 addVect = imgoPair.Value.Position;
                    // Find new empty position.
                    while (isTaken)
                    {
                        if (!collision.ContainsKey(addVect))
                        {
                            collision.Add(addVect, imgoPair.Value);
                            isTaken = false;
                        }
                        else
                        {
                            addVect = RandomizeVector(addVect);
                        }
                    }
                    imgoPair.Value.JumpToLocation(addVect);
                }
                else
                {
                    collision.Add(imgoPair.Value.Position, imgoPair.Value);
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Checks distance between the attacker position and the target position. Distance is compare with occupyDistance.
        /// </summary>
        /// <param Name="attackerPostion">The attacker position</param>
        /// <returns>Returns if attacker is in occupyDistance of the target.</returns>
        private bool CheckDistance(Mogre.Vector3 attackerPostion)
        {
            float maxDist;

            Mogre.Vector3 targetPosition;

            maxDist        = target.OccupyDistance;
            targetPosition = target.Position;


            var xd = targetPosition.x - attackerPostion.x;
            var zd = targetPosition.z - attackerPostion.z;
            var squaredDistance = xd * xd + zd * zd;

            var squaredPickUpDist = maxDist * maxDist;

            if (squaredDistance > (squaredPickUpDist))
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Checks if point is around given position. Maximum distance is squaredMaxDistance constant.
        /// </summary>
        /// <param name="targetPosition">The position of the target game object.</param>
        /// <param name="centerPoint">The target position.</param>
        /// <returns>Returns if object is in acceptable distance.</returns>
        private static bool PointIsAround(Mogre.Vector3 targetPosition, Mogre.Vector3 centerPoint)
        {
            var xd = targetPosition.x - centerPoint.x;
            var yd = targetPosition.z - centerPoint.z;
            var squaredDistance = xd * xd + yd * yd;

            return(squaredDistance < squaredMaxDistance);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Stores data to initialization. Stores target name, target solar system and target position.
        /// Also initializes info Property.
        /// </summary>
        /// <param name="args">The arguments should contains 3 members (target: name, solar system, position)</param>
        public EscortTarget(object[] args)
        {
            targetName  = (string)args[0];
            solSystName = (string)args[1];
            position    = ConvertStringToVector3((string)args[2]);

            targetInfo = new Property <string>("You must escort " + targetName + " to " + position.ToString() + " in solar system " + solSystName);
        }
Exemplo n.º 11
0
 /** Notify that the Affector is rescaled.
  */
 public void _notifyRescaled(Mogre.Vector3 scale)
 {
     if (scale == null)
     {
         throw new ArgumentNullException("scale cannot be null!");
     }
     PlaneCollider__notifyRescaled(nativePtr, scale);
 }
Exemplo n.º 12
0
 /** Add a new position to this emitter
  */
 public void AddPosition(Mogre.Vector3 position)
 {
     if (position == null)
     {
         throw new ArgumentNullException("position cannot be null!");
     }
     PositionEmitter_AddPosition(nativePtr, position);
 }
Exemplo n.º 13
0
 /// <summary>
 /// This is the Cartesian version of Pythagoras' theorem. In three-dimensional space,
 /// the distance between points (x1,y1,z1) and (x2,y2,z2) is
 /// http://upload.wikimedia.org/math/3/a/e/3ae1d79e0bfcc8f38223c7df4a7320c5.png
 /// which can be obtained by two consecutive applications of Pythagoras' theorem.
 /// http://en.wikipedia.org/wiki/Cartesian_coordinate_system#Distance_between_two_points
 /// the square root of (
 ///      ((point2.x - point1.x)squared) +
 ///      ((point2.y - point1.y)squared) +
 ///      ((point2.z - point1.z)squared)
 /// )
 /// </summary>
 public static float distanceBetweenPythagCartesian(Mogre.Vector3 point1, Mogre.Vector3 point2)
 {
     return(Mogre.Math.Sqrt(
                (Mogre.Math.Sqr(point2.x - point1.x) +
                 Mogre.Math.Sqr(point2.y - point1.y) +
                 Mogre.Math.Sqr(point2.z - point1.z)
                )));
 }
Exemplo n.º 14
0
 /// <summary>
 /// Initializes dictionaries and sets the name and the position at Space of the SolarSystem.
 /// </summary>
 /// <param name="name">The name of the SolarSystem.</param>
 /// <param name="position">The position of the SolarSystem.</param>
 public SolarSystem(string name, Mogre.Vector3 position)
 {
     this.name = name;
     this.position = position;
     isgoObjectDict = new Dictionary<string, IStaticGameObject>();
     imgoObjectDict = new Dictionary<string, IMovableGameObject>();
     bulletDict = new Dictionary<string, IBullet>();
 }
Exemplo n.º 15
0
        /// <summary>
        /// Stores data to initialization. Stores target name, target solar system and target position.
        /// Also initializes info Property.
        /// </summary>
        /// <param name="args">The arguments should contains 3 members (target: name, solar system, position)</param>
        public EscortTarget(object[] args)
        {
            targetName = (string)args[0];
            solSystName = (string)args[1];
            position = ConvertStringToVector3((string)args[2]);

            targetInfo = new Property<string>("You must escort " + targetName + " to " + position.ToString() + " in solar system " + solSystName);
        }
Exemplo n.º 16
0
 /** Notify that the Particle System is rescaled.
  */
 public void _notifyRescaled(Mogre.Vector3 scale)
 {
     if (scale == null)
     {
         throw new ArgumentNullException("scale cannot be null!");
     }
     RibbonTrailRenderer__notifyRescaled(nativePtr, scale);
 }
Exemplo n.º 17
0
 /// <summary>
 /// Creates a new box and adds it to this set.
 /// </summary>
 /// <param name="position"></param>
 /// <returns></returns>
 public Box CreateBox(Mogre.Vector3 position)
 {
     if (position == null)
     {
         throw new ArgumentNullException("position cannot be null!");
     }
     return(Box.GetInstance(BoxSet_CreateBox(nativePtr, position)));
 }
Exemplo n.º 18
0
        internal override void Update()
        {
            Mogre.Vector3 pos = _node._getDerivedPosition();

            FreeSL.fslSoundSetPosition(_sound, pos.x, pos.y, pos.z);

            AutoDelete();
        }
Exemplo n.º 19
0
 /// <summary>
 /// Initializes dictionaries and sets the name and the position at Space of the SolarSystem.
 /// </summary>
 /// <param name="name">The name of the SolarSystem.</param>
 /// <param name="position">The position of the SolarSystem.</param>
 public SolarSystem(string name, Mogre.Vector3 position)
 {
     this.name      = name;
     this.position  = position;
     isgoObjectDict = new Dictionary <string, IStaticGameObject>();
     imgoObjectDict = new Dictionary <string, IMovableGameObject>();
     bulletDict     = new Dictionary <string, IBullet>();
 }
Exemplo n.º 20
0
 public Sphere CreateSphere(Mogre.Vector3 position)
 {
     if (position == null)
     {
         throw new ArgumentNullException("position cannot be null!");
     }
     return(Sphere.GetInstance(SphereSet_CreateSphere(nativePtr, position)));
 }
Exemplo n.º 21
0
 /**
  */
 public void AddPoint(Mogre.Vector3 point)
 {
     if (point == null)
     {
         throw new ArgumentNullException("point cannot be null!");
     }
     PathFollower_AddPoint(nativePtr, point);
 }
Exemplo n.º 22
0
 /* Notify that the Behaviour is rescaled.
  */
 public void _notifyRescaled(Mogre.Vector3 scale)
 {
     if (scale == null)
     {
         throw new ArgumentNullException("scale cannot be null!");
     }
     ParticleBehaviour__notifyRescaled(nativePtr, scale);
 }
Exemplo n.º 23
0
 /** Initialises a ForceField */
 public void Initialise(ForceFieldTypes type,
                        uint forceFieldSize,
                        ushort octaves,
                        double frequency,
                        double amplitude,
                        double persistence,
                        Mogre.Vector3 worldSize)
 {
     ForceField_Initialise(nativePtr, type, forceFieldSize, octaves, frequency, amplitude, persistence, worldSize);
 }
Exemplo n.º 24
0
        /// <summary>
        /// Sends objects in the group to the given position. The objects are not sends to the same position,
        /// the positions are prepeted around the given center point.
        /// </summary>
        /// <param name="group">The moving group.</param>
        /// <param name="to">The point of the moving.</param>
        public void GoToLocation(GroupMovables group, Mogre.Vector3 to)
        {
            var destinations = PreparePositions(group.Count, to);

            foreach (IMovableGameObject imgo in group)
            {
                imgo.SetNextLocation(destinations[0]);
                destinations.RemoveAt(0);
            }
        }
Exemplo n.º 25
0
 /**
  */
 public void CalculateDirectionAfterCollision(Particle particle, Mogre.Vector3 distance, float distanceLength)
 {
     if (distance == null)
     {
         throw new ArgumentNullException("distance cannot be null!");
     }
     if (particle == null)
     {
         throw new ArgumentNullException("particle cannot be null!");
     }
     SphereCollider_CalculateDirectionAfterCollision(nativePtr, particle.NativePointer, distance, distanceLength);
 }
Exemplo n.º 26
0
 public Sphere(Mogre.Vector3 position, SphereSet owner)
 {
     if (owner == null)
     {
         throw new ArgumentNullException("owner cannot be null!");
     }
     if (position == null)
     {
         throw new ArgumentNullException("position cannot be null!");
     }
     nativePtr = Sphere_New(position, owner.nativePtr);
     rendererInstances.Add(nativePtr, this);
 }
Exemplo n.º 27
0
        /// <summary>
        /// Returns true when distance between given points is lower then given squaredDistance.
        /// </summary>
        /// <param Name="point1">The first point</param>
        /// <param Name="point2">The second point</param>
        /// <param Name="squaredDistance">THe squared distance (no root needed)</param>
        /// <returns>The distance is lower (true) or not</returns>
        private bool CheckDistance(Mogre.Vector3 point1, Mogre.Vector3 point2, double squaredDistance)
        {
            double xd       = point2.x - point1.x;
            double yd       = point2.z - point1.z;
            double distance = xd * xd + yd * yd;

            if (distance > squaredDistance)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Exemplo n.º 28
0
 /// <summary>
 /// Constructor as called by BoxSet.
 /// </summary>
 /// <param name="position"></param>
 /// <param name="owner"></param>
 public Box(Mogre.Vector3 position, BoxSet owner)
 {
     if (position == null)
     {
         throw new ArgumentNullException("position cannot be null!");
     }
     if (owner == null)
     {
         nativePtr = Box_New2(position, IntPtr.Zero);
     }
     else
     {
         nativePtr = Box_New2(position, owner.NativePointer);
     }
     rendererInstances.Add(nativePtr, this);
 }
Exemplo n.º 29
0
        public Mogre.Vector3 asVec3()
        {
            if (result is Mogre.Vector3)
            {
                return (Mogre.Vector3)result;
            }
            String[] aux = (result as string).Split();
            float x;
            float y;
            float z;

            float.TryParse(aux[0],out x);
            float.TryParse(aux[1],out y);
            float.TryParse(aux[2],out z);

            Mogre.Vector3 vector3D = new Mogre.Vector3(x, y, z);
            return vector3D;
        }
Exemplo n.º 30
0
        /// <summary>
        /// Fill the AxisAlignedBox with data derived from the other arguments.
        /// </summary>
        /// <param name="box"></param>
        /// <param name="position"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="depth"></param>
        public void PopulateAlignedBox(Mogre.AxisAlignedBox box,
                                       Mogre.Vector3 position,
                                       float width,
                                       float height,
                                       float depth)
        {
            if (box == null)
            {
                throw new ArgumentNullException("box cannot be null!");
            }
            if (position == null)
            {
                throw new ArgumentNullException("position cannot be null!");
            }
            IntPtr boxPtr = Marshal.AllocHGlobal(Marshal.SizeOf(box));

            Marshal.StructureToPtr(box, boxPtr, true);
            BaseCollider_PopulateAlignedBox(nativePtr, boxPtr, position, width, height, depth);
        }
        public Mogre.Vector3 GetGizmoIntersectCameraPlane(BaseEditor obj, Mogre.Ray pickRay)
        {
            Mogre.Vector3            vPos   = obj.DerivedPosition;
            Mogre.Pair <bool, float> result = pickRay.Intersects(new Mogre.Plane(-ActiveViewport.CameraEditor.Camera.DerivedDirection, vPos));

            if (result.first)
            {
                Mogre.Vector3 AxisX = obj.DerivedOrientation.XAxis;
                Mogre.Vector3 AxisY = obj.DerivedOrientation.YAxis;
                Mogre.Vector3 AxisZ = obj.DerivedOrientation.ZAxis;

                Mogre.Vector3 Proj  = pickRay.GetPoint(result.second) - vPos;
                Mogre.Vector3 vPos1 = (AxisX.DotProduct(Proj) * AxisX);
                Mogre.Vector3 vPos2 = (AxisY.DotProduct(Proj) * AxisY);
                Mogre.Vector3 vPos3 = (AxisZ.DotProduct(Proj) * AxisZ);
                vPos += vPos1 + vPos2 + vPos3;
            }

            return(vPos);
        }
Exemplo n.º 32
0
        /// <summary>
        /// Radomizes the given vector. It means it adds a constatn to a random direction.
        /// </summary>
        /// <param name="v"></param>
        /// <returns></returns>
        private Mogre.Vector3 RandomizeVector(Mogre.Vector3 v)
        {
            int i = r.Next(4);

            switch (i)
            {
            case 0: v.x += randConst;
                break;

            case 1: v.x -= randConst;
                break;

            case 2: v.z += randConst;
                break;

            case 3: v.z -= randConst;
                break;
            }
            return(v);
        }
Exemplo n.º 33
0
        private void CreateImages(ObservableCollection<IconTextItem> retlist, bool skipCached)
        {
            retlist.Clear();

            Mogre.TexturePtr texture = Mogre.TextureManager.Singleton.CreateManual("EntityTex",
                Mogre.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, Mogre.TextureType.TEX_TYPE_2D,
                256, 256, 0, Mogre.PixelFormat.PF_A8R8G8B8, (int)Mogre.TextureUsage.TU_RENDERTARGET);

            Mogre.RenderTexture rttTex = texture.GetBuffer().GetRenderTarget();
            Mogre.SceneManager sceneMgr = Mogre.Root.Singleton.CreateSceneManager("OctreeSceneManager", "EntityTexMgr");

            Mogre.Light dir1 = sceneMgr.CreateLight("DisplayLight");
            dir1.SetDirection(-1, -1, -1);
            dir1.SetDiffuseColour(1, 1, 1);
            dir1.Type = Mogre.Light.LightTypes.LT_DIRECTIONAL;

            Mogre.Camera RTTCam = sceneMgr.CreateCamera("EntityCam");
            RTTCam.NearClipDistance = 0.01F;
            RTTCam.FarClipDistance = 0;
            RTTCam.AspectRatio = 1;
            RTTCam.FOVy = new Mogre.Radian(new Mogre.Degree(90));
            RTTCam.Position = new Mogre.Vector3(0, 0, 1);
            RTTCam.LookAt(0, 0, 0);

            Mogre.Viewport v = rttTex.AddViewport(RTTCam);
            v.SetClearEveryFrame(true);
            v.BackgroundColour = new Mogre.ColourValue(0, 0, 0, 0);

            Mogre.StringVector list = Mogre.ResourceGroupManager.Singleton.FindResourceNames("ProjectResources", "*.mesh", false);

            IDictionary<string, string> entities = new Dictionary<string, string>(list.Count);
            foreach (string addstr in list)
            {
                if (entities.Values.Contains(addstr) == false)
                {
                    entities.Add(addstr, addstr);
                }
            }

            foreach (KeyValuePair<string, string> ite in entities)
            {
                string addstr = ite.Key;
                string addstrFile = MogitorsSystem.Instance.CombinePath(MogitorsRoot.Instance.ProjectOptions.ProjectDir, addstr + ".png");

                if (!skipCached || !System.IO.File.Exists(addstrFile))
                {
                    Mogre.Entity entity = sceneMgr.CreateEntity("scbDisplay", addstr);
                    sceneMgr.RootSceneNode.AttachObject(entity);

                    Mogre.Vector3 vSize = entity.BoundingBox.HalfSize;
                    Mogre.Vector3 vCenter = entity.BoundingBox.Center;

                    vSize += new Mogre.Vector3(vSize.z, vSize.z, vSize.z);

                    float maxsize = Math.Max(Math.Max(vSize.x, vSize.y), vSize.z);

                    vSize = new Mogre.Vector3(0, 0, maxsize * 1.1f) + vCenter;

                    RTTCam.SetPosition(vSize.x, vSize.y, vSize.z);
                    RTTCam.LookAt(vCenter.x, vCenter.y, vCenter.z);

                    rttTex.Update();
                    rttTex.WriteContentsToFile(addstrFile);

                    entity.ParentSceneNode.DetachObject(entity);
                    sceneMgr.DestroyEntity(entity);
                }

                retlist.Add(new IconTextItem(addstr.Remove(addstr.Length - 5, 5), addstrFile));
            }

            rttTex.RemoveAllViewports();
            Mogre.Root.Singleton.DestroySceneManager(sceneMgr);
            Mogre.Root.Singleton.DetachRenderTarget(rttTex.Name);
            Mogre.TextureManager.Singleton.Unload(texture.Name);
            Mogre.TextureManager.Singleton.Remove(texture.Name);

            list = null;
        }
Exemplo n.º 34
0
 public Teleport(Mogre.Vector3 destination)
 {
     m_TeleportTo = destination;
 }
Exemplo n.º 35
0
        public LogicState()
        {
            m_name = "unknown";
            m_HeadPosition = new Mogre.Vector3(0, 0.65f, 0);
            //forward move
            m_ForwardForce = 20;
            m_ForwardForceBoost = 40;

            //backwardmove
            m_BackwardForce = 10;
            m_BackwardForceBoost = 20;

            //turning angle in degree
            m_spdTurn = 25;
            m_spdTurnBoost = 15;

            //stopping power
            m_ForceStop = 6;
            m_LinearDampingValue = 1.0f;
        }
Exemplo n.º 36
0
 public void setProperty(Property property)
 {
     if (property.getName() == "Position")
     {
         cameraPosition = Registry.instance().GetEngine("Python").run(new Script(property.getValue())).asVec3();
     }
     if (property.getName() == "LookAt")
     {
         lookAt = Registry.instance().GetEngine("Python").run(new Script(property.getValue())).asVec3();
     }
     if (property.getName() == "ViewDistance")
     {
         viewDistance = Registry.instance().GetEngine("Python").run(new Script(property.getValue())).asInt();
     }
 }
Exemplo n.º 37
0
        public virtual void BodyForceCallback(MogreNewt.Body body, float timeStep, int threadIndex)
        {
            //calling each physics iteration

            //testuje jak dawno dotykal gruntu jezeli wartosc przekracza 5 lub 10 iteracji fiyzki
            //zmienia pozycje na lot
            if (m_Onground < 10)
                m_Onground++;
            else//jest w locie - zmieniamy mu stan
                ChangePoseTo("fly");

            if (m_jumpLimit > 0)
                m_jumpLimit--;

            //obnizanie poziomu adrenaliny o staly czynnik
            if (m_adrenaline > 1)
                m_adrenaline -= 0.01f * timeStep;
            else
                m_adrenaline = 1;

            Update();

            //trying to stop body in one position
            if (!m_bBackward && !m_bForward && !m_bLeft && !m_bRight)
            {
                if (!m_MainBody.Velocity.IsZeroLength)
                {//nie zatrzymal sie jeszcze to go zatrzymujemy
                    //dla bardzo malych predksoci dac cos w stylu velocity 0 ... albo wprowadzic
                    //punkt zatrzymania (x,y,z) dla velocity < 0.00001
                    Mogre.Vector3 xyVector = new Mogre.Vector3(0, 0, 1);
                    Mogre.Vector3 velocityxy = m_MainBody.Velocity * new Mogre.Vector3(1, 0, 1);
                    Mogre.Quaternion ForceDirection = xyVector.GetRotationTo(velocityxy);
                    Mogre.Vector3 StoppingForce = -ForceDirection * Mogre.Vector3.UNIT_Z * m_MainBody.Mass * m_Pose.m_ForceStop;
                    m_MainBody.AddForce(-StoppingForce);
                }
            }
        }
Exemplo n.º 38
0
        public override void ProcessParameters(Mogre.NameValuePairList parameters)
        {
            Mogre.NameValuePairList.Iterator ni;

            if ((ni = parameters.Find("Name")) != parameters.End())
                this.name = ni.Value;

            if ((ni = parameters.Find("Position")) != parameters.End())
                this.position = Mogre.StringConverter.ParseVector3(ni.Value);

            if ((ni = parameters.Find("Orientation")) != parameters.End())
                this.orientation = Mogre.StringConverter.ParseQuaternion(ni.Value);

            if ((ni = parameters.Find("ClipDistance")) != parameters.End())
                this.clipDistance = MogreX.StringConverter.ParseVector2(ni.Value);

            if ((ni = parameters.Find("FOV")) != parameters.End())
                this.fov = Mogre.StringConverter.ParseReal(ni.Value);
        }
Exemplo n.º 39
0
        /// <summary>
        /// Perform the given location change if valid.
        /// </summary>
        public static void DeserializeLocations(string contents, Connection sender)
        {
            var AsXML = XElement.Parse(contents);

            // anonymous types!
            var Karts = (from x in AsXML.Elements("Kart")
                         select new {
                             IDStr = x.Attribute("Id").Value,
                             PositionStr = x.Attribute("Pos").Value,
                             SpeedStr = x.Attribute("Vel").Value,
                             OrientationStr = x.Attribute("Or").Value
                         }).ToDictionary((a) => Int32.Parse(a.IDStr));
            foreach (NetworkEntity ne in LKernel.Get<NetworkManager>().Players) {
                if (Karts.ContainsKey(ne.GlobalID) && !ne.local) {
                    if (ne.owner == sender || ne.nm.NetworkType == NetworkTypes.Client) {
                        try {
                            var Kart = Karts[ne.GlobalID];
                            var PosList = Kart.PositionStr.Split(' ').Select((s) => float.Parse(s)).ToList();
                            var SpeedList = Kart.SpeedStr.Split(' ').Select((s) => float.Parse(s)).ToList();
                            var OrList = Kart.OrientationStr.Split(' ').Select((s) => float.Parse(s)).ToList();
                            var Pos = new Mogre.Vector3(PosList[0], PosList[1], PosList[2]);
                            var Speed = new Mogre.Vector3(SpeedList[0], SpeedList[1], SpeedList[2]);
                            var Or = new Mogre.Quaternion(OrList[0], OrList[1], OrList[2], OrList[3]);
                            ne.player.Kart.SetState(Pos, Speed, Or);
                        } catch (Exception e) { }
                    }
                }
            }
            return;
        }
        /// <summary>
        /// Checks if owner team has enough of the materials. If team has enough, so the game action
        /// creates new object and send it to a position (Vector3(100, 0, 100) + gameObject.Position) and returns
        /// text that the creation was successful. Else returns text that the creation failed.
        /// </summary>
        /// <returns>Returns text about the creation.</returns>
        public string OnMouseClick()
        {
            if (gameObject.Team.CheckMaterials(neededMaterials)) {
                // Removes team material
                gameObject.Team.UseMaterials(neededMaterials);

                // Creates arguments of the creation
                var args = new List<object>();
                args.Add(Game.IGameObjectCreator.GetUnusedName("Wolen"));
                args.Add(gameObject.Team);

                string objectPosToString = gameObject.Position.x.ToString() + ';' + gameObject.Position.z.ToString();
                args.Add(new object[] { objectPosToString });

                var solSyst = Game.SolarSystemManager.GetSolarSystem(gameObject);

                // Creates new object.
                var createdGameObject = Game.IGameObjectCreator.CreateImgo(creatingObject, args.ToArray(), solSyst);

                // Sends new object to its position.
                var position = new Mogre.Vector3(100, 0, 100) + gameObject.Position;
                Game.IMoveManager.GoToLocation(createdGameObject, position);
                gameObject.Team.AddIMGO(createdGameObject);

                return creatingObject + " created.";
            } else {
                return creatingObject + " cannot be created, you don't have enough materials.";
            }
        }
Exemplo n.º 41
0
            public uint Flags;                  // TODO: EAX-EFX conversion

            public EaxReverb(uint environment,
                              float environmentSize,
                              float environmentDiffusion,
                              int room,
                              int roomHF,
                              int roomLF,
                              float decayTime,
                              float decayHFRatio,
                              float decayLFRatio,
                              int reflections,
                              float reflectionsDelay,
                              float reflectionsPanX,
                              float reflectionsPanY,
                              float reflectionsPanZ,
                              int reverb,
                              float reverbDelay,
                              float reverbPanX,
                              float reverbPanY,
                              float reverbPanZ,
                              float echoTime,
                              float echoDepth,
                              float modulationTime,
                              float modulationDepth,
                              float airAbsorptionHF,
                              float hfReference,
                              float lfReference,
                              float roomRolloffFactor,
                              uint flags)
            {
                Environment = environment;
                EnvironmentSize = environmentSize;
                EnvironmentDiffusion = environmentDiffusion;
                Room = room;
                RoomHF = roomHF;
                RoomLF = roomLF;
                DecayTime = decayTime;
                DecayHFRatio = decayHFRatio;
                DecayLFRatio = decayLFRatio;
                Reflections = reflections;
                ReflectionsDelay = reflectionsDelay;
                ReflectionsPan = new Mogre.Vector3(reflectionsPanX, reflectionsPanY, reflectionsPanZ);
                Reverb = reverb;
                ReverbDelay = reverbDelay;
                ReverbPan = new Mogre.Vector3(reverbPanX, reverbPanY, reverbPanZ);
                EchoTime = echoTime;
                EchoDepth = echoDepth;
                ModulationTime = modulationTime;
                ModulationDepth = modulationDepth;
                AirAbsorptionHF = airAbsorptionHF;
                HFReference = hfReference;
                LFReference = lfReference;
                RoomRolloffFactor = roomRolloffFactor;
                Flags = flags;
            }
Exemplo n.º 42
0
        public override void ProcessParameters(Mogre.NameValuePairList parameters)
        {
            Mogre.NameValuePairList.Iterator ni;

            if ((ni = parameters.Find("Name")) != parameters.End())
                this.name = ni.Value;

            if ((ni = parameters.Find("Position")) != parameters.End())
                this.position = Mogre.StringConverter.ParseVector3(ni.Value);

            if ((ni = parameters.Find("Orientation")) != parameters.End())
                this.orientation = Mogre.StringConverter.ParseQuaternion(ni.Value);

            if ((ni = parameters.Find("Scale")) != parameters.End())
                this.scale = Mogre.StringConverter.ParseVector3(ni.Value);

            if ((ni = parameters.Find("AutoTrackTarget")) != parameters.End())
                this.autoTrackTarget = ni.Value;
        }
Exemplo n.º 43
0
        public override void Update()
        {
            m_MissionSteps--;

            if (m_MissionSteps <= 0)
            {
                /*if ((m_MissionType & RUN) > 0)
                    m_Pose.m_MaxSpd /= 1.5f;*/
                switch (Core.Singleton.Rand.Next() % 10)
                {
                    case 0:
                    case 1:
                    case 2:
                        m_MissionSteps = Core.Singleton.Rand.Next(5, 10);
                        if (Core.Singleton.Rand.Next() % 2 == 0)
                            m_MissionType = GO_LEFT;
                        else
                            m_MissionType = GO_RIGHT;
                        if (Core.Singleton.Rand.Next() % 2 == 0)
                            m_MissionType += GO_AHEAD;
                        break;
                    case 3:
                    case 4:
                    case 5:
                        m_MissionSteps = Core.Singleton.Rand.Next(20, 60);
                        m_MissionType = GO_AHEAD;
                        break;
                    case 6:
                        m_MissionSteps = Core.Singleton.Rand.Next(30, 120);
                        m_MissionType = RUN;
                        //m_Pose.m_MaxSpd *= 1.5f;
                        break;
                    default:
                        m_MissionSteps = Core.Singleton.Rand.Next(20, 60);
                        m_MissionType = 0;
                        break;
                }
            }

            //m_GoTo = m_LookingAt;
            bool activateidle = true;

            if ((m_MissionType & GO_AHEAD) > 0)
            {
                m_Pose.willForward();
                activateidle = false;
            }
            if ((m_MissionType & RUN) > 0)
            {
                m_Pose.willForward();
                activateidle = false;
            }
            if ((m_MissionType & GO_LEFT) > 0)
            {
                m_Pose.willTurnLeft();
            }
            if ((m_MissionType & GO_RIGHT) > 0)
            {
                m_Pose.willTurnRight();
            }

            if (activateidle == true && m_Pose == m_myPoses["normal"])
            {
                if (!m_MainBody.Velocity.IsZeroLength)
                {//nie zatrzymal sie jeszcze to go zatrzymujemy
                    Mogre.Vector3 xyVector = new Mogre.Vector3(0, 0, 1);
                    Mogre.Vector3 velocityxy = m_MainBody.Velocity * new Mogre.Vector3(1, 0, 1);
                    Mogre.Quaternion ForceDirection = xyVector.GetRotationTo(velocityxy);
                    Mogre.Vector3 StoppingForce = -ForceDirection * Mogre.Vector3.UNIT_Z * m_MainBody.Mass * 6;
                    m_MainBody.AddForce(-StoppingForce);
                }
            }
        }