public void HelixRenderPackage_ApplyPointVertexColors_Array_Success()
        {
            var p = new HelixRenderPackage();
            Assert.NotNull(p);

            PushPointIntoPackage(p);
            p.ApplyPointVertexColors(WhiteByteArrayOfLength(1));
            Assert.AreEqual(1, p.Points.Colors.Count);
        }
        public void HelixRenderPackage_PushMesh()
        {
            var p = new HelixRenderPackage();
            Assert.NotNull(p);

            PushQuadIntoPackage(p);
            Assert.AreEqual(6, p.Mesh.Positions.Count);
            Assert.AreEqual(6, p.Mesh.TextureCoordinates.Count);
            Assert.AreEqual(6, p.Mesh.Indices.Count);
            Assert.AreEqual(0, p.Mesh.Colors.Count);
        }
        public void HelixRenderPackage_PushPoint()
        {
            var p = new HelixRenderPackage();
            Assert.NotNull(p);

            PushPointIntoPackage(p);

            Assert.AreEqual(1, p.Points.Positions.Count);
            Assert.AreEqual(1, p.Points.Indices.Count);
            Assert.AreEqual(0, p.Points.Colors.Count);
        }
        public void HelixRenderPackage_PushData_CountsAreCorrect()
        {
            var p = new HelixRenderPackage();
            Assert.NotNull(p);

            PushQuadIntoPackage(p);
            PushPointIntoPackage(p);
            PushLineIntoPackage(p);

            Assert.AreEqual(2, p.LineVertexCount);
            Assert.AreEqual(6, p.MeshVertexCount);
            Assert.AreEqual(1, p.PointVertexCount);
        }
        public void HelixRenderPackage_ApplyMeshVertexColors_Success()
        {
            var p = new HelixRenderPackage();
            Assert.NotNull(p);

            PushQuadIntoPackage(p);

            p.ApplyMeshVertexColors(WhiteByteArrayOfLength(6));
            Assert.AreEqual(6, p.Mesh.Colors.Count);
        }
        public void HelixRenderPackage_ApplyLineVertexColors_Array_Success()
        {
            var p = new HelixRenderPackage();
            Assert.NotNull(p);

            PushLineIntoPackage(p);
            p.ApplyLineVertexColors(WhiteByteArrayOfLength(2));
            Assert.AreEqual(2, p.Lines.Colors.Count);
        }
        public void HelixRenderPackage_ManyLineVertexColors_AllLineStripVerticesHaveColor_False()
        {
            var p = new HelixRenderPackage();
            Assert.NotNull(p);

            // Different line strip vertex colors.
            HelixRenderPackageTests.PushLineIntoPackage(p);
            p.AddLineStripVertexColor(255, 0, 0, 255);
            p.AddLineStripVertexColor(255, 255, 0, 0);

            Assert.False(p.AllLineStripVerticesHaveColor(Color.FromArgb(255, 255, 0, 0)));
        }
        public void HelixRenderPackage_SingleLineVertexColor_AllLineStripVerticesHaveColor_True()
        {
            var p = new HelixRenderPackage();
            Assert.NotNull(p);

            // Same line strip vertex colors.
            HelixRenderPackageTests.PushLineIntoPackage(p);
            p.AddLineStripVertexColor(255,0,0,255);
            p.AddLineStripVertexColor(255,0,0,255);

            Assert.True(p.AllLineStripVerticesHaveColor(Color.FromArgb(255,255,0,0)));
        }
 public void HelixRenderPackage_Construction_IsInitializedCorrectly()
 {
     var p = new HelixRenderPackage();
     Assert.NotNull(p);
 }
        public void HelixRenderPackage_MeshColorBufferCheck()
        {
            var p = new HelixRenderPackage();

            PushQuadIntoPackage(p);

            var testColors = WhiteByteArrayOfLength(6);

            p.ApplyMeshVertexColors(testColors);

            Assert.AreEqual(p.MeshVertexColors, testColors);
        }
        public void HelixRenderPackage_MeshVertexBufferCheck()
        {
            var p = new HelixRenderPackage();

            PushQuadIntoPackage(p);

            var test1 = p.MeshVertices.Skip(3).Take(3).ToArray();
            var test2 = p.MeshNormals.Take(3).ToArray();

            // Expect Y Up.
            Assert.AreEqual(test1, new double[]{1,0,0});
            Assert.AreEqual(test2, new double[]{0,1,0});
        }
        public void HelixRenderPackage_Clear_IsClearedCompletely()
        {
            var p = new HelixRenderPackage();

            PushQuadIntoPackage(p);

            p.Clear();

            Assert.IsEmpty(p.Points.Positions);
            Assert.IsEmpty(p.Points.Indices);
            Assert.IsEmpty(p.Points.Colors);

            Assert.IsEmpty(p.Mesh.Positions);
            Assert.IsEmpty(p.Mesh.Normals);
            Assert.IsEmpty(p.Mesh.Indices);
            Assert.IsEmpty(p.Mesh.TextureCoordinates);
            Assert.IsEmpty(p.Mesh.Colors);

            Assert.IsEmpty(p.Lines.Positions);
            Assert.IsEmpty(p.Lines.Indices);
            Assert.IsEmpty(p.Lines.Colors);
        }
 private PointGeometryModel3D CreatePointGeometryModel3D(HelixRenderPackage rp)
 {
     var pointGeometry3D = new PointGeometryModel3D
     {
         Geometry = HelixRenderPackage.InitPointGeometry(),
         Transform = Model1Transform,
         Color = Color.White,
         Figure = PointGeometryModel3D.PointFigure.Ellipse,
         Size = defaultPointSize,
         IsHitTestVisible = true,
         IsSelected = rp.IsSelected
     };
     return pointGeometry3D;
 }
 private LineGeometryModel3D CreateLineGeometryModel3D(HelixRenderPackage rp)
 {
     var lineGeometry3D = new LineGeometryModel3D()
     {
         Geometry = HelixRenderPackage.InitLineGeometry(),
         Transform = Model1Transform,
         Color = Color.White,
         Thickness = 0.5,
         IsHitTestVisible = true,
         IsSelected = rp.IsSelected
     };
     return lineGeometry3D;
 }
        private DynamoGeometryModel3D CreateDynamoGeometryModel3D(HelixRenderPackage rp)
        {
            var meshGeometry3D = new DynamoGeometryModel3D()
            {
                Transform = Model1Transform,
                Material = WhiteMaterial,
                IsHitTestVisible = true,
                RequiresPerVertexColoration = rp.RequiresPerVertexColoration,
                IsSelected = rp.IsSelected,
            };

            if (rp.Colors != null)
            {
                var pf = PixelFormats.Bgra32;
                var stride = (rp.ColorsStride / 4 * pf.BitsPerPixel + 7) / 8;
                try
                {
                    var diffMap = BitmapSource.Create(rp.ColorsStride / 4, rp.Colors.Count() / rp.ColorsStride, 96.0, 96.0, pf, null,
                        rp.Colors.ToArray(), stride);
                    var diffMat = new PhongMaterial
                    {
                        Name = "White",
                        AmbientColor = PhongMaterials.ToColor(0.1, 0.1, 0.1, 1.0),
                        DiffuseColor = defaultMaterialColor,
                        SpecularColor = PhongMaterials.ToColor(0.0225, 0.0225, 0.0225, 1.0),
                        EmissiveColor = PhongMaterials.ToColor(0.0, 0.0, 0.0, 1.0),
                        SpecularShininess = 12.8f,
                        DiffuseMap = diffMap
                    };
                    meshGeometry3D.Material = diffMat;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.WriteLine(ex.StackTrace);
                }
            }
            ((MaterialGeometryModel3D)meshGeometry3D).SelectionColor = defaultSelectionColor;

            return meshGeometry3D;
        }