コード例 #1
0
        public void RenderMaterial_SerializationPreservesValues()
        {
            RenderMaterial mat = new RenderMaterial();

            mat.NormalID       = UUID.Random();
            mat.NormalOffsetX  = 2.0f;
            mat.NormalOffsetY  = 2.0f;
            mat.NormalRepeatX  = 2.0f;
            mat.NormalRepeatY  = 2.0f;
            mat.NormalRotation = 180.0f;

            mat.SpecularID       = UUID.Random();
            mat.SpecularOffsetX  = 2.0f;
            mat.SpecularOffsetY  = 2.0f;
            mat.SpecularRepeatX  = 2.0f;
            mat.SpecularRepeatY  = 2.0f;
            mat.SpecularRotation = 180.0f;

            mat.SpecularLightColorR = 127;
            mat.SpecularLightColorG = 127;
            mat.SpecularLightColorB = 127;
            mat.SpecularLightColorA = 255;

            mat.SpecularLightExponent = 2;
            mat.EnvironmentIntensity  = 2;
            mat.DiffuseAlphaMode      = (byte)RenderMaterial.eDiffuseAlphaMode.DIFFUSE_ALPHA_MODE_MASK;
            mat.AlphaMaskCutoff       = 2;

            byte[]         bytes  = mat.ToBytes();
            RenderMaterial newmat = RenderMaterial.FromBytes(bytes, 0, bytes.Length);

            Assert.That(newmat, Is.EqualTo(mat));
        }
コード例 #2
0
        public void RenderMaterial_SerializedMaterialGeneratesTheSameMaterialID()
        {
            RenderMaterial mat   = new RenderMaterial();
            UUID           matID = new UUID(mat.ComputeMD5Hash(), 0);

            byte[] matData = mat.ToBytes();

            RenderMaterial newmat   = RenderMaterial.FromBytes(matData, 0, matData.Length);
            UUID           newmatID = RenderMaterial.GenerateMaterialID(newmat);

            Assert.That(mat, Is.EqualTo(newmat));
            Assert.That(matID, Is.EqualTo(newmatID));
        }
コード例 #3
0
        public void RenderMaterial_ColorValueToFromMaterialTest()
        {
            RenderMaterial mat = new RenderMaterial();

            mat.SpecularLightColorR = 127;
            mat.SpecularLightColorG = 127;
            mat.SpecularLightColorB = 127;
            mat.SpecularLightColorA = 255;

            byte[]         bytes  = mat.ToBytes();
            RenderMaterial newmat = RenderMaterial.FromBytes(bytes, 0, bytes.Length);

            Assert.That(mat, Is.EqualTo(newmat));
            Assert.That(mat.SpecularLightColorR, Is.EqualTo(127));
            Assert.That(mat.SpecularLightColorG, Is.EqualTo(127));
            Assert.That(mat.SpecularLightColorB, Is.EqualTo(127));
            Assert.That(mat.SpecularLightColorA, Is.EqualTo(255));
        }