private void GenerateQuad(GiftWrapQuad quad) { PhysicsComponent physics = Scene.ComponentManager.GetComponent<PhysicsComponent>(); Vertices vets = new Vertices(); vets.Add(quad.TopLeft); vets.Add(quad.TopRight); vets.Add(quad.BottomRight); vets.Add(quad.BottomLeft); List<Vector2> physicsVerts = new List<Vector2>(); vets.ToList<Vector2>().ForEach(s => physicsVerts.Add(ConvertUnits.ToSimUnits(s))); /* List<Vertices> vers = EarclipDecomposer.ConvexPartition(new Vertices(physicsVerts)); Body body = BodyFactory.CreateCompoundPolygon(physics.World, vers, 1); body.BodyType = BodyType.Static; body.IsSensor = true; body.OnCollision += (a, b, c) => { quad._collision++; return true; }; body.OnSeparation += (a, b) => { quad._collision--; }; //body.CollisionCategories = Category.Cat28; //body.CollidesWith = Category.Cat27; VertexPositionTexture[] currentQuad = new VertexPositionTexture[6]; float topDistance = Vector2.Distance(quad.TopLeft, quad.TopRight) / 100; float bottomDistance = Vector2.Distance(quad.BottomLeft, quad.BottomRight) / 100; currentQuad[0].Position = new Vector3(quad.TopLeft, 0); currentQuad[0].TextureCoordinate = new Vector2(0, 0); currentQuad[1].Position = new Vector3(quad.TopRight, 0); currentQuad[1].TextureCoordinate = new Vector2(topDistance, 0); currentQuad[2].Position = new Vector3(quad.BottomRight, 0); currentQuad[2].TextureCoordinate = new Vector2(bottomDistance, 1); currentQuad[3].Position = new Vector3(quad.TopLeft, 0); currentQuad[3].TextureCoordinate = new Vector2(0, 0); currentQuad[4].Position = new Vector3(quad.BottomRight, 0); currentQuad[4].TextureCoordinate = new Vector2(bottomDistance, 1); currentQuad[5].Position = new Vector3(quad.BottomLeft, 0); currentQuad[5].TextureCoordinate = new Vector2(0, 1); _renderVerticies.Add(quad, currentQuad);*/ }
private void GenerateQuad(GiftWrapQuad quad) { VertexPositionColor[] currentQuad = new VertexPositionColor[6]; Color topLeft, topRight, bottomLeft, bottomRight; topLeft = topRight = _topColor; bottomLeft = bottomRight = _bottomColor; currentQuad[0].Position = new Vector3(quad.TopLeft, 0); currentQuad[0].Color = topLeft; currentQuad[1].Position = new Vector3(quad.TopRight, 0); currentQuad[1].Color = topRight; currentQuad[2].Position = new Vector3(quad.BottomRight, 0); currentQuad[2].Color = bottomRight; currentQuad[3].Position = new Vector3(quad.TopLeft, 0); currentQuad[3].Color = topLeft; currentQuad[4].Position = new Vector3(quad.BottomRight, 0); currentQuad[4].Color = bottomRight; currentQuad[5].Position = new Vector3(quad.BottomLeft, 0); currentQuad[5].Color = bottomLeft; _renderVerticies.Add(currentQuad); }