public Colored3VertexesDrawable(int mode, Vector2D[] vertexes, ScalarColor3[] colors) { if (vertexes == null) { throw new ArgumentNullException("vertexes"); } if (colors == null) { throw new ArgumentNullException("colors"); } if (colors.Length != vertexes.Length) { throw new ArgumentException("TODO length !="); } this.vertexes = new ARBArrayBuffer<Vector2D>(vertexes, Vector2D.Size); this.colors = new ARBArrayBuffer<ScalarColor3>(colors, ScalarColor3.Size); this.mode = mode; }
public static ScalarColor3[] CreateColor3Array(ScalarColor3 first, ScalarColor3 rest, int count) { ScalarColor3[] result = new ScalarColor3[count]; result[0] = first; for (int index = 1; index < count; ++index) { result[index] = rest; } return result; }
public static ScalarColor3[] CreateColor3Array(ScalarColor3 first, ScalarColor3 rest, int count) { ScalarColor3[] result = new ScalarColor3[count]; result[0] = first; for (int index = 1; index < count; ++index) { result[index] = rest; } return(result); }
public static IShape CreateColoredMultiPolygon(Vector2D[][] polygons, Scalar gridSpacing) { if (polygons.Length == 1) { return(CreateColoredPolygon(polygons[0], gridSpacing)); } else { MultiPolygonShape shape = new MultiPolygonShape(polygons, gridSpacing); ScalarColor3[][] colors = new ScalarColor3[polygons.Length][]; Vector2D[][] reduced = new Vector2D[polygons.Length][]; for (int index = 0; index < polygons.Length; ++index) { reduced[index] = VertexHelper.Reduce(polygons[index]); colors[index] = CreateColor3Array(reduced[index].Length); } shape.Tag = DrawableFactory.CreateMultiPolygon(reduced, colors); return(shape); } }
public static PolygonShape CreatePolygon(Vector2D[] vertexes, Scalar gridSpacing, ScalarColor3[] colors) { PolygonShape shape = new PolygonShape(vertexes, gridSpacing); shape.Tag = DrawableFactory.CreatePolygon(vertexes, colors); return shape; }
public static IShape CreateColoredMultiPolygon(Vector2D[][] polygons, Scalar gridSpacing) { if (polygons.Length == 1) { return CreateColoredPolygon(polygons[0], gridSpacing); } else { MultiPolygonShape shape = new MultiPolygonShape(polygons, gridSpacing); ScalarColor3[][] colors = new ScalarColor3[polygons.Length][]; Vector2D[][] reduced = new Vector2D[polygons.Length][]; for (int index = 0; index < polygons.Length; ++index) { reduced[index] = VertexHelper.Reduce(polygons[index]); colors[index] = CreateColor3Array(reduced[index].Length); } shape.Tag = DrawableFactory.CreateMultiPolygon(reduced, colors); return shape; } }
public static IShape CreateMultiPolygon(Vector2D[][] polygons, Scalar gridSpacing, ScalarColor3[][] colors) { if (polygons.Length == 1) { return CreatePolygon(polygons[0], gridSpacing, colors[0]); } else { MultiPolygonShape shape = new MultiPolygonShape(polygons, gridSpacing); shape.Tag = DrawableFactory.CreateMultiPolygon(polygons, colors); return shape; } }
public static CircleShape CreateCircle(Scalar radius, int vertexCount, ScalarColor3[] colors) { CircleShape shape = new CircleShape(radius, vertexCount); shape.Tag = DrawableFactory.CreatePolygon(shape.Vertexes, colors); return shape; }
public static void AddStarField(DemoOpenInfo info, int count, BoundingRectangle rect) { Vector2D[] stars = new Vector2D[count]; ScalarColor3[] starColors = new ScalarColor3[stars.Length]; for (int index = 0; index < stars.Length; ++index) { stars[index] = new Vector2D(NextScalar(rect.Min.X, rect.Max.X), NextScalar(rect.Min.Y, rect.Max.Y)); starColors[index] = new ScalarColor3(DemoHelper.NextScalar(), DemoHelper.NextScalar(), DemoHelper.NextScalar()); } Colored3VertexesDrawable stardrawable = new Colored3VertexesDrawable(Gl.GL_POINTS, stars, starColors); Graphic stargraphic = new Graphic(stardrawable, Matrix2x3.Identity, new Lifespan()); stargraphic.ZOrder = -1; stargraphic.DrawProperties.Add(new PointSizeProperty(1)); info.Scene.AddGraphic(stargraphic); }
public static Colored3MultiVertexesDrawable CreateMultiPolygon(Vector2D[][] polygons, ScalarColor3[][] colors) { return new Colored3MultiVertexesDrawable(Gl.GL_POLYGON, polygons, colors); }
public static Colored3VertexesDrawable CreatePolygon(Vector2D[] vertexes, ScalarColor3[] colors) { return new Colored3VertexesDrawable(Gl.GL_POLYGON, vertexes, colors); }
protected override void Open() { dispose += DemoHelper.BasicDemoSetup(DemoInfo); Scene.Engine.AddLogic(new LineFluidLogic(new Line(0, -1, -400), 1.95f, .02f, new Vector2D(0, 0), new Lifespan())); Scene.Engine.AddLogic(new GravityField(new Vector2D(0, 1000), new Lifespan())); Rectangle rect1 = Viewport.Rectangle; BoundingRectangle rect = new BoundingRectangle(rect1.Left, rect1.Top, rect1.Right, rect1.Bottom); rect.Min.X -= 75; rect.Min.Y -= 75; rect.Max.X += 75; rect.Max.Y += 75; DemoHelper.AddShell(DemoInfo, rect, 100, Scalar.PositiveInfinity).ForEach(delegate(Body b) { b.IgnoresGravity = true; }); DemoHelper.AddRagDoll(DemoInfo, new Vector2D(340, 300)); DemoHelper.AddRagDoll(DemoInfo, new Vector2D(640, 300)); IShape shape = ShapeFactory.CreateSprite(Cache<SurfacePolygons>.GetItem("fighter.png"), 3, 16, 4); DemoHelper.AddShape(DemoInfo, shape, 200, new ALVector2D(0, new Vector2D(200, 300))); DemoHelper.AddShape(DemoInfo, shape, 100, new ALVector2D(0, new Vector2D(500, 300))); DemoHelper.AddRectangle(DemoInfo, 20, 200, 25 / 5, new ALVector2D(0, 600, 600)); DemoHelper.AddRectangle(DemoInfo, 20, 200, 25 / 5, new ALVector2D(0, 600, 620)); DemoHelper.AddRectangle(DemoInfo, 50, 100, 50, new ALVector2D(0, 200, 400)); DemoHelper.AddRectangle(DemoInfo, 50, 100, 50, new ALVector2D(0, 400, 200)); Vector2D[] waterVertexes = new Vector2D[4] { new Vector2D(-10, 400), new Vector2D(10000, 400), new Vector2D(10000, 1000), new Vector2D(-10, 1000) }; ScalarColor3[] waterColor = new ScalarColor3[4] { new ScalarColor3(0,0,1), new ScalarColor3(0,0,1), new ScalarColor3(0,0,1), new ScalarColor3(0,0,1) }; Colored3VertexesDrawable drawable = new Colored3VertexesDrawable(Gl.GL_QUADS, waterVertexes, waterColor); Graphic graphic = new Graphic(drawable, Matrix2x3.Identity, new Lifespan()); graphic.ZOrder = -1; Scene.AddGraphic(graphic); }