Beispiel #1
0
        public void AddMesh(Mesh mesh, Vector3 translation, Vector3 scale)
        {
            var vertexTransform = new Vector3Transformation(_ => (_ * scale) + translation);
            var normalTransform = new Vector3Transformation(_ => (scale * _).Normalized);

            AddMesh(mesh, vertexTransform, normalTransform);
        }
Beispiel #2
0
        public void AddMesh(Mesh mesh, Matrix matrix)
        {
            var vertexTransform = new Vector3Transformation(_ => Vector3.Transform(_, matrix));
            var normalTransform = new Vector3Transformation(_ => Vector3.NormalTransform(_, matrix));

            AddMesh(mesh, vertexTransform, normalTransform);
        }
Beispiel #3
0
        public void AddMesh(Mesh mesh, Vector3Transformation vertexTransform, Vector3Transformation normalTransform)
        {
            if (mesh == null)
            {
                throw new ArgumentNullException();
            }

            if (mesh.Indices != null)
            {
                var newIndices = mesh.Indices
                                 .Select(_ => _ + (UInt32)_vertices.Count)
                                 .ToArray();
                _indices.AddRange(newIndices);
            }

            var vertices = mesh.Vertices
                           .Select(_ => vertexTransform(_));

            _vertices.AddRange(vertices);

            if (mesh.Normals != null)
            {
                if (normalTransform == null)
                {
                    throw new ArgumentNullException("normalTransform");
                }

                var normals = mesh.Normals
                              .Select(_ => normalTransform(_));
                _normals.AddRange(normals);
            }
            if (mesh.Colors != null)
            {
                _colors.AddRange(mesh.Colors);
            }
        }
Beispiel #4
0
        public void AddMesh(Mesh mesh, Vector3 translation)
        {
            var transform = new Vector3Transformation(_ => _ + translation);

            AddMesh(mesh, transform, _identityTransformation);
        }
Beispiel #5
0
        public void AddMesh(Mesh mesh, Quaternion rotation)
        {
            var transform = new Vector3Transformation(_ => Vector3.Transform(_, rotation));

            AddMesh(mesh, transform, transform);
        }