/// <summary> /// Creates the array of colors. /// </summary> /// <param name="first">The color of first item in array</param> /// <param name="rest">Color of all array items except first one</param> /// <param name="count">The length of array</param> /// <returns>The array of colors created.</returns> public static ScalarColor3[] CreateColor3Array(ScalarColor3 first, ScalarColor3 rest, int count) { var result = new ScalarColor3[count]; result[0] = first; for (int index = 1; index < count; ++index) { result[index] = rest; } return(result); }
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); }
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); }