public List <TriangleObject> GetTriangleObjects(int primitiveIndex) { List <TriangleObject> triangleObjects = new List <TriangleObject>(); List <int> indices = GetIndices(primitiveIndex); List <Vertex> vertices = GetVertices(primitiveIndex); if ((indices.Count % 3) != 0) { throw new Exception("Indices count not a multiple of 3"); } Material material = new Material(); material.Color = new Color3f(0d, 0d, 1d); int triangleCount = indices.Count / 3; for (int triangleIndex = 0; triangleIndex < triangleCount; triangleIndex++) { string triangleName = string.Format("{0}_PRIMITIVE_{1}_TRIANGLE_{2}", Name, primitiveIndex, triangleIndex); Vertex v0 = vertices[indices[triangleIndex * 3 + 0]]; Vertex v1 = vertices[indices[triangleIndex * 3 + 1]]; Vertex v2 = vertices[indices[triangleIndex * 3 + 2]]; TriangleObject triangleObject = new TriangleObject(triangleName, v0, v1, v2, material); triangleObjects.Add(triangleObject); } return(triangleObjects); }
public MeshIntersectionResult(IIntersectionResult intersectionResult, MeshObject meshObject) { IntersectionDistance = intersectionResult.IntersectionDistance; Intersection = intersectionResult.Intersection; Object = meshObject; TriangleObject = intersectionResult.Object as TriangleObject; }
public static void SpritesGameDemo() { Velotage3DGameEngine.AudioSource.AudioSource.MODPlayer("lintro.xm"); Game mygame = new Game("VeloTage 3D - Demo"); mygame.BackgroundColor = Color.White; TriangleObject mytritobj = new TriangleObject(Color.Cyan); RectangleObject myrectobj = new RectangleObject(Color.Purple); SpriteObject mysprite = new SpriteObject(Color.Chocolate); mygame.AddObject(myrectobj); mygame.AddObject(mytritobj); mygame.AddObject(mysprite); mygame.Run(mygame.game); }
public double GetArea() => TriangleObject?.GetArea() ?? 0;
// Update is called once per frame void Update() { int i = 0; //Clean up lists if no touches if (Input.touchCount == 0) { touches.Clear(); allTriangles.Clear(); } //Debug.Log("Triangles in allTriangles: " + allTriangles.Count); //Handle removal of touches i = 0; while (i < Input.touchCount) { Touch t = Input.GetTouch(i); if (t.phase == TouchPhase.Ended) { //Find the touch and if part of triangle touchVertex thisTouch = touches.Find(touchVertex => touchVertex.touchId == t.fingerId); TriangleObject thisTriangle = allTriangles.Find(TriangleObject => TriangleObject.type == thisTouch.triangleIndex); //If part of triangle, delete that triangle if (thisTriangle != null) { //temp: send away lable if (thisTriangle.type == 2) { Wall.gameObject.SetActive(false); //T2.transform.eulerAngles = new Vector3(0, 0, 0); //T2.transform.position = new Vector2(0, 2000); } else if (thisTriangle.type == 3) { Turret.gameObject.SetActive(false); //T3.transform.eulerAngles = new Vector3(0, 0, 0); //T3.transform.position = new Vector2(0, 2000); } allTriangles.RemoveAt(allTriangles.IndexOf(thisTriangle)); //Find the other vertices of the triangle and remove them from that triangle object List <touchVertex> otherTrignaleTouches = touches.FindAll(touchVertex => touchVertex.triangleIndex == thisTouch.triangleIndex); if (otherTrignaleTouches != null) { for (int v = 0; v < otherTrignaleTouches.Count; v++) { //TriangleIndex = 0 => No triangle touches[v].triangleIndex = 0; } } } //Remove the touch touches.RemoveAt(touches.IndexOf(thisTouch)); } i++; } //Registrer all new touches i = 0; while (i < Input.touchCount) { Touch t = Input.GetTouch(i); if (t.phase == TouchPhase.Began) { touches.Add(new touchVertex(t.fingerId, t.position, 0)); } i++; } //Create all possible vectors for vertices thats is not part of triangle List <touchVertex> allUnassigned = touches.FindAll(touchVertex => touchVertex.triangleIndex == 0); if (allUnassigned.Count > 2 && allTriangles.Count < 3) { CreateVectors(); } //Create possible triangles if (allTriangles.Count < 3) { CreateTriangles(); } // If touches are moved i = 0; while (i < Input.touchCount) { Touch t = Input.GetTouch(i); touchVertex thisTouch = touches.Find(touchVertex => touchVertex.touchId == t.fingerId); if (t.phase == TouchPhase.Moved) { thisTouch.position = t.position; UpdateTrianglePositions(); UpdateTriangleAngle(); } i++; /* * TriangleObject one = allTriangles.Find(TriangleObject => TriangleObject.type == 1); * if(one != null){ * //Debug.Log(one.trianglePosition); * triangleLableOne.transform.position = one.trianglePosition; * } */ } }