public virtual void Render(World world, Faces faces, RenderSettings settings) { if (_initialized == false) { this.Initialize(world); } }
public void Reload(Shape shape, Mesh mesh) { //Load indices into the group var indices = mesh.GetIndices().ToArray(); Faces.Clear(); for (int i = 0; i < indices.Length; i++) { Faces.Add(indices[i]); } if (!PrimitiveTypes.ContainsKey(mesh.PrimitiveType)) { throw new Exception($"Unsupported primitive type! {mesh.PrimitiveType}"); } //Set the primitive type PrimitiveType = PrimitiveTypes[mesh.PrimitiveType];; switch (Stride) { case 2: DrawElementsType = DrawElementsType.UnsignedShort; break; case 4: DrawElementsType = DrawElementsType.UnsignedInt; break; case 1: DrawElementsType = DrawElementsType.UnsignedByte; break; } }
public bool IsValid(decimal epsilon = 0.5m) { return(!GetCoplanarFaces().Any() && // Check coplanar faces !GetBackwardsFaces(epsilon).Any() && // Check faces are pointing outwards !Faces.Any(x => x.GetNonPlanarVertices(epsilon).Any()) && // Check face vertices are all on the plane Faces.All(x => x.IsConvex())); // Check all faces are convex }
// Methods public void AddFace(int faceIndex) { if (!IsFaceAlreadyAdded(faceIndex)) { Faces.Add(faceIndex); } }
/// <summary> /// Conway's kis operator /// </summary> /// <returns>the kis as a new mesh</returns> public Mesh Kis() { // vertices and faces to vertices var vertexPoints = Enumerable.Concat(Vertices.Select(v => v.Position), Faces.Select(f => f.Centroid)); // vertex lookup Dictionary <string, int> vlookup = new Dictionary <string, int>(); int n = Vertices.Count; for (int i = 0; i < n; i++) { vlookup.Add(Vertices[i].Name, i); } // create new tri-faces (like a fan) var faceIndices = new List <IEnumerable <int> >(); // faces as vertex indices for (int i = 0; i < Faces.Count; i++) { foreach (var edge in Faces[i].GetHalfedges()) { // create new face from edge start, edge end and centroid faceIndices.Add(new int[] { vlookup[edge.Prev.Vertex.Name], vlookup[edge.Vertex.Name], i + n }); } } return(new Mesh(vertexPoints, faceIndices)); }
/// <summary> /// Get path geometry for Polar points /// </summary> /// <param name="pointCollection"></param> /// <returns></returns> private static Geometry GetPathGeometry(List <DataPoint> pointCollection) { PathGeometry geometry = new PathGeometry(); PathFigure pathFigure = new PathFigure(); if (pointCollection.Count > 0) { pathFigure.StartPoint = pointCollection[0]._visualPosition; for (int i = 1; i < pointCollection.Count; i++) { LineSegment segment = new LineSegment(); segment.Point = pointCollection[i]._visualPosition; Faces faces = new Faces(); pathFigure.Segments.Add(segment); } } geometry.Figures.Add(pathFigure); return(geometry); }
public void Reset() { VertexValue = 0; Vertices.Clear(); Edges.Clear(); Faces.Clear(); }
public String SaveFace(string username, Byte[] faceBlob) { try { var exisitingUserId = GetUserId(username); if (exisitingUserId == 0) { exisitingUserId = GenerateUserId(); } using (var db = new EmguDBContext()) { var face = new Faces() { username = username, userid = exisitingUserId, faceSample = faceBlob }; db.Faces.Add(face); db.SaveChanges(); } //_sqLiteConnection.Open(); //var insertQuery = "INSERT INTO faces(username, faceSample, userId) VALUES(@username,@faceSample,@userId)"; //var cmd = new SQLiteCommand(insertQuery, _sqLiteConnection); //cmd.Parameters.AddWithValue("username", username); //cmd.Parameters.AddWithValue("userId", exisitingUserId); //cmd.Parameters.Add("faceSample", DbType.Binary, faceBlob.Length).Value = faceBlob; //var result = cmd.ExecuteNonQuery(); return(String.Format("face(s) saved successfully")); } catch (Exception ex) { return(ex.Message); } }
/// <summary> /// Add one or more Faces (or an array) to this set of entities. /// </summary> /// <param name="faces"></param> public void Add(params Face[] faces) { foreach (Face face in faces) { Faces.Add(face); } }
public Faces DetectFaces(byte[] imageData = null, string imageDataName = null, string imageDataMimeType = null, string[] urls = null) { Faces result = null; if (imageData == null && (urls == null || urls.Length < 1)) { throw new ArgumentNullException(string.Format("{0} or {1} are required for 'DetectFaces()'", nameof(imageData), "'urls'")); } if (imageData != null) { if (string.IsNullOrEmpty(imageDataName) || string.IsNullOrEmpty(imageDataMimeType)) { throw new ArgumentNullException(string.Format("{0} and {1} are required for 'DetectFaces()'", nameof(imageDataName), nameof(imageDataMimeType))); } } try { string parameters = null; if (urls != null && urls.Length > 0) { DetectFacesParameters parametersObject = new DetectFacesParameters(); parametersObject.URLs = urls != null ? urls : new string[0]; parameters = JsonConvert.SerializeObject(parametersObject); } var formData = new MultipartFormDataContent(); if (imageData != null) { var imageContent = new ByteArrayContent(imageData); imageContent.Headers.ContentType = MediaTypeHeaderValue.Parse(imageDataMimeType); formData.Add(imageContent, imageDataName, imageDataName); } if (!string.IsNullOrEmpty(parameters)) { var parametersContent = new StringContent(parameters, Encoding.UTF8, HttpMediaType.TEXT_PLAIN); parametersContent.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json"); formData.Add(parametersContent); } result = this.Client.PostAsync($"{ this.Endpoint}{PATH_DETECT_FACES}") .WithArgument("version", VERSION_DATE_2016_05_20) .WithArgument("api_key", ApiKey) .WithBodyContent(formData) .As <Faces>() .Result; } catch (AggregateException ae) { throw ae.Flatten(); } return(result); }
public Expressions(ResourceSet parent) : base("Expressions", parent) { Faces faces = Db.Get().Faces; Angry = new Expression("Angry", this, faces.Angry); Suffocate = new Expression("Suffocate", this, faces.Suffocate); RecoverBreath = new Expression("RecoverBreath", this, faces.Uncomfortable); RedAlert = new Expression("RedAlert", this, faces.Hot); Hungry = new Expression("Hungry", this, faces.Hungry); SickSpores = new Expression("SickSpores", this, faces.SickSpores); Zombie = new Expression("Zombie", this, faces.Zombie); SickFierySkin = new Expression("SickFierySkin", this, faces.SickFierySkin); SickCold = new Expression("SickCold", this, faces.SickCold); Sick = new Expression("Sick", this, faces.Sick); Cold = new Expression("Cold", this, faces.Cold); Hot = new Expression("Hot", this, faces.Hot); FullBladder = new Expression("FullBladder", this, faces.Uncomfortable); Tired = new Expression("Tired", this, faces.Tired); Unhappy = new Expression("Unhappy", this, faces.Uncomfortable); Uncomfortable = new Expression("Uncomfortable", this, faces.Uncomfortable); Happy = new Expression("Happy", this, faces.Happy); Relief = new Expression("Relief", this, faces.Happy); Neutral = new Expression("Neutral", this, faces.Neutral); for (int num = Count - 1; num >= 0; num--) { resources[num].priority = 100 * (Count - num); } }
private void GetBook(Faces face) { List <Card> cardsToRemove = new List <Card>(); int count = 0; foreach (Card card in hand) { if (card.Face == face) { count++; } } if (count == 4) { Num_Of_Books++; foreach (Card card in hand) { if (card.Face == face) { books.Add(card); cardsToRemove.Add(card); } } foreach (Card card in cardsToRemove) { hand.Remove(card); Num_Of_Cards--; } } }
public Faces DetectFaces(string url) { if (string.IsNullOrEmpty(url)) { throw new ArgumentNullException("'url' is required for 'DetectFaces()'"); } Faces result = null; try { result = this.Client.GetAsync($"{this.Endpoint}{PATH_DETECT_FACES}") .WithArgument("url", url) .WithArgument("version", VERSION_DATE_2016_05_20) .WithArgument("api_key", ApiKey) .As <Faces>() .Result; } catch (AggregateException ae) { throw ae.Flatten(); } return(result); }
public int AddFace(int a, int b, int c, int mtl, int gen) {//不排重了 if (a == b || b == c || a == c) { return(-1); } var f = new Face(); f.A = a; f.B = b; f.C = c; f.Mtl = mtl; f.Gen = gen; f.FaceNormal = Vector3.CalcFaceNormal(ref Vertices[a].Position, ref Vertices[b].Position, ref Vertices[c].Position); f.Area = Vector3.CalcArea3(ref Vertices[a].Position, ref Vertices[b].Position, ref Vertices[c].Position); f.Area = Math.Abs(f.Area) * 0.5f; Faces.Add(f); var index = Faces.Count - 1; Atoms[mtl].AddFace(index); return(index); }
protected override object GetFieldValue(Item cognitiveIndexable) { if (Faces == null || Faces.Length == 0) { return(null); } if (Faces.Any(x => x.FaceAttributes.Gender.Equals("male")) && Faces.Any(x => x.FaceAttributes.Gender.Equals("female"))) { return(2); } if (Faces.Any(x => x.FaceAttributes.Gender.Equals("male"))) { return(3); } if (Faces.Any(x => x.FaceAttributes.Gender.Equals("female"))) { return(4); } return(1); }
Mesh <VertexPositionTexture> GetQuad(Faces face) { switch (face) { case Faces.Left: return(_leftQuad); case Faces.Bottom: return(_bottomQuad); case Faces.Forward: return(_forwardQuad); case Faces.Right: return(_rightQuad); case Faces.Top: return(_topQuad); case Faces.Backward: return(_backwardQuad); default: throw new ArgumentOutOfRangeException("face"); } }
public Coordinate GetOrigin() { var points = Faces.SelectMany(x => x.Vertices.Select(y => y.Location)).ToList(); var origin = points.Aggregate(Coordinate.Zero, (x, y) => x + y) / points.Count; return(origin); }
public static Vector3 GetNormal(this Faces face) { switch (face) { case Faces.Left: return(Vector3.Left); case Faces.Bottom: return(Vector3.Down); case Faces.Forward: return(Vector3.ForwardRH); case Faces.Right: return(Vector3.Right); case Faces.Top: return(Vector3.Up); case Faces.Backward: return(Vector3.BackwardRH); default: Debug.Fail("When calling GetNormal, face must be set to a single face."); return(Vector3.Left); } }
private List <Edge2D> GetAllExistedEdges() { List <Edge2D> result = Faces.SelectMany(f => f.AllParents).SelectMany(f => f.BasicEdges).Distinct().ToList(); result.AddRange(AllEdges); return(result); }
private void PerformRoll() { if (Number > MAX_DICE_COUNT) { throw new TooManyDicesException(Number); } RollResult = Add; Random random = new Random(); diceResults = new List <BigInteger>(); if (Faces == 1) { RollResult += Number; } else { byte[] bytes = Faces.ToByteArray(); for (int i = 0; i < Number; i++) { random.NextBytes(bytes); bytes[bytes.Length - 1] &= (byte)0x7F; BigInteger roll = new BigInteger(bytes) % Faces + 1; if (Number <= MAX_DICE_RESULT_COUNT) { DiceResults.Add(roll); } RollResult += roll; } } }
/// <summary> /// Split the given face on the given plane. Remove the original face /// and add as many new faces as required for the split. /// </summary> /// <param name="faceIndex">The index of the face to split.</param> /// <param name="plane">The plane to split the face on. The face will not be split /// if it is not intersected by this plane.</param> /// <param name="onPlaneDistance">If a given edge of the face has a vertex that is within /// this distance of the plane, the edge will not be split.</param> /// <returns>Returns if the edge was actually split.</returns> public bool SplitFace(int faceIndex, Plane plane, double onPlaneDistance = .001) { var newVertices = new List <Vector3Float>(); var newFaces = new List <Face>(); if (Faces[faceIndex].Split(this.Vertices, plane, newFaces, newVertices, onPlaneDistance)) { var vertexCount = Vertices.Count; // remove the face index Faces.RemoveAt(faceIndex); // add the new vertices Vertices.AddRange(newVertices); // add the new faces (have to make the vertex indices to the new vertices foreach (var newFace in newFaces) { Face faceNewIndices = newFace; faceNewIndices.v0 += vertexCount; faceNewIndices.v1 += vertexCount; faceNewIndices.v2 += vertexCount; Faces.Add(faceNewIndices); } CleanAndMerge(); return(true); } return(false); }
private List <int[]> FaceEdgePairs() { var allEdgePairs = new List <int[]>(); var edgePairCounts = new Dictionary <int, int>(); var i = 0; do { var numInFace = (Faces[i] == 0) ? 3 : 4; if ((i + numInFace) < Faces.Count()) { i++; for (var v = 0; v < numInFace; v++) { var pair = (new int[] { Faces[i + v], Faces[((v + 1) == numInFace) ? i : i + v + 1] }).OrderBy(n => n).ToArray(); var foundIndex = allEdgePairs.FindIndex(ep => EqualPair(ep, pair)); if (foundIndex >= 0) { edgePairCounts[foundIndex]++; } else { allEdgePairs.Add(pair); edgePairCounts.Add(allEdgePairs.IndexOf(pair), 1); } } } i += numInFace; } while (i < Faces.Count()); var edgePairIndices = edgePairCounts.Where(kvp => kvp.Value == 1).Select(kvp => kvp.Key).ToList(); return(edgePairIndices.Select(pi => allEdgePairs[pi]).ToList()); }
/// <summary> /// Add one or more Faces from a list to this set of entities. /// </summary> /// <param name="faces"></param> public void Add(IList<Face> faces) { foreach (Face face in faces) { Faces.Add(face); } }
/// <summary> /// Gets the length component. If faces is set to a positive (Right, Top or Backward), the sign of the returned value will be flipped. /// Faces cant use a combination of bit-flags or be set to None. /// </summary> public int GetLengthComponent(Faces faces) { switch (faces) { case Faces.Left: return(Length); case Faces.Bottom: return(Height); case Faces.Forward: return(Width); case Faces.Right: return(Length); case Faces.Top: return(Height); case Faces.Backward: return(Width); default: throw new ArgumentOutOfRangeException("faces"); } }
/// <summary> /// Removes all vertices without faces. /// </summary> private void Cleanup() { if (Faces == null) { return; } List <Vector> newVertices = new List <Vector>(); foreach (Vector vertex in Vertices) { bool contained = false; foreach (Face face in Faces) { if (face.Contains(vertex)) { contained = true; break; } } if (contained) { newVertices.Add(vertex); } } Vertices = newVertices; TextureCoordinates = Faces.SelectMany(x => x.Vertices).Where(x => x is Vertex).Select(x => new TextureCoordinate(((Vertex)x).U, ((Vertex)x).V)).Distinct().ToList(); }
/// <summary> /// Returns the face that is visually below. Cant use bit-flags or be set to None. /// </summary> public static Faces GetTopVisualFace(this Faces face) { switch (face) { case Faces.Left: return(Faces.Top); case Faces.Right: return(Faces.Top); case Faces.Forward: return(Faces.Top); case Faces.Backward: return(Faces.Top); case Faces.Bottom: return(Faces.Backward); case Faces.Top: return(Faces.Forward); default: throw new ArgumentOutOfRangeException("face"); } }
public void SetFace(Faces Face) { Image i = new Image(); switch (Face) { case Faces.Frowny: i.Source = Frowny; BTN_Face.Content = i; break; case Faces.Nervous: i.Source = Nervous; BTN_Face.Content = i; break; case Faces.Smiley: i.Source = Smiley; BTN_Face.Content = i; break; case Faces.Winner: i.Source = Winner; BTN_Face.Content = i; break; } }
/// <summary> /// Returns the intersection point closest to the start of the line. /// </summary> /// <param name="line">The intersection line</param> /// <returns>The closest intersecting point, or null if the line doesn't intersect.</returns> public override Coordinate GetIntersectionPoint(Line line) { return(Faces.Select(x => x.GetIntersectionPoint(line)) .Where(x => x != null) .OrderBy(x => (x - line.Start).VectorMagnitude()) .FirstOrDefault()); }
/// <summary> /// Constructor to build a custom mesh from Rhino's mesh type /// </summary> /// <param name="source">the Rhino mesh</param> public Mesh(Rhino.Geometry.Mesh source) : this() { // Check that the mesh is oriented and manifold bool isOriented, hasBoundary; var isManifold = source.IsManifold(true, out isOriented, out hasBoundary); if (!isManifold || !isOriented) { return; } // Remove unused vertices source.Vertices.CullUnused(); //var faces = Enumerable.Range(0, source.Faces.Count).Select(i => source.TopologyVertices.IndicesFromFace(i)); //InitIndexed(source.TopologyVertices, faces); // Add vertices Vertices.Capacity = source.TopologyVertices.Count; foreach (Point3f p in source.TopologyVertices) { Vertices.Add(new Vertex(p)); } // Add faces (and construct halfedges and store in hash table) for (int i = 0; i < source.Faces.Count; i++) { var vertices = source.TopologyVertices.IndicesFromFace(i).Select(v => Vertices[v]); Faces.Add(vertices); } // Find and link halfedge pairs Halfedges.MatchPairs(); }
private void make_rotation_figure(int cnt_breaks, Edge rot_line, List<Point3d> pts) { double angle = 360.0 / cnt_breaks; angle = angle / 180.0 * Math.PI; double Ax = rot_line.P1.X, Ay = rot_line.P1.Y, Az = rot_line.P1.Z; foreach (var p in pts) p.Apply(Transformation.Translate(-Ax, -Ay, -Az)); List<Point3d> new_pts = new List<Point3d>(); foreach (var p in pts) new_pts.Add(new Point3d(p.X, p.Y, p.Z)); for (int i = 0; i < cnt_breaks; ++i) { foreach (var np in new_pts) np.Apply(Transformation.RotateY(angle)); for (int j = 1; j < pts.Count; ++j) { Face f = new Face(new List<Point3d>(){ new Point3d(pts[j - 1]), new Point3d(new_pts[j - 1]), new Point3d(new_pts[j]), new Point3d(pts[j])}); Faces.Add(f); } foreach (var p in pts) p.Apply(Transformation.RotateY(angle)); } find_center(); }
public static string GetIt(string cowPath, Faces face, bool isThink, int columns, string message) { string[] lines = Wrap (message, columns); string eyes = ConstructFace (face); string thoughts = isThink ? "o" : "\\"; string tongue = " "; StringBuilder sb = new StringBuilder (); ConstructBallon (lines, isThink, sb); sb.AppendLine (FetchAndFormatCow (cowPath ?? DefaultCowPath, thoughts, eyes, tongue)); return sb.ToString (); }
public ActionResult Overlay(string url, int entry) { if (string.IsNullOrEmpty(url)) url = "https://twimg0-a.akamaihd.net/profile_images/769005756/paulstork_foto.png"; //url = "http://museummobile.info/wp-content/uploads/2010/05/NancyPic.png"; using (var db = new DatabaseService()) { string cachefile = @"c:\MWHackathon\Assets\uploaded\" + url.Substring(url.LastIndexOf('/') + 1) + ".json"; string json = ""; if (System.IO.File.Exists(cachefile)) json = System.IO.File.ReadAllText(cachefile); else { json = db.FacialData(url); System.IO.File.WriteAllText(cachefile, json); } var upFaces = new Faces(json, url, null, null); int amount = upFaces.Amount; if (amount < 1) { Response.Write("Darn, I can't find a face in there! Please go back and try a different one."); return new EmptyResult(); } if (amount > 1) { Response.Write("Sorry, this one seems to have multiple faces. I haven't built that yet. Please go back and try a different one."); return new EmptyResult(); } var dbEntry = db.GetAllEntries().First(e => e.id == entry); var dbFace = GetFace(dbEntry); var rnd = new Random(); var allentries = GetEntries(db, amount); var dbNextEntry = allentries.ElementAt(rnd.Next(0,allentries.Count)); var dbNextFace = GetFace(dbNextEntry); ViewBag.Entry = dbEntry; ViewBag.Faces = upFaces; ViewBag.NextFace = dbNextEntry; return View(dbFace); } }
static public TilePosition GetFaceNormal(Faces face) { switch (face) { case Faces.Back: return new TilePosition(0, 0, 1); case Faces.Front: return new TilePosition(0, 0, -1); case Faces.Bottom: return new TilePosition(0, -1, 0); case Faces.Top: return new TilePosition(0, 1, 0); case Faces.Right: return new TilePosition(1, 0, 0); case Faces.Left: return new TilePosition(-1, 0, 0); } return new TilePosition(0, 0, 0); }
static public Faces GetOpposingFace(Faces face) { switch (face) { case Faces.Back: return Faces.Front; case Faces.Front: return Faces.Back; case Faces.Bottom: return Faces.Top; case Faces.Top: return Faces.Bottom; case Faces.Right: return Faces.Left; case Faces.Left: return Faces.Right; } return Faces.Left; }
static string ConstructFace(Faces face) { switch (face) { case Faces.Borg: return "=="; case Faces.Dead: return "U "; case Faces.Greedy: return "$$"; case Faces.Paranoid: return "@@"; case Faces.Stoned: return "**"; case Faces.Tired: return "--"; case Faces.Wired: return "OO"; case Faces.Young: return ".."; default: return "oo"; } }
private int getPlayerId(Faces wall) { // Important: depends on the order of the enums in Faces. return (int) wall; }
public Cards(Suit S, Faces F) { Suits = S; Face = F; }
public Card(Suits suit, Faces face) { Suit = suit; Face = face; }
public void handleWallHit(Faces wallFace) { if (Network.isServer && gameStarted) { int playerNum = getPlayerId(wallFace); networkView.RPC("decreaseHealth", RPCMode.AllBuffered, playerNum); } }