Exemplo n.º 1
0
        public void DirectionalLookup()
        {
            DirectionalLookupTableF <int> lookupTable = new DirectionalLookupTableF <int>(4);

            Assert.AreEqual(4, ((dynamic)lookupTable.Internals).Width);

            // Store 6 * 4 * 4 values.
            int value = 0;

            foreach (Vector3F direction in lookupTable.GetSampleDirections())
            {
                lookupTable[direction] = value;
                value++;
            }

            Assert.AreEqual(6 * 4 * 4, value);

            // Check values.
            value = 0;
            foreach (Vector3F direction in lookupTable.GetSampleDirections())
            {
                Assert.AreEqual(value, lookupTable[direction]);
                value++;
            }

            Assert.AreEqual(6 * 4 * 4, value);
        }
Exemplo n.º 2
0
        public void SerializationBinary()
        {
            var lookupTable = new DirectionalLookupTableF<int>(4);

              // Store 6 * 4 * 4 values.
              int value = 0;
              foreach (Vector3F direction in lookupTable.GetSampleDirections())
              {
            lookupTable[direction] = value;
            value++;
              }

              // Serialize object.
              var stream = new MemoryStream();
              var formatter = new BinaryFormatter();
              formatter.Serialize(stream, lookupTable);

              // Deserialize object.
              stream.Position = 0;
              var deserializer = new BinaryFormatter();
              lookupTable = (DirectionalLookupTableF<int>)deserializer.Deserialize(stream);

              // Check values.
              value = 0;
              foreach (Vector3F direction in lookupTable.GetSampleDirections())
              {
            Assert.AreEqual(value, lookupTable[direction]);
            value++;
              }
        }
Exemplo n.º 3
0
        public void DirectionalLookup()
        {
            DirectionalLookupTableF<int> lookupTable = new DirectionalLookupTableF<int>(4);
              Assert.AreEqual(4, ((dynamic)lookupTable.Internals).Width);

              // Store 6 * 4 * 4 values.
              int value = 0;
              foreach (Vector3F direction in lookupTable.GetSampleDirections())
              {
            lookupTable[direction] = value;
            value++;
              }

              Assert.AreEqual(6 * 4 * 4, value);

              // Check values.
              value = 0;
              foreach (Vector3F direction in lookupTable.GetSampleDirections())
              {
            Assert.AreEqual(value, lookupTable[direction]);
            value++;
              }

              Assert.AreEqual(6 * 4 * 4, value);
        }
        protected override void Write(ContentWriter output, ConvexPolyhedron value)
        {
            dynamic internals = value.Internals;
            DirectionalLookupTableF <ushort> directionalLookupTable = internals.DirectionalLookupTable;
            VertexAdjacency vertexAdjacency = internals.VertexAdjacency;

            var vertices         = value.Vertices;
            int numberOfVertices = vertices.Count;

            output.Write(numberOfVertices);
            for (int i = 0; i < numberOfVertices; i++)
            {
                output.WriteRawObject(vertices[i]);
            }

            output.WriteRawObject(value.GetAabb());
            output.WriteRawObject(value.InnerPoint);
            output.WriteObject(directionalLookupTable);
            output.WriteObject(vertexAdjacency);
        }