예제 #1
0
파일: Quad.cs 프로젝트: mdvulfix/SpaceGame
    private void AddChild(QuadType type, int level, float size, Vector3 centrePoint)
    {
        string childName = type.ToString();
        var    empty     = new GameObject(childName);

        empty.transform.parent        = gameObject.transform;
        empty.transform.rotation      = gameObject.transform.rotation;
        empty.transform.localPosition = centrePoint;

        // TODO: offset position of empty to centre of new Quad

        empty.layer = gameObject.layer;

        Quad child = empty.AddComponent <Quad>();

        child.QuadType                 = type;
        child.Root                     = Root;
        child.Face                     = Face;
        child.Parent                   = this;
        child.Level                    = level;
        child.Size                     = size;
        child.Subdivisions             = Subdivisions;
        child.SubdivisionDistances     = SubdivisionDistances;
        child.TriangleCache            = TriangleCache;
        child.Material                 = Material;
        child.StartingNoiseFrequency   = StartingNoiseFrequency;
        child.StartingNoiseAmplitude   = StartingNoiseAmplitude;
        child.SmoothNegativeElevations = SmoothNegativeElevations;
        child.Active                   = true;
        child.Initialise();

        _children[(int)type] = child;
    }
예제 #2
0
 public QuadTree(Vector2 position, float gridSize, QuadTree parent, QuadType quadType)
 {
     this.topLeft = null;
     this.topRight = null;
     this.bottomLeft = null;
     this.bottomRight = null;
     this.position = position;
     this.gridSize = gridSize;
     this.parent = parent;
     this.entities = new List<GraphicalEntity>();
     this.quadType = quadType;
     this.boundRect = new Rectangle((int)position.X, (int)position.Y, (int)gridSize, (int)gridSize);
 }
    Color GetQuadColor(QuadType quadType)
    {
        switch (quadType)
        {
        case QuadType.WALL:
            return(Color.black);

        case QuadType.FLOOR:
            return(Color.white);

        default:
            return(Color.red);
        }
    }
예제 #4
0
 private void getAllWhoShareEdgeInternal(QuadType type, RegionQuadtree <T> original, List <RegionQuadtree <T> > share, QuadDirection[] dir)
 {
     if (this.Type == type && this.aabb.Intersects(ref original.aabb))
     {
         share.Add(this);
     }
     else if (this.Type == QuadType.Grey)
     {
         for (int i = 0; i < dir.Length; i++)
         {
             this[dir[i]].getAllWhoShareEdgeInternal(type, original, share, dir);
         }
     }
 }
예제 #5
0
        public void AddGranularStoredProcData(string userId, string procName, long callPrep, long callWait, long callProcess, long callTotal, long dataTransferAmt)
        {
            List <QuadType <long, long, long, long> > innerList;

            if (CollectionUtilities.isNotEmptyContainsKey(this.granularStoredProcCounts, userId))
            {
                innerList = this.granularStoredProcCounts[userId];
            }
            else
            {
                innerList = new List <QuadType <long, long, long, long> >();
                this.granularStoredProcCounts.Add(userId, innerList);
            }

            var procStats = new QuadType <long, long, long, long>(callPrep, callWait, callProcess, callTotal);

            innerList.Add(procStats);

            //Get the capture object
            CPNHSDataVO cvo = null;

            AddCaptureObject(CPNHSDataVO.PackDataType.GRANSTOREDPROC, userId, out cvo);

            //Fill in capture data
            cvo.PackType             |= CPNHSDataVO.PackDataType.GRANSTOREDPROC;
            cvo.PackType             |= CPNHSDataVO.PackDataType.DATAXFERIN;
            cvo.ClientProcName        = procName;
            cvo.ClientCallPrepTime    = callPrep;
            cvo.ClientCallProcessTime = callProcess;
            cvo.ClientCallTotalTime   = callTotal;
            cvo.ClientCallWaitTime    = callWait;
            cvo.NumberTransactionsIn += 1;
            cvo.TotalTimeTxferDataIn += callTotal;
            cvo.CurrentLatency       += callWait;
            //Must be in bytes per second
            cvo.CurrentDataRateIn += (decimal)dataTransferAmt / (callTotal * 1000);

            //Force this call through as we need every granular proc data point
            UpdateInternalData(userId, true);
        }
 public void SetQuadType(int x, int y, QuadType type)
 {
     _quads[x, y].quadType = type;
 }
 public void SetQuadType(Vector2 position, QuadType type)
 {
     SetQuadType((int)position.x, (int)position.y, type);
 }
예제 #8
0
 public Quad(Vector2 position, QuadType quadType)
 {
     _position = position;
     _quadType = quadType;
 }
예제 #9
0
        public xQuad(Device device, 
					float x, float y, float Width, float Height,
					Color color1, Color color2,
					Color color3, Color color4,
					QuadType type)
            : base(device)
        {
            SetDimensions(Width, Height, 0f);
            if(type == QuadType.Rectangle)
            {
                SetVertices(x, y, 0f, x + Width, y, 0f,
                x + Width, y + Height, 0f,
                x, y + Height, 0f);
            }
            SetAllColor(color1, color2, color3, color4);
            SetupColored();
            SetupIndices();
        }
예제 #10
0
        public xQuad(Device device, 
			float x, float y, float Width, float Height,
			Texture texture, QuadType type)
            : base(device)
        {
            SetDimensions(Width, Height, 0f);
            m_Texture = texture;
            if(type == QuadType.Rectangle)
            {
                SetVertices(x, y, 0f, x + Width, y, 0f,
                x + Width, y + Height, 0f,
                x, y + Height, 0f);

            }
            else if(type == QuadType.Square)
            {

                if(Width != Height)
                {
                    Height = Width;
                }

                SetVertices(x, y, 0f, x + Width, y, 0f,
                    x + Width, y + Height, 0f,
                    x, y + Height, 0f);

            }
            else if(type == QuadType.Diamond)
            {
                SetVertices(x + (Width * .5f), y, 0f,
                    x + Width, y + (Height * .5f), 0f,
                    x + (Width * .5f), y + Height, 0f,
                    x, y + (Height * .5f), 0f);
            }
            SetupTextured();
            SetupIndices();
        }
예제 #11
0
        public xQuad(Device device, 
			float x, float y, float Width, float Height,
			Color color, QuadType type)
            : base(device)
        {
            SetDimensions(Width, Height, 0f);
            if(type == QuadType.Rectangle)
            {
                SetVertices(x, y, 0f, x + Width, y, 0f,
                    x + Width, y + Height, 0f,
                    x, y + Height, 0f);
                Radius = x + Width / 2;
            }
            else if(type == QuadType.Square)
            {

                if(Width != Height)
                {
                    Height = Width;
                }

                SetVertices(x, y, 0f, x + Width, y, 0f,
                    x + Width, y + Height, 0f,
                    x, y + Height, 0f);

            }
            else if(type == QuadType.Diamond)
            {
                SetVertices(x + (Width * .5f), y, 0f,
                    x + Width, y + (Height * .5f), 0f,
                    x + (Width * .5f), y + Height, 0f,
                    x, y + (Height * .5f), 0f);
            }
            SetAllColor(color);
            SetupColored();
            SetupIndices();
        }
예제 #12
0
파일: Quad.cs 프로젝트: mdvulfix/SpaceGame
 public Quad GetChild(QuadType type)
 {
     return(_children[(int)type]);
 }
예제 #13
0
        private List <RegionQuadtree <T> > getAllWhoShareEdge(QuadDirection direction, QuadType type)
        {
            QuadDirection[] dir;
            var             op = QDO.OpSide(direction);

            if ((int)direction % 2 == 0)
            {
                dir = new QuadDirection[] { QDO.Quad(op, QDO.CSide(op)), QDO.Quad(op, QDO.CCSide(op)) };
            }
            else
            {
                dir = new QuadDirection[] { QDO.OpSide(op) };
            }

            if (type == QuadType.Grey)
            {
                throw new ArgumentException("Grey isn't allowed!");
            }

            var share = new List <RegionQuadtree <T> >();

            getAllWhoShareEdgeInternal(type, this, share, dir);

            return(share);
        }