예제 #1
0
파일: GlMesh.cs 프로젝트: yusitnikov/magnus
 protected void addCylinder(Color color, GlIndexedVertex[] circle1, GlIndexedVertex[] circle2)
 {
     for (var i = 1; i <= circle1.Length; i++)
     {
         int             i1 = i - 1, i2 = i % circle1.Length;
         GlIndexedVertex p1 = circle1[i1], p2 = circle1[i2], p3 = circle2[i2], p4 = circle2[i1];
         addPolygon(color, p1, p2, p3, p4);
     }
 }
예제 #2
0
        public GlTriangle(Color color, GlIndexedVertex v0, GlIndexedVertex v1, GlIndexedVertex v2)
        {
            Color = color;
            var normal = Point3D.VectorMult(v1.Position - v0.Position, v2.Position - v0.Position).Normal;

            V0 = new GlNormalizedVertex(v0, normal);
            V1 = new GlNormalizedVertex(v1, normal);
            V2 = new GlNormalizedVertex(v2, normal);
        }
예제 #3
0
파일: GlMesh.cs 프로젝트: yusitnikov/magnus
        protected GlIndexedVertex[] getCirclePoints(double radius, int circlePointsCount = DefaultCirclePointsCount)
        {
            var points = new GlIndexedVertex[circlePointsCount];

            for (var i = 0; i < circlePointsCount; i++)
            {
                points[i] = new GlIndexedVertex(radius * Point3D.YAxis.RotateRoll(2 * Math.PI * i / circlePointsCount), nextVertexIndex);
            }
            return(points);
        }
예제 #4
0
        public GlPlayerBody(Player player)
        {
            var blackPoints       = getBatPoints(player, 1);
            var redPoints         = getBatPoints(player, -1);
            var redPointsReversed = new GlIndexedVertex[redPoints.Length];

            for (var i = 0; i < redPoints.Length; i++)
            {
                redPointsReversed[i] = redPoints[redPoints.Length - 1 - i];
            }

            addPolygon(Color.Black, blackPoints);
            addPolygon(Color.Red, redPointsReversed);
            addCylinder(getWoodColor(player), redPoints, blackPoints);

            addShadow();
        }
예제 #5
0
        public GlPlayerHandle(Player player)
        {
            var woodColor = getWoodColor(player);

            var nearestLinePoints         = getBatPoints(player, Constants.BatBiggerRadius - Constants.BallRadius, Constants.BatThickness / 2);
            var nearestLinePointsReversed = new GlIndexedVertex[nearestLinePoints.Length];

            for (var i = 0; i < nearestLinePoints.Length; i++)
            {
                nearestLinePointsReversed[i] = nearestLinePoints[nearestLinePoints.Length - 1 - i];
            }
            var nearLinePoints = getBatPoints(player, Constants.BatBiggerRadius, Constants.BallRadius / 2);
            var farLinePoints  = getBatPoints(player, Constants.BatBiggerRadius * 1.5, Constants.BallRadius / 2);

            addPolygon(woodColor, nearestLinePointsReversed);
            addCylinder(woodColor, nearestLinePoints, nearLinePoints);
            addCylinder(woodColor, nearLinePoints, farLinePoints);
            addPolygon(woodColor, farLinePoints);

            addShadow();
        }
예제 #6
0
        public GlCube(Color color, double x1, double y1, double z1, double x2, double y2, double z2, bool withShadow = true)
        {
            GlIndexedVertex
                v0 = new GlIndexedVertex(new Point3D(x1, y1, z1), nextVertexIndex),
                v1 = new GlIndexedVertex(new Point3D(x1, y1, z2), nextVertexIndex),
                v2 = new GlIndexedVertex(new Point3D(x2, y1, z2), nextVertexIndex),
                v3 = new GlIndexedVertex(new Point3D(x2, y1, z1), nextVertexIndex),
                v4 = new GlIndexedVertex(new Point3D(x1, y2, z1), nextVertexIndex),
                v5 = new GlIndexedVertex(new Point3D(x1, y2, z2), nextVertexIndex),
                v6 = new GlIndexedVertex(new Point3D(x2, y2, z2), nextVertexIndex),
                v7 = new GlIndexedVertex(new Point3D(x2, y2, z1), nextVertexIndex);

            addPolygon(color, v0, v1, v2, v3);
            addPolygon(color, v0, v4, v5, v1);
            addPolygon(color, v1, v5, v6, v2);
            addPolygon(color, v2, v6, v7, v3);
            addPolygon(color, v3, v7, v4, v0);
            addPolygon(color, v7, v6, v5, v4);

            if (withShadow)
            {
                addShadow();
            }
        }
예제 #7
0
 public GlNormalizedVertex(GlIndexedVertex vertex, Point3D normal)
 {
     Vertex = vertex;
     Normal = normal;
 }