Exemple #1
0
 public NpcController(Mogre.Node node,Mogre.Entity entity,float mass)
     : base(node, entity, mass)
 {
     m_MainBody.Type = (int)PhysicsManager.BodyTypes.NPC;
     m_MainBody.MaterialGroupID = Core.Singleton.PhysicsManager.getMaterialID("NPC");
     m_SecondBody.MaterialGroupID = Core.Singleton.PhysicsManager.getMaterialID("NPC");
 }
Exemple #2
0
        public Trigger(string _shapename, Mogre.Vector3 _shapesize)
        {
            switch (_shapename)
            {
                case "box":
                    m_collision = new MogreNewt.CollisionPrimitives.Box(
                                    Core.Singleton.NewtonWorld,
                                    _shapesize,
                                    new Mogre.Quaternion(new Mogre.Radian(1.57f), new Mogre.Vector3(0, 0, 1)),
                                    Core.Singleton.GetUniqueBodyId()
                                    );
                    break;
                case "ellipsoid":
                    m_collision = new MogreNewt.CollisionPrimitives.Ellipsoid(
                                    Core.Singleton.NewtonWorld,
                                    _shapesize,
                                    new Mogre.Quaternion(new Mogre.Radian(1.57f), new Mogre.Vector3(0, 0, 1)),
                                    Core.Singleton.GetUniqueBodyId()
                                    );
                    break;
            }

            m_collision.IsTriggerVolume = true;
            m_Body = new MogreNewt.Body(Core.Singleton.NewtonWorld, m_collision, true);
            m_Body.UserData = this;
            m_Body.Type = (int)PhysicsManager.BodyTypes.TRIGGER;
            m_Body.MaterialGroupID = Core.Singleton.PhysicsManager.getMaterialID("Trigger");
        }
 /// <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);
     }
 }
Exemple #4
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>();
 }
Exemple #5
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)
         ));
 }
Exemple #6
0
        /* __gl_meshCheckMesh( mesh ) checks a mesh for self-consistency.
        */
        public static void __gl_meshCheckMesh(Mogre.Utils.GluTesselator.GLUmesh mesh)
        {
            Mogre.Utils.GluTesselator.GLUface fHead = mesh.fHead;
            Mogre.Utils.GluTesselator.GLUvertex vHead = mesh.vHead;
            Mogre.Utils.GluTesselator.GLUhalfEdge eHead = mesh.eHead;
            Mogre.Utils.GluTesselator.GLUface f, fPrev;
            Mogre.Utils.GluTesselator.GLUvertex v, vPrev;
            Mogre.Utils.GluTesselator.GLUhalfEdge e, ePrev;

            fPrev = fHead;
            for (fPrev = fHead; (f = fPrev.next) != fHead; fPrev = f)
            {
                //assert(f.prev == fPrev);
                e = f.anEdge;
                do
                {
                    //assert(e.Sym != e);
                    //assert(e.Sym.Sym == e);
                    //assert(e.Lnext.Onext.Sym == e);
                    //assert(e.Onext.Sym.Lnext == e);
                    //assert(e.Lface == f);
                    e = e.Lnext;
                }
                while (e != f.anEdge);
            }
            //assert(f.prev == fPrev && f.anEdge == null && f.data == null);

            vPrev = vHead;
            for (vPrev = vHead; (v = vPrev.next) != vHead; vPrev = v)
            {
                //assert(v.prev == vPrev);
                e = v.anEdge;
                do
                {
                    //assert(e.Sym != e);
                    //assert(e.Sym.Sym == e);
                    //assert(e.Lnext.Onext.Sym == e);
                    //assert(e.Onext.Sym.Lnext == e);
                    //assert(e.Org == v);
                    e = e.Onext;
                }
                while (e != v.anEdge);
            }
            //assert(v.prev == vPrev && v.anEdge == null && v.data == null);

            ePrev = eHead;
            for (ePrev = eHead; (e = ePrev.next) != eHead; ePrev = e)
            {
                //assert(e.Sym.next == ePrev.Sym);
                //assert(e.Sym != e);
                //assert(e.Sym.Sym == e);
                //assert(e.Org != null);
                //assert(e.Sym.Org != null);
                //assert(e.Lnext.Onext.Sym == e);
                //assert(e.Onext.Sym.Lnext == e);
            }
            //assert(e.Sym.next == ePrev.Sym && e.Sym == mesh.eHeadSym && e.Sym.Sym == e && e.Org == null && e.Sym.Org == null && e.Lface == null && e.Sym.Lface == null);
        }
 public void killtest(Mogre.Vector3 position)
 {
     Mogre.OverlayManager.Singleton.GetByName("BrokenScreen").Show();
     Mogre.MaterialPtr mat = Mogre.MaterialManager.Singleton.GetByName("BrokenScreen");
     Mogre.TextureUnitState tus = mat.GetTechnique(0).GetPass(0).GetTextureUnitState(0);
     mat.GetTechnique(0).GetPass(0).SetSceneBlending(Mogre.SceneBlendType.SBT_TRANSPARENT_ALPHA);
     tus.SetAlphaOperation(Mogre.LayerBlendOperationEx.LBX_MODULATE, Mogre.LayerBlendSource.LBS_MANUAL, Mogre.LayerBlendSource.LBS_TEXTURE, 1);
     Core.Singleton.SoundDict.Play("die_01.wav", position);
 }
 public BillboardSystem(SceneManager sceneManager, SceneNode worldNode, string materialName, Mogre.BillboardType type, Vector2 defaultDimension, float defaultTimeToLive)
 {
     BillboardSet = sceneManager.CreateBillboardSet();
     BillboardSet.SetMaterialName(materialName);
     BillboardSet.SetBillboardsInWorldSpace(true);
     BillboardSet.BillboardType = type;
     worldNode.AttachObject(BillboardSet);
     this.DefaultDimension = defaultDimension;
     this.DefaultTimeToLive = defaultTimeToLive;
 }
Exemple #9
0
        public Boolean FrameRenderingQueued( Mogre.FrameEvent evt)
        {
            if( m_stateManager->getActiveState() )
                m_stateManager->getActiveState()->updateFrameEvent( evt );

            double time = evt.timeSinceLastFrame;
            ///// Bullet time tymczasowo wyci?ty
            //if( m_keyStates[OIS.KC_B] )
            //	time = 0.3 * evt.timeSinceLastFrame;
            //else
            //	time = 1.0 * evt.timeSinceLastFrame;

            double tElapsed = m_elapsed += time;
            double tUpdate = m_update;

            // loop through and update as many times as necessary (up to 10 times maximum).
            if ((tElapsed > tUpdate) && (tElapsed < (tUpdate * 10)) )
            {
                while (tElapsed > tUpdate)
                {
                    //for( std.list<TimeObserver *>.iterator it = m_TimeObservers.begin(); it != m_TimeObservers.end(); it++ )
                    //	(*it)->update( tUpdate );
                    m_stateManager->update( tUpdate );
                    tElapsed -= tUpdate;
                }
            }
            else
            {
                if (tElapsed < tUpdate)
                {
                    // not enough time has passed this loop, so ignore for now.
                }
                else
                {
                    // too much time has passed (would require more than 10 updates!), so just update once and reset.
                    // this often happens on the first frame of a game, where assets and other things were loading, then
                    // the elapsed time since the last drawn frame is very long.
                    //for( std.list<TimeObserver *>.iterator it = m_TimeObservers.begin(); it != m_TimeObservers.end(); it++ )
                    //	(*it)->update( tUpdate );
                    m_stateManager->update( tUpdate );
                    tElapsed = 0.0f; // reset the elapsed time so we don't become "eternally behind".
                }
            }

            Core.Singleton().m_elapsed = tElapsed;
            Core.Singleton().m_update = tUpdate;

            //wstrzykiwanie uplywu czasu do CEgui
            //CEGUI.System.getSingleton().injectTimePulse(evt.timeSinceLastFrame);

            return true;
        }
//    *
//	Set the text content.
//	\param text New text for processing (default "OgreProcedural")
//	\exception Ogre::InvalidParametersException Empty text
//
        public TextShape setText(string text)
        {
            if (text.empty())
            {
//C++ TO C# CONVERTER TODO TASK: There is no direct equivalent in C# to the C++ __LINE__ macro:
//C++ TO C# CONVERTER TODO TASK: There is no direct equivalent in C# to the C++ __FILE__ macro:
                throw ExceptionFactory.create(Mogre.ExceptionCodeType <Mogre.Exception.ExceptionCodes.ERR_INVALIDPARAMS>(), "There must be more than 0 characters in text", "Procedural::TextShape::setText(Ogre::String text)", __FILE__, __LINE__);
            }
            ;

            mText = text;
            return(this);
        }
Exemple #11
0
        public override void GetObjectProperties(Mogre.NameValuePairList retList)
        {
            base.GetObjectProperties(retList);

            retList["MeshFile"] = this.meshFile;
            retList["CastShadows"] = Mogre.StringConverter.ToString(this.castShadows);

            for (int i = 0; i < this.subMeshes.Count; ++i)
            {
                string paramName = "SubEntity" + Mogre.StringConverter.ToString(i) + ".";
                retList[paramName + "Visible"] = Mogre.StringConverter.ToString(this.subMeshes[i].Visible);
                retList[paramName + "Material"] = this.subMeshes[i].Material;
            }
        }
Exemple #12
0
        private ISound sound; // Current playing song

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Initializes music player and randomizer. After that plays first song
        /// from file and sets event receiver.
        /// </summary>
        /// <param name="mWindow">The RenderWindow instance for making overlays</param>
        public SoundPlayer( Mogre.RenderWindow mWindow)
        {
            engine = new ISoundEngine();
            songs = Directory.GetFiles(songPath);
            r = new Random();
            this.mWindow = mWindow;
            sound = engine.Play2D(songs[0]);
            sound.setSoundStopEventReceiver(this);
            ShowCurrentPlaying(songs[current]);

            effects = new Dictionary<string, string>();
            var tempEff = Directory.GetFiles(effectPath);
            foreach (var effName in tempEff) {
                var splited = effName.Split('\\');
                effects.Add(splited[splited.Length - 1], effName);
            }
        }
Exemple #13
0
        void MogitorsRoot.IDragDropHandler.OnDragDrop(DragData dragData, Mogre.Viewport vp, Mogre.Vector2 position)
        {
            if (dragData.Object != null)
            {
                Mogre.NameValuePairList parameters = new Mogre.NameValuePairList();
                dragData.Object.GetObjectProperties(parameters);
                dragData.Object.Destroy(false);
                dragData.Object = null;

                dragData.Parameters["Position"] = parameters["Position"];

                MogitorsRoot.Instance.CreateEditorObject(null, dragData.ObjectType, dragData.Parameters, true, true);
            }

            dragData.Parameters.Clear();
            dragData.ObjectType = "";
            dragData.Object = null;
        }
Exemple #14
0
        public void SetPhysics(Mogre.Entity entity, Mogre.SceneNode node, float mass)
        {
            MogreNewt.ConvexCollision collision = new MogreNewt.CollisionPrimitives.Cylinder(
                Core.Singleton.NewtonWorld,

                Core.Singleton.PhysicsManager.getCollisionCylinderRadius(entity, node),
                Core.Singleton.PhysicsManager.getCollisionCylinderHeight(entity, node),
                new Mogre.Quaternion(new Mogre.Radian(1.57f), new Mogre.Vector3(0f, 0f, 1f)),
                Core.Singleton.GetUniqueBodyId()
                );

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

            m_Body = new MogreNewt.Body(Core.Singleton.NewtonWorld, collision, true);
            m_Body.AttachNode(node);
            m_Body.SetMassMatrix(mass, inertia);
            m_Body.SetPositionOrientation(node.Position + new Vector3(0, 1, 0), node.Orientation);
            m_Body.MaterialGroupID = Core.Singleton.PhysicsManager.getMaterialID("Metal");
        }
//    *
//	Set the font for the text.
//	\param fontName Filenpath of a font or name of font (only on windows desktops)
//	\param fontSize Size of font [px] (default 12)
//	\exception Ogre::InvalidParametersException Empty font name
//	\exception Ogre::InvalidParametersException Font size is below 4
//	\todo Add search for font names on non windows systems.
//
        public TextShape setFont(string fontName, byte fontSize)
        {
            if (fontName.empty())
            {
//C++ TO C# CONVERTER TODO TASK: There is no direct equivalent in C# to the C++ __LINE__ macro:
//C++ TO C# CONVERTER TODO TASK: There is no direct equivalent in C# to the C++ __FILE__ macro:
                throw ExceptionFactory.create(Mogre.ExceptionCodeType <Mogre.Exception.ExceptionCodes.ERR_INVALIDPARAMS>(), "There must be more than 0 characters in font name", "Procedural::TextShape::setFont(Ogre::String fontName, Ogre::byte fontSize)", __FILE__, __LINE__);
            }
            ;
            if (fontSize < 4)
            {
//C++ TO C# CONVERTER TODO TASK: There is no direct equivalent in C# to the C++ __LINE__ macro:
//C++ TO C# CONVERTER TODO TASK: There is no direct equivalent in C# to the C++ __FILE__ macro:
                throw ExceptionFactory.create(Mogre.ExceptionCodeType <Mogre.Exception.ExceptionCodes.ERR_INVALIDPARAMS>(), "Minimum font size is 4", "Procedural::TextShape::setFont(Ogre::String fontName, Ogre::byte fontSize)", __FILE__, __LINE__);
            }
            ;

            mFontName = fontName;
            mFontSize = fontSize;
            return(this);
        }
        /* really __gl_pqHeapNewPriorityQ */
        public PriorityQHeap(Mogre.Utils.GluTesselator.PriorityQ.Leq leq)
        {
            size = 0;
            max = Mogre.Utils.GluTesselator.PriorityQ.INIT_SIZE;
            nodes = new Mogre.Utils.GluTesselator.PriorityQ.PQnode[Mogre.Utils.GluTesselator.PriorityQ.INIT_SIZE + 1];
            for (int i = 0; i < nodes.Length; i++)
            {
                nodes[i] = new PQnode();
            }
            handles = new Mogre.Utils.GluTesselator.PriorityQ.PQhandleElem[Mogre.Utils.GluTesselator.PriorityQ.INIT_SIZE + 1];
            for (int i = 0; i < handles.Length; i++)
            {
                handles[i] = new PQhandleElem();
            }
            initialized = false;
            freeList = 0;
            this.leq = leq;

            nodes[1].handle = 1; /* so that Minimum() returns NULL */
            handles[1].key = null;
        }
 //: this(towgs84, false)
 public MatrixTransform(Mogre.Matrix4 reference_frame)
 {
     //copiar reference a la matrix v
     v = new double[16];
     v[0] = reference_frame.m00;
     v[1] = reference_frame.m01;
     v[2] = reference_frame.m02;
     v[3] = reference_frame.m03;
     v[4] = reference_frame.m10;
     v[5] = reference_frame.m11;
     v[6] = reference_frame.m12;
     v[7] = reference_frame.m13;
     v[8] = reference_frame.m20;
     v[9] = reference_frame.m21;
     v[10] = reference_frame.m22;
     v[11] = reference_frame.m23;
     v[12] = reference_frame.m30;
     v[13] = reference_frame.m31;
     v[14] = reference_frame.m32;
     v[15] = reference_frame.m33;
 }
Exemple #18
0
        public override BaseEditor CreateObject(ref BaseEditor parent, Mogre.NameValuePairList parameters)
        {
            EntityEditor editor = new EntityEditor();

            if (parameters.Find("MeshFile") == parameters.End())
                parameters["MeshFile"] = "scbCamera.mesh";

            if (parameters.Find("Init") != parameters.End())
            {
                string entName = Path.GetFileNameWithoutExtension(parameters["MeshFile"]);
                parameters["Name"] = entName + MogitorsRoot.Instance.CreateUniqueID(entName, "", -1);
            }

            editor.ProcessParameters(parameters);
            editor.Parent = parent;

            InstanceCount++;
            return editor;
        }
Exemple #19
0
        public override void ProcessParameters(Mogre.NameValuePairList parameters)
        {
            base.ProcessParameters(parameters);

            Mogre.NameValuePairList.Iterator ni;

            if ((ni = parameters.Find("MeshFile")) != parameters.End())
                this.meshFile = ni.Value;

            if ((ni = parameters.Find("CastShadows")) != parameters.End())
                this.castShadows = Mogre.StringConverter.ParseBool(ni.Value);

            foreach (KeyValuePair<string, string> param in parameters)
            {
                if (!param.Key.StartsWith("SubEntity"))
                    continue;

                string valStr = param.Key;
                valStr = valStr.Remove(0, 9);

                if (valStr.EndsWith("Visible"))
                {
                    valStr = valStr.Remove(valStr.Length - 8, 8);
                    int ID = Mogre.StringConverter.ParseInt(valStr);
                    GetSubMesh(ID).Visible = Mogre.StringConverter.ParseBool(param.Value);
                }
                else if (valStr.EndsWith("Material"))
                {
                    valStr = valStr.Remove(valStr.Length - 9, 9);
                    int ID = Mogre.StringConverter.ParseInt(valStr);
                    GetSubMesh(ID).Material = param.Value;
                }
            }
        }
 public SceneUpdatedEventArgs(Mogre.SceneManager sceneMngr, Mogre.Camera camera, Mogre.RenderTarget renderTarget)
 {
     this.sceneMngr = sceneMngr;
     this.camera = camera;
     this.renderTarget = renderTarget;
 }
 /// <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);
 }
 /// <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;
 }
Exemple #23
0
 public static Vector3 FromMogre(Mogre.Vector3 loc)
 {
     return new Vector3(loc.x, loc.y, loc.z);
 }
 private void setPos(Mogre.Vector3 pos)
 {
     if (!player_freeze && !textBarUsage && !control.Actor.IsDisposed)
     {
         control.Actor.MoveGlobalPosition(pos);
         // actors.UpdateAllActors(.0f);
         //nodes["drone"].SetPosition(pos.x, pos.y, pos.z);
     }
 }
Exemple #25
0
        bool MogitorsRoot.IDragDropHandler.OnDragOver(DragData dragData, Mogre.Viewport vp, Mogre.Vector2 position)
        {
            if (dragData.ObjectType == "")
                return false;

            if (dragData.Object == null)
                return true;

            Mogre.Ray mouseRay;
            mouseRay = vp.Camera.GetCameraToViewportRay(position.x, position.y);

            Mogre.Vector3 vPos = Mogre.Vector3.ZERO;
            PropertyInfo prop = dragData.Object.GetType().GetProperty("Position");
            if (prop != null)
                vPos = (Mogre.Vector3)prop.GetValue(dragData.Object, null);

            if (vPos.x == 999999 && vPos.y == 999999 && vPos.z == 999999)
                vPos = mouseRay.Origin + (mouseRay.Direction * 40.0f);
            else
                vPos = MogitorsRoot.Instance.GetGizmoIntersectCameraPlane(dragData.Object, mouseRay);

            if (prop != null)
                prop.SetValue(dragData.Object, vPos, null);

            return true;
        }
Exemple #26
0
 public void setBackGroundColor(Mogre.Vector4 color)
 {
     backGroundColor = color;
 }
//    *
//	 * Build a MultiShape from chars (one Shape per character)
//	 * \exception Ogre::InternalErrorException Freetype error
//	 * \todo Need to split shapes of multi region chars. For example the letter \c O
//	 * has two shapes, but they are connected to one shape.
//
        public MultiShape realizeShapes()
        {
            MultiShape retVal = new MultiShape();

            FT_Library   ftlib = new FT_Library();
            FT_Face      face  = new FT_Face();
            FT_GlyphSlot slot  = new FT_GlyphSlot();

            FT_Error error = FT_Init_FreeType(ftlib);

            if (error == 0)
            {
                error = FT_New_Face(ftlib, getFontFileByName().c_str(), 0, face);
                if (error == FT_Err_Unknown_File_Format)
                {
                    //C++ TO C# CONVERTER TODO TASK: There is no direct equivalent in C# to the C++ __LINE__ macro:
                    //C++ TO C# CONVERTER TODO TASK: There is no direct equivalent in C# to the C++ __FILE__ macro:
                    throw ExceptionFactory.create(Mogre.ExceptionCodeType <Mogre.Exception.ExceptionCodes.ERR_INTERNAL_ERROR>(), "FreeType ERROR: FT_Err_Unknown_File_Format", "Procedural::TextShape::realizeShapes()", __FILE__, __LINE__);
                    ;
                }
                else if (error != null)
                {
                    //C++ TO C# CONVERTER TODO TASK: There is no direct equivalent in C# to the C++ __LINE__ macro:
                    //C++ TO C# CONVERTER TODO TASK: There is no direct equivalent in C# to the C++ __FILE__ macro:
                    throw ExceptionFactory.create(Mogre.ExceptionCodeType <Mogre.Exception.ExceptionCodes.ERR_INTERNAL_ERROR>(), "FreeType ERROR: FT_New_Face - " + StringConverter.toString(error), "Procedural::TextShape::realizeShapes()", __FILE__, __LINE__);
                    ;
                }
                else
                {
                    FT_Set_Pixel_Sizes(face, 0, mFontSize);

                    int px = 0;
                    int py = 0;
                    slot = face.glyph;

                    for (int n = 0; n < mText.length(); n++)
                    {
                        error = FT_Load_Char(face, mText[n], FT_LOAD_NO_BITMAP);
                        if (error != null)
                        {
                            continue;
                        }

                        Shape s = new Shape();

                        int         nContours = face.glyph.outline.n_contours;
                        int         startPos  = 0;
                        string      tags      = face.glyph.outline.tags;
                        FT_Vector[] vec       = face.glyph.outline.points;

                        for (int k = 0; k < nContours; k++)
                        {
                            if (k > 0)
                            {
                                startPos = face.glyph.outline.contours[k - 1] + 1;
                            }
                            int endPos = face.glyph.outline.contours[k] + 1;

                            Vector2 lastPoint = Vector2.ZERO;
                            for (int j = startPos; j < endPos; j++)
                            {
                                if (FT_CURVE_TAG(tags[j]) == FT_CURVE_TAG_ON)
                                {
                                    lastPoint = Vector2((float)vec[j].x, (float)vec[j].y);
                                    s.addPoint(lastPoint / 64.0f);
                                }
                                else
                                {
                                    if (FT_CURVE_TAG(tags[j]) == FT_CURVE_TAG_CUBIC)
                                    {
                                        int prevPoint = j - 1;
                                        if (j == 0)
                                        {
                                            prevPoint = endPos - 1;
                                        }
                                        int nextIndex = j + 1;
                                        if (nextIndex >= endPos)
                                        {
                                            nextIndex = startPos;
                                        }
                                        Vector2[] nextPoint = new Vector2[nextIndex]((float)vec.x, (float)vec[nextIndex].y);
                                        if ((FT_CURVE_TAG(tags[prevPoint]) != FT_CURVE_TAG_ON) && (FT_CURVE_TAG(tags[prevPoint]) == FT_CURVE_TAG_CUBIC))
                                        {
                                            BezierCurve2 bc = new BezierCurve2();
                                            bc.addPoint(Vector2((float)vec[prevPoint].x, (float)vec[prevPoint].y) / 64.0f);
                                            bc.addPoint(Vector2((float)vec[j].x, (float)vec[j].y) / 64.0f);
                                            bc.addPoint(Vector2((float)vec[nextIndex].x, (float)vec[nextIndex].y) / 64.0f);
                                            s.appendShape(bc.realizeShape());
                                        }
                                    }
                                    else
                                    {
                                        Vector2[] conicPoint = new Vector2[j]((float)vec.x, (float)vec[j].y);
                                        if (j == startPos)
                                        {
                                            if ((FT_CURVE_TAG(tags[endPos - 1]) != FT_CURVE_TAG_ON) && (FT_CURVE_TAG(tags[endPos - 1]) != FT_CURVE_TAG_CUBIC))
                                            {
                                                Vector2[] lastConnic = new Vector2[endPos - 1]((float)vec.x, (float)vec[endPos - 1].y);
                                                lastPoint = (conicPoint + lastConnic) / 2;
                                            }
                                        }

                                        int nextIndex = j + 1;
                                        if (nextIndex >= endPos)
                                        {
                                            nextIndex = startPos;
                                        }

                                        Vector2[] nextPoint = new Vector2[nextIndex]((float)vec.x, (float)vec[nextIndex].y);

                                        bool nextIsConnic = (FT_CURVE_TAG(tags[nextIndex]) != FT_CURVE_TAG_ON) && (FT_CURVE_TAG(tags[nextIndex]) != FT_CURVE_TAG_CUBIC);
                                        if (nextIsConnic)
                                        {
                                            nextPoint = (conicPoint + nextPoint) / 2;
                                        }

                                        int          pc = s.getPointCount();
                                        BezierCurve2 bc = new BezierCurve2();
                                        if (pc == 0)
                                        {
                                            bc.addPoint(Vector2.ZERO);
                                        }
                                        else
                                        {
                                            bc.addPoint(s.getPoint(pc - 1));
                                        }
                                        bc.addPoint(lastPoint / 64.0f);
                                        bc.addPoint(conicPoint / 64.0f);
                                        bc.addPoint(nextPoint / 64.0f);
                                        if (pc == 0)
                                        {
                                            s.appendShape(bc.realizeShape());
                                        }
                                        else
                                        {
                                            List <Vector2> subShape = bc.realizeShape().getPoints();
                                            for (List <Vector2> .Enumerator iter = subShape.GetEnumerator(); iter.MoveNext(); iter++)
                                            {
                                                if (iter != subShape.GetEnumerator())
                                                {
                                                    s.addPoint(iter.Current);
                                                }
                                            }
                                        }

                                        if (nextIsConnic)
                                        {
//
//ORIGINAL LINE: lastPoint = nextPoint;
                                            lastPoint = (nextPoint);
                                        }
                                    }
                                }
                            }
                        }

                        s.close();
                        s.translate((float)px, (float)py);
                        retVal.addShape(s);

                        px += slot.advance.x >> 6;
                        py += slot.advance.y >> 6;
                    }
                    FT_Done_Face(face);
                }
                FT_Done_FreeType(ftlib);
            }
            else
            {
                //C++ TO C# CONVERTER TODO TASK: There is no direct equivalent in C# to the C++ __LINE__ macro:
                //C++ TO C# CONVERTER TODO TASK: There is no direct equivalent in C# to the C++ __FILE__ macro:
                throw ExceptionFactory.create(Mogre.ExceptionCodeType <Mogre.Exception.ExceptionCodes.ERR_INTERNAL_ERROR>(), "FreeType ERROR: FT_Init_FreeTyp", "Procedural::TextShape::realizeShapes()", __FILE__, __LINE__);
                ;
            }

            return(retVal);
        }
 /// <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;
     }
 }
        /// <summary>
        /// Creates the List of positions around the given point.
        /// </summary>
        /// <param Name="count">The number of positions</param>
        /// <param Name="position">The center position</param>
        /// <returns>The List with positions around given position</returns>
        private List<Mogre.Vector3> PreparePositions(int count, Mogre.Vector3 position)
        {
            List<Mogre.Vector3> positionList = new List<Mogre.Vector3>();
            List<Mogre.Vector3> collision = new List<Mogre.Vector3>();
            Mogre.Vector3 positionToGo = position;

            for (int i = 0; i < count; i++) {
                if (collision.Contains(positionToGo)) {
                    bool isTaken = true;
                    positionToGo = position;

                    while (isTaken) {
                        if (!collision.Contains(positionToGo)) {
                            collision.Add(positionToGo);
                            isTaken = false;
                        } else {
                            positionToGo = RandomizeVector(positionToGo);
                        }
                    }
                    positionList.Add(positionToGo);
                } else {
                    collision.Add(position);
                    positionList.Add(position);
                }
            }
            return positionList;
        }
Exemple #30
0
        private bool Update(Mogre.FrameEvent evt)
        {
            if (m_RenderWindow.IsClosed)
                return false;

            if (m_Shutdown)
                return false;

            try
            {
                m_TimeAccumulator += evt.timeSinceLastFrame;
                m_GFXFPSAccumulator += evt.timeSinceLastFrame;
                m_GFXFPS++;

                while (m_TimeAccumulator >= m_FixedTime)
                {
                    m_PHYSUPSAccumulator += m_FixedTime;
                    m_PHYSUPS++;

                    m_Keyboard.Capture();
                    m_Mouse.Capture();

                    m_StateManager.Update();

                    // not sure where exactly should be these lines below (State Updates?)    ~MDZ
                    m_ObjectManager.Update();
                    m_NewtonWorld.Update(m_FixedTime);
                    m_GameCamera.Update();
                    m_SoundDict.Update();

                    m_TimeAccumulator -= m_FixedTime;

                    if (m_PHYSUPSAccumulator >= 1.0f)
                    {
                        m_PHYSUPSStored = m_PHYSUPS;
                        m_PHYSUPS = 0;
                        m_PHYSUPSAccumulator -= 1.0f;
                    }
                }

                if (m_GFXFPSAccumulator >= 1.0f)
                {
                    m_GFXFPSStored = m_GFXFPS;
                    m_GFXFPS = 0;
                    m_GFXFPSAccumulator -= 1.0f;
                    if (m_ShowFPS)
                        Console.WriteLine("FPS: " + m_GFXFPSStored + " (gfx), " + m_PHYSUPSStored + " (phys)");
                }

                WindowEventUtilities.MessagePump();

                if (m_Keyboard.IsKeyDown(MOIS.KeyCode.KC_F3))
                    m_NewtonDebugger.ShowDebugInformation();
                else
                    m_NewtonDebugger.HideDebugInformation();

                return true;
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e);
                m_Shutdown = true;
                return false;
            }
        }
        private void resetPlayer2(Mogre.Vector3 loc, Quaternion orient)
        {
            //MoveScale_Camera_forwardback = control.Actor.GlobalPosition.z - loc.z;
            //MoveScale_Camera_leftright = control.Actor.GlobalPosition.x - loc.x;
            //MoveScale_Camera_updown = control.Actor.GlobalPosition.y - loc.y;

            //Mogre.Vector3 loc1 = control.Actor.GlobalPosition;
            pauseUpdates();
            Mogre.Vector3 loc2 = control.Actor.GlobalOrientationQuaternion * loc;
            setPos(loc2 + loc);
            TranslateVector_Camera = new Mogre.Vector3(0f, 0f, 0f);
            MoveScale_Camera_forwardback = 0f;
            MoveScale_Camera_leftright = 0f;
            MoveScale_Camera_updown = 0f;
               // setPos(loc);
            setOrient(orient);
            unPauseUpdates();
        }
Exemple #32
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);
        }
 private void sendLocationBeacon(Mogre.Vector3 pos)
 {
     Memories mems = new Memories();
     mems.Add(new Memory("", KeyWord.CARTESIAN_X, pos.x.ToString(), null));
     mems.Add(new Memory("", KeyWord.CARTESIAN_Y, pos.y.ToString(), null));
     mems.Add(new Memory("", KeyWord.CARTESIAN_Z, pos.z.ToString(), null));
     Event ev = new Event();
     ev._Keyword = KeyWord.CARTESIAN_SECRETPLAYERLOCATION;
     ev._Memories = mems;
     ev._IntendedRecipients = EventTransfer.CLIENTTOSERVER;
     base.outboxMessage(this, ev);
     // log("Location: X=" + imAt.x.ToString() + " Y=" + imAt.y.ToString() + " Z=" + imAt.z.ToString());
 }