当前位置: 首页>>代码示例>>C#>>正文


C# Vector3.Select方法代码示例

本文整理汇总了C#中Vector3.Select方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3.Select方法的具体用法?C# Vector3.Select怎么用?C# Vector3.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Vector3的用法示例。


在下文中一共展示了Vector3.Select方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MeshBlock

        public MeshBlock(Vector3[] mesh, Vector3 color)
        {
            this.mesh = mesh.Select(p => new BlockVertex()
            {
                position = p,
                color = color
            }).ToArray();

            for (int i = 0; i < this.mesh.Length; i += 3)
            {
                Vector3 a = this.mesh[i + 0].position;
                Vector3 b = this.mesh[i + 1].position;
                Vector3 c = this.mesh[i + 2].position;

                Vector3 normal =
                    Vector3.Cross(
                        Vector3.Normalize(b - a),
                        Vector3.Normalize(c - a));

                for (int j = 0; j < 3; j++)
                {
                    this.mesh[i + j].normal = normal;
                }
            }
        }
开发者ID:MasterQ32,项目名称:BlocksWorld,代码行数:25,代码来源:MeshBlock.cs

示例2: CreatePolygons

        private static IEnumerable<Polygon> CreatePolygons(Vector3[] points, int[][] indices, Func<int, Vector3, Vertex> vertexFactory)
        {
            Vertex[] vertices = points.Select((v, i) => vertexFactory(i, v)).ToArray();

            for (int i = 0; i < indices.Length; i += 3)
                yield return new Polygon(indices[i].Select(index => vertices[index]));
        }
开发者ID:martindevans,项目名称:csg.js,代码行数:7,代码来源:Mesh.cs

示例3: Rainbow

        public Rainbow(Game game)
            : base(game)
        {
            dash = game.Content.Load<Texture2D>("dash");

            var RainbowTexels = new Vector3[] {
                new Vector3(1.0F, 0.25F, 0.25F),
                new Vector3(1.0F, 0.5F, 0.25F),
                new Vector3(0.96F, 0.96F, 0),
                new Vector3(0.25F, 1.0F, 0.5F),
                new Vector3(0, 0.375F, 1.0F),
                new Vector3(0.375F, 0, 0.625F)
            };

            RainbowTextureFlat = new Texture2D(device, 1, RainbowTexels.Length);
            RainbowTextureFlat.SetData(RainbowTexels.Select(t => new Color(new Vector4(t, 1.0F))).ToArray());

            //Rainbow bands are made up of the original texels, at half intensity
            var RainbowBandTexels = RainbowTexels.Select(t => new Vector4(t * 0.5F, 0F)).ToArray();

            //Add gap equal to the rainbow width
            RainbowBandTexels = RainbowBandTexels.Concat(Enumerable.Repeat(Vector4.Zero, RainbowBandTexels.Length)).ToArray();

            //Multiply it to 11 copies
            RainbowBandTexels = Enumerable.Repeat(RainbowBandTexels, 11).SelectMany(c => c).ToArray();

            //Remove the last gap
            RainbowBandTexels = RainbowBandTexels.Take(RainbowBandTexels.Length - RainbowTexels.Length).ToArray();

            RainbowBandTexture = new Texture2D(device, 1, RainbowBandTexels.Length);
            RainbowBandTexture.SetData(RainbowBandTexels.Select(t => new Color(t)).ToArray());

            Phases = new Phase[] {
                //new Phase(0, 2, DoPhase0),
                new Phase(0, 2, DoPhase1),
                new Phase(2, 17, DoPhase2),
                new Phase(15, 17, DoPhase3),
                new Phase(17, 40, DoPhase4),
                new Phase(38, 40, DoPhase1),
                new Phase(40, 62, DoPhase5),
                new Phase(60, 62, DoPhase6),
            };

            RainbowBlendState = GetRainbowBlendState();
        }
开发者ID:noxo,项目名称:SecondRealityponyWinRT,代码行数:45,代码来源:Rainbow.cs

示例4: CreateCurve

 public static Vector3[] CreateCurve(Vector3[] roadLine, int Segments, float Offset, bool Invert)
 {
     Vector2[] roadCurve = Misc.GetBezierApproximation(roadLine.Select(p=>p.Xz).ToArray(), Segments);
     Vector2[] heightLine = new Vector2[roadLine.Length];
     Vector2 prevPoint = roadLine[0].Xz;
     for (int i = 0; i < heightLine.Length; i++)
     {
         heightLine[i] = new Vector2((roadLine[i].Xz - prevPoint).Length, roadLine[i].Y);
         prevPoint = roadLine[i].Xz;
     }
     Vector2[] heightCurve = Misc.GetBezierApproximation(heightLine, Segments);
     Vector3[] PathNodes = new Vector3[Segments + 1];
     for (int i = 0; i < Segments + 1; i++)
     {
         Vector2 dir = new Vector2();
         if (i== 0) dir = (roadCurve[i] - roadCurve[i+1]);
         else if (i == Segments) dir = (roadCurve[i - 1] - roadCurve[i]);
         else dir = (roadCurve[i - 1] - roadCurve[i]) + (roadCurve[i] - roadCurve[i + 1]);
         dir.Normalize();
         dir *= Offset;
         PathNodes[(Invert) ? Segments - i : i] = new Vector3(roadCurve[i].X + dir.Y, heightCurve[i].Y, roadCurve[i].Y - dir.X);
     }
     return PathNodes;
 }
开发者ID:jakakordez,项目名称:Eternal,代码行数:24,代码来源:Path.cs

示例5: DrawAllMap

        public void DrawAllMap(GameTime gt, Camera cam)
        {
            _passn++;
            if (_passn > Sectn*Sectn - 1) {
                _passn = 0;
            }

            _be.Parameters["worldMatrix"].SetValue(Matrix.Identity);
            _be.Parameters["viewMatrix"].SetValue(Main.Camera.View);
            _be.Parameters["projectionMatrix"].SetValue(Main.Camera.Projection);
            _be.Parameters["diffuseColor"].SetValue(Color.White.ToVector4());
            _be.Parameters["ambientColor"].SetValue(Color.DarkGray.ToVector4());
            var ld = new Vector3(0.5f, -1, -1.2f);
            ld.Normalize();
            _be.Parameters["lightDirection"].SetValue(ld);
            _be.Parameters["shaderTexture"].SetValue(Main.texatlas);

            _gd.RasterizerState = RasterizerState.CullCounterClockwise;
            _gd.DepthStencilState = DepthStencilState.Default;
            _gd.BlendState = BlendState.AlphaBlend;

            drawed_sects = 0;
            drawed_verts = 0;

            foreach (EffectPass pass in _be.CurrentTechnique.Passes) {
                pass.Apply();
                foreach (MapSector a in N) {
                    if (cam.Frustum.Contains(new BoundingBox(a.bounding.Min, a.bounding.Max)) !=
                        ContainmentType.Disjoint) {
                        if (!a.builded) {
                            a.RebuildSectorGeo(_gd, Main.z_cam);
                            sectrebuild++;
                        }
                        if (!a.empty) {
                            drawed_sects++;
                            _gd.DrawUserPrimitives(PrimitiveType.TriangleList, a.VertexArray, 0, a.index/3);
                            drawed_verts += a.index/3;
                        }
                    }
                }

                foreach (MapSector a in N) {
                    if (a.indextransparent > 0) {
                        _gd.DrawUserPrimitives(PrimitiveType.TriangleList, a.VertexArrayTransparent, 0,
                                               a.indextransparent/3);
                        drawed_verts += a.indextransparent/3;
                    }
                }
            }

            _basice2.VertexColorEnabled = true;
            _basice2.Alpha = 0.5f;
            _basice2.Projection = cam.Projection;
            _basice2.View = cam.View;

            //_gd.BlendState = BlendState.AlphaBlend;

            Color greentop = At(Main.Selector).BlockID == 0
                                 ? At(Main.Selector.X, Main.Selector.Y, Main.Selector.Z + 1).BlockID != 0
                                       ? Color.Yellow
                                       : Color.Red
                                 : Color.Green;
            greentop.A = 128;
            Color greencube = greentop*0.5f;

            Color selecttop = Color.LightGray;
            selecttop.A = 128;
            Color selectcube = selecttop*0.5f;

            vl1.Clear();

            var ramka_3 = new Vector3();
            if (Mouse.GetState().RightButton == ButtonState.Pressed) {
                Main.ramka_2.X = Math.Max(Main.Selector.X, Main.ramka_1.X);
                Main.ramka_2.Y = Math.Max(Main.Selector.Y, Main.ramka_1.Y);
                Main.ramka_2.Z = Math.Max(Main.Selector.Z, Main.ramka_1.Z);

                ramka_3 = new Vector3(Math.Min(Main.Selector.X, Main.ramka_1.X),
                                      Math.Min(Main.Selector.Y, Main.ramka_1.Y),
                                      Math.Min(Main.Selector.Z, Main.ramka_1.Z));
            }

            foreach (EffectPass pass in _basice2.CurrentTechnique.Passes) {
                pass.Apply();
                AddCubeverts(Main.Selector, new Vector3(Main.Selector.X + 1, Main.Selector.Y + 1, Main.Selector.Z + 127),
                             greencube, greentop, 0.02f);
                if (Mouse.GetState().RightButton == ButtonState.Pressed) {
                    AddCubeverts(ramka_3, new Vector3(Main.ramka_2.X + 1, Main.ramka_2.Y + 1, Main.ramka_2.Z + 1),
                                 selectcube, selecttop, 0.01f);
                }

                //VertexBuffer vb1 = new VertexBuffer(gd, typeof (VertexPositionColor), 18, BufferUsage.WriteOnly);
                //vb1.SetData(vl1,0,18);

                //gd.SetVertexBuffer(vb1);
                _gd.DrawUserPrimitives(PrimitiveType.TriangleList, vl1.ToArray(), 0, vl1.Count()/3);
            }

            _basice.VertexColorEnabled = false;
            _basice.Projection = cam.Projection;
//.........这里部分代码省略.........
开发者ID:ishellstrike,项目名称:Mork,代码行数:101,代码来源:SectorMap.cs

示例6: AssertDots

        private void AssertDots(float torque, Vector3 position, params float[] expected)
        {
            var perp = CalculatePerp(position, torque);
            var exhaust = new Vector3[] { Vector3.up, Vector3.right, Vector3.down, Vector3.left };
            var dots = exhaust.Select(v => Mathf.Max(Vector3.Dot(perp, v), 0)).ToArray();

            foreach (var dot in dots)
            {
                Console.Write(dot + " ");
            }
            Console.WriteLine();
            CollectionAssert.AreEqual(dots, expected);
        }
开发者ID:Bergecraft,项目名称:Leviticus,代码行数:13,代码来源:UnitTests.cs

示例7: SetPositions

 public void SetPositions(Vector3[] vertices)
 {
     Vector3 norm = new Vector3(0, 0, -1);
     SetPositions(vertices, vertices.Select(_ => norm).ToArray(), vertices.Select(_ => System.Drawing.Color.White).ToArray());
 }
开发者ID:virrkharia,项目名称:dynamight,代码行数:5,代码来源:PointCloudProgram.cs

示例8: BuildMesh

    private void BuildMesh()
    {
        /*
        1. Loop through hex grid in offset-coordinates (http://www.redblobgames.com/grids/hexagons/#map-storage)
        2. For each hex pos, get coordinates of each corner
        3. Use hash table to get vertex index of corner, store corner with index if not found.
        4. Create triangles based on vertex indices stored in hash table.
        */

        int numTiles = SizeX * SizeZ;
        int numTriangles = numTiles * 4;
        //var verticesMap = new Dictionary<Vector3, int>();
        var vertices = new Vector3[numTiles * 6];
        var triangles = new int[numTriangles * 3];
        var hexes = new HexCoord[numTiles];
        var uvMap = new Dictionary<int, Vector2>();

        int triIndex = 0;
        int vIndex = 0;
        int x, z, h = 0;
        for (x = 0; x < SizeX; x++)
            for (z = 0; z < SizeZ; z++)
            {
                hexes[h] = HexCoord.FromOffsetOddR(x, z);
                var corners = hexes[h].Corners().Select(p => new Vector3(p.x * TileScale, 0, p.y * TileScale)).ToArray();
                triangles[triIndex++] = vIndex + 0;
                triangles[triIndex++] = vIndex + 5;
                triangles[triIndex++] = vIndex + 4;

                triangles[triIndex++] = vIndex + 0;
                triangles[triIndex++] = vIndex + 4;
                triangles[triIndex++] = vIndex + 3;

                triangles[triIndex++] = vIndex + 0;
                triangles[triIndex++] = vIndex + 3;
                triangles[triIndex++] = vIndex + 1;

                triangles[triIndex++] = vIndex + 1;
                triangles[triIndex++] = vIndex + 3;
                triangles[triIndex++] = vIndex + 2;

                int cornerIndex = 0;
                foreach (var v in corners)
                {
                    vertices[vIndex] = v;
                    var uv = GetUvForCornerAndPlayer(cornerIndex, Player.NoPlayer);
                    uvMap.Add(vIndex, uv);
                    vIndex++;
                    cornerIndex++;
                }
                h++;
            }

        var mesh = new Mesh();
        mesh.vertices = vertices;
        mesh.normals = vertices.Select(i => Vector3.up).ToArray();
        mesh.uv = uvMap.OrderBy(pair => pair.Key).Select(pair => pair.Value).ToArray();
        mesh.triangles = triangles;
        var meshFilter = GetComponent<MeshFilter>();
        meshFilter.mesh = mesh;
        var meshCollider = GetComponent<MeshCollider>();
        meshCollider.sharedMesh = mesh;
    }
开发者ID:Koala00,项目名称:BLStudio-TowerGame,代码行数:63,代码来源:HexBoard.cs

示例9: getClockwisePoint2D

 private static graphPoint[] getClockwisePoint2D(Vector3[] points)
 {
     return area.simplePolygon(points.Select(x => (Vector2)x).ToArray()) <= 0
          ? points.Select(x => new graphPoint(x, false)).ToArray()
          : points.Select(x => new graphPoint(x, false)).Reverse().ToArray();
 }
开发者ID:devion-user,项目名称:unity,代码行数:6,代码来源:m.csg.cs

示例10: calculateLines

        public static graphLine[] calculateLines(Vector3[] aPoints, Vector3[] bPoints)
        {
            //Create triangles and reverse if unclockwise
             var aPoints2D = getClockwisePoint2D(aPoints);
             var bPoints2D = getClockwisePoint2D(bPoints);
             //Create edges
             var aEdges = new List<graphLine>(aPoints.Length);
             for (int i = 0; i < aPoints2D.Length; i++)
             {
                 var edge = new graphLine { aMain = true, a = true, p1 = aPoints2D[i], p2 = aPoints2D[(i + 1) % aPoints2D.Length] };
                 aEdges.Add(edge);
             }
             var bEdges = new List<graphLine>(bPoints.Length);
             for (int i = 0; i < bPoints2D.Length; i++)
             {
                 var edge = new graphLine { aMain = false, b = true, p1 = bPoints2D[i], p2 = bPoints2D[(i + 1) % bPoints2D.Length] };
                 bEdges.Add(edge);
             }
             //Phase 1: Split & cross
             int aFirstCrossIndex = -1, bFirstCrossIndex = -1;
             for (int i1 = 0; i1 < aEdges.Count; i1++)
             {
                 for (int i2 = 0; i2 < bEdges.Count; i2++)
                 {
                     graphLine[] aOut, bOut;
                     if (_detectIntersectionsIfNeed(aEdges[i1], bEdges[i2], out aOut, out bOut))
                     {
                         aEdges.RemoveAt(i1);
                         bEdges.RemoveAt(i2);
                         aEdges.InsertRange(i1, aOut);
                         bEdges.InsertRange(i2, bOut);
                         aFirstCrossIndex = i1 + 1;
                         bFirstCrossIndex = i2 + 1;
                         i2++;
                     }
                 }

             }
             //Phase 2: Fill
             if (aFirstCrossIndex != -1)
             {
                 bool cursor = aEdges[aFirstCrossIndex].b;
                 for (int i = 0; i < aEdges.Count; i++)
                 {
                     var index = (i + aFirstCrossIndex)%aEdges.Count;
                     var edge = aEdges[index];
                     edge.b = cursor;
                     if (edge.p2.isCross)
                         cursor = !cursor;
                 }
             }
             if (bFirstCrossIndex != -1)
             {
                 bool cursor = bEdges[bFirstCrossIndex].a;
                 for (int i = 0; i < bEdges.Count; i++)
                 {
                     var index = (i + bFirstCrossIndex) % bEdges.Count;
                     var edge = bEdges[index];
                     edge.a = cursor;
                     if (edge.p2.isCross)
                         cursor = !cursor;
                 }
             }
             if (aFirstCrossIndex == -1 && bFirstCrossIndex == -1)
             {
                 //contains triangle area
                 var aV2 = aPoints.Select(x => (Vector2) x).ToArray();
                 var bV2 = bPoints.Select(x => (Vector2) x).ToArray();
                 if (isConvexPolygon(aV2) && isConvexPolygon(bV2))
                 {
                     if (contain.convex(aV2, bV2[0], true))
                     {
                         bEdges.ForEach(x => x.a = true);
                         var advancedEdge = new graphLine { a = true, aMain = true, b = false, p1 = MaxYItem(aPoints2D), p2 = MaxYItem(bPoints2D)};
                         aEdges.Add(advancedEdge);
                     } else if (contain.convex(bV2, aV2[0], true))
                     {
                         aEdges.ForEach(x => x.b = true);
                         var advancedEdge = new graphLine { b = true, aMain = false, a = false, p1 = MaxYItem(aPoints2D), p2 = MaxYItem(bPoints2D)};
                         bEdges.Add(advancedEdge);
                     }
                 }
                 else //if not convex
                 {
                     if (contain.nonzeroRule(aV2, bV2[0]))
                     {
                         bEdges.ForEach(x => x.a = true);
                         var advancedEdge = new graphLine { a = true, aMain = true, b = false, p1 = MaxYItem(aPoints2D), p2 = MaxYItem(bPoints2D) };
                         aEdges.Add(advancedEdge);
                     }
                     else if (contain.nonzeroRule(bV2, aV2[0]))
                     {
                         aEdges.ForEach(x => x.b = true);
                         var advancedEdge = new graphLine { b = true, aMain = false, a = false, p1 = MaxYItem(aPoints2D), p2 = MaxYItem(bPoints2D) };
                         bEdges.Add(advancedEdge);
                     }
                 }
             }
             return aEdges.Concat(bEdges).ToArray();
        }
开发者ID:devion-user,项目名称:unity,代码行数:100,代码来源:m.csg.cs

示例11: CreateGreenGemModel

        public GemModel CreateGreenGemModel()
        {
            var gemCorners = new Vector3[] {
                //Top back vertex
                new Vector3(0, 0.8F, -0.2F),
                //Middle ring two back vertices
                new Vector3(0.12F, 0.4F, -0.30F),
                new Vector3(-0.12F, 0.4F, -0.30F),
                //Bottom ring two back vertices
                new Vector3(0.08F, -0.8F, -0.20F),
                new Vector3(-0.08F, -0.8F, -0.20F),
            };
            //Now create more by rotating these 120° and 240° around the Y axis
            gemCorners = gemCorners
                .Concat(
                    gemCorners.Select(v => Vector3.Transform(v, Matrix.CreateRotationY(MathHelper.Pi * 2 / 3))).ToArray()
                ).Concat(
                    gemCorners.Select(v => Vector3.Transform(v, Matrix.CreateRotationY(MathHelper.Pi * 4 / 3))).ToArray()
                ).ToArray();

            var faceCorners = new int[][] {
                //Top face
                new int[] { 0, 5, 10 },
                //Upper band
                new int[] { 0, 1, 2 },
                new int[] { 0, 2, 6 },
                new int[] { 0, 6, 5 },
                new int[] { 5, 6, 7 },
                new int[] { 5, 7, 11 },
                new int[] { 5, 11, 10 },
                new int[] { 10, 11, 12 },
                new int[] { 10, 12, 1 },
                new int[] { 10, 1, 0 },
                //Lower band
                new int[] { 1, 3, 4 },
                new int[] { 1, 4, 2 },
                new int[] { 2, 4, 8 },
                new int[] { 2, 8, 6 },
                new int[] { 6, 8, 9 },
                new int[] { 6, 9, 7 },
                new int[] { 7, 9, 13 },
                new int[] { 7, 13, 11 },
                new int[] { 11, 13, 14 },
                new int[] { 11, 14, 12 },
                new int[] { 12, 14, 3 },
                new int[] { 12, 3, 1 },
                //Bottom face
                new int[] { 8, 4, 3 },
                new int[] { 13, 9, 8 },
                new int[] { 3, 14, 13 },
                new int[] { 3, 13, 8 }
            };

            //Just hardcode the list of edges to inset
            var insetEdges = new int[][] {
                new int[] {0, 1},
                new int[] {1, 2},
                new int[] {2, 0},
                new int[] {1, 3},
                new int[] {3, 4},
                new int[] {4, 2},
                new int[] {0, 5},
                new int[] {2, 6},
                new int[] {4, 8}
            };
            //Copy it 3 times
            var insetEdges1 = insetEdges.Select(ii => ii.Select(i => (i + 5) % 15).ToArray()).ToArray();
            var insetEdges2 = insetEdges.Select(ii => ii.Select(i => (i + 10) % 15).ToArray()).ToArray();
            insetEdges = insetEdges.Concat(insetEdges1).Concat(insetEdges2).ToArray();

            var gemVerticesOuterList = new List<VertexPositionNormalTexture>();
            var gemVerticesInnerList = new List<VertexPositionNormalTexture>();

            foreach (int[] corners in faceCorners)
            {
                float edge0 = GreenGemInsetEdge(corners[0], corners[1], insetEdges);
                float edge1 = GreenGemInsetEdge(corners[1], corners[2], insetEdges);
                float edge2 = GreenGemInsetEdge(corners[2], corners[0], insetEdges);

                gemVerticesOuterList.AddRange(MakeTriangle(gemCorners, corners, new float[] { 0.0F, 0.0F, 0.0F }));
                gemVerticesInnerList.AddRange(MakeTriangle(gemCorners, corners, new float[] { edge0, edge1, edge2 }, 0.02F));
            }

            return new GemModel(device, gemVerticesOuterList, gemVerticesInnerList, Color.Green );
        }
开发者ID:noxo,项目名称:SecondRealityponyWinRT,代码行数:85,代码来源:Rarity.cs

示例12: CreateBlueGemModel

        public GemModel CreateBlueGemModel()
        {
            var gemCorners = new Vector3[] {
                new Vector3(0F, 0.7F, 0.5F),
                new Vector3(0.35F, 0.4F, 0.35F * (float) Math.Sqrt(3))
            };

            //Create 6 rotations of those two vertices
            gemCorners = (from i in Enumerable.Range(0, 6)
                          from v in gemCorners
                         select Vector3.Transform(v, Matrix.CreateRotationY(MathHelper.Pi * i / 3F))).ToArray();

            //Append top-center and bottom-center vertices
            gemCorners = gemCorners.Concat(new Vector3[] {
                new Vector3(0, 0.7F, 0),
                new Vector3(0, -0.7F, 0)
            }).ToArray();

            //Tilt entire gem slightly towards the viewer, so we can see the top face
            gemCorners = gemCorners.Select(v => Vector3.Transform(v, Matrix.CreateRotationX(0.3F))).ToArray();

            //Define 4 triangles, then create 6 rotations of them too
            var faceCorners = new int[][] {
                new int[] {12, 0, 2},
                new int[] {0, 1, 2},
                new int[] {1, 3, 2},
                new int[] {1, 13, 3}
            };
            Func<int, int, int> nextStep = (i, n) => (i >= 12 ? i : (i + n * 2) % 12);
            faceCorners = (from n in Enumerable.Range(0, 6)
                          from ints in faceCorners
                          select ints.Select(i => nextStep(i, n)).ToArray()).ToArray();

            var gemVerticesOuterList = new List<VertexPositionNormalTexture>();
            var gemVerticesInnerList = new List<VertexPositionNormalTexture>();

            foreach (int[] corners in faceCorners)
            {
                //Inset all edges, except edges 0 and 2 when vertex0 is 12 (top center)
                float edge0 = corners[0] != 12 ? 0.03F : 0;
                float edge1 = 0.03F;
                float edge2 = corners[0] != 12 ? 0.03F : 0;

                gemVerticesOuterList.AddRange(MakeTriangle(gemCorners, corners, new float[] { 0.0F, 0.0F, 0.0F }));
                gemVerticesInnerList.AddRange(MakeTriangle(gemCorners, corners, new float[] { edge0, edge1, edge2 }, 0.02F));
            }

            return new GemModel(device, gemVerticesOuterList, gemVerticesInnerList, new Color(48, 48, 255));
        }
开发者ID:noxo,项目名称:SecondRealityponyWinRT,代码行数:49,代码来源:Rarity.cs

示例13: LightShape

        public LightShape(Vector3 C, float size, Vector3 E1, Vector3 E2, Vector3 E3, Func<Vector2, Vector2> texTran)
        {
            Vertices = new Vector3[]
            {
                C,
                new Vector3(
                    C.X + size * 0.5f * E1.X + size * 0.5f * E2.X + size * 0.5f * E3.X,
                    C.Y + size * 0.5f * E1.Y + size * 0.5f * E2.Y + size * 0.5f * E3.Y,
                    C.Z + size * 0.5f * E1.Z + size * 0.5f * E2.Z + size * 0.5f * E3.Z),
                new Vector3(
                    C.X - size * 0.5f * E1.X + size * 0.5f * E2.X + size * 0.5f * E3.X,
                    C.Y - size * 0.5f * E1.Y + size * 0.5f * E2.Y + size * 0.5f * E3.Y,
                    C.Z - size * 0.5f * E1.Z + size * 0.5f * E2.Z + size * 0.5f * E3.Z),
                new Vector3(
                    C.X - size * 0.5f * E1.X - size * 0.5f * E2.X + size * 0.5f * E3.X,
                    C.Y - size * 0.5f * E1.Y - size * 0.5f * E2.Y + size * 0.5f * E3.Y,
                    C.Z - size * 0.5f * E1.Z - size * 0.5f * E2.Z + size * 0.5f * E3.Z),
                new Vector3(
                    C.X + size * 0.5f * E1.X - size * 0.5f * E2.X + size * 0.5f * E3.X,
                    C.Y + size * 0.5f * E1.Y - size * 0.5f * E2.Y + size * 0.5f * E3.Y,
                    C.Z + size * 0.5f * E1.Z - size * 0.5f * E2.Z + size * 0.5f * E3.Z),
            };

            Indices = new int[]
            {
                0, 1, 2, 0, 2, 3, 0, 3, 4, 0, 4, 1, 1, 2, 3, 3, 4, 1
            };

            Vertices = Indices.Select(i => Vertices[i]).ToArray();
            int c = 0;
            Indices = Indices.Select(_ => c++).ToArray();

            var ids = Dynamight.ImageProcessing.CameraCalibration.Range.OfInts(Indices.Length / 3);
            Func<int, Vector3> findN = (i) =>
            {
                var p0 = Vertices[i * 3 + 0];
                var p1 = Vertices[i * 3 + 1];
                var p2 = Vertices[i * 3 + 2];
                var e1 = p1 - p0;
                var e2 = p2 - p0;
                var n = Vector3.Cross(e1, e2);
                n.Normalize();
                return n;
            };

            Normals = Indices.Select(i => findN((int)Math.Floor((double)i / (double)3))).ToArray();

            Texcoords = Vertices.Select(v => texTran(new Vector2(0, 0))).ToArray();

            Colors = Vertices.Select(_ => ColorToRgba32(Color.White)).ToArray();
        }
开发者ID:virrkharia,项目名称:dynamight,代码行数:51,代码来源:LightRenderable.cs

示例14: SetPositions

        public void SetPositions(Vector3[][] verts, Matrix4[] modelviews)
        {
            SetPositions(verts.SelectMany(v => v));
            ModelViews = modelviews;

            int c = 0;
            Lengths = verts.Select(v => c += v.Length * 6).ToArray();
        }
开发者ID:virrkharia,项目名称:dynamight,代码行数:8,代码来源:LightStudioProgram.cs

示例15: move

        /**
         * Move a block with a translation around x, y and z, and a rotation around x, y and z.
         */
        public bool move(Vector3 translate, Vector3 rotate)
        {
            //Calculate theoretical movement

            //Translation: absolute, so origin
            Vector3 newOrigin = origin+translate;

            //Rotation: relative, so cubes matrix.
            Matrix rotX = Matrix.CreateFromAxisAngle(Vector3.UnitX, (float)(rotate.X * Math.PI / 2));
            Matrix rotY = Matrix.CreateFromAxisAngle(Vector3.UnitY, (float)(rotate.Y * Math.PI / 2));
            Matrix rotZ = Matrix.CreateFromAxisAngle(Vector3.UnitZ, (float)(rotate.Z * Math.PI / 2));
            Matrix rotTotal = rotX * rotY * rotZ; //Total rotation

            Vector3[] newCubes = new Vector3[cubes.Length];
            Vector3.Transform(cubes,ref rotTotal, newCubes); //Applies rotation matrix

            for (int i = 1; i < newCubes.Length; i++) //Round cubes to ints.
            {
                newCubes[i] = new Vector3((int)newCubes[i].X, (int)newCubes[i].Y, (int)newCubes[i].Z);
            }

            //Check collision: add the origin and the cubes together and use that set for collission detection.
            if(checkCollision(newCubes.Select(newCube=>newCube+newOrigin).ToArray()))
            {
                return false;
            }

            //Perform movement with calculated values
            this.origin = newOrigin;
            this.cubes = newCubes;
            return true; //Succes!
        }
开发者ID:pascalaldo,项目名称:5ES03,代码行数:35,代码来源:Block.cs


注:本文中的Vector3.Select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。