public LocalToWorldDirection ( Vector3 dir ) : Vector3 | ||
dir | Vector3 | |
Результат | Vector3 |
private void ConnectCrossToStreet(Street _street, bool _isStreetStart) { if (m_cross.GetStartConnection().m_OtherComponent == null) { if (_isStreetStart) { OrientedPoint op = _street.m_Spline.GetFirstOrientedPoint(); SetCrossTransform(op.Position - op.LocalToWorldDirection(Vector3.forward) * 1.2f, op.Rotation * Quaternion.Euler(0, 180f, 0)); StreetComponentManager.DestroyDeadEnd((DeadEnd)_street.GetStartConnection().m_OtherComponent); Connection.Combine(m_cross.GetStartConnection(), _street.GetStartConnection()); } else { OrientedPoint op = _street.m_Spline.GetLastOrientedPoint(); SetCrossTransform(op.Position + op.LocalToWorldDirection(Vector3.forward) * 1.2f, op.Rotation); StreetComponentManager.DestroyDeadEnd((DeadEnd)_street.m_EndConnection.m_OtherComponent); Connection.Combine(m_cross.GetStartConnection(), _street.m_EndConnection); } } }
private void GenerateMesh(int keepBuffer) { UpdatePath(keepBuffer); if (m_SplinePathIndex < 2) { return; } int numPath = m_SplinePath.Count; int vertsInShape = shapeVertices.Count; int[] triangleIndices = m_OMesh.triangles; Vector3[] vertices = m_OMesh.vertices; Vector3[] normals = m_OMesh.normals; Vector2[] uvs = m_OMesh.uvs; int segments = numPath - m_MeshingNodeIndex; int tLengthNeeded = (m_MeshingIndex + segments * vertsInShape) * 6; if (tLengthNeeded >= triangleIndices.Length) { if (Overflow != null) { Overflow.Invoke(); } return; } int updateOffset = m_MeshingIndex; for (int i = 0; i < segments; i++) { OrientedPoint op = m_SplinePath[m_MeshingNodeIndex]; float vCoord = ( float )i / (( float )segments) * textureScale; for (int iVertex = 0; iVertex < vertsInShape; iVertex++) { Vertex v = shapeVertices[iVertex]; vertices[m_MeshingIndex] = op.LocalToWorld(v.point * shapeSize); normals[m_MeshingIndex] = op.LocalToWorldDirection(v.normal); uvs[m_MeshingIndex] = new Vector2(v.uCoord, vCoord); m_MeshingIndex++; } m_MeshingNodeIndex++; } int index = updateOffset; int ti = updateOffset * 6; if (index > vertsInShape) { index -= vertsInShape; } else { segments--; } for (int i = 0; i < segments; i++) { for (int iVertex = 0; iVertex < vertsInShape; iVertex++) { int offset = (iVertex == (vertsInShape - 1)) ? -(vertsInShape - 1) : 1; int a = index + vertsInShape; int b = index; int c = index + offset; int d = index + offset + vertsInShape; triangleIndices[ti++] = c; triangleIndices[ti++] = a; triangleIndices[ti++] = b; triangleIndices[ti++] = a; triangleIndices[ti++] = c; triangleIndices[ti++] = d; index++; } } m_OMesh.vertIndex = m_MeshingIndex; m_OMesh.triIndex = ti; m_OMesh.UpdateBuffers(); }