public void FillTriangle(Vector2 point1, Vector2 point2, Vector2 point3, Color4 color)
        {
            Prepare(BlendMode.Normal, dot);

            vertices[vertexCount++] = new Vertex2D(
                point1,
                Vector2.Zero,
                color
                );
            vertices[vertexCount++] = new Vertex2D(
                point2,
                Vector2.Zero,
                color
                );
            vertices[vertexCount++] = new Vertex2D(
                point3,
                Vector2.Zero,
                color
                );
            vertices[vertexCount++] = new Vertex2D(
                point3,
                Vector2.Zero,
                color
                );

            primitiveCount += 2;
        }
예제 #2
0
        public static void ClosestPointOnPolygon(RenderVertex3D[] rgv, Vertex2D pvin, bool fClosed, out Vertex2D pvOut, out int piSeg)
        {
            var count   = rgv.Length;
            var minDist = Constants.FloatMax;

            piSeg = -1;             // in case we are not next to the line
            pvOut = new Vertex2D();
            var loopCount = count;

            if (!fClosed)
            {
                --loopCount;                 // Don"t check segment running from the end point to the beginning point
            }

            // Go through line segment, calculate distance from point to the line
            // then pick the shortest distance
            for (var i = 0; i < loopCount; ++i)
            {
                var p2 = i < count - 1 ? i + 1 : 0;

                var rgvi = new RenderVertex3D();
                rgvi.Set(rgv[i].X, rgv[i].Y, rgv[i].Z);
                var rgvp2 = new RenderVertex3D();
                rgvp2.Set(rgv[p2].X, rgv[p2].Y, rgv[p2].Z);
                var a = rgvi.Y - rgvp2.Y;
                var b = rgvp2.X - rgvi.X;
                var c = -(a * rgvi.X + b * rgvi.Y);

                var dist = MathF.Abs(a * pvin.X + b * pvin.Y + c) / MathF.Sqrt(a * a + b * b);

                if (dist < minDist)
                {
                    // Assuming we got a segment that we are closet to, calculate the intersection
                    // of the line with the perpendicular line projected from the point,
                    // to find the closest point on the line
                    var d = -b;
                    var f = -(d * pvin.X + a * pvin.Y);

                    var det        = a * a - b * d;
                    var invDet     = det != 0.0f ? 1.0f / det : 0.0f;
                    var intersectX = (b * f - a * c) * invDet;
                    var intersectY = (c * d - a * f) * invDet;

                    // If the intersect point lies on the polygon segment
                    // (not out in space), then make this the closest known point
                    if (intersectX >= MathF.Min(rgvi.X, rgvp2.X) - 0.1 &&
                        intersectX <= MathF.Max(rgvi.X, rgvp2.X) + 0.1 &&
                        intersectY >= MathF.Min(rgvi.Y, rgvp2.Y) - 0.1 &&
                        intersectY <= MathF.Max(rgvi.Y, rgvp2.Y) + 0.1)
                    {
                        minDist = dist;
                        var seg = i;

                        pvOut.X = intersectX;
                        pvOut.Y = intersectY;
                        piSeg   = seg;
                    }
                }
            }
        }
예제 #3
0
 public HitCircle(Vertex2D center, float radius, float zLow, float zHigh, ItemType itemType, IItem item) : base(itemType, item)
 {
     Center        = center;
     Radius        = radius;
     HitBBox.ZLow  = zLow;
     HitBBox.ZHigh = zHigh;
 }
예제 #4
0
 /// <summary>
 /// Add vertex to last layout's set
 /// </summary>
 /// <param name="vertex2D"></param>
 public void AddVertex(Vertex2D vertex2D)
 {
     if (vertex2D.VertexType != VertexType.Spline)
     {
         this.vertex2Ds.Last().Add(vertex2D);
     }
 }
예제 #5
0
        protected Dictionary <Vertex2D, VertexNetwork2D> BuildTable(Triangulation2D tri)
        {
            var table     = new Dictionary <Vertex2D, VertexNetwork2D>();
            var triangles = tri.Triangles;

            for (int i = 0, n = triangles.Length; i < n; i++)
            {
                var      t = triangles[i];
                Vertex2D a = t.a, b = t.b, c = t.c;
                if (!table.ContainsKey(a))
                {
                    table.Add(a, new VertexNetwork2D(a, ExternalPoint(a)));
                }
                if (!table.ContainsKey(b))
                {
                    table.Add(b, new VertexNetwork2D(b, ExternalPoint(b)));
                }
                if (!table.ContainsKey(c))
                {
                    table.Add(c, new VertexNetwork2D(c, ExternalPoint(c)));
                }
            }
            // tri.Points.ForEach(p => {
            // if(!table.ContainsKey(p)) table.Add(p, new VertexNetwork2D(p, ExternalPoint(p)));
            // });
            return(table);
        }
예제 #6
0
        public MeshContainer(double[,] point, int[,] element)
        {
            _vertex   = new List <Vertex2D>();
            _edge     = new List <Edge2D>();
            _triangle = new List <Triangle2D>();

            for (int n = 0; n < point.GetLength(0); n++)
            {
                Vertex2D v = AddVertex(point[n, 0], point[n, 1]);
                v.extID = n + 1;
            }

            for (int n = 0; n < element.GetLength(0); n++)
            {
                Vertex2D v1 = _vertex.Find(item => item.extID == element[n, 0]);
                Vertex2D v2 = _vertex.Find(item => item.extID == element[n, 1]);
                Vertex2D v3 = _vertex.Find(item => item.extID == element[n, 2]);

                Triangle2D t = new Triangle2D(v1, v2, v3);
                t.extID = n + 1;

                _triangle.Add(t);

                t.E1 = AddEdgeIfNotExist(v1, v2);
                t.E2 = AddEdgeIfNotExist(v2, v3);
                t.E3 = AddEdgeIfNotExist(v3, v1);
            }
        }
예제 #7
0
        /// <summary>
        /// Get info about new vertex
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        private Vertex2D GetNewVertex(MouseEventArgs e)
        {
            Color    color       = e.Button == MouseButtons.Left ? this.colorsControl.MainColor.ColorEditor : this.colorsControl.ExtendColor.ColorEditor;
            Vertex2D visualPoint = null;
            float    oXCoord     = ((float)e.X - openGLControl.Width / 2) / (openGLControl.Width / 2);
            float    oYCoord     = -((float)e.Y - openGLControl.Height / 2) / (openGLControl.Height / 2);

            switch (paintStyle.Value)
            {
            case PaintStyle.Eraser:
                visualPoint = new Eraser(baseColor, oXCoord, oYCoord);
                break;

            case PaintStyle.Brush:
                visualPoint = new OpenGlElements.Brush(color, oXCoord, oYCoord);
                break;

            case PaintStyle.Pencil:
                visualPoint = new Vertex2D(color, oXCoord, oYCoord);
                break;

            case PaintStyle.Image:
                visualPoint = new OpenGlElements.Image(Properties.Resources.fox, openGLControl.OpenGL, oXCoord, oYCoord);
                break;

            case PaintStyle.Sign:
                visualPoint = new OpenGlElements.Image(Properties.Resources.sign, openGLControl.OpenGL, oXCoord, oYCoord);
                break;

            case PaintStyle.Spline:
                visualPoint = new Spline(color, oXCoord, oYCoord);
                break;
            }
            return(visualPoint);
        }
예제 #8
0
        // https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line
        protected float Distance(Segment2D line, Vertex2D v)
        {
            Vector2 a = line.a.Coordinate, b = line.b.Coordinate, p = v.Coordinate;
            float   dx = (b.x - a.x), dy = (b.y - a.y);

            return(Mathf.Abs((dy * p.x) - (dx * p.y) + (b.x * a.y) - (b.y * a.x)) / Mathf.Sqrt(dy * dy + dx * dx));
        }
예제 #9
0
        public static bool CheckAndSortVertexSequence(ref Vertex2D p1, ref Vertex2D p2, ref Vertex2D p3)
        {
            // p1,p2,p3在同一水平面上,这时三角形看起来就是一条线,可以不画它;
            if (p1.y == p2.y && p1.y == p3.y)
            {
                return(false);
            }
            // p1,p2,p3在同一垂直面上,同上;
            if (p1.x == p2.x && p1.x == p3.x)
            {
                return(false);
            }
            // 按y轴坐标从上到下(从小到大)进行排序;
            Vertex2D tempSort;

            if (p3.y < p2.y)
            {
                tempSort = p2;
                p2       = p3;
                p3       = tempSort;
            }
            if (p3.y < p1.y)
            {
                tempSort = p1;
                p1       = p3;
                p3       = tempSort;
            }
            if (p2.y < p1.y)
            {
                tempSort = p1;
                p1       = p2;
                p2       = tempSort;
            }
            return(true);
        }
예제 #10
0
 public Quadrangle(Vertex2D a, Vertex2D b, Vertex2D c, Vertex2D d)
 {
     A = a;
     B = b;
     C = c;
     D = d;
 }
예제 #11
0
        public void DrawVerticalGradient(Rectangle rect, Color4 top, Color4 bottom)
        {
            if (rs.ScissorEnabled && !scissorUsed)
            {
                Flush();
                scissorUsed = true;
            }
            Prepare(BlendMode.Normal, dot, false);
            var x = (float)rect.X;
            var y = (float)rect.Y;
            var w = (float)rect.Width;
            var h = (float)rect.Height;

            vertices[vertexCount++] = new Vertex2D(
                new Vector2(x, y),
                noTex,
                top
                );
            vertices[vertexCount++] = new Vertex2D(
                new Vector2(x + w, y),
                noTex,
                top
                );
            vertices[vertexCount++] = new Vertex2D(
                new Vector2(x, y + h),
                noTex,
                bottom
                );
            vertices[vertexCount++] = new Vertex2D(
                new Vector2(x + w, y + h),
                noTex,
                bottom
                );
            primitiveCount += 2;
        }
예제 #12
0
        public override float HitTest(Ball ball, float dTime, CollisionEvent coll, PlayerPhysics physics)
        {
            if (!IsEnabled)
            {
                return(-1.0f);
            }

            // transform ball to cylinder coordinate system
            var oldPos = ball.State.Pos.Clone();
            var oldVel = ball.Hit.Vel.Clone();

            ball.State.Pos.ApplyMatrix2D(Matrix);
            ball.State.Pos.ApplyMatrix2D(Matrix);

            // and update z bounds of LineZ with transformed coordinates
            var oldZ = new Vertex2D(HitBBox.ZLow, HitBBox.ZHigh);

            HitBBox.ZLow  = ZLow;            // HACK; needed below // evil cast to non-const, should actually change the stupid HitLineZ to have explicit z coordinates!
            HitBBox.ZHigh = ZHigh;           // dto.

            var hitTime = base.HitTest(ball, dTime, coll, physics);

            ball.State.Pos.Set(oldPos.X, oldPos.Y, oldPos.Z); // see above
            ball.Hit.Vel.Set(oldVel.X, oldVel.Y, oldVel.Z);
            HitBBox.ZLow  = oldZ.X;                           // HACK
            HitBBox.ZHigh = oldZ.Y;                           // dto.

            if (hitTime >= 0)
            {
                // transform hit normal back to world coordinate system
                coll.HitNormal.Set(Matrix.MultiplyVectorT(coll.HitNormal));
            }

            return(hitTime);
        }
예제 #13
0
 public VertexNetwork2D(Vertex2D vertex, bool contour)
 {
     this.vertex     = vertex;
     this.height     = 0f;
     this.contour    = this.elevated = contour;
     this.connection = new HashSet <VertexNetwork2D>();
 }
예제 #14
0
 public Chord2D(Vertex2D src, Vertex2D dst, Face2D face)
 {
     this.src        = src;
     this.dst        = dst;
     this.face       = face;
     this.connection = new List <Chord2D>();
 }
예제 #15
0
        /// <summary>
        /// Returns the hit line polygons for the surface.
        /// </summary>
        private void GenerateLinePolys(RenderVertex2D pv1, Vertex2D pv2, float playfieldHeight, ICollection <ICollider> colliders)
        {
            var bottom = _component.HeightBottom + playfieldHeight;
            var top    = _component.HeightTop + playfieldHeight;

            if (!pv1.IsSlingshot)
            {
                colliders.Add(new LineCollider(pv1.ToUnityFloat2(), pv2.ToUnityFloat2(), bottom, top, _api.GetColliderInfo()));
            }
            else
            {
                colliders.Add(new LineSlingshotCollider(_colliderComponent.SlingshotForce, pv1.ToUnityFloat2(), pv2.ToUnityFloat2(), bottom, top, _api.GetColliderInfo()));
            }

            if (_component.HeightBottom != 0)
            {
                // add lower edge as a line
                colliders.Add(new Line3DCollider(new float3(pv1.X, pv1.Y, bottom), new float3(pv2.X, pv2.Y, bottom), _api.GetColliderInfo()));
            }

            // add upper edge as a line
            colliders.Add(new Line3DCollider(new float3(pv1.X, pv1.Y, top), new float3(pv2.X, pv2.Y, top), _api.GetColliderInfo()));

            // create vertical joint between the two line segments
            colliders.Add(new LineZCollider(pv1.ToUnityFloat2(), bottom, top, _api.GetColliderInfo()));

            // add upper and lower end points of line
            if (_component.HeightBottom != 0)
            {
                colliders.Add(new PointCollider(new float3(pv1.X, pv1.Y, bottom), _api.GetColliderInfo()));
            }

            colliders.Add(new PointCollider(new float3(pv1.X, pv1.Y, top), _api.GetColliderInfo()));
        }
예제 #16
0
        /// <summary>
        /// Add new layout's set and add vertex to one
        /// </summary>
        /// <param name="vertex2D"></param>
        public void AddNewSet(Vertex2D vertex2D)
        {
            IVisualSet visualSet = null;

            switch (vertex2D.VertexType)
            {
            case VertexType.Vertex:
                visualSet = new SimpleSet();
                break;

            case VertexType.Brush:
                visualSet = new BrushSet();
                break;

            case VertexType.Eraser:
                visualSet = new EraserSet();
                break;

            case VertexType.Image:
                visualSet = new ImageSet();
                break;

            case VertexType.Spline:
                visualSet           = IsInstrumentChanged ? new SplineSet() : vertex2Ds.Last(x => x is SplineSet);
                IsInstrumentChanged = false;
                break;
            }

            visualSet?.Add(vertex2D);
            if (visualSet != null)
            {
                vertex2Ds.Add(visualSet);
            }
        }
        public void DrawVerticalGradient(Rectangle rect, Color4 top, Color4 bottom)
        {
            Prepare(BlendMode.Normal, dot);
            var x = (float)rect.X;
            var y = (float)rect.Y;
            var w = (float)rect.Width;
            var h = (float)rect.Height;

            vertices[vertexCount++] = new Vertex2D(
                new Vector2(x, y),
                Vector2.Zero,
                top
                );
            vertices[vertexCount++] = new Vertex2D(
                new Vector2(x + w, y),
                Vector2.Zero,
                top
                );
            vertices[vertexCount++] = new Vertex2D(
                new Vector2(x, y + h),
                Vector2.Zero,
                bottom
                );
            vertices[vertexCount++] = new Vertex2D(
                new Vector2(x + w, y + h),
                Vector2.Zero,
                bottom
                );
            primitiveCount += 2;
        }
예제 #18
0
        public void FillRectangleColors(RectangleF rec, Color4 tl, Color4 tr, Color4 bl, Color4 br)
        {
            Prepare(BlendMode.Normal, dot, false);

            float x = (float)rec.X;
            float y = (float)rec.Y;
            float w = (float)rec.Width;
            float h = (float)rec.Height;

            vertices [vertexCount++] = new Vertex2D(
                new Vector2(x, y),
                Vector2.Zero,
                tl
                );
            vertices [vertexCount++] = new Vertex2D(
                new Vector2(x + w, y),
                Vector2.Zero,
                tr
                );
            vertices [vertexCount++] = new Vertex2D(
                new Vector2(x, y + h),
                Vector2.Zero,
                bl
                );
            vertices [vertexCount++] = new Vertex2D(
                new Vector2(x + w, y + h),
                Vector2.Zero,
                br
                );

            primitiveCount += 2;
        }
예제 #19
0
        private void SetCellColorByMode(Vertex2D pos)
        {
            CellStates cellMode = GetSelectedCellStateMode();

            UpdateStartOrTargetByMode(pos, cellMode);
            gridMaze.SetCellColorAtPosition(pos, GetCellColorByMode(cellMode));
        }
예제 #20
0
        public RenderPipeline(GraphicsContext gfx, int max_vertex_count, Rect render_area)
        {
            this.render_surfaces = new RenderSurface[5];

            AddSurface(render_area, "MainSurface");

            this.max_vertex_count = max_vertex_count;

            vertices = new Vertex2D[max_vertex_count];

            indices = new ushort[max_vertex_count / 4 * 6];

            ushort indice_i = 0;

            for (var i = 0; i < indices.Length; i += 6, indice_i += 4)
            {
                indices[i + 0] = (ushort)(indice_i + 0);
                indices[i + 1] = (ushort)(indice_i + 1);
                indices[i + 2] = (ushort)(indice_i + 2);
                indices[i + 3] = (ushort)(indice_i + 0);
                indices[i + 4] = (ushort)(indice_i + 2);
                indices[i + 5] = (ushort)(indice_i + 3);
            }

            this.gfx = gfx;

            ImplInitialize();
        }
예제 #21
0
 public HitCircle(Vertex2D center, float radius, float zLow, float zHigh)
 {
     Center        = center;
     Radius        = radius;
     HitBBox.ZLow  = zLow;
     HitBBox.ZHigh = zHigh;
 }
        void Flush()
        {
            if (vertexCount == 0 || primitiveCount == 0)
            {
                return;
            }
            rs.Cull         = false;
            rs.BlendMode    = currentMode;
            rs.DepthEnabled = false;
            currentTexture.BindTo(0);
            if (currentTexture.Format == SurfaceFormat.R8)
            {
                imgShader.SetFloat(blendLocation, 1f);
            }
            else
            {
                imgShader.SetFloat(blendLocation, 0f);
            }
            var verts = new Vertex2D[vertexCount];

            for (int i = 0; i < vertexCount; i++)
            {
                verts[i] = vertices[i];
            }
            vbo.EndStreaming(vertexCount);
            vbo.Draw(PrimitiveTypes.TriangleList, primitiveCount);
            vertices       = (Vertex2D *)vbo.BeginStreaming();
            vertexCount    = 0;
            primitiveCount = 0;
            currentTexture = null;
            rs.Cull        = true;
        }
예제 #23
0
        /// <summary>
        /// 判断顶点是否可以分割
        /// </summary>
        /// <param name="node"></param>
        private static void UpdateVertexSeparableStatus(LinkedListNode <Vertex2D> node)
        {
            Vertex2D current = node.Value;
            Vertex2D prev    = node.Previous != null ? node.Previous.Value : node.List.Last.Value;
            Vertex2D next    = node.Next != null ? node.Next.Value : node.List.First.Value;

            //如果当前点与前后点是同一个点,则当前点直接可分割
            if (current == prev || current == next || prev == next)//prev == next 存疑
            {
                current.IsSeparable = true;
                return;
            }

            //如果当前点与前后点在同一直线上,则当前点直接可分割
            if (IsThreeVertexInLine(current, prev, next))
            {
                current.IsSeparable = true;
                return;
            }

            //判断当前点的凹凸性
            current.IsConvex = IsVertexConvex(prev, current, next);
            if (!current.IsConvex)//凹点绝对不可分
            {
                current.IsSeparable = false;
            }
            else//凸点需要进一步判断三角形内部是否存在内点,有内点则不可分
            {
                bool triangleHasInnerPoint = IsTriangleHasInnerPoint(current, prev, next, node.List);
                current.IsSeparable = !triangleHasInnerPoint;
            }
        }
예제 #24
0
        public static void DrawTriangle(Matrix4 transMat, Vertex v0, Vertex v1, Vertex v2,
                                        Texture tex, int width, int height, RenderType rt, List <IPosLight> lights, AddPixelHandler handler)
        {
            Camera camera = Camera.Default;

            if (null == camera)
            {
                return;
            }
            // 将3d坐标投影到2d空间;
            Vertex2D p0 = BuildVertex2D(v0, transMat, camera.Pos, lights, width, height);
            Vertex2D p1 = BuildVertex2D(v1, transMat, camera.Pos, lights, width, height);
            Vertex2D p2 = BuildVertex2D(v2, transMat, camera.Pos, lights, width, height);

            switch (rt)
            {
            case RenderType.WireFrame:
                // 计算线段;
                Line.DrawLine(p0, p1, handler, DrawLineType.Bresenham, SoftDevice.Default.ZTest);
                Line.DrawLine(p1, p2, handler, DrawLineType.Bresenham, SoftDevice.Default.ZTest);
                Line.DrawLine(p2, p0, handler, DrawLineType.Bresenham, SoftDevice.Default.ZTest);
                break;

            case RenderType.Solid:
                // 填充三角形;
                _VertexPragma(tex, p0, p1, p2, handler);
                break;
            }
        }
        public void DrawLine(Color4 color, Vector2 start, Vector2 end)
        {
            Prepare(BlendMode.Normal, dot);

            var edge  = end - start;
            var angle = (float)Math.Atan2(edge.Y, edge.X);
            var sin   = (float)Math.Sin(angle);
            var cos   = (float)Math.Cos(angle);
            var x     = start.X;
            var y     = start.Y;
            var w     = edge.Length();

            vertices[vertexCount++] = new Vertex2D(
                new Vector2(x, y),
                Vector2.Zero,
                color
                );
            vertices[vertexCount++] = new Vertex2D(
                new Vector2(x + w * cos, y + (w * sin)),
                Vector2.Zero,
                color
                );
            vertices[vertexCount++] = new Vertex2D(
                new Vector2(x - sin, y + cos),
                Vector2.Zero,
                color
                );
            vertices[vertexCount++] = new Vertex2D(
                new Vector2(x + w * cos - sin, y + w * sin + cos),
                Vector2.Zero,
                color
                );

            primitiveCount += 2;
        }
예제 #26
0
        public LineSeg[] GenerateLineSegs(float height, Vertex2D tangent, IItem item)
        {
            if (_gateData.TwoWay)
            {
                return(new LineSeg[0]);
            }

            var halfLength = _gateData.Length * 0.5f;
            var angleMin   = MathF.Min(_gateData.AngleMin, _gateData.AngleMax);           // correct angle inversions
            var angleMax   = MathF.Max(_gateData.AngleMin, _gateData.AngleMax);

            _gateData.AngleMin = angleMin;
            _gateData.AngleMax = angleMax;

            // oversize by the ball's radius to prevent the ball from clipping through
            var rgv = new[] {
                _gateData.Center.Clone().Add(tangent.Clone().MultiplyScalar(halfLength + PhysicsConstants.PhysSkin)),
                _gateData.Center.Clone().Sub(tangent.Clone().MultiplyScalar(halfLength + PhysicsConstants.PhysSkin)),
            };
            var lineSeg = new LineSeg(rgv[0], rgv[1], height, height + 2.0f * PhysicsConstants.PhysSkin, ItemType.Gate, item);             //!! = ball diameter

            lineSeg.SetElasticity(_gateData.Elasticity);
            lineSeg.SetFriction(_gateData.Friction);

            return(new[] { lineSeg });
        }
예제 #27
0
        /// <summary>
        /// 三点组成的两个向量的叉积,两向量分别为前点指向后点
        /// </summary>
        /// <param name="currentVertex"></param>
        /// <param name="previeVertex"></param>
        /// <param name="nextVertex"></param>
        /// <returns></returns>
        private static double CrossProductOfThreePoints(Vertex2D currentVertex, Vertex2D previeVertex, Vertex2D nextVertex)
        {
            Vector vector1 = VertexToVector(previeVertex, currentVertex);
            Vector vector2 = VertexToVector(currentVertex, nextVertex);

            return(Vector.CrossProduct(vector1, vector2));
        }
예제 #28
0
파일: Mesh2D.cs 프로젝트: NMO13/SolidTurn
 public void AddVertex(Vertex2D v)
 {
     Vertex2D res;
     if (!m_Vertices.TryGetValue(v, out res))
     {
         m_Vertices.Add(v, v);
     }
 }
예제 #29
0
 public Parallelogram(Vertex2D a, Vertex2D b, Vertex2D c)
 {
     A = a;
     B = b;
     C = c;
     D = new Vertex2D(a.X - b.X + c.X,
                      a.Y - b.Y + c.Y);
 }
예제 #30
0
 public FlipperState(string name, bool isVisible, float angle, Vertex2D center, string material, string texture, string rubberMaterial) : base(name, isVisible)
 {
     Angle          = angle;
     Center         = center;
     Material       = material;
     Texture        = texture;
     RubberMaterial = rubberMaterial;
 }
예제 #31
0
 /// <summary>
 /// 将给定两个定点转为矢量
 /// </summary>
 /// <param name="vertex1"></param>
 /// <param name="vertex2"></param>
 /// <returns></returns>
 private static Vector VertexToVector(Vertex2D vertex1, Vertex2D vertex2)
 {
     return(new Vector()
     {
         X = vertex2.X - vertex1.X,
         Y = vertex2.Y - vertex1.Y
     });
 }
예제 #32
0
파일: Mesh2D.cs 프로젝트: NMO13/SolidTurn
 public void CreateLine(Vertex2D v0, Vertex2D v1)
 {
     if (!m_Vertices.TryGetValue(v0, out v0))
         throw new Exception("Vertex was not found in dictionary");
     if (!m_Vertices.TryGetValue(v1, out v1))
         throw new Exception("Vertex was not found in dictionary");
     Line line = new Line(new Vector2D(v0.x, v0.y), new Vector2D(v1.x, v1.y));
     m_Lines.Add(line);
 }
예제 #33
0
        public void AddLines(SharpDX.Mathematics.Interop.RawVector2[] pointsRef)
        {
            for (int i = 0; i < pointsRef.Length; i++)
            {
                Vertex2D v = new Vertex2D();
                v.pt = pointsRef[i];

                m_figureVertices.Add(v);

                /*if (m_figureVertices.Count > 0)
                {

                }*/
            }
        }
예제 #34
0
파일: MapNodes.cs 프로젝트: ago1024/ElTools
 public POINode(ClusteredMap map, Vertex2D location)
     : base(map, location)
 {
 }
예제 #35
0
파일: 3DBuild.cs 프로젝트: marazahar/Alex3D
 public void ReadObjFile(string path, string pathTextureMap)
 {
     FileStream myStream = new FileStream(path, FileMode.Open);
     StreamReader myReader = new StreamReader(myStream);
     textureMap = (Bitmap)Image.FromFile(pathTextureMap);
     List<Vertex> verticesTemp = new List<Vertex>();
     List<Triangle> trianglesTemp = new List<Triangle>();
     List<Vertex2D> textureCoordinatesTemp = new List<Vertex2D>();
     string line = null;
     while ((line = myReader.ReadLine()) != null)
     {
         if (line != "")
         {
             char indicator1 = line[0];
             char indicator2 = line[1];
             if (indicator2 == 'n')
             {
                 indicator1 = 'n';
             }
             if (indicator2 == 't')
             {
                 indicator1 = 't';
             }
             string[] array = new string[3];
             string[] array1 = new string[6];
             double[] coord = new double[3];
             int[] tri = new int[3];
             int[] tex = new int[3];
             switch (indicator1)
             {
                 case 'v':
                     {
                         line = line.Trim('v', ' ');
                         array = line.Split(' ');
                         for (int i = 0; i < 3; i++)
                         {
                             coord[i] = double.Parse(array[i].Replace(".", ","));
                         }
                         Vertex v = new Vertex(coord[0], coord[1], coord[2]);
                         verticesTemp.Add(v);
                         break;
                     }
                 case 'f':
                     {
                         line = line.Trim('f', ' ');
                         array1 = line.Split(' ', '/');
                         for (int j = 0, i = 0; j < array1.Length; j++)
                         {
                             if (array1[j] != "")
                             {
                                 array1[i] = array1[j];
                                 i++;
                             }
                         }
                         for (int i = 0, j = 0; i < 3 && j < array1.Length; i++, j += 3)
                         {
                             tri[i] = int.Parse(array1[j]);
                             tex[i] = int.Parse(array1[j + 1]);
                         }
                         Triangle t = new Triangle(tri[0], tri[1], tri[2], tex[0], tex[1], tex[2]);
                         trianglesTemp.Add(t);
                     }
                     break;
                 case 't':
                     {
                         line = line.Trim('t', 'v', ' ');
                         array = line.Split(' ');
                         for (int i = 0; i < 2; i++)
                         {
                             coord[i] = double.Parse(array[i].Replace(".", ","));
                         }
                         Vertex2D v = new Vertex2D(coord[0], coord[1]);
                         textureCoordinatesTemp.Add(v);
                     }
                     break;
             }
         }
     }
     vertices = verticesTemp;
     triangles = trianglesTemp;
     textureCoordinates = textureCoordinatesTemp;
 }
예제 #36
0
파일: MapNodes.cs 프로젝트: ago1024/ElTools
 public MapNode(ClusteredMap map, short x, short y)
 {
     this.map = map;
     this.location = new Vertex2D(x, y);
 }
예제 #37
0
파일: MapNodes.cs 프로젝트: ago1024/ElTools
 public MapNode(ClusteredMap map, Vertex2D location)
 {
     this.map = map;
     this.location = location;
 }
예제 #38
0
파일: MapNodes.cs 프로젝트: ago1024/ElTools
 public UseTeleportNode(ClusteredMap map, Vertex2D location, MapNode target, short useObject, short useWithObject)
     : base(map, location, target)
 {
     this.useObject = useObject;
     this.useWithObject = useWithObject;
 }
예제 #39
0
파일: MapNodes.cs 프로젝트: ago1024/ElTools
 public TeleportPadNode(ClusteredMap map, short x, short y, short padx, short pady, ClusteredMap destMap, short destX, short destY)
     : base(map, x, y, destMap, destX, destY)
 {
     this.padLocation = new Vertex2D(padx, pady);
 }
예제 #40
0
파일: MapNodes.cs 프로젝트: ago1024/ElTools
 public TeleportPadNode(ClusteredMap map, Vertex2D location, MapNode target, Vertex2D padLocation)
     : base(map, location, target)
 {
     this.padLocation = padLocation;
 }
예제 #41
0
파일: MapNodes.cs 프로젝트: ago1024/ElTools
 public BeamMeNode(ClusteredMap map, Vertex2D location, MapNode target)
     : base(map, location, target)
 {
 }
예제 #42
0
        public void BeginFigure(SharpDX.Mathematics.Interop.RawVector2 startPoint, FigureBegin figureBegin)
        {
            this.m_figureVertices.Clear();

            Vertex2D v = new Vertex2D()
            {
                pt = startPoint,
                inter1 = Vector2.Zero,
                inter2 = Vector2.Zero,
                norm = Vector2.Zero
            };
            this.m_figureVertices.Add(v);
        }
예제 #43
0
파일: MapNodes.cs 프로젝트: ago1024/ElTools
 public TeleportNode(ClusteredMap map, Vertex2D location, MapNode target)
     : base(map, location)
 {
     this.target = target;
 }