protected override void InternalDraw(GameTime time, Matrix absoluteTransform, PrimitiveBatch primitiveBatch, Camera camera) { if (_mesh != null) { primitiveBatch.DrawMesh(_mesh, absoluteTransform, camera); } }
public static void Draw(PrimitiveBatch primBatch, SpriteBatch spriteBatch) { if (CurrentLevel != null) { foreach (PhysicsRectangle rectangle in CurrentLevel.Rectangles) { primBatch.DrawRectangle(true, rectangle.Position, rectangle.Width, rectangle.Height, rectangle.Rotation, PhysicsColor); primBatch.DrawRectangle(false, rectangle.Position, rectangle.Width, rectangle.Height, rectangle.Rotation, Color.Black); } startPoint.Draw(primBatch); } else { //GraphicsDevice. spriteBatch.GraphicsDevice.Clear(Color.Black); } switch (Mousemode) { case MouseMode.DrawRectangle: if (tempRectangle != PhysicsRectangle.Empty) primBatch.DrawRectangleFromPoints(true, tempRectangle.TopLeft, tempRectangle.BottomRight, 0, PhysicsColor); break; case MouseMode.DrawRectangleRotate: //if (tempRectangle != PhysicsRectangle.Empty) primBatch.DrawRectangle(true, tempRectangle.Position, tempRectangle.Size, tempRectangle.Rotation, PhysicsColor); break; } }
public HeadUpDisplayService(Game game) : base(game) { this.Visible = false; // no automatic drawing this.Health = 100; this.primitiveBatch = new PrimitiveBatch(game.GraphicsDevice); }
public override void Draw(SpriteBatch spriteBatch, PrimitiveBatch primBatch) { spriteBatch.Begin(); spriteBatch.DrawString(Font, toPrint, new Vector2(10, 10), Color.Black); spriteBatch.End(); base.Draw(spriteBatch, primBatch); }
public override void Draw(SpriteBatch spriteBatch, PrimitiveBatch primBatch) { spriteBatch.Begin(); spriteBatch.Draw(_1v1, new Vector2(10, 10), Color.White); spriteBatch.End(); base.Draw(spriteBatch, primBatch); }
/// <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() { // TODO: Add your initialization logic here PhysicsCore.Initialize(new Vector2(0, 9.82f)); Camera.Initialize(GraphicsDevice.Viewport); primBatch = new PrimitiveBatch(GraphicsDevice); ScreenCentre = GraphicsDevice.Viewport.Bounds.Center.ToVector(); base.Initialize(); }
public void Draw(GameTime g, Matrix parentTransform, PrimitiveBatch batch, Camera cam) { localTransform = Matrix.CreateScale(scl) * Matrix.CreateFromQuaternion(rot) * Matrix.CreateTranslation(pos); absoluteTransform = pivotTransform * localTransform * parentTransform; InternalDraw(g, absoluteTransform, batch, cam); foreach (SceneNode n in children) { n.Draw(g, Matrix.Invert(pivotTransform) * absoluteTransform, batch, cam); } }
public PathNode(XNA2DCamera camera, GraphicsDeviceManager g, int x, int y) { mPosition.X = x; mPosition.Y = y; mNeighbours = new List<PathNode>(); mActive = true; marked = false; mGraphics = g; mPrimitiveBatch = new PrimitiveBatch(camera, mGraphics.GraphicsDevice); }
public void Draw(PrimitiveBatch primitiveBatch) { int i; for(i=0; i<points.Length-1;i++) { primitiveBatch.AddVertex(points[i], Color.Red); primitiveBatch.AddVertex(points[i+1], Color.Red); } primitiveBatch.AddVertex(points[i], Color.Red); primitiveBatch.AddVertex(points[0], Color.Red); }
protected override void Initialize() { Application.Idle += delegate { Invalidate(); }; spriteBatch = new SpriteBatch(GraphicsDevice); primitiveBatch = new PrimitiveBatch(GraphicsDevice); Art.GraphicsDevice = GraphicsDevice; content = new ContentManager(Services); content.RootDirectory = "Content"; LoadContent(content); ScreenCentre = new Vector2(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height) / 2; }
public void Draw(SpriteBatch spriteBatch, PrimitiveBatch primBatch) { if (CurrentTest != null) CurrentTest.Draw(spriteBatch, primBatch); if (bDrawData) { string text = "Name: " + CurrentTest.Name + "\nDescription: " + CurrentTest.Description; Vector2 size = Font.MeasureString(text); Rectangle rect = new Rectangle(7, 2, (int)size.X, (int)size.Y); spriteBatch.Begin(); spriteBatch.Draw(Art.Pixel, rect, Color.Gray * 0.7f); spriteBatch.DrawString(Font, text, new Vector2(7, 2), Color.Black); spriteBatch.End(); } }
public override void Draw(SpriteBatch spriteBatch, PrimitiveBatch primBatch) { primBatch.DrawLine(testLine, Color.Black); //primBatch.DrawLine(mousePos, (Vector2)testLine.Start, Color.Black); //primBatch.DrawLine((Vector2)testLine.Start, (Vector2)(testLine.Start) + testLine.StartToEnd.Normal, Color.Black); spriteBatch.Begin(); spriteBatch.DrawString(Font, "Gradient: " + testLine.Gradient + "\nDot: " + dot, new Vector2(10, 400), Color.Black); spriteBatch.Draw(Art.Pixel, AABB.ToRectangle(), Color.Red * 0.5f); spriteBatch.Draw(Art.Pixel, mousePos, null, Color.Black, 0, Vector2.Zero, 3, 0, 0); spriteBatch.End(); base.Draw(spriteBatch, primBatch); }
public override void Draw(SpriteBatch spriteBatch, PrimitiveBatch primBatch) { Device.SetRenderTarget(target); spriteBatch.Begin(); spriteBatch.Draw(balrog, new Vector2(10, 10), null, Color.White, 0, Vector2.Zero, 1, 0, 0); spriteBatch.Draw(balrog, new Vector2(10, 80), null, Color.White, 0, Vector2.Zero, 1, 0, 0); spriteBatch.End(); Device.SetRenderTarget(null); spriteBatch.Begin(0, null, SamplerState.PointClamp, null, null); spriteBatch.Draw(target, new Vector2(0, 0), null, Color.White, 0, Vector2.Zero, 2, 0, 0); spriteBatch.End(); base.Draw(spriteBatch, primBatch); }
private void Warm(GraphicsDevice device) { primitivebatch = new PrimitiveBatch(device); view = Matrix.Identity; proj = Matrix.CreateTranslation(-0.5f, -0.5f, 0) * Matrix.CreateOrthographicOffCenter(0, device.Viewport.Width, device.Viewport.Height, 0, 0, 1); material = Resources.spriterenderer_material; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); primBatch = new PrimitiveBatch(GraphicsDevice); Testbed.LoadContent(Content); if (File.Exists(prefsPath)) { using (StreamReader reader = new StreamReader(prefsPath)) { int test = Convert.ToInt32(reader.ReadToEnd()); Testbed.StartTest(test); currentTest = test; } } else Testbed.StartTest(0); // TODO: use this.Content to load your game content here }
/// <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() { terrainBatch = new PrimitiveBatch<VertexPositionColor>(graphics.GraphicsDevice); //terrainDrawContext.BasicEffect.FogEnabled = true; //terrainDrawContext.BasicEffect.FogColor = new Color(20, 20, 20).ToVector3(); //terrainDrawContext.BasicEffect.FogStart = 50; //terrainDrawContext.BasicEffect.FogEnd = 200; contentManager = new ContentManager( GraphicsDeviceServiceHelper.MakePrivateServiceProvider(graphics), Content.RootDirectory ); debugDrawer = new DebugDrawer(graphics); // Displays a FPS counter Components.Add(new FpsComponent(graphics, Content.RootDirectory)); // Create a new screen. Screens manage the state of a GUI and accept input // notifications. If you have an in-game computer display where you want // to use a GUI, you can create a second screen for that and thus cleanly // separate the state of the in-game computer from your game's own GUI :) Viewport viewport = GraphicsDevice.Viewport; Screen mainScreen = new Screen(viewport.Width, viewport.Height); gui.Screen = mainScreen; // Each screen has a 'desktop' control. This invisible control by default // stretches across the whole screen and serves as the root of the control // tree in which all visible controls are managed. All controls are positioned // using a system of fractional coordinates and pixel offset coordinates. // We now adjust the position of the desktop window to prevent GUI or HUD // elements from appearing outside of the title-safe area. mainScreen.Desktop.Bounds = new UniRectangle( new UniScalar(0.0f, 0.0f), new UniScalar(0.0f, 0.0f), // x and y = 10% new UniScalar(1.0f, 0.0f), new UniScalar(1.0f, 0.0f) // width and height = 80% ); // Now let's do something funky: add buttons directly to the desktop. // This will also show the effect of the title-safe area. createDesktopControls(mainScreen); // Create a new camera with a perspective projection matrix camera = new Camera( Matrix.CreateLookAt( new Vector3(0.0f, 0.0f, -100.0f), // camera location new Vector3(0.0f, 0.0f, 0.0f), // camera focal point Vector3.Up // up vector for the camera's orientation ), Matrix.CreatePerspectiveFieldOfView( MathHelper.PiOver4, // field of view (float)Window.ClientBounds.Width / (float)Window.ClientBounds.Height, // aspect ratio 0.01f, 1000.0f // near and far clipping plane ) ); base.Initialize(); //Initialized = true; }
protected virtual void InternalDraw(GameTime g, Matrix absoluteTransform, PrimitiveBatch batch, Camera cam) { }
public void TestRenderParticles() { SimpleParticle[] particles = new SimpleParticle[] { new SimpleParticle(Vector3.Zero, Vector3.Zero), new SimpleParticle(Vector3.Zero, Vector3.Zero), new SimpleParticle(Vector3.Zero, Vector3.Zero), new SimpleParticle(Vector3.Zero, Vector3.Zero) }; PrimitiveBatch<SimpleParticle> primitiveBatch; using( primitiveBatch = new PrimitiveBatch<SimpleParticle>( this.mockedGraphicsDeviceService.GraphicsDevice, this.vertexDeclaration, SimpleParticle.SizeInBytes ) ) { PointParticleRenderer<SimpleParticle> renderer = createRenderer(); renderer.Render( new ArraySegment<SimpleParticle>(particles, 1, 2), primitiveBatch ); } }
/// <summary> /// LoadContent will be called only once before drawing and it's the place to load /// all of your content. /// </summary> public virtual void LoadContent() { frameNumber = Kinect.FramesCount; content = ScreenManager.Game.Content; spriteBatch = ScreenManager.SpriteBatch; PrimitiveBatch = new PrimitiveBatch(ScreenManager.GraphicsDevice); font = content.Load<SpriteFont>("SpriteFont1"); // songs = MyExtension.LoadListContent<Song>(content, "Audio\\"); //songsarray = songs.ToArray(); // sampleMediaLibrary = new MediaLibrary(); random = new Random(); //MediaPlayer.Stop(); // stop current audio playback // generate a random valid index into Albums voiceCommands = ScreenManager.Kinect.voiceCommands; if (showAvatar) { userAvatar = new UserAvatar(ScreenManager.Kinect, content, ScreenManager.GraphicsDevice, spriteBatch); userAvatar.LoadContent(); } depthTex = new Texture2D(screenManager.GraphicsDevice, 320, 240); }
public virtual void Draw(SpriteBatch spriteBatch, PrimitiveBatch primBatch) { }
protected override void InternalDraw(GameTime g, Matrix absoluteTransform, PrimitiveBatch batch, Camera cam) { base.InternalDraw(g, absoluteTransform, batch, cam); bounds.Center = absoluteTransform.Translation; batch.DrawMesh(mesh, absoluteTransform, cam); }
private void Warm(GraphicsDevice device) { primitivebatch = new PrimitiveBatch(device); material = Resources.spriterenderer_material; }
public void Draw(PrimitiveBatch primBatch) { primBatch.DrawFilledCircle(Position, radius, StartPointColor); primBatch.DrawFilledCircle(Position, 5, Color.Green); }