private static ITexture ProcessTexture(bool hasTexture, Color4D color4, TextureSlot textureSlot, string dir) { Log.Info($"Processing texture:: hasTex:{hasTexture}, Color: {color4}, Texture:{textureSlot.FilePath}"); return(hasTexture ? (ITexture) new Texture(Path.Combine(dir, textureSlot.FilePath)) : new SolidColor(Color.FromAssimpColor4(color4))); }
public static void Write(this BinaryWriter writer, Color4D val) { writer.Write(val.R); writer.Write(val.G); writer.Write(val.B); writer.Write(val.A); }
public void WriteColor4D(Color4D color) { this.Write(color.R); this.Write(color.G); this.Write(color.B); this.Write(color.A); }
public static void Write(this BinaryWriter writer, Color4D v) { writer.Write(v.R); writer.Write(v.G); writer.Write(v.B); writer.Write(v.A); }
public static Color FromAssimp(this Color4D value) { return(new Color(( byte )(value.R * 255f), ( byte )(value.G * 255f), ( byte )(value.B * 255f), ( byte )(value.A * 255f))); }
public void TestOpSubtractByValue() { float r1 = .5f, g1 = .25f, b1 = .7f, a1 = 1.0f; float value = .2f; float r = r1 - value; float g = g1 - value; float b = b1 - value; float a = a1 - value; Color4D c1 = new Color4D(r1, g1, b1, a1); //Test left to right Color4D c = c1 - value; TestHelper.AssertEquals(r, g, b, a, c, "Testing OpSubtractValue"); r = value - r1; g = value - g1; b = value - b1; a = value - a1; //Test right to left c = value - c1; TestHelper.AssertEquals(r, g, b, a, c, "Testing OpSubtractValue"); }
public static Color ToNumerics(this Color4D value) { return(new Color(( byte )(value.R * 255f), ( byte )(value.G * 255f), ( byte )(value.B * 255f), ( byte )(value.A * 255f))); }
public void TestEquals() { float r1 = .25f, g1 = .1f, b1 = .75f, a1 = 1.0f; float r2 = .75f, g2 = 1.0f, b2 = 1.0f, a2 = .5f; Color4D c1 = new Color4D(r1, g1, b1, a1); Color4D c2 = new Color4D(r1, g1, b1, a1); Color4D c3 = new Color4D(r2, g2, b2, a2); //Test IEquatable Equals Assert.IsTrue(c1.Equals(c2), "Test IEquatable equals"); Assert.IsFalse(c1.Equals(c3), "Test IEquatable equals"); //Test object equals override Assert.IsTrue(c1.Equals((object)c2), "Tests object equals"); Assert.IsFalse(c1.Equals((object)c3), "Tests object equals"); //Test op equals Assert.IsTrue(c1 == c2, "Testing OpEquals"); Assert.IsFalse(c1 == c3, "Testing OpEquals"); //Test op not equals Assert.IsTrue(c1 != c3, "Testing OpNotEquals"); Assert.IsFalse(c1 != c2, "Testing OpNotEquals"); }
public static void AssertEquals(float r, float g, float b, float a, Color4D c) { AssertEquals(r, c.R); AssertEquals(g, c.G); AssertEquals(b, c.B); AssertEquals(a, c.A); }
public static void AssertEquals(float r, float g, float b, float a, Color4D c, String msg) { AssertEquals(r, c.R, msg + String.Format(" => checking R component ({0} == {1}", r, c.R)); AssertEquals(g, c.G, msg + String.Format(" => checking G component ({0} == {1}", g, c.G)); AssertEquals(b, c.B, msg + String.Format(" => checking B component ({0} == {1}", b, c.B)); AssertEquals(a, c.A, msg + String.Format(" => checking A component ({0} == {1}", a, c.A)); }
public void TestEquals() { float r1 = .25f, g1 = .1f, b1 = .75f, a1 = 1.0f; float r2 = .75f, g2 = 1.0f, b2 = 1.0f, a2 = .5f; Color4D c1 = new Color4D(r1, g1, b1, a1); Color4D c2 = new Color4D(r1, g1, b1, a1); Color4D c3 = new Color4D(r2, g2, b2, a2); //Test IEquatable Equals Assert.IsTrue(c1.Equals(c2), "Test IEquatable equals"); Assert.IsFalse(c1.Equals(c3), "Test IEquatable equals"); //Test object equals override Assert.IsTrue(c1.Equals((object) c2), "Tests object equals"); Assert.IsFalse(c1.Equals((object) c3), "Tests object equals"); //Test op equals Assert.IsTrue(c1 == c2, "Testing OpEquals"); Assert.IsFalse(c1 == c3, "Testing OpEquals"); //Test op not equals Assert.IsTrue(c1 != c3, "Testing OpNotEquals"); Assert.IsFalse(c1 != c2, "Testing OpNotEquals"); }
private static (float emissive, float diffuse, float reflective, float refractive) ProcessMaterialParts( Color4D ambient, Color4D diffuse, Color4D specular) { (float emissive, float diffuse, float reflective, float refractive)parts = (Color.FromAssimpColor4(ambient).GetBrightness(), Color.FromAssimpColor4(diffuse).GetBrightness(), Color.FromAssimpColor4(specular).GetBrightness(), 0); return(parts); }
//public override void UnapplyMaterial(Mesh, Material, Tex) public override void ApplyGhostMaterial(Mesh mesh, Material material, bool shaded, bool twoSided) { var color = new Color4D(.6f, .6f, .9f, 0.15f); var oldColor = material.ColorDiffuse; material.ColorDiffuse = color; ApplyMaterial(mesh, material, false, shaded, twoSided); material.ColorDiffuse = oldColor; }
public static Color FromAssimpColor4(Color4D color4) { return(new Color { R = color4.R, G = color4.G, B = color4.B }); }
public static Color4 FromColor(Color4D color) { Color4 c; c.R = color.R; c.G = color.G; c.B = color.B; c.A = color.A; return c; }
public FullVertex(Vector4 position) { _position = new Vector4(0, 0, 0, 0); _normal = new Vector4(0, 0, 0, 0); _color = new Color4D(1, 1, 1, 1); _textureCoordinate = new Vector4(0, 0, 0, 0); _tangent = new Vector4(0, 0, 0, 0); _bitangent = new Vector4(0, 0, 0, 0); }
private Color4 FromColor(Color4D color) { Color4 c; c.R = color.R; c.G = color.G; c.B = color.B; c.A = color.A; return(c); }
protected Color4 toColor(Color4D color) { Color4 c; c.R = color.R; c.G = color.G; c.B = color.B; c.A = color.A; return(c); }
public static Vector4 FromAssimpColor(Color4D col) { Vector4 outCol; outCol.X = col.R; outCol.Y = col.G; outCol.Z = col.B; outCol.W = col.A; return(outCol); }
public static Color4 FromColor(Color4D color) { Color4 c; c.R = color.R; c.G = color.G; c.B = color.B; c.A = color.A; return(c); }
public void TestIsBlack() { Color4D c1 = new Color4D(0, 0, 0, 1.0f); Color4D c2 = new Color4D(.25f, 1.0f, .5f, 1.0f) * .002f; Color4D c3 = new Color4D(.25f, .65f, 1.0f); Assert.IsTrue(c1.IsBlack(), "Testing isBlack"); Assert.IsTrue(c2.IsBlack(), "Testing isBlack"); Assert.IsFalse(c3.IsBlack(), "Testing !isBlack"); }
private Color FromColor(Color4D color) { Color c; c.R = (byte)(color.R * 255); c.G = (byte)(color.G * 255); c.B = (byte)(color.B * 255); c.A = (byte)(color.A * 255); return(c); }
public void TestIndexer() { float r = .25f, g = .5f, b = .05f, a = 1.0f; Color4D c = new Color4D(); c[0] = r; c[1] = g; c[2] = b; c[3] = a; TestHelper.AssertEquals(r, c[0], "Test Indexer, R"); TestHelper.AssertEquals(g, c[1], "Test Indexer, G"); TestHelper.AssertEquals(b, c[2], "Test Indexer, B"); TestHelper.AssertEquals(a, c[3], "Test Indexer, A"); }
public void TestDivideByFactor() { float r1 = .5f, g1 = .25f, b1 = .7f, a1 = 1.0f; float value = .2f; float r = r1 / value; float g = g1 / value; float b = b1 / value; float a = a1 / value; Color4D c1 = new Color4D(r1, g1, b1, a1); Color4D c = c1 / value; TestHelper.AssertEquals(r, g, b, a, c, "Testing OpDivideByFactor"); }
public override void Convert(ConverterContext context) { var colors = context.Mesh.VertexColorChannels[0]; var color = new Color4D(1, 1, 1, 1); if (context.VertexIndex < colors.Count) { color = colors[context.VertexIndex]; } context.ValuesList.Add(color.R); context.ValuesList.Add(color.G); context.ValuesList.Add(color.B); context.ValuesList.Add(color.A); }
public void TestOpMultiply() { float r1 = .5f, g1 = .25f, b1 = .7f, a1 = 1.0f; float r2 = .2f, g2 = .1f, b2 = .05f, a2 = .25f; float r = r1 * r2; float g = g1 * g2; float b = b1 * b2; float a = a1 * a2; Color4D c1 = new Color4D(r1, g1, b1, a1); Color4D c2 = new Color4D(r2, g2, b2, a2); Color4D c = c1 * c2; TestHelper.AssertEquals(r, g, b, a, c, "Testing OpMultiply"); }
public void TestOpSubtract() { float r1 = .5f, g1 = .25f, b1 = .7f, a1 = 1.0f; float r2 = .2f, g2 = .1f, b2 = .05f, a2 = .25f; float r = r1 - r2; float g = g1 - g2; float b = b1 - b2; float a = a1 - a2; Color4D c1 = new Color4D(r1, g1, b1, a1); Color4D c2 = new Color4D(r2, g2, b2, a2); Color4D c = c1 - c2; TestHelper.AssertEquals(r, g, b, a, c, "Testing OpSubtract"); }
public void TestDivide() { float r1 = .5f, g1 = .25f, b1 = .7f, a1 = 1.0f; float r2 = .2f, g2 = .1f, b2 = .05f, a2 = .25f; float r = r1 / r2; float g = g1 / g2; float b = b1 / b2; float a = a1 / a2; Color4D c1 = new Color4D(r1, g1, b1, a1); Color4D c2 = new Color4D(r2, g2, b2, a2); Color4D c = c1 / c2; TestHelper.AssertEquals(r, g, b, a, c, "Testing OpDivide"); }
public void TestOpAdd() { float r1 = .5f, g1 = .25f, b1 = .7f, a1 = 1.0f; float r2 = .2f, g2 = .1f, b2 = .05f, a2 = .25f; float r = r1 + r2; float g = g1 + g2; float b = b1 + b2; float a = a1 + a2; Color4D c1 = new Color4D(r1, g1, b1, a1); Color4D c2 = new Color4D(r2, g2, b2, a2); Color4D c = c1 + c2; TestHelper.AssertEquals(r, g, b, a, c, "Testing OpAdd"); }
private static void WorldToScene(Scene scene, World_000B world, string textureExtension) { for (int i = 0; i < world.materialList.materialList.Length; i++) { var mat = world.materialList.materialList[i]; scene.Materials.Add(new Material() { ColorDiffuse = new Color4D( mat.materialStruct.color.R / 255f, mat.materialStruct.color.G / 255f, mat.materialStruct.color.B / 255f, mat.materialStruct.color.A / 255f), TextureDiffuse = mat.materialStruct.isTextured != 0 ? new TextureSlot() { FilePath = mat.texture.diffuseTextureName.stringString + textureExtension, TextureType = TextureType.Diffuse } : default,
public void TestOpMultiplyByScalar() { float r1 = .5f, g1 = .25f, b1 = .7f, a1 = 1.0f; float value = .2f; float r = r1 * value; float g = g1 * value; float b = b1 * value; float a = a1 * value; Color4D c1 = new Color4D(r1, g1, b1, a1); //Test left to right Color4D c = c1 * value; TestHelper.AssertEquals(r, g, b, a, c, "Testing OpMultiplyByValue"); //Test right to left c = value * c1; TestHelper.AssertEquals(r, g, b, a, c, "Testing OpMultiplyByValue"); }
public void TestOpAddValue() { float r1 = .5f, g1 = .25f, b1 = .7f, a1 = 1.0f; float value = .2f; float r = r1 + value; float g = g1 + value; float b = b1 + value; float a = a1 + value; Color4D c1 = new Color4D(r1, g1, b1, a1); //Test left to right Color4D c = c1 + value; TestHelper.AssertEquals(r, g, b, a, c, "Testing OpAddValue"); //Test right to left c = value + c1; TestHelper.AssertEquals(r, g, b, a, c, "Testing OpAddValue"); }
/// <summary> /// Retrieves a color value from the material property table. /// </summary> /// <param name="mat">Material to retrieve the data from</param> /// <param name="key">Ai mat key (base) name to search for</param> /// <param name="texType">Texture Type semantic, always zero for non-texture properties</param> /// <param name="texIndex">Texture index, always zero for non-texture properties</param> /// <returns>The color if it exists. If not, the default Color4D value is returned.</returns> public static Color4D GetMaterialColor(ref AiMaterial mat, String key, TextureType texType, uint texIndex) { IntPtr ptr = IntPtr.Zero; try { ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Color4D))); aiGetMaterialColor(ref mat, key, (uint) texType, texIndex, ptr); Color4D color = new Color4D(); if(ptr != IntPtr.Zero) { color = MemoryHelper.MarshalStructure<Color4D>(ptr); } return color; } finally { if(ptr != IntPtr.Zero) { Marshal.FreeHGlobal(ptr); } } }
private static unsafe Color4 ConvertColor(Color4D value) { return *(Color4*)&value; }
private unsafe static SharpDX.Color4 ConvertColor(Color4D value) { return *(SharpDX.Color4*)&value; }
private static bool AreNullableColorsApproxEqual(Color4D? a, Color4D? b) { if (a.HasValue != b.HasValue) { return false; } if (!a.HasValue) { return true; } var diff = a.Value - b.Value; return Math.Abs(diff.R) + Math.Abs(diff.G) + Math.Abs(diff.B) + Math.Abs(diff.A) < MergeVectorEpsilon; }
public float ToFloat(Color4D color) { return (color.R + color.G + color.B + color.A) / 4f; }
private static Color ConvertColor(Color4D c, AssimpMaterial aMaterial) { if (!aMaterial.HasColorTransparent) { // no transparency specified return Color.FromArgb(255, (byte)(255 * c.R), (byte)(255 * c.G), (byte)(255 * c.B)); } return Color.FromArgb((byte)(255 * c.A), (byte)(255 * c.R), (byte)(255 * c.G), (byte)(255 * c.B)); }
private Color4 FromColor(Color4D color) { Color4 c; c.R = color.R; c.G = color.G; c.B = color.B; c.A = color.A; return c; }
private Color FromColor(Color4D color) { Color c; c.R = (byte)(color.R * 255); c.G = (byte)(color.G * 255); c.B = (byte)(color.B * 255); c.A = (byte)(color.A * 255); return c; }
public static int ToInteger(Color4D color) { return (int)(color.R * 255) | ((int)(color.G * 255) << 8) | ((int)(color.B * 255) << 16) | ((int)(color.A * 255) << 24); }
public static void Write (this BinaryWriter writer, Color4D val) { writer.Write(val.R); writer.Write(val.G); writer.Write(val.B); writer.Write(val.A); }
private Color ConvertMaterialColor(Color4D c) { return new Color(c.R, c.G, c.B, c.A); }