private static DSColor ByARGB(byte alpha, byte red, byte green, byte blue, string name) { DSColor clr = new DSColor(alpha, red, green, blue); clr.Name = name; return(clr); }
public DSGeometry SetColor(DSColor color) { mColor = color; if (null != Display) { Display.SetColor(mColor.IColor); } return(this); }
private bool CheckEquals(DSColor color) { if (color == null) { return(false); } return(color.AlphaValue == this.AlphaValue && color.RedValue == this.RedValue && color.GreenValue == this.GreenValue && color.BlueValue == this.BlueValue); }
internal override bool TessellateCore(IRenderPackage package) { if (base.TessellateCore(package)) { return(true); } DSColor c = (this.Color == null) ? DSColor.Yellow : this.Color; package.PushPointVertex(this.X, this.Y, this.Z); package.PushPointVertexColor(c.RedValue, c.GreenValue, c.BlueValue, c.AlphaValue); return(true); }
internal static DSColor FromIColor(IColor color) { if (null == color) { return(null); } ARGBColor c = color as ARGBColor; if (null != c) { return(c); } return(DSColor.ByARGB(color.AlphaValue, color.RedValue, color.GreenValue, color.BlueValue)); }
/// <summary> /// Extracts the underlying geometry from the topology and makes it /// persistent. /// </summary> /// <param name="color">Color to be assigned to extracted geometry.</param> /// <returns>Geometry</returns> public DSGeometry _ExtractGeometry(DSColor color) { DSGeometry geom = this.Geometry; if (null != geom) { mAutoDispose = false; //someone else is taking control geom.Persist(); if (null != color) { geom.Color = color; } } return(geom); }
public override bool Equals(object obj) { if (object.ReferenceEquals(this, obj)) { return(true); } DSColor color = obj as DSColor; if (null != color) { return(CheckEquals(color)); } IColor icolor = obj as IColor; return(icolor != null && this.CheckEquals(icolor)); }
internal override bool TessellateCore(IRenderPackage package) { if (base.TessellateCore(package)) { return(true); } DSColor c = (this.Color == null) ? DSColor.Yellow : this.Color; DSPoint[] vertices = this.Vertices; foreach (var item in vertices) { package.PushLineStripVertex(item.X, item.Y, item.Z); package.PushLineStripVertexColor(c.RedValue, c.GreenValue, c.BlueValue, c.AlphaValue); } //Close the loop package.PushLineStripVertex(vertices[0].X, vertices[0].Y, vertices[0].Z); package.PushLineStripVertexColor(c.RedValue, c.GreenValue, c.BlueValue, c.AlphaValue); package.PushLineStripVertexCount(vertices.Length + 1); return(true); }
private static DSColor ByARGB(byte alpha, byte red, byte green, byte blue, string name) { DSColor clr = new DSColor(alpha, red, green, blue); clr.Name = name; return clr; }
private bool CheckEquals(DSColor color) { if (color == null) return false; return color.AlphaValue == this.AlphaValue && color.RedValue == this.RedValue && color.GreenValue == this.GreenValue && color.BlueValue == this.BlueValue; }
/// <summary> /// Constructs a subdivision mesh by vertex shading, given an input /// array of vertex points and an input array of faces defined by a set /// of numbers, which are the indices of the vertices in the 'vertices' /// array making up the face. /// </summary> /// <param name="vertices">Input array of vertex points</param> /// <param name="faceIndices">Input array of faces indices for each /// vertex </param> /// <param name="vertexNormals">Input array of vertex normals</param> /// <param name="vertexColors">Input array of color assigned to each /// vertex </param> /// <param name="subDivisionLevel">Initial smoothness level, subDivisionLevel must /// have a value greater than or equal to 0 and less than 5.</param> /// <returns>SubDivisionMesh</returns> public static DSSubDivisionMesh ByVerticesFaceIndices(DSPoint[] vertices, int[][] faceIndices, DSVector[] vertexNormals, DSColor[] vertexColors, int subDivisionLevel) { string kMethodName = "DSSubDivisionMesh.ByVerticesFaceIndices"; if (subDivisionLevel < 0 || subDivisionLevel >= 5) throw new System.ArgumentException(string.Format(Properties.Resources.InvalidInput, "subDivisionLevel", kMethodName)); IPointEntity[] points = vertices.ConvertAll(DSGeometryExtension.ToEntity<DSPoint, IPointEntity>); if (points.Length < 3 || points.ArePointsColinear()) throw new System.ArgumentException(string.Format(Properties.Resources.InvalidInput, "vertices", kMethodName)); ISubDMeshEntity entity = HostFactory.Factory.SubDMeshByVerticesFaceIndices(points, faceIndices, subDivisionLevel); if (null == entity) throw new System.InvalidOperationException(string.Format(Properties.Resources.OperationFailed, kMethodName)); DSSubDivisionMesh mesh = new DSSubDivisionMesh(entity, true); try { if (null != vertexNormals && vertexNormals.Length > 0) { if (vertexNormals.Length != entity.GetNumVertices()) throw new System.ArgumentException(string.Format(Properties.Resources.NotEqual, "size of vertexNormals", "number of vertices"), "vertexNormals"); if (!entity.UpdateSubDMeshNormals(vertexNormals.ConvertAll((DSVector v)=>v.IVector))) throw new System.InvalidOperationException(string.Format(Properties.Resources.OperationFailed, kMethodName)); } if (null != vertexColors && vertexColors.Length > 0) { if (subDivisionLevel > 0) throw new System.InvalidOperationException(Properties.Resources.VertexColorNotSupported); if (vertexColors.Length != entity.GetNumVertices()) throw new System.ArgumentException(string.Format(Properties.Resources.NotEqual, "size of vertexColors", "number of vertices"), "vertexColors"); if (!entity.UpdateSubDMeshColors(vertexColors.ConvertAll((DSColor c)=>c.IColor))) throw new System.InvalidOperationException(string.Format(Properties.Resources.OperationFailed, kMethodName)); } } catch (System.Exception ex) { mesh.Dispose(); throw ex; } mesh.SubDivisionLevel = subDivisionLevel; return mesh; }
/// <summary> /// /// </summary> /// <param name="alpha"></param> /// <param name="red"></param> /// <param name="green"></param> /// <param name="blue"></param> /// <returns></returns> public static DSColor ByARGB(byte alpha, byte red, byte green, byte blue) { DSColor clr = new DSColor(alpha, red, green, blue); return clr; }
/// <summary> /// Sets color to entity/geometry /// </summary> /// <param name="color">Color value</param> public DSTopology SetColor(DSColor color) { return SetColorCore(color); }
/// <summary> /// Constructs a subdivision mesh by vertex shading, given an input /// array of vertex points and an input array of faces defined by a set /// of numbers, which are the indices of the vertices in the 'vertices' /// array making up the face. /// </summary> /// <param name="vertices">Input array of vertex points</param> /// <param name="faceIndices">Input array of faces indices for each /// vertex </param> /// <param name="vertexColors">Input array of color assigned to each /// vertex </param> /// <param name="subDivisionLevel">Initial smoothness level, subDivisionLevel must /// have a value greater than or equal to 0 and less than 5.</param> /// <returns>SubDivisionMesh</returns> public static DSSubDivisionMesh ByVerticesFaceIndices(DSPoint[] vertices, int[][] faceIndices, DSColor[] vertexColors, int subDivisionLevel) { return ByVerticesFaceIndices(vertices, faceIndices, null, vertexColors, subDivisionLevel); }
DSTopology SetColorCore(DSColor color) { this.Color = color; return(this); }
/// <summary> /// Sets color to entity/geometry /// </summary> /// <param name="color">Color value</param> public DSTopology SetColor(DSColor color) { return(SetColorCore(color)); }
/// <summary> /// Extracts the underlying geometry from the topology and makes it /// persistent. /// </summary> /// <param name="color">Color to be assigned to extracted geometry.</param> /// <returns>Geometry</returns> public DSGeometry _ExtractGeometry(DSColor color) { DSGeometry geom = this.Geometry; if (null != geom) { mAutoDispose = false; //someone else is taking control geom.Persist(); if (null != color) geom.Color = color; } return geom; }
/// <summary> /// Sets color by RGB value to this geometry. /// </summary> /// <param name="redValue">Red value for the color</param> /// <param name="greenValue">Green value for the color</param> /// <param name="blueValue">Blue value for the color</param> /// <returns>This geometry after color is applied</returns> public DSGeometry SetColor(byte redValue, byte greenValue, byte blueValue) { return(SetColor(DSColor.ByARGB(255, redValue, greenValue, blueValue))); }
DSTopology SetColorCore(DSColor color) { this.Color = color; return this; }
/// <summary> /// Sets color by RGB value to the underlying geometry of this topology. /// </summary> /// <param name="redValue">Red value for the color</param> /// <param name="greenValue">Green value for the color</param> /// <param name="blueValue">Blue value for the color</param> /// <returns>This topology after color is applied</returns> public DSTopology SetColor(byte redVal, byte greenVal, byte blueVal) { return(SetColor(DSColor.ByARGB(255, redVal, greenVal, blueVal))); }
/// <summary> /// /// </summary> /// <param name="alpha"></param> /// <param name="red"></param> /// <param name="green"></param> /// <param name="blue"></param> /// <returns></returns> public static DSColor ByARGB(byte alpha, byte red, byte green, byte blue) { DSColor clr = new DSColor(alpha, red, green, blue); return(clr); }