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


C# Vector3.GetLength方法代码示例

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


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

示例1: OnPointsChanged

        void OnPointsChanged(Vector3[,] points)
        {
            int rowCount = points.GetLength(0);
            int colCount = points.GetLength(1);

            #region Calculate line segments for show in SceneView
            List<Vector3> lineSegments = new List<Vector3>();

            for (int i = 0; i < rowCount; i++) {
                for (int j = 0; j < colCount; j++) {

                    if (i != rowCount - 1) {
                        lineSegments.Add(points[i, j]);
                        lineSegments.Add(points[i + 1, j]);
                    }

                    if (j != colCount - 1) {
                        lineSegments.Add(points[i, j]);
                        lineSegments.Add(points[i, j + 1]);
                    }
                }
            }

            view.SetGrid(lineSegments.ToArray(), Color.white);
            #endregion

            #region Calculate cells for Board
            ThreeTTD.Board.Board board = GameObject.FindObjectOfType<ThreeTTD.Board.Board>();
            board.UpdateCellData(points);
            EditorUtility.SetDirty(board);
            #endregion
        }
开发者ID:Sundem,项目名称:TD,代码行数:32,代码来源:Presenter.cs

示例2: Wind

        /// <summary>
        /// Initializes a new instance of the <see cref="FreezingArcher.Content.Wind"/> class.
        /// </summary>
        /// <param name="globalWind">Global wind force.</param>
        /// <param name="fieldResolution">Wind field resolution.</param>
        /// <param name="defaultFieldForce">Default field force.</param>
        public Wind(Vector3 globalWind, Vector3i fieldResolution, Vector3 defaultFieldForce = default(Vector3))
        {
            Global = globalWind;
            FieldResolution = fieldResolution;
            WindField = new Vector3[FieldResolution.X, FieldResolution.Y, FieldResolution.Z];

            for (int x = 0; x < WindField.GetLength(0); x++)
                for (int y = 0; y < WindField.GetLength(1); y++)
                    for (int z = 0; z < WindField.GetLength(2); z++)
                        WindField[x, y, z] = defaultFieldForce;
        }
开发者ID:AreonDev,项目名称:NoWayOut,代码行数:17,代码来源:Wind.cs

示例3: UpdateCellData

        public void UpdateCellData(Vector3[,] points)
        {
            rowCount = points.GetLength(0) - 1;
            colCount = points.GetLength(1) - 1;

            cells = new Cell[rowCount * colCount];

            for (int i = 0; i < rowCount; i++) {
                for (int j = 0; j < colCount; j++) {
                    Cell cell = new Cell(new Vector3[4] { points[i, j], points[i, j + 1], points[i + 1, j + 1], points[i + 1, j] });
                    cells[i * colCount + j] = cell;
                }
            }
        }
开发者ID:Sundem,项目名称:TD,代码行数:14,代码来源:Board.cs

示例4: setOutlines

 public void setOutlines(Vector3[,] newOutlines, Color newcolor)
 {
     if(newOutlines.GetLength(0)>0)	{
         outlines.Add(newOutlines);
         //Debug.Log ("no "+newOutlines.GetLength(0).ToString());
         colors.Add(newcolor);
     }
 }
开发者ID:Luxe84,项目名称:UnityTest,代码行数:8,代码来源:BoundBoxes_drawLines.cs

示例5: updateVertices

    void updateVertices(Vector3[] vert)
    {
        Release ();
        // reallocate buffers ans stuff <3
        UnityEngine.Debug.Log ("This should not be called twice!!");
        mCount = vert.GetLength(0);
        // allocate buffer for computeShader
        /*
            buffer = new ComputeBuffer(mCount, sizeof(float)*3, ComputeBufferType.Default);
            normal = new ComputeBuffer(mCount, sizeof(float)*3, ComputeBufferType.Default);
            normalGenerated = new ComputeBuffer(mCount, sizeof(float)*3, ComputeBufferType.Default);

            tangent = new ComputeBuffer(mCount, sizeof(float)*3, ComputeBufferType.Default);
            debugColor = new ComputeBuffer(mCount, sizeof(float)*3, ComputeBufferType.Default);
            // holds the infered crater
            generatedBuffer = new ComputeBuffer(mCount, sizeof(float)*3, ComputeBufferType.Default);
            iteratorCount = new ComputeBuffer(mCount, sizeof(int), ComputeBufferType.Default);

            error = new ComputeBuffer(mCount, sizeof(float), ComputeBufferType.Default);
            SAD = new ComputeBuffer(numGroups, sizeof(float), ComputeBufferType.Default);
            SADArray = new float[numGroups];
            SetBuffer ("buffer", buffer);
            SetBuffer ("_normal", normal);
            SetBuffer ("_normalGenerated", normalGenerated);
            SetBuffer ("_tangent", tangent);

            SetBuffer ("debugColor", debugColor);
            SetBuffer ("generatedBuffer", generatedBuffer);
            SetBuffer ("iteratorCount", iteratorCount);
            SADShader.SetBuffer (SADKernel,"SAD", SAD);
            SADShader.SetBuffer(SADKernel,"error", error);
            UnityEngine.Debug.LogFormat ("Total verts, "+mCount);
            // copy points to gpu

            buffer.SetData(vert);
            //		CCI.onGeometryUpdate ();
         */
    }
开发者ID:savashito,项目名称:bayesCraterModeling,代码行数:38,代码来源:VertexShaderCrater.cs

示例6: Start

    void Start()
    {
        Random.seed = SpawnSeed;

        mapSort = this.GetComponent<MapSortingScript>();

        float Width = 0;
        float Height = 0;
        float Depth = 0;

        if (null != defaultSpawnObject.transform.FindChild("Floor"))
        {
            Width = defaultSpawnObject.transform.FindChild("Floor").lossyScale.x;
            Height = defaultSpawnObject.transform.FindChild("Floor").lossyScale.y;
            Depth = defaultSpawnObject.transform.FindChild("Floor").lossyScale.z;
        }
        else
        {
            Width = defaultSpawnObject.transform.localScale.x;
            Height = defaultSpawnObject.transform.localScale.y;
            Depth = defaultSpawnObject.transform.localScale.z;
        }

        //print("Width=" + Width + " Height=" + Height + " Depth=" + Depth);

        float MaxWidth = Mathf.Max(spawnSpace[0].transform.position.x, spawnSpace[1].transform.position.x);
        float MaxHeight = Mathf.Max(spawnSpace[0].transform.position.y, spawnSpace[1].transform.position.y);
        float MaxDepth = Mathf.Max(spawnSpace[0].transform.position.z, spawnSpace[1].transform.position.z);

        //print("MaxWidth=" + MaxWidth + " MaxHeight=" + MaxHeight + " MaxDepth=" + MaxDepth);

        Vector3 StartingVec = Vector3.zero;

        if (spawnSpace[0].transform.position.x < spawnSpace[1].transform.position.x)
            StartingVec = spawnSpace[0].transform.position;
        else
            StartingVec = spawnSpace[1].transform.position;

        List<Vector3> spawnWidthPlaces = GetSpawnLocationOnAxis(new Vector3(Width, 0, 0), new Vector3(MaxWidth, MaxHeight, MaxDepth), StartingVec);

        if (spawnSpace[0].transform.position.y < spawnSpace[1].transform.position.y)
            StartingVec = spawnSpace[0].transform.position;
        else
            StartingVec = spawnSpace[1].transform.position;

        List<Vector3> spawnHeightPlaces = GetSpawnLocationOnAxis(new Vector3(0, Height, 0), new Vector3(MaxWidth, MaxHeight, MaxDepth), StartingVec);

        if (spawnSpace[0].transform.position.z < spawnSpace[1].transform.position.z)
            StartingVec = spawnSpace[0].transform.position;
        else
            StartingVec = spawnSpace[1].transform.position;

        List<Vector3> spawnDepthPlaces = GetSpawnLocationOnAxis(new Vector3(0, 0, Depth), new Vector3(MaxWidth, MaxHeight, MaxDepth), StartingVec);

        Vector3[,,] RoomSpawnVecs = new Vector3[spawnWidthPlaces.Count, spawnHeightPlaces.Count, spawnDepthPlaces.Count];

        for (int i = 0; i < RoomSpawnVecs.GetLength(0); i++)
        {
            RoomSpawnVecs[i, 0, 0] = spawnWidthPlaces[i];
        }
        for (int i = 0; i < RoomSpawnVecs.GetLength(1); i++)
        {
            RoomSpawnVecs[0, i, 0] = spawnHeightPlaces[i];
        }
        for (int i = 0; i < RoomSpawnVecs.GetLength(2); i++)
        {
            RoomSpawnVecs[0, 0, i] = spawnDepthPlaces[i];
        }

        for (int i = 0; i < RoomSpawnVecs.GetLength(0); i++)
        {
            for (int j = 0; j < RoomSpawnVecs.GetLength(1); j++)
            {
                if (i == 0 && j == 0)
                {
                    continue;
                }
                else
                {

                    for (int k = 0; k < RoomSpawnVecs.GetLength(2); k++)
                    {
                        if ((i == 0 || j == 0) && k == 0)
                        {
                            continue;
                        }
                        else
                        {
                            RoomSpawnVecs[i, j, k] = new Vector3(MaxWidth, MaxHeight, MaxDepth);
                            RoomSpawnVecs[i, j, k].x = RoomSpawnVecs[i, 0, 0].x;
                            RoomSpawnVecs[i, j, k].y = RoomSpawnVecs[0, j, 0].y;
                            RoomSpawnVecs[i, j, k].z = RoomSpawnVecs[0, 0, k].z;
                        }
                    }
                }
            }
        }

        foreach (Vector3 vec in RoomSpawnVecs)
        {
//.........这里部分代码省略.........
开发者ID:VincentHui,项目名称:fireworks,代码行数:101,代码来源:SpaceRandomFillManager.cs

示例7: indexOfClosestPointMultiDim

    public int[] indexOfClosestPointMultiDim(Vector3[,] pointsFrom, Vector3 point)
    {

        float[,] sqrMagnitudes = new float[pointsFrom.GetLength(0), pointsFrom.GetLength(1)];

        for (int i = 0; i < pointsFrom.GetLength(0); i++)
        {

            for (int j = 0; j < pointsFrom.GetLength(1); j++)
            {
                sqrMagnitudes[i,j] = ((point.x - pointsFrom[i, j].x) * (point.x - pointsFrom[i, j].x)) + ((point.z - pointsFrom[i, j].z) * (point.z - pointsFrom[i, j].z));
            }

        }

        return findIndexMinMultiDim(sqrMagnitudes);

    }
开发者ID:JonathanMG,项目名称:TerrainGen,代码行数:18,代码来源:HelperMethods.cs

示例8: Update


//.........这里部分代码省略.........
            meshColors[pointIndex] = this.pointList[i].color;
            meshUVs[pointIndex] = new Vector2(xPosUV, 1.0f);
            pointIndex++;
            meshVertices[pointIndex] = tempVector;
            meshNormals[pointIndex] = -rightNormal;
            meshColors[pointIndex] = this.pointList[i].color;
            meshUVs[pointIndex] = new Vector2(xPosUV, 1.0f);
            pointIndex++;

            tempVector = position + right;
            meshVertices[pointIndex] = tempVector;
            meshNormals[pointIndex] = -upNormal;
            meshColors[pointIndex] = this.pointList[i].color;
            meshUVs[pointIndex] = new Vector2(xPosUV, 0.0f);
            pointIndex++;
            meshVertices[pointIndex] = tempVector;
            meshNormals[pointIndex] = rightNormal;
            meshColors[pointIndex] = this.pointList[i].color;
            meshUVs[pointIndex] = new Vector2(xPosUV, 0.0f);
            pointIndex++;

            tempVector = position - right;
            meshVertices[pointIndex] = tempVector;
            meshNormals[pointIndex] = -upNormal;
            meshColors[pointIndex] = this.pointList[i].color;
            meshUVs[pointIndex] = new Vector2(xPosUV, 0.0f);
            pointIndex++;
            meshVertices[pointIndex] = tempVector;
            meshNormals[pointIndex] = -rightNormal;
            meshColors[pointIndex] = this.pointList[i].color;
            meshUVs[pointIndex] = new Vector2(xPosUV, 0.0f);
        }

        pointIndex = meshVertices.GetLength(0) - 4;

        position = this.pointList[this.pointList.Count - 1].position;
        up = this.pointList[this.pointList.Count - 1].normal * this.pointList[this.pointList.Count - 1].height;
        forward = -(this.pointList[this.pointList.Count - 2].position - position);
        if (forward == Vector3.zero)
            forward = lastForward;
        lastForward = forward;
        forwardNormal = forward.normalized;
        if (forwardNormal == Vector3.zero)
            forwardNormal = lastForwardNormal;
        lastForwardNormal = forwardNormal;
        right = Vector3.Cross(up, forward).normalized * this.pointList[this.pointList.Count - 1].width;

        tempVector = position + (right * 0.5f) + up;
        meshVertices[pointIndex] = tempVector;
        meshNormals[pointIndex] = forwardNormal;
        meshColors[pointIndex] = this.pointList[this.pointList.Count - 1].color;
        meshUVs[pointIndex] = new Vector2(1.0f, 1.0f);
        pointIndex++;

        tempVector = position - (right * 0.5f) + up;
        meshVertices[pointIndex] = tempVector;
        meshNormals[pointIndex] = forwardNormal;
        meshColors[pointIndex] = this.pointList[this.pointList.Count - 1].color;
        meshUVs[pointIndex] = new Vector2(1.0f, 1.0f);
        pointIndex++;

        tempVector = position + (right * 0.5f);
        meshVertices[pointIndex] = tempVector;
        meshNormals[pointIndex] = forwardNormal;
        meshColors[pointIndex] = this.pointList[this.pointList.Count - 1].color;
        meshUVs[pointIndex] = new Vector2(1.0f, 0.0f);
开发者ID:RavenNevermore,项目名称:EndOfLine,代码行数:67,代码来源:OptimizedLineRenderer.cs

示例9: InitialiseParticles

        public void InitialiseParticles(Vector3[,] config)
        {
            float i, j;
            //initialise fluid particles from array
            foreach (var v in config)
            {
                Particle p = new Particle();
                Vector2 temp = new Vector2(v.X, v.Y);
                p.Position = temp;
                p.Oldposition = temp;
                if (v.Z == 1)
                    p.Mass = 1;

                plst.Add(p);
            }

            //Create four walls for the box
            box_width = config[config.GetLength(0) - 1, config.GetLength(1) - 1].X + 20;
            box_height = config[config.GetLength(0) - 1, 0].Y + 15;
            //initialise base particles
            for (i = 0; i <= /*256*/box_width; i += 3)
                for (j = 0; j <= 9; j += 3)
                {
                    Particle bp = new Particle();
                    Vector2 temp = new Vector2(i, j);
                    bp.Position = temp;
                    bp.Oldposition = temp;
                    bp.Isstationaryboundary = true;
                    plst.Add(bp);
                }
            //initialise left wall particles
            for (i = 0; i <= 9; i += 3)
                for (j = 12; j <= /*253*/box_height; j += 3)
                {
                    Particle mbp = new Particle();
                    Vector2 temp2 = new Vector2(i, j);
                    mbp.Position = temp2;
                    mbp.Oldposition = temp2;
                    mbp.Ismovingboundary = true;
                    plst.Add(mbp);
                }
            //initalise right wall particles
            for (i = box_width - 10; i <= box_width; i += 3)
                for (j = 12; j <= box_height; j += 3)
                {
                    Particle bp = new Particle();
                    Vector2 temp = new Vector2(i, j);
                    bp.Position = temp;
                    bp.Oldposition = temp;
                    bp.Isstationaryboundary = true;
                    plst.Add(bp);
                }
            //initialise top of box
            for (i = 0; i <= box_width; i += 3)
                for (j = box_height + 2; j <= box_height + 10; j += 3)
                {
                    Particle bp = new Particle();
                    Vector2 temp = new Vector2(i, j);
                    bp.Position = temp;
                    bp.Oldposition = temp;
                    bp.Isstationaryboundary = true;
                    plst.Add(bp);
                }

            foreach (Particle p in plst)
            {
                p.Vsigma = vsigma;
                p.Vbeta = vbeta;
            }
        }
开发者ID:jpneill,项目名称:SPHSim,代码行数:70,代码来源:Game_Engine.cs


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