Esempio n. 1
0
        public void Draw(gxtSpriteBatch spriteBatch, Vector2 position, float rotation, Vector2 scale, SpriteEffects spriteEffects)
        {
            if (!visible || entity == null)
                return;

            entity.Draw(spriteBatch, position, rotation, scale, spriteEffects, colorOverlay, renderDepth);
        }
Esempio n. 2
0
        public virtual void Draw(gxtSpriteBatch spriteBatch, Vector2 position, float rotation, Vector2 scale, SpriteEffects spriteEffects, Color colorOverlay, float renderDepth)
        {
            gxtDebug.Assert(gxtPrimitiveManager.SingletonIsInitialized);

            //float radiusOverDefault = radius / gxtPrimitiveManager.Singleton.CircleTextureRadius;
            scale = new Vector2(scale.X * radiusOverTextureRadius, scale.Y * radiusOverTextureRadius);

            spriteBatch.DrawSprite(gxtPrimitiveManager.Singleton.CircleTexture, position, colorOverlay, rotation, new Vector2(gxtPrimitiveManager.Singleton.CircleTextureRadius),
                scale, SpriteEffects.None, renderDepth);
        }
Esempio n. 3
0
File: gxtLine.cs Progetto: Loko/GXT
        public void Draw(gxtSpriteBatch spriteBatch, Vector2 position, float rotation, Vector2 scale, SpriteEffects spriteEffects, Color colorOverlay, float renderDepth)
        {
            gxtDebug.Assert(gxtPrimitiveManager.SingletonIsInitialized);

            Matrix rotMat = Matrix.CreateRotationZ(rotation);
            Vector2 tStart = Vector2.Transform(Vector2.Multiply(start, scale), rotMat) + position;

            spriteBatch.DrawSprite(gxtPrimitiveManager.Singleton.PixelTexture, tStart, colorOverlay, angle + rotation, ORIGIN,
                Vector2.Multiply(scale, lineScale), spriteEffects, renderDepth);
        }
Esempio n. 4
0
 public void Draw(gxtSpriteBatch spriteBatch, Vector2 position, float rotation, Vector2 scale, SpriteEffects spriteEffects, Color colorOverlay, float renderDepth)
 {
     if (texture != null)
         spriteBatch.DrawSprite(Texture, position, colorOverlay, rotation, origin, scale, spriteEffects, renderDepth);
     else
     {
         gxtLog.WriteLineV(gxtVerbosityLevel.CRITICAL, "Drawable Sprite Does Not Have A Texture (Position: " + position.ToString() + " )");
         if (gxtDebugDrawer.SingletonIsInitialized)
         {
             //if (!gxtDebugDrawer.Singleton.IsSet(true))
             //    gxtLog.WriteLineV(gxtVerbosityLevel.WARNING, "The Debug Drawer Is Not Set: A \"NO TEXTURE\" string will not be drawn");
             gxtDebugDrawer.Singleton.AddString("NO TEXTURE", position, Color.Magenta, 0.0f);
         }
     }
 }
Esempio n. 5
0
 public void Draw(gxtSpriteBatch spriteBatch, Vector2 position, float rotation, Vector2 scale, SpriteEffects spriteEffects, Color colorOverlay, float renderDepth)
 {
     if (spriteFont != null)
         spriteBatch.DrawString(spriteFont, text, position, colorOverlay, rotation, origin, scale, spriteEffects, renderDepth);
     else
     {
         gxtLog.WriteLineV(gxtVerbosityLevel.CRITICAL, "Drawable Text Field Does Not Have A Sprite Font (Position {0}, Text: {1})", position.ToString(), text);
         if (gxtDebugDrawer.SingletonIsInitialized)
         {
             // check if debug drawer has a spritefont??
             // why not just get the debug drawer spritefont and feed it in here?
             gxtDebugDrawer.Singleton.AddString("NO SPRITEFONT", position, Color.Magenta, 0.0f);
         }
     }
 }
Esempio n. 6
0
        public void Draw(gxtSpriteBatch spriteBatch, Vector2 position, float rotation, Vector2 scale, SpriteEffects spriteEffects, Color colorOverlay, float renderDepth)
        {
            gxtDebug.Assert(gxtPrimitiveManager.SingletonIsInitialized);

            Matrix rotMat = Matrix.CreateRotationZ(rotation);
            for (int i = 0; i < vertices.Count; i += 2)
            {
                Vector2 tStart = Vector2.Transform(Vector2.Multiply(vertices[i], scale), rotMat) + position;

                int halfIndex = i / 2;

                spriteBatch.DrawSprite(gxtPrimitiveManager.Singleton.PixelTexture, tStart, colorOverlay, cachedValues[halfIndex].Y + rotation, gxtLine.ORIGIN,
                    Vector2.Multiply(new Vector2(cachedValues[halfIndex].X, lineThickness), scale), spriteEffects, renderDepth);
            }
        }
Esempio n. 7
0
        public void Draw(gxtSpriteBatch spriteBatch, Vector2 position, float rotation, Vector2 scale, SpriteEffects spriteEffects, Color colorOverlay, float renderDepth)
        {
            gxtDebug.Assert(gxtPrimitiveManager.SingletonIsInitialized);

            Matrix rotMat = Matrix.CreateRotationZ(rotation);
            for (int j = vertices.Count - 1, i = 0; i < vertices.Count; j = i, i++)
            {
                Vector2 tStart = Vector2.Transform(Vector2.Multiply(vertices[j], scale), rotMat) + position;
                //Vector2 tEnd = Vector2.Transform(Vector2.Multiply(vertices[i], scale), rotMat) + position;
                //Vector2 tD = tEnd - tStart;
                //float ang = gxtMath.Atan2(tD.Y, tD.X);
                //float dist = tD.Length() + 1.0f;

                //gxtLog.WriteLineV(gxtVerbosityLevel.WARNING, "New Distance: {0}", dist);
                //gxtLog.WriteLineV(gxtVerbosityLevel.CRITICAL, "Precached Distance: {0}", cachedValues[j].X);
                //gxtLog.WriteLineV(gxtVerbosityLevel.SUCCESS, "Scale: {0}", scale.ToString());

                //Vector2 xAxis, yAxis;
                //gxtMath.GetAxesVectors(rotation, out xAxis, out yAxis);

                //float absScaleX = 1.0f - gxtMath.Abs(scale.X - 1.0f);
                //if (scale.X == 1.0f)
                //    absScaleX = 1.0f;
                spriteBatch.DrawSprite(gxtPrimitiveManager.Singleton.PixelTexture, tStart, colorOverlay, cachedValues[j].Y + rotation, gxtLine.ORIGIN,
                    new Vector2((cachedValues[j].X * gxtMath.Abs(scale.X)), lineThickness), spriteEffects, renderDepth);
                /*
                gxtLog.WriteLineV(gxtVerbosityLevel.WARNING, scale.ToString());

                float finalRot = cachedValues[j].Y + rotation;
                Vector2 xAxis, yAxis;
                gxtMath.GetAxesVectors(cachedValues[j].Y, out xAxis, out yAxis);
                xAxis *= (cachedValues[j].X * scale.X);
                yAxis *= (cachedValues[j].X * scale.Y);
                float dist = (xAxis + yAxis).Length();
                spriteBatch.Draw(gxtPrimitiveManager.Singleton.PixelTexture, tStart, null, colorOverlay, finalRot, origin,
                    new Vector2(dist, lineThickness), spriteEffects, renderDepth);
                */
                //spriteBatch.Draw(gxtPrimitiveManager.Singleton.PixelTexture, tStart, null, colorOverlay, cachedValues[j].Y + rotation, origin,
                //    new Vector2(cachedValues[j].X * scale.X * scale.Y, lineThickness), spriteEffects, renderDepth);

                /* Expensive, but works */
                //spriteBatch.Draw(gxtPrimitiveManager.Singleton.PixelTexture, tStart, null, colorOverlay, ang, origin,
                //    new Vector2(dist, lineThickness), spriteEffects, renderDepth);
            }
        }
Esempio n. 8
0
 public void Draw(gxtSpriteBatch spriteBatch, Vector2 position, float rotation, Vector2 scale, SpriteEffects spriteEffects, Color colorOverlay, float renderDepth)
 {
     SetColor(colorOverlay);
     spriteBatch.DrawPolygon(texture, vertexBuffer, indexBuffer, position, rotation, scale, spriteEffects, renderDepth);
 }
Esempio n. 9
0
        public void Draw(gxtSpriteBatch spriteBatch, Vector2 position, float rotation, Vector2 scale, SpriteEffects spriteEffects, Color colorOverlay, float renderDepth)
        {
            gxtDebug.Assert(gxtPrimitiveManager.SingletonIsInitialized);

            spriteBatch.DrawSprite(gxtPrimitiveManager.Singleton.PixelTexture, position, colorOverlay, rotation, ORIGIN, Vector2.Multiply(size, scale), spriteEffects, renderDepth);
        }
Esempio n. 10
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();
            camera = new gxtCamera(Vector2.Zero, 0.0f, 0.0f, false);
            gxtDisplayManager.Singleton.RegisterCamera(camera);
            gxtDisplayManager.Singleton.SetResolution(800, 600, false);
            gxtDisplayManager.Singleton.WindowTitle = "Custom SpriteBatch Test";
            base.IsMouseVisible = true;

            grassTexture = Content.Load<Texture2D>("Textures\\grass");
            scrapTexture = Content.Load<Texture2D>("Textures\\scratched_metal");
            brickTexture = Content.Load<Texture2D>("Textures\\seamless_brick");
            font = Content.Load<SpriteFont>("Fonts\\debug_font");

            sceneGraph = new gxtSceneGraph();
            sceneGraph.Initialize();

            spriteBatch = new gxtSpriteBatch();
            spriteBatch.Initialize(gxtRoot.Singleton.XNASpriteBatch, gxtRoot.Singleton.Graphics);

            gxtPolygon poly = gxtGeometry.CreateCirclePolygon(200, 11);
            vertexBuffer = new VertexBuffer(GraphicsDevice, typeof(VertexPositionColorTexture), poly.NumVertices, BufferUsage.WriteOnly);
            indexBuffer = new IndexBuffer(GraphicsDevice, typeof(int), 3 + ((poly.NumVertices - 3) * 3), BufferUsage.WriteOnly);
            Triangulate(poly);
            CalculateUVCoords(poly);

            if (gxtDebugDrawer.SingletonIsInitialized)
            {
                int debugDrawId = gxtDebugDrawer.Singleton.GetNewId();
                gxtDebugDrawer.Singleton.AddSceneGraph(debugDrawId, sceneGraph);
            }
        }