public VoxelVertexOutput ResolveVoxelVertex(VoxelVertexInput input, VoxelModelGenerationSettings settings)
        {
            VoxelVertexOutput output = new VoxelVertexOutput();

            output.SetDefaults(input, settings);
            return(output);
        }
        public void SetDefaults(VoxelVertexInput input, Material mat, VoxelModelGenerationSettings settings)
        {
            BoundsInt bounds = input.SourceVolume.GetVolumeBounds();
            Vector3   centre = Vector3.Scale(bounds.size, settings.NormalizedPivot) + bounds.min;

            RenderedMaterial = mat;
            Position         = Vector3.Scale(((input.Coord + input.CoordOffset) - centre), settings.Scale);
            Normal           = input.Normal;
        }
Exemple #3
0
        private int AddVertex(Vector3Int coord, Vector3Int normal, VoxelCell cell, Vector3 offset, object scratch, out Material assignedMaterial)
        {
            VoxelVertexInput input = new VoxelVertexInput
            {
                SourceVolume = m_Volume,
                Coord        = coord,
                CoordOffset  = offset,
                Normal       = normal,
                Cell         = cell
            };

            return(AddVertex(input, scratch, out assignedMaterial));
        }
Exemple #4
0
            private int AddVertex(Vector3Int coord, Vector3Int normal, VoxelCell cell, Vector3 offset, out int submeshID)
            {
                VoxelVertexInput input = new VoxelVertexInput
                {
                    SourceVolume = m_Volume,
                    Coord        = coord,
                    CoordOffset  = offset,
                    Normal       = normal,
                    Cell         = cell
                };

                return(AddVertex(input, out submeshID));
            }
Exemple #5
0
            private int AddVertex(VoxelVertexInput input, out int submeshID)
            {
                VoxelVertexOutput vertex = m_MaterialResolver.ResolveVoxelVertex(input, m_Settings);
                int vertexIndex          = m_Intermediate.Positions.Count;

                m_Intermediate.Positions.Add(vertex.Position);
                m_Intermediate.Normals.Add(vertex.Normal);
                m_Intermediate.Colours.Add(vertex.Colour);

                // Make sure all UV channels are kept inline
                Vector4[] vertexUVs = vertex.UVs ?? new Vector4[0];

                int channels = Mathf.Max(vertexUVs.Length, m_Intermediate.UVs.Count);

                for (int c = 0; c < channels; ++c)
                {
                    Vector4 uv = c < vertexUVs.Length ? vertexUVs[c] : Vector4.zero;

                    if (m_Intermediate.UVs.Count <= c)
                    {
                        List <Vector4> newChannel = new List <Vector4>();

                        // Fill channel with default
                        for (int i = 0; i < vertexIndex; ++i)
                        {
                            newChannel.Add(Vector4.zero);
                        }

                        m_Intermediate.UVs.Add(newChannel);
                    }

                    m_Intermediate.UVs[c].Add(uv);
                }

                submeshID = vertex.SubmeshID;
                return(vertexIndex);
            }