Beispiel #1
0
        protected void AdjustVertices()
        {
            if (m_sp.Member == null)
            {
                return;
            }
            if (vertexBuffer == null)
            {
                return;
            }

            float[,] aUVs = GenerateUVs();

            ERectangleF rct = new ERectangleF(0, 0, 1, 1);

            CustomVertex[] vertices = null;
            try
            {
                vertices = vertexBuffer.Lock(0, 0) as CustomVertex[];
            }
            catch (Exception e)
            {
                //TODO: why does this happen??
                return;
                //throw new Exception("Failed to lock buffer...");
            }
            int nColor = System.Drawing.Color.FromArgb(255, 255, 0, 120).ToArgb();                //255,255,255,255

            vertices[0] = new CustomVertex(rct.Left, rct.Top, 0.0f, aUVs[0, 0], aUVs[0, 1]);      //,      nColor);
            vertices[1] = new CustomVertex(rct.Right, rct.Top, 0.0f, aUVs[1, 0], aUVs[1, 1]);     //,      nColor);
            vertices[2] = new CustomVertex(rct.Left, -rct.Bottom, 0.0f, aUVs[3, 0], aUVs[3, 1]);  //,nColor);
            vertices[3] = new CustomVertex(rct.Right, -rct.Bottom, 0.0f, aUVs[2, 0], aUVs[2, 1]); //,nColor);
            vertexBuffer.Unlock();
        }
Beispiel #2
0
 public Preview3D(CustomVertex.PositionNormalTextured[] Verts,Control handle,int Setup,PCCFile pcc)
 {
     verts = Verts;
     Pcc = pcc;
     if (verts.Length == 0)
         return;
     boxorigin = new Vector3(verts[0].X, verts[0].Y, verts[0].Z); ;
     box = new Vector3(verts[0].X, verts[0].Y, verts[0].Z); ;
     for (int i = 0; i < verts.Length; i++)
     {
         boxorigin.X = Math.Min(boxorigin.X, verts[i].X);
         boxorigin.Y = Math.Min(boxorigin.Y, verts[i].Y);
         boxorigin.Z = Math.Min(boxorigin.Z, verts[i].Z);
         box.X = Math.Max(box.X, verts[i].X);
         box.Y = Math.Max(box.Y, verts[i].Y);
         box.Z = Math.Max(box.Z, verts[i].Z);
     }
     box -= boxorigin;
     for (int i = 0; i < verts.Length; i++)
     {
         verts[i].X -= boxorigin.X + box.X / 2;
         verts[i].Y -= boxorigin.Y + box.Y / 2;
         verts[i].Z -= boxorigin.Z + box.Z / 2;
     }
     CamDistance = (float)Math.Sqrt(box.X * box.X + box.Y * box.Y + box.Z * box.Z);
     LoadBodySetup(BodySetup);
     init = InitializeGraphics(handle);
 }
        private void BtnAddEdge(object sender, RoutedEventArgs e)
        {
            CustomVertex vertexTo;

            if (targetVeritces.SelectedIndex == -1)
            {
                MessageBox.Show("You must select a source and a target vertex!");
            }
            else
            {
                vertexTo = new CustomVertex();
                vertexTo = (CustomVertex)targetVeritces.SelectedItem;

                string trigger = txtTrigger.Text.Trim();

                if (this.machine is FirstStateMachine)
                {
                    ((FirstStateMachine)this.machine).AddNewEdge(this.vertexFrom, trigger, vertexTo);
                    this.DataContext = this.machine.MyGraph;
                }
                else
                {
                    ((SecondStateMachine)this.machine).AddNewEdge(this.vertexFrom, trigger, vertexTo);
                    this.DataContext = this.machine.MyGraph;
                }
            }
        }
Beispiel #4
0
        public override void UnhideEdges(CustomVertex vertex, List <CustomEdge> edgesIn, List <CustomEdge> edgesOut)
        {
            if (vertex.BackgroundColor == Colors.Red || vertex.Display == false)
            {
                this.MyGraph.GetVertexByName(vertex.Text).BackgroundColor = Colors.Wheat;
                this.MyGraph.GetVertexByName(vertex.Text).Display         = true;
                for (int i = 0; i < edgesIn.Count; i++)
                {
                    if (string.Compare(edgesIn[i].Target.Text, vertex.Text) == 0 || string.Compare(edgesIn[i].Trigger, vertex.Text) == 0)
                    {
                        CustomEdge edge = new CustomEdge(edgesIn[i].Trigger, edgesIn[i].Source, edgesIn[i].Target);
                        this.MyGraph.AddEdge(edge);
                        edgesIn.Remove(edgesIn[i]);
                        i--;
                    }
                }

                int lenghtOut = edgesOut.Count;
                for (int i = 0; i < edgesOut.Count; i++)
                {
                    if (string.Compare(edgesOut[i].Source.Text, vertex.Text) == 0)
                    {
                        CustomEdge edge = new CustomEdge(edgesOut[i].Trigger, edgesOut[i].Source, edgesOut[i].Target);
                        this.MyGraph.AddEdge(edge);
                        edgesOut.Remove(edgesOut[i]);
                        i--;
                    }
                }
            }
            else
            {
                MessageBox.Show("Nothing to unhide!");
            }
        }
Beispiel #5
0
        /// <summary>
        /// Gets the nodes and represents them.
        /// </summary>
        public override void SetGraphNodes()
        {
            foreach (FSMState state in this.Configuration.ArrayOfFSMState)
            {
                CustomVertex vertex = new CustomVertex(state.Name, Colors.Wheat, true);
                this.MyGraph.AddVertex(vertex);
            }

            FSMTrigger t = new FSMTrigger();

            try
            {
                foreach (FSMState state in this.Configuration.ArrayOfFSMState)
                {
                    foreach (AllowedTrigger trigger in state.ArrayOfAllowedTrigger)
                    {
                        t = this.Configuration.FoundTriggerInList(trigger);
                        if (string.IsNullOrEmpty(trigger.TriggerName))
                        {
                            this.MyGraph.AddNewEdge(trigger.StateAndTriggerName, this.MyGraph.GetVertexByName(state.Name), this.MyGraph.GetVertexByName(trigger.StateAndTriggerName));
                        }
                        else
                        {
                            this.MyGraph.AddNewEdge(trigger.TriggerName, this.MyGraph.GetVertexByName(state.Name), this.MyGraph.GetVertexByName(trigger.StateName));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Beispiel #6
0
        /// <summary>
        /// Gets the nodes and represents them.
        /// </summary>
        public override void SetGraphNodes()
        {
            foreach (FSMState state in this.Configuration.ArrayOfFSMState)
            {
                CustomVertex vertex = new CustomVertex(state.Name, Colors.Wheat, true);
                this.MyGraph.AddVertex(vertex);
            }

            FSMTrigger t = new FSMTrigger();
            try
            {
                foreach (FSMState state in this.Configuration.ArrayOfFSMState)
                {
                    foreach (AllowedTrigger trigger in state.ArrayOfAllowedTrigger)
                    {
                        t = this.Configuration.FoundTriggerInList(trigger);
                        if (string.IsNullOrEmpty(trigger.TriggerName))
                        {
                            this.MyGraph.AddNewEdge(trigger.StateAndTriggerName, this.MyGraph.GetVertexByName(state.Name), this.MyGraph.GetVertexByName(trigger.StateAndTriggerName));
                        }
                        else
                        {
                            this.MyGraph.AddNewEdge(trigger.TriggerName, this.MyGraph.GetVertexByName(state.Name), this.MyGraph.GetVertexByName(trigger.StateName));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Beispiel #7
0
        public override void HideEdges(CustomVertex vertex, List <CustomEdge> edgesIn, List <CustomEdge> edgesOut)
        {
            if (vertex.BackgroundColor == Colors.Wheat || vertex.Display == true)
            {
                this.MyGraph.GetVertexByName(vertex.Text).BackgroundColor = Colors.Red;
                this.MyGraph.GetVertexByName(vertex.Text).Display         = false;
                IEnumerable <CustomEdge> collectionIn  = this.MyGraph.InEdges(vertex);
                IEnumerable <CustomEdge> collectionOut = this.MyGraph.OutEdges(vertex);
                foreach (var item in collectionIn)
                {
                    CustomEdge edge = new CustomEdge(item.Trigger, item.Source, item.Target);
                    edgesIn.Add(edge);
                }

                foreach (var item in collectionOut)
                {
                    CustomEdge edge = new CustomEdge(item.Trigger, item.Source, item.Target);
                    edgesOut.Add(edge);
                }

                this.MyGraph.ClearEdges(vertex);
            }
            else
            {
                MessageBox.Show("Already hidden!");
            }
        }
 /// <summary>
 /// Agregar triangulo al batch
 /// </summary>
 public void addTriangle(CustomVertex.PositionColored a, CustomVertex.PositionColored b, CustomVertex.PositionColored c)
 {
     vertices[idx] = a;
     vertices[idx + 1] = b;
     vertices[idx + 2] = c;
     idx += 3;
 }
Beispiel #9
0
    private void BtnAddEdge(object sender, RoutedEventArgs e)
    {
      CustomVertex vertexFrom;
      CustomVertex vertexTo;
      if (sourceVeritces.SelectedIndex == -1 || targetVeritces.SelectedIndex == -1)
      {
        MessageBox.Show("You must select a source and a target vertex!");
      }
      else
      {
        vertexFrom = new CustomVertex();
        vertexFrom = (CustomVertex)sourceVeritces.SelectedItem;
        vertexTo = new CustomVertex();
        vertexTo = (CustomVertex)targetVeritces.SelectedItem;

        string trigger = txtTrigger.Text.Trim();

        if (this.machine is FirstStateMachine)
        {
          ((FirstStateMachine)this.machine).AddNewEdge(vertexFrom, trigger, vertexTo);
          this.DataContext = this.machine.MyGraph;
        }
        else
        {
          ((SecondStateMachine)this.machine).AddNewEdge(vertexFrom, trigger, vertexTo);
          this.DataContext = this.machine.MyGraph;
        }
      }
    }
 public AdjustableQuad(CustomVertex.TransformedColoredTextured topLeft, CustomVertex.TransformedColoredTextured topRight,
     CustomVertex.TransformedColoredTextured bottomLeft, CustomVertex.TransformedColoredTextured bottomRight)
     : base(topLeft, topRight, bottomLeft, bottomRight)
 {
     fullwidthV = this.TWidth;
     fullwidthX = this.Width;
 }
Beispiel #11
0
        public override void UnhideEdges(CustomVertex vertex, List <CustomEdge> edgesIn, List <CustomEdge> edgesOut)
        {
            if (vertex.BackgroundColor == Colors.Red)
            {
                this.MyGraph.GetVertexByName(vertex.Text).BackgroundColor = Colors.Wheat;
                foreach (var item in edgesIn)
                {
                    if (string.Compare(item.Target.Text, vertex.Text) == 0)
                    {
                        CustomEdge edge = new CustomEdge(item.Trigger, item.Source, item.Target);
                        this.MyGraph.AddEdge(edge);
                    }
                }

                foreach (var item in edgesOut)
                {
                    if (string.Compare(item.Source.Text, vertex.Text) == 0)
                    {
                        CustomEdge edge = new CustomEdge(item.Trigger, item.Source, item.Target);
                        this.MyGraph.AddEdge(edge);
                    }
                }
            }
            else
            {
                MessageBox.Show("Nothing to unhide!");
            }
        }
Beispiel #12
0
        public bool Clip(int xStart, int yStart, int xWidth, int yHeight, CustomVertex.TransformedColoredTextured[] Vertices)
        {
            switch (this.Evaluate(xStart, yStart, xWidth, yHeight))
            {
                case ClipType.Outside:
                    return false;

                case ClipType.Inside:
                {
                    float num = -0.5f + xStart;
                    float num2 = -0.5f + yStart;
                    float num3 = num + xWidth;
                    float num4 = num2 + yHeight;
                    Vertices[0].X = Vertices[1].X = num3;
                    Vertices[0].Y = Vertices[2].Y = num4;
                    Vertices[1].Y = Vertices[3].Y = num2;
                    Vertices[2].X = Vertices[3].X = num;
                    Vertices[0].Tu = Vertices[0].Tv = Vertices[1].Tu = Vertices[2].Tv = 1f;
                    Vertices[1].Tv = Vertices[2].Tu = Vertices[3].Tu = Vertices[3].Tv = 0f;
                    return true;
                }
                case ClipType.Partial:
                {
                    int num5 = xStart;
                    int num6 = yStart;
                    int xEnd = xStart + xWidth;
                    int yEnd = yStart + yHeight;
                    if (xStart < this.m_xStart)
                    {
                        num5 = this.m_xStart;
                    }
                    if (yStart < this.m_yStart)
                    {
                        num6 = this.m_yStart;
                    }
                    if (xEnd > this.m_xEnd)
                    {
                        xEnd = this.m_xEnd;
                    }
                    if (yEnd > this.m_yEnd)
                    {
                        yEnd = this.m_yEnd;
                    }
                    Vertices[0].X = Vertices[1].X = -0.5f + xEnd;
                    Vertices[0].Y = Vertices[2].Y = -0.5f + yEnd;
                    Vertices[1].Y = Vertices[3].Y = -0.5f + num6;
                    Vertices[2].X = Vertices[3].X = -0.5f + num5;
                    double num9 = 1.0 / ((double) xWidth);
                    double num10 = 1.0 / ((double) yHeight);
                    Vertices[0].Tu = Vertices[1].Tu = (float) (num9 * (xEnd - xStart));
                    Vertices[0].Tv = Vertices[2].Tv = (float) (num10 * (yEnd - yStart));
                    Vertices[1].Tv = Vertices[3].Tv = (float) (num10 * (num6 - yStart));
                    Vertices[2].Tu = Vertices[3].Tu = (float) (num9 * (num5 - xStart));
                    return true;
                }
            }
            return false;
        }
        public List<CustomVertex.TransformedColored[]> Generator(CustomVertex.TransformedColored[] start, List<CustomVertex.TransformedColored[]> drawList)
        {
            Random rand = new Random();
            for (int i = 0; i < 30; i++)
            {
                CustomVertex.TransformedColored[] newBox = new CustomVertex.TransformedColored[5];
                for (int j = 0; j < newBox.Length; j++)
                {
                    newBox[j].Color = System.Drawing.Color.FromArgb(rand.Next(0, 255), rand.Next(0, 255), rand.Next(0, 255)).ToArgb();
                    newBox[j].X = start[j].X + (10 * i);
                    newBox[j].Y = start[j].Y + (10 * i);
                }

                drawList.Add(newBox);
            }

            for (int k = 0; k < 30; k++)
            {
                CustomVertex.TransformedColored[] newBox = new CustomVertex.TransformedColored[5];
                for (int j = 0; j < newBox.Length; j++)
                {
                    newBox[j].Color = System.Drawing.Color.FromArgb(rand.Next(0, 255), rand.Next(0, 255), rand.Next(0, 255)).ToArgb();
                    newBox[j].X = start[j].X - (10 * k);
                    newBox[j].Y = start[j].Y - (10 * k);
                }

                drawList.Add(newBox);
            }

            for (int m = 0; m < 30; m++)
            {
                CustomVertex.TransformedColored[] newBox = new CustomVertex.TransformedColored[5];
                for (int j = 0; j < newBox.Length; j++)
                {
                    newBox[j].Color = System.Drawing.Color.FromArgb(rand.Next(0, 255), rand.Next(0, 255), rand.Next(0, 255)).ToArgb();
                    newBox[j].X = start[j].X + (10 * m);
                    newBox[j].Y = start[j].Y - (10 * m);
                }

                drawList.Add(newBox);
            }

            for (int l = 0; l < 30; l++)
            {
                CustomVertex.TransformedColored[] newBox = new CustomVertex.TransformedColored[5];
                for (int j = 0; j < newBox.Length; j++)
                {
                    newBox[j].Color = System.Drawing.Color.FromArgb(rand.Next(0, 255), rand.Next(0, 255), rand.Next(0, 255)).ToArgb();
                    newBox[j].X = start[j].X - (10 * l);
                    newBox[j].Y = start[j].Y + (10 * l);
                }

                drawList.Add(newBox);
            }

            return drawList;
        }
Beispiel #14
0
        public void pt(ref CustomVertex.PositionNormal ret, int u, int v)
        {
            ret.X = 1.0f * (float)Math.Sin((float)u * Math.PI / (float)usteps);
            ret.Y = 1.0f * (float)Math.Cos((float)u * Math.PI / (float)usteps);
            ret.Z = 2.0f * ((float)v / (float)vsteps) - 1.0f;// (float)Math.Cos((float)v * Math.PI / (float)vsteps);

            ret.Nx = ret.X;
            ret.Ny = ret.Y;
            ret.Nz = ret.Z;
        }
 private static void BuildRingOnZ(CustomVertex.PositionColored[] verts, int index, int clr, Vector2[] points)
 {
     int pIdx = 0;
     for (int i = index; i < index + points.Length; i++)
     {
         verts[i] = new CustomVertex.PositionColored(points[pIdx].X, points[pIdx].Y, 0, clr);
         pIdx++;
     }
     verts[index + points.Length] = new CustomVertex.PositionColored(points[0].X, points[0].Y, 0, clr);
 }
Beispiel #16
0
 /// <summary>Creates a new Quad</summary>
 /// <param name="topLeft">Top left vertex.</param>
 /// <param name="topRight">Top right vertex.</param>
 /// <param name="bottomLeft">Bottom left vertex.</param>
 /// <param name="bottomRight">Bottom right vertex.</param>
 public Quad(CustomVertex.TransformedColoredTextured topLeft, CustomVertex.TransformedColoredTextured topRight,
     CustomVertex.TransformedColoredTextured bottomLeft, CustomVertex.TransformedColoredTextured bottomRight)
 {
     m_vertices = new CustomVertex.TransformedColoredTextured[6];
     m_vertices[0] = topLeft;
     m_vertices[1] = bottomRight;
     m_vertices[2] = bottomLeft;
     m_vertices[3] = topLeft;
     m_vertices[4] = topRight;
     m_vertices[5] = bottomRight;
 }
Beispiel #17
0
        public override void UpdatePosition(ref CustomVertex.TransformedColored vt, ref myownvertexformat Particle,int i)
        {
            vt.X += Particle.speed.X + this.world.gravityX;
                vt.Y += Particle.speed.Y + (this.world.gravityY * Particle.lifecount/5f);

                Particle.lifecount++;
                if (Particle.lifecount >= Particle.lifetime )
                {
                    this.remove_particle(i);

                }
        }
        private CustomVertex CreateFlexVertex(float X, float Y, float Z, float rhw, float tu, float tv)
        {
            CustomVertex custVertex = new CustomVertex();

            custVertex.X   = X;
            custVertex.Y   = Y;
            custVertex.Z   = Z;
            custVertex.rhw = rhw;
            custVertex.tu  = tu;
            custVertex.tv  = tv;
            return(custVertex);
        }
Beispiel #19
0
        private CustomVertex CreateFlexVertex(float X, float Y, float Z, float rhw, float tu, float tv)
        {
            CustomVertex cv = new CustomVertex();

            cv.X   = X;
            cv.Y   = Y;
            cv.Z   = Z;
            cv.rhw = rhw;
            cv.tu  = tu;
            cv.tv  = tv;
            return(cv);
        }
Beispiel #20
0
        public CustomVertex AddVertex(Object node)
        {
            CustomVertex v = nodeVertices[node] as CustomVertex;

            if (v != null)
            {
                return(v);
            }
            v       = (CustomVertex)this.graph.AddVertex();
            v.Value = node;
            this.nodeVertices.Add(node, v);
            return(v);
        }
Beispiel #21
0
 public OneTriangle(Device device, CallOfCS cocs, CustomVertex.PositionNormalTextured first, CustomVertex.PositionNormalTextured second, CustomVertex.PositionNormalTextured third)
     : base(device,cocs,0,0,0)
 {
     verts = new CustomVertex.PositionNormalTextured[3];
     verts[0] = first;
     verts[1] = second;
     verts[2] = third;
     this.center = new Vector3((first.X+second.X+third.X)/3,(first.Y+second.Y+third.Y)/3,(first.Z+second.Z+third.Z)/3);
     vBuff = new VertexBuffer(typeof(CustomVertex.PositionNormalTextured), 3, device, Usage.None, CustomVertex.PositionNormalTextured.Format, Pool.Managed);
     vBuff.SetData(verts,0,LockFlags.None);
     this.count = 1;
     this.type = PrimitiveType.TriangleList;
 }
Beispiel #22
0
        protected void AdjustVertices(ERectangleF rctfCropped)
        {
            if (_sp != null)
            {
                if (_sp.Member == null)
                {
                    return;
                }
                rctfCropped = _sp.GetPortionOfMemberToDisplay();
            }
            else
            {
                if (rctfCropped == null)
                {
                    rctfCropped = new ERectangleF(0, 0, 1, 1);
                }
            }

            if (_vertexBuffer == null)
            {
                return;
            }

            float[,] aUVs = GenerateUVs(rctfCropped);


            CustomVertex[] vertices = null;
            try
            {
                vertices = _vertexBuffer.Lock(0, 0) as CustomVertex[];
            }
            catch (Exception e)
            {
                //TODO: why does this happen??
                Console.WriteLine(e.Message);
                return;
                //throw new Exception("Failed to lock buffer...");
            }
            //ERectangleF rct = new ERectangleF(0, 0, 1, 1);
            //int nColor = System.Drawing.Color.FromArgb(255,255,0,120).ToArgb(); //255,255,255,255
            //vertices[0] = new CustomVertex(rct.Left,		rct.Top, 0.0f, aUVs[0,0], aUVs[0,1]);//,      nColor);
            //vertices[1] = new CustomVertex(rct.Right,	rct.Top, 0.0f, aUVs[1,0], aUVs[1,1]);//,      nColor);
            //vertices[2] = new CustomVertex(rct.Left,		-rct.Bottom, 0.0f, aUVs[3,0], aUVs[3,1]);//,nColor);
            //vertices[3] = new CustomVertex(rct.Right,	-rct.Bottom, 0.0f, aUVs[2,0], aUVs[2,1]);//,nColor);
            vertices[0] = new CustomVertex(0f, 0f, 0.0f, aUVs[0, 0], aUVs[0, 1]);
            vertices[1] = new CustomVertex(1f, 0f, 0.0f, aUVs[1, 0], aUVs[1, 1]);
            vertices[2] = new CustomVertex(0f, -1f, 0.0f, aUVs[3, 0], aUVs[3, 1]);
            vertices[3] = new CustomVertex(1f, -1f, 0.0f, aUVs[2, 0], aUVs[2, 1]);
            _vertexBuffer.Unlock();
        }
        public TerrainPatch(DivisibleTerrain father, CustomVertex.PositionTextured[] data, TgcBoundingBox bb)
        {
            this.father = father;
            totalVertices = data.Length;
            this.BoundingBox = bb;
            this.vbTerrainPatch  = new VertexBuffer(typeof(CustomVertex.PositionTextured), data.Length, GuiController.Instance.D3dDevice, Usage.Dynamic | Usage.WriteOnly, CustomVertex.PositionTextured.Format, Pool.Default);
            this.Effect = father.Effect;
            this.Technique = father.Technique;
            this.Enabled = father.Enabled;
            this.RenderBB = false;
            vbTerrainPatch.SetData(data, 0, LockFlags.None);

            
        }
Beispiel #24
0
 public BinaryTriangleTree(CustomVertex.PositionTextured[] ElevatedVertices, int VertexDensity, // must be a power of 2
     int Margin, double LayerRadius)
 {
     this._elevatedVertices = ElevatedVertices;
     this._vertexDensity = VertexDensity;
     this._margin = Margin;
     this._layerRadius = LayerRadius;
     this._verticeDensity = this._margin + this._vertexDensity + this._margin + 1;
     // indices to four corners vertices of terrain (inside walls/margin)
     this.nw = (short) ((this._margin*this._verticeDensity) + this._margin);
     this.sw = (short) (nw + (short) (this._vertexDensity*this._verticeDensity));
     this.ne = (short) (nw + (short) (this._vertexDensity));
     this.se = (short) (sw + (short) (this._vertexDensity));
 }
Beispiel #25
0
        public override string DeleteEdge(string sourceText, string targetText)
        {
            CustomVertex source = this.MyGraph.GetVertexByName(sourceText);
            CustomVertex target = this.MyGraph.GetVertexByName(targetText);

            if (source == null)
            {
                return(string.Format("Vertex with name {0} doesn't exist!", sourceText));
            }

            if (target == null)
            {
                return(string.Format("Vertex with name {0} doesn't exist!", targetText));
            }

            if (source.CompareTo(target))
            {
                if (this.MyGraph.RemoveItselfEdge(source))
                {
                    return("Edge to " + sourceText + " succesfully deleted!");
                }
            }
            else
            {
                foreach (var item in this.Configuration.ArrayOfFSMState)
                {
                    if (string.Compare(item.Name, sourceText) == 0)
                    {
                        foreach (var it in item.ArrayOfAllowedTrigger.ToList())
                        {
                            if (string.Compare(it.StateAndTriggerName, targetText) == 0 || string.Compare(it.StateName, targetText) == 0)
                            {
                                item.ArrayOfAllowedTrigger.Remove(it);
                            }
                        }
                    }
                }

                this.MyGraph.RemoveEdgeIf(v => v.Source.Text.Equals(source.Text) && v.Target.Text.Equals(target.Text));
                return(string.Format("Successfully deleted an edge between {0} and {1}", source.Text, target.Text));
            }

            return(string.Format("This edge doesn't exist!"));
        }
        public AddEdgeToWindow(StateMachine fsm, CustomVertex vertex)
            : this()
        {
            this.vertexFrom = new CustomVertex();
            if (fsm is FirstStateMachine)
            {
                this.machine = new FirstStateMachine(fsm.CurrentVersion);
            }
            else
            {
                if (fsm is SecondStateMachine)
                {
                    this.machine = new SecondStateMachine(fsm.CurrentVersion);
                }
            }

            this.machine     = fsm;
            this.vertexFrom  = vertex;
            this.DataContext = this.machine.MyGraph;
        }
    public AddEdgeToWindow(StateMachine fsm, CustomVertex vertex)
      : this()
    {
      this.vertexFrom = new CustomVertex();
      if (fsm is FirstStateMachine)
      {
        this.machine = new FirstStateMachine(fsm.CurrentVersion);
      }
      else
      {
        if (fsm is SecondStateMachine)
        {
          this.machine = new SecondStateMachine(fsm.CurrentVersion);
        }
      }

      this.machine = fsm;
      this.vertexFrom = vertex;
      this.DataContext = this.machine.MyGraph;
    }
Beispiel #28
0
        /// <summary>
        /// Adds a new edge, a new allowed trigger to source vertex, a new trigger if it doesn't exist.
        /// </summary>
        /// <param name="vertexFrom">The vertex from.</param>
        /// <param name="trigger">The trigger.</param>
        /// <param name="vertexTo">The vertex to.</param>
        public override void AddNewEdge(CustomVertex vertexFrom, string trigger, CustomVertex vertexTo)
        {
            FSMVState      state = new FSMVState();
            AllowedTrigger aw    = new AllowedTrigger();
            FSMVTrigger    trig  = new FSMVTrigger();

            state.Name = vertexFrom.Text;
            if (string.IsNullOrEmpty(trigger))
            {
                CustomEdge edge = new CustomEdge(vertexTo.Text, vertexFrom, vertexTo);
                this.MyGraph.AddNewEdge(vertexTo.Text, vertexFrom, vertexTo);
                aw.StateAndTriggerName = trig.CommonID = vertexTo.Text;
            }
            else
            {
                CustomEdge edge = new CustomEdge(trigger, vertexFrom, vertexTo);
                this.MyGraph.AddNewEdge(vertexTo.Text, vertexFrom, vertexTo);
                aw.StateName    = vertexTo.Text;
                aw.TriggerName  = trigger;
                trig.Name       = vertexTo.Text;
                trig.SequenceID = trigger;
            }

            foreach (var item in this.Configuration.ArrayOfFSMVState)
            {
                if (item.Name == state.Name)
                {
                    if (item.ArrayOfAllowedTrigger == null)
                    {
                        item.ArrayOfAllowedTrigger = new Collection <AllowedTrigger>();
                    }

                    item.ArrayOfAllowedTrigger.Add(aw);
                    break;
                }
            }

            this.Configuration.AddNewTrigger(trig);
        }
Beispiel #29
0
        /// <summary>
        /// Adds a new state.
        /// </summary>
        /// <param name="stateName">Name of the state.</param>
        /// <param name="stateDefaultHandler">The state default handler.</param>
        /// <param name="stateReentryTrigger">The state reentry trigger.</param>
        /// <returns></returns>
        public override string AddNewState(string stateName, string stateDefaultHandler, string stateReentryTrigger)
        {
            if (!string.IsNullOrEmpty(stateName))
            {
                if (this.MyGraph.Vertices.Where(v => string.Compare(v.Text.ToLower(), stateName.ToLower()) == 0).FirstOrDefault() != null)
                {
                    return(string.Format("A vertex with the name {0} already exists in the graph!", stateName));
                }
                else
                {
                    CustomVertex vertex = new CustomVertex(stateName, Colors.Wheat, true);
                    FSMState     state  = new FSMState();
                    state.Name                = stateName;
                    state.DefaultHandler      = stateDefaultHandler;
                    state.ReentryUsingTrigger = stateReentryTrigger;
                    this.Configuration.ArrayOfFSMState.Add(state);
                    this.MyGraph.AddVertex(vertex);
                    return(string.Format("Vertex {0} successfully added!", stateName));
                }
            }

            return("Please complete the fields first!");
        }
Beispiel #30
0
        public override string DeleteVertex(string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return("Invalid name \n It cannot be empty!");
            }

            CustomVertex vertex = this.MyGraph.GetVertexByName(text);

            if (vertex == null)
            {
                return(string.Format("A vertex with name {0} doesn't exist in the graph!", text));
            }

            foreach (var item in this.Configuration.ArrayOfFSMState)
            {
                if (string.Compare(item.Name, text) == 0)
                {
                    this.Configuration.ArrayOfFSMState.Remove(item);
                    break;
                }
            }

            this.MyGraph.RemoveVertex(vertex);
            foreach (var item in this.Configuration.ArrayOfFSMState)
            {
                foreach (var it in item.ArrayOfAllowedTrigger.ToList())
                {
                    if (string.Compare(it.StateAndTriggerName, vertex.Text) == 0 || string.Compare(it.StateName, vertex.Text) == 0)
                    {
                        item.ArrayOfAllowedTrigger.Remove(it);
                    }
                }
            }

            return(string.Format("Successfully deleted vertex {0}!", text));
        }
Beispiel #31
0
    void Start()
    {
        _material       = new Material(material);
        _material.name += " (clone)";

        CustomVertex[] points = new CustomVertex[vertexCount];
        vertexBuffer     = new ComputeBuffer(vertexCount, Marshal.SizeOf(typeof(CustomVertex)), ComputeBufferType.Default);
        vertexBufferOrig = new ComputeBuffer(vertexCount, Marshal.SizeOf(typeof(CustomVertex)), ComputeBufferType.Default);

        Random.InitState(0);

        Vector3 p0off = Vector3.zero, p1off = Vector3.zero, p2off = Vector3.zero;

        p0off.x = twidth;
        p1off.y = twidth;
        p2off.x = -twidth;
        Vector3 position   = Vector3.zero;
        Color   startColor = Color.black;
        int     v;

        for (int t = 0; t < triangleCount; t++)
        {
            position.x = Random.Range(-range, range);
            position.y = Random.Range(-range, range);

            v = t * 3;

            points[v + 0].position = position + p0off;
            points[v + 0].color    = startColor;
            points[v + 1].position = position + p1off;
            points[v + 1].color    = startColor;
            points[v + 2].position = position + p2off;
            points[v + 2].color    = startColor;
        }
        vertexBuffer.SetData(points);
        vertexBufferOrig.SetData(points);
    }
Beispiel #32
0
		/// <summary>
		/// Creates a textured rectangle from a rectangle structure.
		/// </summary>
		/// <param name="verts">The destination vertices.</param>
		/// <param name="index">The start index in the destination vertices.</param>
		/// <param name="rect">The source rectangle structure.</param>
		public static void CreateTexturedRectangle(CustomVertex.PositionNormalTextured[] verts, int index, RectangleF rect) {
			verts[index].Position = new Vector3(rect.X, rect.Y, 0);
			verts[index].Normal = new Vector3(0, 0, -1);
			verts[index].Tu = 0;
			verts[index].Tv = 0;

			verts[index+1].Position = new Vector3(rect.X, rect.Y + rect.Height, 0);
			verts[index+1].Normal = new Vector3(0, 0, -1);
			verts[index+1].Tu = 0;
			verts[index+1].Tv = 1;

			verts[index+2].Position = new Vector3(rect.X + rect.Width, rect.Y + rect.Height, 0);
			verts[index+2].Normal = new Vector3(0, 0, -1);
			verts[index+2].Tu = 1;
			verts[index+2].Tv = 1;

			verts[index+3].Position = new Vector3(rect.X, rect.Y, 0);
			verts[index+3].Normal = new Vector3(0, 0, -1);
			verts[index+3].Tu = 0;
			verts[index+3].Tv = 0;

			verts[index+4].Position = new Vector3(rect.X + rect.Width, rect.Y + rect.Height, 0);
			verts[index+4].Normal = new Vector3(0, 0, -1);
			verts[index+4].Tu = 1;
			verts[index+4].Tv = 1;

			verts[index+5].Position = new Vector3(rect.X + rect.Width, rect.Y, 0);
			verts[index+5].Normal = new Vector3(0, 0, -1);
			verts[index+5].Tu = 1;
			verts[index+5].Tv = 0;
		}
Beispiel #33
0
		/// <summary>
		/// Creates a line from the given points.
		/// </summary>
		/// <param name="verts">The destination vertices.</param>
		/// <param name="index">The start index in the destination vertices.</param>
		/// <param name="x1">The x-coordinate of the first point.</param>
		/// <param name="y1">The y-coordinate of the first point..</param>
		/// <param name="x2">The x-coordinate of the second point.</param>
		/// <param name="y2">The y-coordinate of the second point.</param>
		/// <param name="color">The color of the vertices.</param>
		static internal void CreateColoredLine(CustomVertex.PositionColored[] verts, int index, float x1, float y1, float x2, float y2, int color) {
			verts[index+0].Position = new Vector3(x1, y1, 0);
			verts[index+1].Position = new Vector3(x2, y2, 0);

			verts[index+0].Color = color;
			verts[index+1].Color = color;
		}
Beispiel #34
0
		/// <summary>
		/// Creates a colored vertex list from the points array.
		/// </summary>
		/// <param name="verts">The destination vertices.</param>
		/// <param name="points">The source points array.</param>
		/// <param name="srcIndex">The start index in the source array.</param>
		/// <param name="dstIndex">The start index in the destination vertices.</param>
		/// <param name="count">The number of vertices to copy.</param>
		/// <param name="color">The color of the vertices.</param>
		static internal void CreateColoredVertexList(CustomVertex.PositionColored[] verts, PointF[] points, int srcIndex, int dstIndex, int count, int color) {
			for (int i = 0; i < count; i++) {
				PointF point = points[i+srcIndex];
				verts[i+dstIndex].Position = new Vector3(point.X, point.Y, 0);
				verts[i+dstIndex].Color = color;
			}
		}
Beispiel #35
0
		/// <summary>
		/// Creates a colored rectangle from a rectangle structure.
		/// </summary>
		/// <param name="verts">The destination vertices.</param>
		/// <param name="index">The start index in the destination vertices.</param>
		/// <param name="x">The x-coordinate of the source rectangle.</param>
		/// <param name="y">The y-coordinate of the source rectangle.</param>
		/// <param name="width">The width of the source rectangle.</param>
		/// <param name="height">The height of the source rectangle.</param>
		/// <param name="color">The color of the vertices.</param>
		public static void CreateColoredRectangle(CustomVertex.PositionColored[] verts, int index, float x, float y, float width, float height, int color) {
			verts[index+0].Position = new Vector3(x, y, 0);
			verts[index+1].Position = new Vector3(x, y + height, 0);
			verts[index+2].Position = new Vector3(x + width, y + height, 0);
			verts[index+3].Position = new Vector3(x, y, 0);
			verts[index+4].Position = new Vector3(x + width, y + height, 0);
			verts[index+5].Position = new Vector3(x + width, y, 0);

			for (int i=index; i<index+6; i++) {
				verts[i].Color = color;
			}
		}
Beispiel #36
0
		/// <summary>
		///Creates a rectangle line strip from a rectangle structure.
		/// </summary>
		/// <param name="verts">The destination vertices.</param>
		/// <param name="index">The start index in the destination vertices.</param>
		/// <param name="rect">The source rectangle structure.</param>
		/// <param name="color">The color of the vertices.</param>
		public static void CreateColoredRectangleOutline(CustomVertex.PositionColored[] verts, int index, RectangleF rect, int color) {
			verts[index+0].Position = new Vector3(rect.X, rect.Y, 0);
			verts[index+1].Position = new Vector3(rect.X, rect.Y + rect.Height, 0);
			verts[index+2].Position = new Vector3(rect.X + rect.Width, rect.Y + rect.Height, 0);
			verts[index+3].Position = new Vector3(rect.X + rect.Width, rect.Y, 0);
			verts[index+4].Position = new Vector3(rect.X, rect.Y, 0);

			for (int i=index; i<index+5; i++) {
				verts[i].Color = color;
			}
		}
Beispiel #37
0
        private Result InitGeometry()
        {
            CustomVertex[] vertices = new CustomVertex[]
            {
                //new CustomVertex(){Pos=new Vector3(-1.0f, 1.0f,0.0f),Tex=new Vector2(0.0f,0.0f)},    // top left
                //new CustomVertex(){Pos=new Vector3( 1.0f, 1.0f,0.0f),Tex=new Vector2(1.0f,0.0f)},    // top right
                //new CustomVertex(){Pos=new Vector3(-1.0f,-1.0f,0.0f),Tex=new Vector2(0.0f,1.0f)},    // lower left
                //new CustomVertex(){Pos=new Vector3( 1.0f,-1.0f,0.0f),Tex=new Vector2(1.0f,1.0f)},    // lower right

                new CustomVertex()
                {
                    Pos = new Vector3(-1.0f, 1.0f, 0.0f), Tex = new Vector2(0.0f, 0.0f)
                },                                                                                          // top left
                new CustomVertex()
                {
                    Pos = new Vector3(0.0f, 1.0f, 0.0f), Tex = new Vector2(1.0f, 0.0f)
                },                                                                                           // top right
                new CustomVertex()
                {
                    Pos = new Vector3(-1.0f, 0.0f, 0.0f), Tex = new Vector2(0.0f, 1.0f)
                },                                                                                         // lower left
                new CustomVertex()
                {
                    Pos = new Vector3(0.0f, 0.0f, 0.0f), Tex = new Vector2(1.0f, 1.0f)
                },                                                                                          // lower right

                new CustomVertex()
                {
                    Pos = new Vector3(0.0f, 1.0f, 0.0f), Tex = new Vector2(0.0f, 0.0f)
                },                                                                                          // top left
                new CustomVertex()
                {
                    Pos = new Vector3(1.0f, 1.0f, 0.0f), Tex = new Vector2(1.0f, 0.0f)
                },                                                                                           // top right
                new CustomVertex()
                {
                    Pos = new Vector3(0.0f, 0.0f, 0.0f), Tex = new Vector2(0.0f, 1.0f)
                },                                                                                         // lower left
                new CustomVertex()
                {
                    Pos = new Vector3(1.0f, 0.0f, 0.0f), Tex = new Vector2(1.0f, 1.0f)
                },                                                                                          // lower right

                new CustomVertex()
                {
                    Pos = new Vector3(-1.0f, 0.0f, 0.0f), Tex = new Vector2(0.0f, 0.0f)
                },                                                                                          // top left
                new CustomVertex()
                {
                    Pos = new Vector3(0.0f, 0.0f, 0.0f), Tex = new Vector2(1.0f, 0.0f)
                },                                                                                           // top right
                new CustomVertex()
                {
                    Pos = new Vector3(-1.0f, -1.0f, 0.0f), Tex = new Vector2(0.0f, 1.0f)
                },                                                                                         // lower left
                new CustomVertex()
                {
                    Pos = new Vector3(0.0f, -1.0f, 0.0f), Tex = new Vector2(1.0f, 1.0f)
                },                                                                                          // lower right

                new CustomVertex()
                {
                    Pos = new Vector3(0.0f, 0.0f, 0.0f), Tex = new Vector2(0.0f, 0.0f)
                },                                                                                          // top left
                new CustomVertex()
                {
                    Pos = new Vector3(1.0f, 0.0f, 0.0f), Tex = new Vector2(1.0f, 0.0f)
                },                                                                                           // top right
                new CustomVertex()
                {
                    Pos = new Vector3(0.0f, -1.0f, 0.0f), Tex = new Vector2(0.0f, 1.0f)
                },                                                                                         // lower left
                new CustomVertex()
                {
                    Pos = new Vector3(1.0f, -1.0f, 0.0f), Tex = new Vector2(1.0f, 1.0f)
                },                                                                                          // lower right
            };
            _VertexStride = System.Runtime.InteropServices.Marshal.SizeOf(vertices[0]);
            _VertexBuffer = new VertexBuffer(_Device, vertices.Length * _VertexStride, Usage.None, CUSTOMVERTEXFORMAT, Pool.Default);
            if (Result.Last.IsFailure)
            {
                return(Result.Last);
            }
            _VertexBuffer.Lock(0, 0, LockFlags.None).WriteRange(vertices);
            if (Result.Last.IsFailure)
            {
                return(Result.Last);
            }
            _VertexBuffer.Unlock();
            return(Result.Last);
        }
Beispiel #38
0
		/// <summary>
		/// Creates a colored rectangle from a rectangle structure.
		/// </summary>
		/// <param name="verts">The destination vertices.</param>
		/// <param name="index">The start index in the destination vertices.</param>
		/// <param name="rect">The source rectangle structure.</param>
		/// <param name="color">The color of the vertices.</param>
		public static void CreateColoredRectangle(CustomVertex.PositionColored[] verts, int index, RectangleF rect, int color) {
			CreateColoredRectangle(verts, index, rect.X, rect.Y, rect.Width, rect.Height, color);
		}
 private void SquareVertices(CustomVertex[] vertices)
 {
     // Create a square, composed of 2 triangles
     vertices[0] = CreateFlexVertex(60, 60, 0, 1, Color.FromArgb((int)Red1.Value, (int)Green1.Value, (int)Blue1.Value), 0, 0);
     vertices[1] = CreateFlexVertex(240, 60, 0, 1, Color.FromArgb((int)Red2.Value, (int)Green2.Value, (int)Blue2.Value), 1, 0);
     vertices[2] = CreateFlexVertex(60, 240, 0, 1, Color.FromArgb((int)Red3.Value, (int)Green3.Value, (int)Blue3.Value), 0, 1);
     vertices[3] = CreateFlexVertex(240, 240, 0, 1, Color.FromArgb((int)Red4.Value, (int)Green4.Value, (int)Blue4.Value), 1, 1);
 }
Beispiel #40
0
        /// <summary>
        /// Crear los vértices de la línea con valores extremos especificados
        /// </summary>
        private void createLineVertices(CustomVertex.PositionColored[] vertices, int idx, Vector3 min, Vector3 max, int c)
        {
            // Front face
            vertices[idx] = new CustomVertex.PositionColored(min.X, max.Y, max.Z, c);
            vertices[idx + 1] = new CustomVertex.PositionColored(min.X, min.Y, max.Z, c);
            vertices[idx + 2] = new CustomVertex.PositionColored(max.X, max.Y, max.Z, c);
            vertices[idx + 3] = new CustomVertex.PositionColored(min.X, min.Y, max.Z, c);
            vertices[idx + 4] = new CustomVertex.PositionColored(max.X, min.Y, max.Z, c);
            vertices[idx + 5] = new CustomVertex.PositionColored(max.X, max.Y, max.Z, c);

            // Back face (remember this is facing *away* from the camera, so vertices should be clockwise order)
            vertices[idx + 6] = new CustomVertex.PositionColored(min.X, max.Y, min.Z, c);
            vertices[idx + 7] = new CustomVertex.PositionColored(max.X, max.Y, min.Z, c);
            vertices[idx + 8] = new CustomVertex.PositionColored(min.X, min.Y, min.Z, c);
            vertices[idx + 9] = new CustomVertex.PositionColored(min.X, min.Y, min.Z, c);
            vertices[idx + 10] = new CustomVertex.PositionColored(max.X, max.Y, min.Z, c);
            vertices[idx + 11] = new CustomVertex.PositionColored(max.X, min.Y, min.Z, c);

            // Top face
            vertices[idx + 12] = new CustomVertex.PositionColored(min.X, max.Y, max.Z, c);
            vertices[idx + 13] = new CustomVertex.PositionColored(max.X, max.Y, min.Z, c);
            vertices[idx + 14] = new CustomVertex.PositionColored(min.X, max.Y, min.Z, c);
            vertices[idx + 15] = new CustomVertex.PositionColored(min.X, max.Y, max.Z, c);
            vertices[idx + 16] = new CustomVertex.PositionColored(max.X, max.Y, max.Z, c);
            vertices[idx + 17] = new CustomVertex.PositionColored(max.X, max.Y, min.Z, c);

            // Bottom face (remember this is facing *away* from the camera, so vertices should be clockwise order)
            vertices[idx + 18] = new CustomVertex.PositionColored(min.X, min.Y, max.Z, c);
            vertices[idx + 19] = new CustomVertex.PositionColored(min.X, min.Y, min.Z, c);
            vertices[idx + 20] = new CustomVertex.PositionColored(max.X, min.Y, min.Z, c);
            vertices[idx + 21] = new CustomVertex.PositionColored(min.X, min.Y, max.Z, c);
            vertices[idx + 22] = new CustomVertex.PositionColored(max.X, min.Y, min.Z, c);
            vertices[idx + 23] = new CustomVertex.PositionColored(max.X, min.Y, max.Z, c);

            // Left face
            vertices[idx + 24] = new CustomVertex.PositionColored(min.X, max.Y, max.Z, c);
            vertices[idx + 25] = new CustomVertex.PositionColored(min.X, min.Y, min.Z, c);
            vertices[idx + 26] = new CustomVertex.PositionColored(min.X, min.Y, max.Z, c);
            vertices[idx + 27] = new CustomVertex.PositionColored(min.X, max.Y, min.Z, c);
            vertices[idx + 28] = new CustomVertex.PositionColored(min.X, min.Y, min.Z, c);
            vertices[idx + 29] = new CustomVertex.PositionColored(min.X, max.Y, max.Z, c);

            // Right face (remember this is facing *away* from the camera, so vertices should be clockwise order)
            vertices[idx + 30] = new CustomVertex.PositionColored(max.X, max.Y, max.Z, c);
            vertices[idx + 31] = new CustomVertex.PositionColored(max.X, min.Y, max.Z, c);
            vertices[idx + 32] = new CustomVertex.PositionColored(max.X, min.Y, min.Z, c);
            vertices[idx + 33] = new CustomVertex.PositionColored(max.X, max.Y, min.Z, c);
            vertices[idx + 34] = new CustomVertex.PositionColored(max.X, max.Y, max.Z, c);
            vertices[idx + 35] = new CustomVertex.PositionColored(max.X, min.Y, min.Z, c);
        }
Beispiel #41
0
        protected virtual void CreateMesh(GeographicBoundingBox geographicBoundingBox, int meshPointCount, ref CustomVertex.PositionColoredTextured[] vertices, ref short[] indices)
        {
            int upperBound = meshPointCount - 1;
            float scaleFactor = (float)1/upperBound;
            double latrange = Math.Abs(geographicBoundingBox.North - geographicBoundingBox.South);
            double lonrange;
            if(geographicBoundingBox.West < geographicBoundingBox.East)
                lonrange = geographicBoundingBox.East - geographicBoundingBox.West;
            else
                lonrange = 360.0f + geographicBoundingBox.East - geographicBoundingBox.West;

            double layerRadius = m_parentProjectedLayer.World.EquatorialRadius;

            int opacityColor = System.Drawing.Color.FromArgb(
                //m_parentProjectedLayer.Opacity,
                0,0,0).ToArgb();
            vertices = new CustomVertex.PositionColoredTextured[meshPointCount * meshPointCount];
            for(int i = 0; i < meshPointCount; i++)
            {
                for(int j = 0; j < meshPointCount; j++)
                {
                    double height = 0;
                    if(m_parentProjectedLayer.World.TerrainAccessor != null)
                        height = m_verticalExaggeration * m_parentProjectedLayer.World.TerrainAccessor.GetElevationAt(
                            (double)geographicBoundingBox.North - scaleFactor * latrange * i,
                            (double)geographicBoundingBox.West + scaleFactor * lonrange * j,
                            (double)upperBound / latrange);

                    Point3d pos = MathEngine.SphericalToCartesian(
                        geographicBoundingBox.North - scaleFactor*latrange*i,
                        geographicBoundingBox.West + scaleFactor*lonrange*j,
                        layerRadius + height);

               vertices[i * meshPointCount + j].X = (float)pos.X;
               vertices[i * meshPointCount + j].Y = (float)pos.Y;
               vertices[i * meshPointCount + j].Z = (float)pos.Z;

                    vertices[i*meshPointCount + j].Tu = j*scaleFactor;
                    vertices[i*meshPointCount + j].Tv = i*scaleFactor;
                    vertices[i*meshPointCount + j].Color = opacityColor;
                }
            }

            indices = new short[2 * upperBound * upperBound * 3];
            for(int i = 0; i < upperBound; i++)
            {
                for(int j = 0; j < upperBound; j++)
                {
                    indices[(2*3*i*upperBound) + 6*j] = (short)(i*meshPointCount + j);
                    indices[(2*3*i*upperBound) + 6*j + 1] = (short)((i+1)*meshPointCount + j);
                    indices[(2*3*i*upperBound) + 6*j + 2] = (short)(i*meshPointCount + j+1);

                    indices[(2*3*i*upperBound) + 6*j + 3] = (short)(i*meshPointCount + j+1);
                    indices[(2*3*i*upperBound) + 6*j + 4] = (short)((i+1)*meshPointCount + j);
                    indices[(2*3*i*upperBound) + 6*j + 5] = (short)((i+1)*meshPointCount + j+1);
                }
            }
        }
Beispiel #42
0
        void graphviz_FormatVertex(object sender, FormatVertexEventArgs e)
        {
            CustomVertex vertex = (CustomVertex)e.Vertex;

            e.VertexFormatter.Label = String.Format("{0}", vertex.Value);
        }
Beispiel #43
0
 /// <summary>
 /// Updates a vertex that has not been created with the provider
 /// </summary>
 /// <param name="v">vertex to update</param>
 public void UpdateVertex(CustomVertex v)
 {
     v.ID = m_NextID++;
 }
Beispiel #44
0
 /// <summary>
 /// Crear linea en Z
 /// </summary>
 private void createLineZ(CustomVertex.PositionColored[] vertices, int idx, int color, Vector3 min, Vector3 max)
 {
     Vector3 min2 = new Vector3(min.X - thickness, min.Y - thickness, min.Z);
     Vector3 max2 = new Vector3(max.X + thickness, max.Y + thickness, max.Z);
     createLineVertices(vertices, idx, min2, max2, color);
 }
 public RenderDataSource(string name, CustomVertex.PositionNormalColored[] vertices, ushort[] indices)
 {
     this.name = name;
     this.vertices = vertices;
     this.indices = indices;
 }
 private CustomVertex CreateFlexVertex(float X, float Y, float Z, float rhw, Color color, float tu, float tv)
 {
     CustomVertex custVertex = new CustomVertex();
     custVertex.X = X;
     custVertex.Y = Y;
     custVertex.Z = Z;
     custVertex.rhw = rhw;
     custVertex.color = color.ToArgb();
     custVertex.tu = tu;
     custVertex.tv = tv;
     return custVertex;
 }
 private CustomVertex CreateFlexVertex(float X, float Y, float Z, float rhw, float tu, float tv)
 {
     CustomVertex cv = new CustomVertex();
     cv.X = X;
     cv.Y = Y;
     cv.Z = Z;
     cv.rhw = rhw;
     cv.tu = tu;
     cv.tv = tv;
     return cv;
 }
Beispiel #48
0
        public PrimitiveShape(CustomVertex.PositionColored[] vertices)
        {
            Vertices = new CustomVertex.PositionColored[vertices.Length];

            for (int i = 0; i < vertices.Length; i++)
                Vertices[i] = vertices[i];
        }
 private void SquareVertices(CustomVertex[] vertices)
 {
     // Create a square, composed of 2 triangles
     vertices[0] = CreateFlexVertex(60, 60, 0, 1, 0, 0);
     vertices[1] = CreateFlexVertex(240, 60, 0, 1, 1, 0);
     vertices[2] = CreateFlexVertex(60, 240, 0, 1, 0, 1);
     vertices[3] = CreateFlexVertex(240, 240, 0, 1, 1, 1);
 }