Esempio n. 1
0
        protected override void Open()
        {
            dispose += DemoHelper.BasicDemoSetup(DemoInfo);


            Scene.Engine.AddLogic(new GravityPointField(new Vector2D(500, 500), 1000, new Lifespan()));


            Light light = new Light();
            light.Position.X = 000;
            light.Position.Y = 000;
            light.Position.Z = 0100;

            Body lightBody = new Body(new PhysicsState(), ShapeFactory.CreateCircle(15, 20), 40, new Coefficients(0, 1), new Lifespan());
            BodyGraphic lightGraphic = new BodyGraphic(lightBody);

            lightGraphic.DrawProperties.Add(new Color3Property(1, 1, 1));

            Scene.AddGraphic(lightGraphic);

            lightBody.PositionChanged += delegate(object sender, EventArgs e)
            {
                light.Position = lightBody.State.Position.Linear.ToVector3D(100);
            };

            IShape shape = ShapeFactory.CreateSprite(
                Cache<SurfacePolygons>.GetItem("Monkey.png"),
                Cache<Surface>.GetItem("MonkeyNormal.bmp"),
                false, true,
                3, 8, 16,
                light);
            DemoHelper.AddGrid(DemoInfo, shape, 40, new BoundingRectangle(40, 40, 900, 900), 100, 100);

        }
 public BumpmapSpriteDrawable(
     Surface surface, 
     Surface bumpmap, 
     Vector2D[] vertexes, Vector2D[] coordinates,
     bool flip, bool xInverted, bool yInverted,
     Light light)
 {
     this.light = light;
     this.size = Math.Max(surface.Width, surface.Height);
     this.xInverted = xInverted;
     if (flip)
     {
         this.yInverted = !yInverted;
     }
     else
     {
         this.yInverted = yInverted;
     }
     this.vertexes = new ARBArrayBuffer<Vector2D>(vertexes, Vector2D.Size);
     this.coordinates = new ARBArrayBuffer<Vector2D>(coordinates, Vector2D.Size);
     this.bumpmap = new Texture2D(bumpmap, flip, new TextureOptions());
     this.sprite = new Texture2D(surface, flip, new TextureOptions());
 }
Esempio n. 3
0
 public static IShape CreateSprite(SurfacePolygons surfacePolygons, Surface bumpmap, bool xInverted, bool yInverted, int reduce, Scalar subdivide, Scalar gridSpacing, Light light)
 {
     Vector2D[][] polygons = surfacePolygons.Polygons;
     for (int index = 1; index < reduce; index++)
     {
         polygons = VertexHelper.ReduceRange(polygons, index);
     }
     polygons = VertexHelper.SubdivideRange(polygons, subdivide);
     Vector2D centroid = surfacePolygons.Offset;
     IShape shape;
     if (polygons.Length == 1)
     {
         shape = new PolygonShape(polygons[0], gridSpacing);
     }
     else
     {
         shape = new MultiPolygonShape(polygons, gridSpacing);
     }
     shape.Tag = DrawableFactory.CreateSprite(surfacePolygons.Surface, bumpmap,xInverted,yInverted, centroid,light);
     return shape;
 }
        public static BumpmapSpriteDrawable CreateSprite(
            Surface surface, Surface bumpmap, bool xInverted, bool yInverted,
            Vector2D offset, Light light)
        {
            Vector2D[] vertexes = new Vector2D[4];
            vertexes[0] = -offset;
            vertexes[1] = new Vector2D(-offset.X, surface.Height - offset.Y);
            vertexes[2] = new Vector2D(surface.Width - offset.X, surface.Height - offset.Y);
            vertexes[3] = new Vector2D(surface.Width - offset.X, -offset.Y);

            Scalar xScale = surface.Width / (Scalar)TextureHelper.GetPower(surface.Width);
            Scalar yScale = surface.Height / (Scalar)TextureHelper.GetPower(surface.Height);
            Vector2D[] coordinates = new Vector2D[4];
            coordinates[1] = new Vector2D(0, 0);
            coordinates[0] = new Vector2D(0, yScale);
            coordinates[3] = new Vector2D(xScale, yScale);
            coordinates[2] = new Vector2D(xScale, 0);
            return new BumpmapSpriteDrawable(surface, bumpmap, vertexes, coordinates, true, xInverted, yInverted, light);
        }