Exemplo n.º 1
0
        byte[] GetNormalsBytes(Rhino.Geometry.Collections.MeshVertexNormalList normals, out Vector3f min, out Vector3f max)
        {
            Vector3f vMin = new Vector3f()
            {
                X = float.PositiveInfinity, Y = float.PositiveInfinity, Z = float.PositiveInfinity
            };
            Vector3f vMax = new Vector3f()
            {
                X = float.NegativeInfinity, Y = float.NegativeInfinity, Z = float.NegativeInfinity
            };

            //Preallocate to reduce time spent on allocations
            List <float> floats = new List <float>(normals.Count * 3);

            foreach (Vector3f normal in normals)
            {
                floats.AddRange(new float[] { normal.X, normal.Y, normal.Z });

                vMin.X = Math.Min(vMin.X, normal.X);
                vMax.X = Math.Max(vMax.X, normal.X);

                vMin.Y = Math.Min(vMin.Y, normal.Y);
                vMax.Y = Math.Max(vMax.Y, normal.Y);

                vMax.Z = Math.Max(vMax.Z, normal.Z);
                vMin.Z = Math.Min(vMin.Z, normal.Z);
            }

            IEnumerable <byte> bytesEnumerable = floats.SelectMany(value => BitConverter.GetBytes(value));

            min = vMin;
            max = vMax;

            return(bytesEnumerable.ToArray());
        }
Exemplo n.º 2
0
        glTFLoader.Schema.Buffer CreateNormalsBuffer(Rhino.Geometry.Collections.MeshVertexNormalList normals, out Vector3f min, out Vector3f max)
        {
            byte[] bytes = GetNormalsBytes(normals, out min, out max);

            return(new glTFLoader.Schema.Buffer()
            {
                Uri = Constants.TextBufferHeader + Convert.ToBase64String(bytes),
                ByteLength = bytes.Length,
            });
        }
Exemplo n.º 3
0
 private void addRhinoMeshVertices(Rhino.Geometry.Collections.MeshTopologyVertexList meshVertexList, Rhino.Geometry.Collections.MeshVertexNormalList meshVertexNormalList)
 {
     for (int i = 0; i < meshVertexList.Count; i++)
     {
         addVertex(UsefulFunctions.convertPointToVector(meshVertexList[i]));
     }
 }