Search Results

Search found 1663 results on 67 pages for 'xna 4 0'.

Page 8/67 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Outline Shader Effect for Orthogonal Geometry in XNA

    - by Griffin
    I just recently started learning the art of shading, but I can't give an outline width to 2D, concave geometry when restrained to a single vertex/pixel shader technique (thanks to XNA). the shape I need to give an outline to has smooth, per-vertex coloring, as well as opacity. The outline, which has smooth, per-vertex coloring, variable width, and opacity cannot interfere with the original shape's colors. A pixel depth border detection algorithm won't work because pixel depth isn't a 3.0 semantic. expanding geometry / redrawing won't work because it interferes with the original shape's colors. I'm wondering if I can do something with the stencil/depth buffer outside of the shader functions since I have access to that through the graphics device. But I don't believe I'm able to manipulate actual values. How might I do this?

    Read the article

  • XNA - Debugging/Testing Individual Sprites and Pixel Collision

    - by kwelch
    I ran through the first training on XNA where you make a shooter game. They did some thing that I would not do and I want to use their starting point to learn more things. I want to try better collision and adding a menu. I saw something online with the sonic physics where they have a frame by frame of sonic moving 1 pixel. See picture below. I am new to development, but I have been programming for years now. What would you guys suggest to try these different things out. How would I simulate a similar frame by frame testing as they do in the above picture? Thanks!

    Read the article

  • Problems using easing equations in C# XNA

    - by codinghands
    I'm having some trouble using the easing equations suggested by Robert Penner for ActionScript (http://www.robertpenner.com/easing/, and a Flash demo here) in my C# XNA game. Firstly, what is the definition of the following variables passed in as arguments to each equation? float t, float b, float c, float d I'm currently calculating the new X position of a sprite in the Update() loop, however even for the linear tween equation I'm getting some odd results. I'm using the following values: float t = gameTime.TotalGameTime.TotalMilliseconds; float d = 8000f; float b = x.Position.X; float c = (ScreenManager.Game.GraphicsDevice.Viewport.Width >> 1) - (x.Position.X + x.frameSize.X / 2); And this equation for linear easing: float val = c*t/d + b;

    Read the article

  • XNA: Runtime differences in ClickOnce install versus development version

    - by Sean Colombo
    I have a game written in XNA, and I use ClickOnce installers to distribute the game to testers. I keep once computer as a test machine which does NOT have development environments installed, so that I can test the installed version. We've found a reproducible bug in our game, but the bug ONLY occurs on the non-development machines that use the ClickOnce installer. The bug is related to some of our code for moving around 3D objects and is not tied to Networking or GamerServices. Are there known differences in the ClickOnce runtime and the version on dev? Are there any best-practices for debugging something like this?

    Read the article

  • movement of sprites with kinect and xna

    - by pablopp83
    im working on a proyect with kinect sdk and xna 4.0. i need take the position of the hands and draw a sprite over it. im doing it directly and, because of that, i get a "trembling hands" effect. so, i was thinking on make the sprite move from the previous position to the new one, given in every frame by the new hand position. this way, the sprite does not jump from one position to another. this is working just fine, but im using a constant value for the velocity, and i really would like to use a variable velocity given by the difference between the prev and the new position. this is, if the hand move more quickly in the reality, the velocity will be higher. I really dont have a clue on how to make this works. can somebody point me in the right direction? thanks.

    Read the article

  • XNA content.load Dependancy

    - by Richard
    Quick question, My project i'm building for test purposes is working fine but i have dependencies flying around everywhere due to the XNA framework. In Update i have gametime passed everywhere... this is okay. In Draw i have gametime & spritebatch passed everywhere... this is okay. My issue is in the content.load textures/sounds/fonts. I have them as public variables ie Texture1 = Content.load(of texture2d)("Texture1") I'm passing a 'Game1' pointer into the constructor of every new class being instantiated to gain access to these variables. Am i missing an OOP trick to prevent me having to pass a pointer to 'game1' to every New class?

    Read the article

  • Assigning a different texture based on picking(XNA)

    - by Thomas Carmichael
    I'm making a game using XNA. I have some simple objects like cube and sphere, and I would like to change the texture of one face of these objects based on picking. That is, when the cursor is over one face, it turns red. The only way I've seen to do this is to overload the content processor as here: http://xbox.create.msdn.com/en-US/education/catalog/sample/picking_triangle but it seems like it shouldn't be this complicated. I'm using .x models, and would like to be able to implement this for more complex models in the future beyond cubes/spheres/etc. Is this the best/only way to go about it? I'll figure that out if that's what is necessary, but it seems that there would be a simpler solution to load a different texture to a face than I've seen, I just don't know what it is.

    Read the article

  • C# XNA render an entire frame to a texture2d

    - by redcodefinal
    I asked a question here: C# XNA Make rendered screen a texture2d But, I ended up not getting the exact result I was looking for since I didn't ask the question right. In a game I am writing, I render an extremely large city out of objects, this can cause lag when moving the camera to view things that are off screen. I need a way to render then ENTIRE city, even the stuff that is off screen, and make it into a Texture2D. The answer I chose for the last one didn't work entirely right because it only gets what is on screen, not what is off.

    Read the article

  • XNA 2D Rotated Rectangle Collision Response

    - by Kyle Uithoven
    I am using Rotated Rectangles which collide using the Separating Axis Theorem and they work perfectly fine for collision detection using Intersects and Contains. However, I am starting to use faster objects in my game now and there is the issue of the two object overlapping during collision due to their higher velocities. I would like to do a collision response where I find out how much they are overlapping in the X and Y and put position them outside of each other. I would like to use something like this: http://go.colorize.net/xna/2d_collision_response_xna/index.html. But I am having some issues trying to adapt this to handle the rotation of the bounds. Is this possible? Are there any resources out there that I can look at?

    Read the article

  • Drawing Transparency in XNA 4.0

    - by dpaz
    Using C# (VS2010) with XNA 4.0, I have a terrain layer (RenderTarget2D) in a 2D side-scroller. My visual system tracks updates to redraw individual tiles, but I am having trouble finding a way to clear out the rectangle where the tile will be drawn, which I must do because A) there may no longer be a tile or B) the tile may itself contain transparency. How can I draw a rectangle of transparency onto an existing RenderTarget2D? I essentially want to clear just that rectangular portion of it. My Google searches have not yielded anything relevant.

    Read the article

  • Relative Positions Of Player And Enemy Are Different In XNA 3D Game

    - by CoOlDud3
    I am having a problem in my 3D Jet Fighter Game using XNA. I have a Player Jet and a few enemy drones built from a separate class. The problem is that when I set Player position and a drone's position to a height 10f in y direction. They aren't at the same height. But if i move Drone's Position up 500f in the y direction then it is pretty much close to the player. Relatively They are supposedly at the same height but with different position values. Can Any One Help Please?

    Read the article

  • Help to understand directions of sprites in XNA

    - by 3Dkreativ
    If I want to move a sprite to the right and upwards in a 45 degree angle I use Vector2 direction = new Vector2(1,-1); And if the sprite should move straight to right Vector2 direction = new Vector2(1,0); But how would I do if I want another directions, lets say somewhere between this values? I have tested with some other values, but then the sprite either moves to fast and or in another direction than I expected!? I suspect it's about normalize!? Another thing I have problem with to understand. I'm doing a simple asteroids game as a task in a class in C# and XNA. When the asteroids hit the window borders, I want them to bounce back in a random direction, but I can't do this before I understand how directions and Vector2 works. Help is preciated! Thanks!

    Read the article

  • XNA: Camera's Rotation and Translation matrices seem to interfere with each other

    - by Danjen
    I've been following the guide here for how to create a custom 2D camera in XNA. It works great, I've implemented it before, but for some reason, the matrix math is throwing me off. public sealed class Camera2D { public Vector2 Origin { get; set; } public Vector2 Position { get; set; } public float Scale { get; set; } public float Rotation { get; set; } } It might be easier to just show you a picture of my problem: http://i.imgur.com/H1l6LEx.png What I want to do is allow the camera to pivot around any given point. Right now, I have the rotations mapped to my shoulder buttons on a gamepad, and if I press them, it should rotate around the point the camera is currently looking at. Then, I use the left stick to move the camera around. The problem is that after it's been rotated, pressing "up" results in it being used relative to the rotation, creating the image above. I understand that matrices have to be applied in a certain order, and that I have to offset the thing to be rotated around the world origin and move it back, but it just won't work! public Matrix GetTransformationMatrix() { Matrix mRotate = Matrix.Identity * Matrix.CreateTranslation(-Origin.X, -Origin.Y, 0.00f) * // Move origin to world center Matrix.CreateRotationZ(MathHelper.ToRadians(Rotation)) * // Apply rotation Matrix.CreateTranslation(+Origin.X, +Origin.Y, 0.00f); // Undo the move operation Matrix mTranslate = Matrix.Identity * Matrix.CreateTranslation(-Position.X, Position.Y, 0.00f); // Apply the actual translation return mRotate * mTranslate; } So to recap, it seems I can have it rotate around an arbitrary point and lose the ability to have "up" move the camera straight up, or I can rotate it around the world origin and have the camera move properly, but not both.

    Read the article

  • How can I make an object's hitbox rotate with its texture?

    - by Matthew Optional Meehan
    In XNA, when you have a rectangular sprite that doesnt rotate, it's easy to get its four corners to make a hitbox. However, when you do a rotation, the points get moved and I assume there is some kind of math that I can use to aquire them. I am using the four points to draw a rectangle that visually represents the hitboxes. I have seen some per-pixel collision examples, but I can forsee they would be hard to draw a box/'convex hull' around. I have also seen physics like farseer but I'm not sure if there is a quick tutorial to do what I want.

    Read the article

  • xna download website source code

    - by Emre Canbazoglu
    I have to download the html code of a web site during the game. I am taking the poster url of a movie from the imdb web site by scrapping the html ( also other informations ). I have to do the download process many times during the game for different movies. I can download and scrap the html but downloading the html takes too much time and it causes the game to slow down(freeze while downloading). How can I solve this problem? My one approach is to download and scrap all the information and store them in a database before the game and during the game access this information from the database. I think this will work properly but that is not what I exactly want. It would be better if it is dynamic. I also thought of using multi-threading but I am a bit confused about how to implement threading in xna. I read some articles about it but it is not so clear. I mean when should I start the thread and what about the update function etc. I need your help guys

    Read the article

  • Oscillating Sprite Movement in XNA

    - by Nick Van Hoogenstyn
    I'm working on a 2d game and am looking to make a sprite move horizontally across the screen in XNA while oscillating vertically (basically I want the movement to look like a sin wave). Currently for movement I'm using two vectors, one for speed and one for direction. My update function for sprites just contains this: Position += direction * speed * (float)t.ElapsedGameTime.TotalSeconds; How could I utilize this setup to create the desired movement? I'm assuming I'd call Math.Sin or Math.Cos, but I'm unsure of where to start to make this sort of thing happened. My attempt looked like this: public override void Update(GameTime t) { double msElapsed = t.TotalGameTime.Milliseconds; mDirection.Y = (float)Math.Sin(msElapsed); if (mDirection.Y >= 0) mSpeed.Y = moveSpeed; else mSpeed.Y = -moveSpeed; base.Update(t, mSpeed, mDirection); } moveSpeed is just some constant positive integer. With this, the sprite simply just continuously moves downward until it's off screen. Can anyone give me some info on what I'm doing wrong here? I've never tried something like this so if I'm doing things completely wrong, let me know!

    Read the article

  • Best practice for setting Effect parameters in XNA

    - by hichaeretaqua
    I want to ask if there is a best practice for setting Effect parameters in XNA. Or in other words, what exactly happens when I call pass.Apply(). I can imagine multiple scenarios: Each time Apply is called, all effect parameters are transferred to the GPU and therefor it has no real influence how often I set a parameter. Each time Apply is called, only the parameters that got reset are transferred. So caching Set-operations that don't actually set a new value should be avoided. Each time Apply is called, only the parameters that got changed are transferred. So caching Set-operations is useless. This whole questions is bootless because no one of the mentions ways has any noteworthy impact on game performance. So the final question: Is it useful to implement some caching of set operation like: private Matrix _world; public Matrix World { get{ return _world; } set { if (value == world) return; _effect.Parameters["xWorld"].SetValue(value); _world = value; } } Thanking you in anticipation.

    Read the article

  • XNA Required information to represent 2D Sprite graphically

    - by Fire-Dragon-DoL
    I was thinking about dividing my game engine into 2 threads: render thread and update thread (I can't come up on how to divide update thread from physic thread at the moment). That said, I have to duplicate all Sprite informations, what do I really need to represents a 2D Sprite graphically? Here are my ideas (I'll mark with ? things that I'm not sure): Vector2 Position float Rotation ? Vector2 Pivot ? Rectangle TextureRectangle Texture2D Texture Vector2 ImageOrigin ? (is it tracked somewhere else?) If you have any suggestion about using different types for datas, it's appreciated Last part of the question: isn't this a lot of data to copy in a buffer?what should I really copy in the buffer?I'm following this tutorial: http://www.sgtconker.com/2009/11/article-multi-threading-your-xna/3/ Thanks UPDATE 1: Newer values at the moment: Vector2 Position float Rotation Vector2 Pivot Rectangle TextureRectangle Texture2D Texture Color Color byte Facing (can be left or right, I'll do it with an enum) I re-read the tutorial, what I was doing wrong is not that I need to pass all those values, I need to pass only changed values as messages. UPDATE 2: Vector2 Position float Rotation Vector2 Pivot Rectangle TextureRectangle Texture2D Texture Color Color bool Flip uint DrawOrder Vector2 Scale bool Visible ? Mhhh, should Visibile be included?

    Read the article

  • Playing a Song causing WP7 to crash on phone, but not on emulator

    - by Michael Zehnich
    Hi there, I am trying to implement a song into a game that begins playing and continually loops on Windows Phone 7 via XNA 4.0. On the emulator, this works fine, however when deployed to a phone, it simply gives a black screen before going back to the home screen. Here is the rogue code in question, and commenting this code out makes the app run fine on the phone: // in the constructor fields private Song song; // in the LoadContent() method song = Content.Load<Song>("song"); // in the Update() method if (MediaPlayer.GameHasControl && MediaPlayer.State != MediaState.Playing) { MediaPlayer.Play(song); } The song file itself is a 2:53 long, 2.28mb .wma file at 106kbps bitrate. Again this works perfectly on emulator but does not run at all on phone. Thanks for any help you can provide!

    Read the article

  • Mixing XNA and silverlight gives wierd graphics

    - by Mech0z
    I making a small 3dgame which is made as a Silverlight and XNA app, but when I draw the sprites the graphics becomes all wierd. All my primitive types are rendered correctly, but my 3d models are just wierd My Draw is like this when silverlight is set to draw private void OnDraw(object sender, GameTimerEventArgs e) { // Render the Silverlight controls using the UIElementRenderer elementRenderer.Render(); // Clear the screen to a solid color SharedGraphicsDeviceManager.Current.GraphicsDevice.Clear(Color.CornflowerBlue); switch (gameState) { case GameState.ChooseStarter: TextBlockStatus.Text = "Find Starting Player"; break; case GameState.PlaceBrick: TextBlockPlayer.Text = (playerTurn == PlayerTurn.PlayerOne) ? "Player One" : "Player Two"; TextBlockState.Text = "Place Brick"; foreach (IGraphicObject obj in _3dObjects) { obj.Draw(cameraPosition, e); } break; case GameState.GiveBrick: TextBlockState.Text = "Give Brick"; break; } spriteBatch.Begin(); // Using the texture from the UIElementRenderer, // draw the Silverlight controls to the screen spriteBatch.Draw(elementRenderer.Texture, cameraProjection, Color.White); spriteBatch.End(); } This gives me this output If I comment the spritebatch lines out I get the correct output, except the silverlight text is of course not shown I am not entirely sure what to look for except that zero vector I am giving to the spritebatch, but if thats the source I have no idea what I am supposed to set it as epspecially when its a 2d vector

    Read the article

  • Model won't render in my XNA game

    - by Daniel Lopez
    I am trying to create a simple 3D game but things aren't working out as they should. For instance, the mode will not display. I created a class that does the rendering so I think that is where the problem lies. P.S I am using models from the MSDN website so I know the models are compatible with XNA. Code: class ModelRenderer { private float aspectratio; private Model model; private Vector3 camerapos; private Vector3 modelpos; private Matrix rotationy; float radiansy = 0; public ModelRenderer(Model m, float AspectRatio, Vector3 initial_pos, Vector3 initialcamerapos) { model = m; if (model.Meshes.Count == 0) { throw new Exception("Invalid model because it contains zero meshes!"); } modelpos = initial_pos; camerapos = initialcamerapos; aspectratio = AspectRatio; return; } public Vector3 CameraPosition { set { camerapos = value; } get { return camerapos; } } public Vector3 ModelPosition { set { modelpos = value; } get { return modelpos; } } public void RotateY(float radians) { radiansy += radians; rotationy = Matrix.CreateRotationY(radiansy); } public float AspectRatio { set { aspectratio = value; } get { return aspectratio; } } public void Draw() { Matrix world = Matrix.CreateTranslation(modelpos) * rotationy; Matrix view = Matrix.CreateLookAt(this.CameraPosition, this.ModelPosition, Vector3.Up); Matrix projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), this.AspectRatio, 1.0f, 10000f); model.Draw(world, view, projection); } } If you need more code just make a comment.

    Read the article

  • XNA Seeing through heightmap problem

    - by Jesse Emond
    I've recently started learning how to program in 3D with XNA and I've been trying to implement a Terrain3D class(a very simple height map). I've managed to draw a simple terrain, but I'm getting a weird bug where I can see through the terrain. This bug happens when I'm looking through a hill from the map. Here is a picture of what happens: I was wondering if this is a common mistake for starters and if any of you ever experienced the same problem and could tell me what I'm doing wrong. If it's not such an obvious problem, here is my Draw method: public override void Draw() { Parent.Engine.SpriteBatch.Begin(SpriteBlendMode.None, SpriteSortMode.Immediate, SaveStateMode.SaveState); Camera3D cam = (Camera3D)Parent.Engine.Services.GetService(typeof(Camera3D)); if (cam == null) throw new Exception("Camera3D couldn't be found. Drawing a 3D terrain requires a 3D camera."); float triangleCount = indices.Length / 3f; basicEffect.Begin(); basicEffect.World = worldMatrix; basicEffect.View = cam.ViewMatrix; basicEffect.Projection = cam.ProjectionMatrix; basicEffect.VertexColorEnabled = true; Parent.Engine.GraphicsDevice.VertexDeclaration = new VertexDeclaration( Parent.Engine.GraphicsDevice, VertexPositionColor.VertexElements); foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes) { pass.Begin(); Parent.Engine.GraphicsDevice.Vertices[0].SetSource(vertexBuffer, 0, VertexPositionColor.SizeInBytes); Parent.Engine.GraphicsDevice.Indices = indexBuffer; Parent.Engine.GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, vertices.Length, 0, (int)triangleCount); pass.End(); } basicEffect.End(); Parent.Engine.SpriteBatch.End(); } Parent is just a property holding the screen that the component belongs to. Engine is a property of that parent screen holding the engine that it belongs to. If I should post more code(like the initialization code), then just leave a comment and I will.

    Read the article

  • Best practice settings Effect parameters in XNA

    - by hichaeretaqua
    I want to ask if there is a best practice settings effect parameters in XNA. Or in other words, what exactly happens when I call pass.Apply(). I can imagine multiple scenarios: Each time Apply() is called, all effect parameters are transferred to the GPU and therefor it has no real influence how often I set a parameter. Each time Apply() is called, only the parameters that got reset are transferred. So caching Set-operations that don't actually set a new value should be avoided. Each time Apply() is called, only the parameters that got changed are transferred. So caching Set-operations is useless. This whole questions is bootless because no one of the mentions ways has any noteworthy impact on game performance. So the final question: Is it useful to implement some caching of Set-operation like: private Matrix _world; public Matrix World { get{ return _world;} set { if(value == world)return; _effect.Parameters["xWorld"].SetValue(value); _world = value; } Thanking you in anticipation

    Read the article

  • 2D XNA C#: Texture2D Wrapping Issue

    - by Kieran
    Working in C#/XNA for a Windows game: I'm using Texture2D to draw sprites. All of my sprites are 16 x 32. The sprites move around the screen as you would expect, by changing the top X/Y position of them when they're being drawn by the spritebatch. Most of the time when I run the game, the sprites appear like this: and when moved, they move as I expect, as one element. Infrequently they appear like this: and when moved it's like there are two sprites with a gap in between them - it's hard to describe. It only seems to happen sometimes - is there something I'm missing? I'd really like to know why this is happening. [Edit:] Adding Draw code as requested: This is the main draw routine - it first draws the sprite to a RenderTarget then blows it up by a scale of 4: protected override void Draw(GameTime gameTime) { // Draw to render target GraphicsDevice.SetRenderTarget(renderTarget); GraphicsDevice.Clear(Color.CornflowerBlue); Texture2D imSprite = null; spriteBatch.Begin(SpriteSortMode.FrontToBack, null, SamplerState.PointWrap, null, null); ManSprite.Draw(spriteBatch); base.Draw(gameTime); spriteBatch.End(); // Draw render target to screen GraphicsDevice.SetRenderTarget(null); imageFrame = (Texture2D)renderTarget; GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.DarkSlateBlue, 1.0f, 0); spriteBatch.Begin(SpriteSortMode.FrontToBack, null, SamplerState.PointClamp, null, null); spriteBatch.Draw(imageFrame, new Vector2(0, 0), null, Color.White, 0, new Vector2(0, 0), IM_SCALE, SpriteEffects.None, 0); spriteBatch.End(); } This is the draw routine for the Sprite class: public virtual void Draw(SpriteBatch spriteBatch) { spriteBatch.Draw(Texture, new Vector2(PositionX, PositionY), null, Color.White, 0.0f, Vector2.Zero, Scale, SpriteEffects.None, 0.3f); }

    Read the article

  • Xna Equivalent of Viewport.Unproject in a draw call as a matrix transformation

    - by Nick Crowther
    I am making a 2D sidescroller and I would like to draw my sprite to world space instead of client space so I do not have to lock it to the center of the screen and when the camera stops the sprite will walk off screen instead of being stuck at the center. In order to do this I wanted to make a transformation matrix that goes in my draw call. I have seen something like this: http://stackoverflow.com/questions/3570192/xna-viewport-projection-and-spritebatch I have seen Matrix.CreateOrthographic() used to go from Worldspace to client space but, how would I go about using it to go from clientspace to worldspace? I was going to try putting my returns from the viewport.unproject method I have into a scale matrix such as: blah = Matrix.CreateScale(unproject.X,unproject.Y,0); however, that doesn't seem to work correctly. Here is what I'm calling in my draw method(where X is the coordinate my camera should follow): Vector3 test = screentoworld(X, graphics); var clienttoworld = Matrix.CreateScale(test.X,test.Y, 0); animationPlayer.Draw(theSpriteBatch, new Vector2(X.X,X.Y),false,false,0,Color.White,new Vector2(1,1),clienttoworld); Here is my code in my unproject method: Vector3 screentoworld(Vector2 some, GraphicsDevice graphics): Vector2 Position =(some.X,some.Y); var project = Matrix.CreateOrthographic(5*graphicsdevice.Viewport.Width, graphicsdevice.Viewport.Height, 0, 1); var viewMatrix = Matrix.CreateLookAt( new Vector3(0, 0, -4.3f), new Vector3(X.X,X.Y,0), Vector3.Up); //I have also tried substituting (cam.Position.X,cam.Position.Y,0) in for the (0,0,-4.3f) Vector3 nearSource = new Vector3(Position, 0f); Vector3 nearPoint = graphicsdevice.Viewport.Unproject(nearSource, project, viewMatrix, Matrix.Identity); return nearPoint;

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >