Outlining external edges on a complex shape made of cubes? A gallery of my problem can be found here. I had to do it this way as it won't let me post more than 2 links due to my reputation. I'm trying to use 3D cubes to generate an isometric cube world. I got that working great and I merge only the visible vertices indices into a buffer and draw from that. Only problem is, as with any isometric game, it becomes difficult to differentiate between heights. For example in the first image this archways top merges with the cubes below. I ended up finding this shader and got it working by using it against a rendered normal map (second image) of the cubes. You may be able to guess my problem from that image. The final result looks like the third image. The back edges are not draw with an outline, which are the most important. Which based on the normal map also means that diagonals also have the same problem on their sides (fourth image). Is there any solution I can do for this? Either in the shader itself or perhaps when calculating the normals? I almost need to add something to the normal to distinguish their depth height so faces on similar planes don't merge on edge detection. Or maybe there's a totally different option I could use. Ideally I was aiming more for only edges to the air to be outlined so the archways bottom edges would not be outlined like they are now


How would I achieve diablo like 2D isometric projection? I am in the process of coming up with an idea for a game, and I would like it to be isometric like Diablo. The problem is I have no idea how it achieves the effect of height like in the following screenshot (on the columns) Whatever the case, I'm sure it is going to be harder to achieve then creating a traditional isometric game, but any ideas regarding the topic would be greatly appreciated.


Keep 3d model facing the camera at all angles I'm trying to keep a 3d plane facing the camera at all angles but while i have some success with this Vector3 gunToCam cam.cameraPosition getWorld.Translation Vector3 beamRight Vector3.Cross(torpDirection, gunToCam) beamRight.Normalize() Vector3 beamUp Vector3.Cross(beamRight, torpDirection) shipeffect.beamWorld Matrix.Identity shipeffect.beamWorld.Forward (torpDirection) 1f shipeffect.beamWorld.Right beamRight shipeffect.beamWorld.Up beamUp shipeffect.beamWorld.Translation shipeffect.beamPosition Note Logic not wrote by me i just found this rather useful It seems to only face the camera at certain angles. For example if i place the camera behind the plane you can see it that only Roll's around the axis like this http i.imgur.com FOKLx.png (imagine if you are looking from behind where you have fired from. Any idea what to what the problem is (angles are not my specialty) shipeffect is an object that holds this class variables public Texture2D altBeam public Model beam public Matrix beamWorld public Matrix gunTransforms public Vector3 beamPosition


3D Animations in XNA 3.1 Well, guys. I'm in a Game Design class at school. Before you ask "WHY ARE YOU USING 3.1 INSTEAD OF 4" I would like to point out that C 2008, and .NET framework 3 is NOT my preferred environment, nor is Blender 2.49. I have gotten a pretty decent grip on Blender so far, I think. At least, for what I've figured out how to do. ( Applying textures, exporting to .fbx, and bone weights ). Now, I've seen various mentions of using "Skinned Models" in xna 4.0, and I've noticed that 3.1 has no such distinction, so I assume anything you do in 4 with skinned models means alternative methods in 3.1. I have also found nearly NO documentation on 3.1. All of them seem to have actually been updated to cover 4.0 ( Seriously, since when do people update their outdated tutorials? ) I'm asking around to see if there's any way to play animations stored in .fbx files ( if so, how to do it ), so that I don't waste my time understanding the animations and what not in Blender. ( Or better yet, is there something else that I SHOULD be doing instead? ) If it's not achievable, then I can obviously just use a bunch of constants or some work around system to apply bone transformations, but it would be really nice if I didn't need to do that. Some other things I've noticed that ALL models I load seem to have semi transparent textures. Can anybody offer an immediate explanation for this? To see what I'm talking about, here's a video. Also, could somebody give me advice as far as loading an environment and multiple models? I think I would use the same camera and projection matrix, and then simply give a new "World" matrix to all of the items, but for some reason, I don't think that's quite right. I read somewhere that the purpose of the Matrix type was to avoid storing position information for every individual model, and store it collectively instead. ( Which, makes sense, really. Especially when some games probably load a gajillion models x3 Vector3's. That could add up fairly quickly, I'm sure. ) I know this is fairly generic vague, but since I haven't written any code with bugs, I can't exactly ask specific questions, I guess. If you have a resource that is still rele


Scroller game level map advice I'm started a XNA project to make a game similar in gameplay to Super Spy Hunter on a NES, which is used as a feature reference. The first thing I thought of is how to store and display level. Currently I'm thinking of using some tile graphics editor and custom pipeline for drawing level. I'm not sure however, that all is possible to implement every feature of reference game, but at least it's a start. Question is, looking at a given gameplay video, can you think of any possibly better approach then to design level using a tiles? By "better approach" I mean which will be either easier to work with, which will be more "natural" for this kind of game. The doubt comes mainly from a huge technology gap between then (1990) and now. So there is possibility that using current cpu power this could be done easier. Update 1. As I continue study reference game and ashes999 correctly mentioned procedural generation also comes into my mind. I began to think game logic is something like (simplified) while next road section exist get road section data set road generation options (borders type, road type, etc) set road section lenght while not end of a section generate road apply pseudorandom eye candy stuff this all looks like a pretty good data driven algorithm.


Keystone Correction using 3D Points of Kinect With XNA, I am displaying a simple rectangle which is projected onto the floor. The projector can be placed at an arbitrary position. Obviously, the projected rectangle gets distorted according to the projectors position and angle. A Kinect scans the floor looking for the four corners. Now my goal is to transform the original rectangle such that the projection is no longer distorted by basically pre warping the rectangle. My first approach was to do everything in 2D First compute a perspective transformation (using OpenCV's warpPerspective()) from the scanned points to the internal rectangle's points und apply the inverse to the rectangle. This seemed to work but was too slow as it couldn't be rendered on the GPU. The second approach was to do everything in 3D in order to use XNA's rendering features. First, I would display a plane, scan its corners with Kinect and map the received 3D Points to the original plane. Theoretically, I could apply the inverse of the perspective transformation to the plane, as I did in the 2D approach. However, since XNA works with a view and projection matrix, I can't just call a function such as warpPerspective() and get the desired result. I would need to compute the new parameters for the camera's view and projection matrix. Question Is it possible to compute these parameters and split them into two matrices (view and projection)? If not, is there another approach I could use?


How can I deal with actor translations and other "noise" in third party motion capture data? I'm working on a game, and I've run into a problem with motion capture data. My team is using 3DS Max 2011 and trying to put free motion capture files on our models. The problem we're having is it has become extremely hard to find motion capture data that stays in place. We've found some great motion captures of things like walking and jumping but the actors themselves move within the data, so when we attach these animations to our models and bring them into XNA, the models walk forward even when they should technically be standing still (and then there's also the problem of them resetting at the end of the animation). How can we clean up, at runtime or asset processing time, the animation in these motion capture files?


Is there a way to write a camera class without matrix transformation? I have a problem with a camera class I got from the internet. It does a transformation like this public Matrix get transformation(GraphicsDevice graphicsDevice) transform Matrix.CreateTranslation(new Vector3( pos.X, pos.Y, 0)) Matrix.CreateRotationZ(Rotation) Matrix.CreateScale(new Vector3(Zoom, Zoom, 1)) Matrix.CreateTranslation(new Vector3(ViewportWidth 0.5f, ViewportHeight 0.5f, 0)) return transform Later the spritebatch is called like this spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, cam.get transformation(device)) The problem is that at this point the mouse coordinates are not relative anymore to the other sprites I draw. This is a problem because I try detect which sprite has been clicked. I understand that this issue can be solved by considering the following picture This was posted in a very good awnser before, here. But somehow this does not really help me. So my question is Is there a way to create a Camera class which does not use transformation, can be moved with keys and keeps the viewport coordinates relative? Thanks in advance!


2D terrain with midpoint displacement and collision I followed this theory Here to implement a simple scrolling 2D terrain for my running game. I am used to dealing with collision via a tile system but am looking for a good theory on how to perform terrain collision (keeping the player on top the land) with a midpoint displacement 2D terrain I am not worried about the physics aspect but how to determine if a character intersects an array of points generated by the theory above. Example if I have an array of points Points these points are used to draw lines to make a terrain. Now in my mind I would first find the player center. Take the center X and see which two points it is between. So if X is 4.6 lets say it is between points that lay on X 3 and X 6. Player X 4.6 Point1 X 3, Y 3 Point2 X 6, Y 5 So now knowing this I somehow need to calculate what Y would be giving that X 4.6. And once I have Y ensure that the Player Y CalculatedY. If it is not push the player up to what Y the player should be. So I guess what I a saying is X 3, Y 3 X 6, Y 5 X 4.6, Solve for Y


3D Procedural Planet Generation I was looking for some inspration for my Voxel based game I am writting and came across this http www.youtube.com watch?v rL8zDgTlXso. I would like to know how to go about (or preferably source examples) of how I would do that, in real time, and infinitley. In addition to that I was wondering how I would do this with a voxel based terrain? A procedural planet generator in 3D which constructs voxel data, my voxels are of the same size of thoose in minecraft. Any ideas? Edit I ported the simplex noise function i grok suggested written in C Python to C , I sure hope it works ) http pastebin.com TZSQwnye Edit 2 float noise(float x, float y, float z, float persistance, float amplitude, float frequency, float octaves) float total 0 for (int i 0 i lt octaves i ) frequency frequency i or frequency 2 ? amplitude amplitude i total total SimplexNoise.raw noise 3d(x frequency, y frequency, z frequency) amplitude return total


Simple collision detection for pong I'm making a simple pong game, and things are great so far, but I have an odd bug which causes my ball (well, it's a box really) to get stuck on occasion when detecting collision against the ceiling or floor. It looks as though it is trying to update too frequently to get out of the collision check. Basically the box slides against the top or bottom of the screen from one paddle to the other, and quickly bounces on and off the wall while doing so, but only bounces a few pixels from the wall. What can I do to avoid this problem? It seems to occur at random. Below is my collision detection for the wall, as well as my update method for the ball. public void UpdatePosition() size.X (int)position.X size.Y (int)position.Y position.X speed (float)Math.Cos(direction) position.Y speed (float)Math.Sin(direction) CheckWallHit() Checks for collision with the ceiling or floor. 2 Math.pi 360 degrees TODO Change collision so that ball bounces from wall after getting caught private void CheckWallHit() while (direction gt 2 Math.PI) direction 2 Math.PI while (direction lt 0) direction 2 Math.PI if (position.Y lt 0 (position.Y gt resetPos.Y 2 size.Height)) direction 2 Math.PI direction


2D graphics why use spritesheets? I have seen many examples of how to render sprites from a spritesheet but I havent grasped why it is the most common way of dealing with sprites in 2d games. I have started out with 2d sprite rendering in the few demo applications I've made by dealing with each animation frame for any given sprite type as its own texture and this collection of textures is stored in a dictionary. This seems to work for me, and suits my workflow pretty well, as I tend to make my animations as gif mng files and then extract the frames to individual pngs. Is there a noticeable performance advantage to rendering from a single sheet rather than from individual textures? With modern hardware that is capable of drawing millions of polygons to the screen a hundred times a second, does it even matter for my 2d games which just deal with a few dozen 50x100px rectangles? The implementation details of loading a texture into graphics memory and displaying it in XNA seems pretty abstracted. All I know is that textures are bound to the graphics device when they are loaded, then during the game loop, the textures get rendered in batches. So it's not clear to me whether my choice affects performance. I suspect that there are some very good reasons most 2d game developers seem to be using them, I just don't understand why.


Multiple ( V I ) Buffers, is it sane? Currently I am developing an RTS game using XNA ( ANX.Framework ). There is one thing bothers me. I am not sure in what way or how to organise Buffers. Should I use a new Vertexbuffer for any object ( e.g. a Char, a Table, an model ) or is it better to use ONE HUGE BIG Buffer to store any geometry in? I am still new to 3D Programming though I finished yet couple games using DirectX 9. Well, I hope this question qin't a duplicate and I appreciate any answer leading me into the right direction.


Best depth sorting method for a Top Down 2D game using a 3D physics engine I've spent many days googling this and still have issues with my game engine I'd like to ask about, which I haven't seen addressed before. I think the problem is that my game is an unusual combination of a completely 2D graphical approach using XNA's SpriteBatch, and a completely 3D engine (the amazing BEPU physics engine) with rotation mostly disabled. In essence, my question is similar to this one (the part about "faux 3D"), but the difference is that in my game, the player as well as every other creature is represented by 3D objects, and they can all jump, pick up other objects, and throw them around. What this means is that sorting by one value, such as a Z position (how far north south a character is on the screen) won't work, because as soon as a smaller creature jumps on top of a larger creature, or a box, and walks backwards, the moment its z value is less than that other creature, it will appear to be behind the object it is actually standing on. I actually originally solved this problem by splitting every object in the game into physics boxes which MUST have a Y height equal to their Z depth. I then based the depth sorting value on the object's y position (how high it is off the ground) PLUS its z position (how far north or south it is on the screen). The problem with this approach is that it requires all moving objects in the game to be split graphically into chunks which match up with a physical box which has its y dimension equal to its z dimension. Which is stupid. So, I got inspired last night to rewrite with a fresh approach. My new method is a little more complex, but I think a little more sane every object which needs to be sorted by depth in the game exposes the interface IDepthDrawable and is added to a list owned by the DepthDrawer object. IDepthDrawable contains public interface IDepthDrawable Rectangle Bounds get possibly change this to a class if struct copying of the xna Rectangle type becomes an issue DepthDrawShape DepthShape get void Draw(SpriteBatch spriteBatch) The Bounds Rectangle of each IDepthDrawable object represents the 2D Axis Aligned Bounding Box it will take up when drawn to the screen. Anything that doesn't intersect the screen will be culled at this stage and the remaining on screen IDepthDrawables will be Bounds tested for intersections with each other. This is where I get a little less sure of what I'm doing. Each group of collisions will be added to a list or other collection, and each list will sort itself based on its DepthShape property, which will have access to the object to be drawn's physics information. For starting out, lets assume everything in the game is an axis aligned 3D Box shape. Boxes are pretty easy to sort. Something like if (depthShape1.Back gt depthShape2.Front) if depthShape1 is in front of depthShape2. depthShape1 goes on top. else if (depthShape1.Bottom gt depthShape2.Top) if depthShape1 is above depthShape2. depthShape1 goes on top. if neither of these are true, depthShape2 must be in front or above. So, by sorting draw order by several different factors from the physics engine, I believe I can get a really correct draw order. My question is, is this a good way of going about this, or is there some tried and true, tested way which is completely different and has somehow completely eluded me on the internets?


Making sense of the Game State manager tutorial? I have come across the Game State Managemnet tutorial at http create.msdn.com en US education catalog sample game state management because I thought this would be a good place to start a game off. I have added a new screen, but I am still a bit lost on how everything works. When I make my game, do I only need one more additional screen? just for gameplay? or should I have a different screen for each level?


Position sprite at center of screen I am trying to get a sprite to position itself at the center of the screen but nothing seems to be working for me. I'm trying Viewport viewport graphics.GraphicsDevice.Viewport logoPosition new Vector2((viewport.Width towerImage.Width) 2, (viewport.Height towerImage.Height) 2) and spriteBatch.Draw(towerImage, centre, null, Color.White, 0, baseOrigin, 1.0f, SpriteEffects.None, 0) This is my first time using XNA and I don't really have a clue what I'm doing.


HLSL Gaussian blur pixelshader blur is not occurring I am trying to use postprocessing to create a gaussian blur, however, no blur is to be seen, what am I doing wrong? I have included the full code at the bottom of this post in a google docs link, but here are the most important bits and pieces. Part of the xna draw method RenderTarget2D renderTarget renderTarget new RenderTarget2D(this.device, screenWidth, screenHeight, true, pp.BackBufferFormat, pp.DepthStencilFormat) this.device.SetRenderTarget(renderTarget) this.device.Clear(ClearOptions.Target ClearOptions.DepthBuffer, Color.DeepSkyBlue, 1.0f, 0) Rectangle screenRectangle new Rectangle(0, 0, screenWidth, screenHeight) Set the effect parameters (the 'simple' technique creates a red lambertian shaded model, like is shown on the image below) effect.CurrentTechnique effect.Techniques "Simple" effect.Parameters "TextureWidth" .SetValue(screenWidth) device.DepthStencilState DepthStencilState.Default device.BlendState BlendState.Opaque Draw the model mesh.Draw() Render our scene this.device.SetRenderTarget(null) effect.CurrentTechnique effect.Techniques "GaussianBlur" spriteBatch.Begin(0, BlendState.Opaque, null, null, null, effect) spriteBatch.Draw((Texture2D)renderTarget, screenRectangle, Color.White) spriteBatch.End() The pixelshader float Pixels 13 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, float BlurWeights 13 0.002216, 0.008764, 0.026995, 0.064759, 0.120985, 0.176033, 0.199471, 0.176033, 0.120985, 0.064759, 0.026995, 0.008764, 0.002216, float4 GaussianPixelShader(float2 TextureCoordinate TEXCOORD0) COLOR Pixel width float pixelWidth 1 TextureWidth float4 color 0, 0, 0, 1 float2 blur blur.y TextureCoordinate.y for (int i 0 i lt 13 i ) blur.x TextureCoordinate.x Pixels i pixelWidth color tex2D(TextureSampler, blur.xy) BlurWeights i return color What I have further found out by testing The code in the GaussianPixelShader does get executed (if I set it to just return a black color it gives an entire solid black screen) but just doesn't seem to work do the blurring. Images This is how currently my model looks (I cant see any blurring but maybe the blurring is just too light) image. Full Code Link to the shader code and the link to the xna c code.


XNA Rendering vertices that only appear within the cameras view I'm making a game in XNA and I recall hearing that professionally made games use a technique to only render the polygons that appear within the cameras projection. I've been trying to find something on this to do something similar in my game, could anyone point me in the right direction? Right now all I have is a plane grid of vertices that you can set the X Y on which is drawn using DrawUserIndexedPrimitives, but I plan to make a bunch of props as scenery items and I can imagine myself running into issues later on if I don't address this now. Thanks


XNA Skinning sample, keyframes and time I've been using the skinned sample from XNA tutorials to understand and play FBX files animation. While the animation in all my tests runs correctly, I fail to understand the technic to calculate time versus keyframes. Most of the models I found so far for free and testing purpose on google store all animations into one "take" and split frames into all animations. So, walk would be frame 1 to 14, run 15 to 30, jump 32 to 48, etc. On the other hand, the skinning sample loads all frames and store a calculated time which it will be using to loop the animation. The part where I'm getting confused is on the keyframe part. For example a model I've been trying to load gives me a 12 seconds timespan with 20160 keyframes. While the timespan seems right, the keyframe count seems to have been altered in some way since in Milkshape and in the Autodesk converter the frame count is at 300. What is it doing? Here's my setup for model conversion. I use Milkshape 3D to export a model and its animation to an FBX binary file. Then, I use the Autodesk file converter to convert the file into an ASCII FBX (so far I tried and tested the FBX2012 and version 6.1, which is the same as the "dude.fbx" given with the skinning sample). Processing model inside XNA with the SkinnedModelProcessor given with the skinning sample. What I'm really trying to achieve here is to split animation into smaller clips so I can switch depending on the user action. I'm perfectly fine with counting keyframes, but as you can see, the keyframe count is way too high.


Loading levels from .txt or .XML for XNA I'm attemptin to add multiple levels to my pong game. I'd like to simply exchange a few elements with each level, nothing crazy. Just the background texture, the color of the AI paddle (the one on the right side), and the music. It seems that the best way to go about this is by utilizing the StreamReader to read and write the files from XML. If there is a better, or more efficient alternative way then I'm all for it. In looking over the XNA Starter Platformer Kit provided by MS it seems that they've done it in this manner as well. I'm perplexed by a few things, however, namely parts within the Level class which aren't commented. lt summary gt Iterates over every tile in the structure file and loads its appearance and behavior. This method also validates that the file is well formed with a player start point, exit, etc. lt summary gt lt param name "fileStream" gt A stream containing the tile data. lt param gt private void LoadTiles(Stream fileStream) Load the level and ensure all of the lines are the same length. int width List lt string gt lines new List lt string gt () using (StreamReader reader new StreamReader(fileStream)) string line reader.ReadLine() width line.Length while (line ! null) lines.Add(line) if (line.Length ! width) throw new Exception(String.Format("The length of line 0 is different from all preceeding lines.", lines.Count)) line reader.ReadLine() What does width line.Length mean exactly? I mean I know how it reads the line, but what difference does it make if one line is longer than any of the others? Finally, their levels are simply text files that look like this .................... .................... .................... .................... .................... .................... .................... .........GGG........ ......... ........ .................... ....GGG.......GGG... .... ....... ... .................... .1................X. It can't be that easy..... Can it?


Camera wont stay behind model after pitch, then rotation I have a camera position behind a model. Currently, if I push the left thumbstick making my model move forward, backward, or strafe, the camera stays with the model. If I push the right thumbstick left or right, the model rotates in those directions fine along with the camera rotating while maintaining its position relatively behind the model. But when I pitch the model up or down, then rotate the model afterwards, the camera moves slightly rotates in a clock like fashion behind the model. If I do a few rotations of the model and try to pitch the camera, the camera will eventually be looking at the side, then eventually the front of the model while also rotating in a clock like fashion. My question is, how do I keep the camera to pitch up and down behind the model no matter how much the model has rotated? Here is what I got Rotates model and pitches camera on its own axis public void modelRotMovement(GamePadState pController) Rotates Camera with model Yaw pController.ThumbSticks.Right.X MathHelper.ToRadians(angularSpeed) AddRotation Quaternion.CreateFromYawPitchRoll(Yaw, 0, 0) ModelLoad.MRotation AddRotation MOrientation Matrix.CreateFromQuaternion(ModelLoad.MRotation) Pitches Camera around model Pitch pController.ThumbSticks.Right.Y MathHelper.ToRadians(angularSpeed) Orbit (yaw) Camera around with model (only seeing back of model) public void cameraYaw(Vector3 axisYaw, float yaw) ModelLoad.CameraPos Vector3.Transform(ModelLoad.CameraPos ModelLoad.camTarget, Matrix.CreateFromAxisAngle(axisYaw, yaw)) ModelLoad.camTarget Raise camera above or below model's shoulders public void cameraPitch(Vector3 axisPitch, float pitch) ModelLoad.CameraPos Vector3.Transform(ModelLoad.CameraPos ModelLoad.camTarget, Matrix.CreateFromAxisAngle(axisPitch, pitch)) ModelLoad.camTarget Call in update method public void updateCamera() cameraYaw(Vector3.Up, Yaw) cameraPitch(Vector3.Right, Pitch) NOTE I tried to use addPitch just like addRotation but it didn't work... UPDATE I understand the problem Im having fully. While Im facing world North or world South, the camera pitches around the model like normal. But lets say I'm facing world East. The camera will still point to the model regardless of the rotation, but when I pitch the camera, it will rise and fall in a clock like fashion around the back of the model. So the camera itself is still pitching as to world's North and South. Not the model's North and South.


How can I do a Metroid like transition between two tilemaps with Monogame Extended? I want to do a transition like those in the Metroid games. Here is an example of what i mean https www.youtube.com watch?v RKJ3MAi0ZI0. You enter the door, the screen fades to black and the camera scrolls to the next room where the screen fades in again. I'm using Monogame Extended and i have a TiledMap. I use them like described in the documentation. I have a camera with a view matrix and a projection matrix Camera2D camera ... public void DrawGame(GameTime gameTime, SpriteBatch spriteBatch) var viewMatrix camera.GetViewMatrix() var projectionMatrix Matrix.CreateOrthographicOffCenter(0, gDevice.Viewport.Width, gDevice.Viewport.Height, 0, 0f, 1f) tiledMap.Draw(viewMatrix, projectionMatrix) My idea is now to create a second tiledMap to placing them directly next to the first one where the transition occurs. Then i just have to move the camera from one map to the next one. My problem now is that i have no clue how to put them next to each other. From my understanding i somehow have to use the view and projection matrix to draw the tiledMap but i can't figure out how it should work with two tiledMaps.


Alternatives to distance fog I'm looking for some ideas algorithm name for alternative to distance fog. I'm playing around an "infinite" terrain engine. I can't draw the whole map because there are no borders and I don't like the idea of hiding the terrain at a distance with fog.


Help Reading this Data in XML as a List (ContentReader) Edit So i'm going to rephrase the question a bit, seeing as now i think know how i'm going to read this data. Looking at this example as my guide http forums.create.msdn.com forums p 53404 323877.aspx This is pretty much what i'm currently doing, and to be clear and show you guys http pastebin.com GxqQcBDg, that's how i'm loading my data. So looking at that guys example from his post, he has a similar layout, his "Enemies" can equal my element "Animated Tiles" and then his "Items" could be equal to my "Tile" objects, at least if you compare my data to his they look extremely similar, and yes i did update the Data as Richard Marskell Drackir suggested, But i'm wondering if i can have "Type" definitions like the guy has in his example, to show what i mean lt Animated Tiles Type "System.Collections.Generic.List Namespace.Class " gt Can that be done? Or is it only the "Asset" element that can have the Type definition? Currently this is what my new data layout looks like http pastebin.com i42166ZQ But currently, it seems to start reading it but i get this error by the first "Tile" Element. So the only difference i see between his amp my layouts are that he has the Asset containing the List definition whereas i have "Animated Tiles". So i'm unsure can any element can have the "Type Blah" definition?


Data structure to store map layers in each Tile while keeping the order of terrain, items and monsters intact My game represents its map as a 2D array of tiles, each of which stores a stack of layers. I'm looking for a data structure to efficiently represent this . I want to be able to add layers dynamically, so fixed arrays won't do. Additionally, the layers are applied in zones, to make sure that terrain is always drawn before items and monsters, and that items monsters are drawn before the player. This is the order terrainlayer terraineffectlayers itemlayers monsterlayers playerlayers specialeffectslayers I want to store all those zones in the same data structure, so I can traverse it from end to end in either direction. I also need to be able to add a monster layer that would automatically go at the end of monsterlayers data structure while still having a global object that would let me traverse from the all the layers. I also need the ability to access the data structure with index, so I can get the 3rd monster in the tile easily or remove the 3rd monster. Add will always be sequential, but remove are at random indexes. Does a data structure like this already exist or do I need to make some sort of vector doubly linked list deque hybrid? I have already seen this question but it doesn't help me.


Torus World Collision Dection I am looking for a collision detection solution for use when 2d screen wrapping. Specifically, when the image is split between the right and left side I can only detect a collision for a limited area. For example, the program detects the collision when the rectangle intersects the circle in the first image. However, it doesn't in the second image. I am using the Rectangle.Instersects method to check for the collision in both cases. I used the screen wrapping solution at the following link How to create a 2D region where sprites are automatically wrapped? However, since I am not using the physics engine, I am not using the related solution at How to create a very specific kind of joint in Farseer? I am aware of the following question https stackoverflow.com questions 8679304 wrapping drawn image in xna 4 0, and incorporated part of the code to reset the draw rectangle's position when wrapping for both sprites reset draw rectangle for wrapping if (drawRectangle.X lt sprite.Width) drawRectangle.X parentWindowWidth if (drawRectangle.X gt parentWindowWidth) drawRectangle.X parentWindowWidth if (drawRectangle.Y lt sprite.Height) drawRectangle.Y parentWindowHeight if (drawRectangle.Y gt parentWindowHeight) drawRectangle.Y parentWindowHeight This post also says that I have to check for the collision in the two separate positions, but I am having trouble doing so. Any suggestions?


XNA Scale only parent I was wondering, is it possible to Scale(Vector3) a ModelBone without scaling its children. Lets say I got a Bone A at position 1,0,3. And one of its children Bone B is at position 1,0,5 (he is touching Bone A). Could I scale Bone A along Z axis without scaling Bone B, but keep Bone B position and rotation so that he is still touching Bone A. Thanks in advance


Units issue when exporting from 3DS Max to XNA I am working on a XNA game where we have defined that 1 XNA unit equals to 1 meter. Then, I set meters as system unit in 3DS Max and set to meters the units in the FBX exporter. However, when I export my models, they are much bigger in the game. Am I missing something? What should I do to avoid problems with my units? Investigating the FBX file, I noticed that I it has two values called UnitScaleFactor and OriginalUnitScaleFactor. They both are 100 when I export the files... And if I manually change UnitScaleFactor to 1, it works fine S


Keyboard.GetState() only work first time, and Memory increase (not Disposing) EDIT UPDATE 3 I been searching the web for a solution and found several people struggling with Memoryleak using MonoGame while trying to dispose objects. It could be the case that MonoGame should be started and then closed as a own process, not from another program which are my case. When I click on the button, a new thread is created and the MonoGame application is started viThread new Thread(startDemo) viThread.Priority ThreadPriority.Highest viThread.Start() private void startDemo() using (Demo d new Demo()) d.Run() The "Demo" is closed by a Game.Exit command and i have also tried with Disposed(true) without any success. Next time I launch the MonoGame is Keyboard.GetsState() always empty and the memory is incresed. I made a loop where I started and closed the application 100times and it are eating my memory. I have seen lots of discussion about SharpDX not working correcly with dispsing resources. So here I am, stuck. Just want to point out that this worked fine for XNA but not now when changed to MonoGame. And again, thanks for all comments I got so far. I have uploaded a project where you can see the issue by yourself. The second time dosn't the keyboard input work but mouseinput does and the memory is increasing for each time Donwload sln project EDIT UPDATE 4 It is SharpDX which increase the memory, I perform following line before i exit SharpDX.Diagnostics.ObjectTracker.ReportActiveObjects().Length And its increasing all the time. So I guess it isnt released. Someone know how to do that?


Avoiding lag when playing sound for first time using Cue.Play In my code I'm using SoundBank.GetCue("cuename") and Cue.Play() to play my sounds. On the xbox whenever I first play a cue I get lag of about about one second. How can I avoid this? I'm thinking I probably have to do something like call GetCue (without playing it) for every Cue I'm going to use, however I don't have a central place where I list all cues I'll want to play, so is there an easy way to do that? Update It seems calling GetCue for all sounds i want to play doesn't work. I'm still getting stuttering in various places in my game when i call GetCue....Play.


XNA Distortion Shader problem So I came up with a distortion pixel shader in hlsl, but it has some issues. First of all, here is how it works The shader uses another texture generated by the program as a distortion "map" (if that's the correct term) I called this map a "mask". The shader uses the red values in the mask for horizontal distortion and the blue values as vertical distortion. The green values are not used. It subtracts 0.5 from the red and green values so that they have a range from 0.5 to 0.5 instead of 0 to 1. This lets the distortion go in any direction using only two color values. I let the shader "push" pixels up to 128 pixels. sampler s0 texture textu sampler tex sampler sampler state Texture textu float2 screenSize float4 PixelShaderFunction(float2 coords TEXCOORD0) COLOR0 float4 tex color tex2D(tex sampler, coords) if (tex color.a) float distX (tex color.r 0.5f) (256.0f screenSize.x) tex color.a float distY (tex color.b 0.5f) (256.0f screenSize.y) tex color.a return tex2D(s0, float2(coords.x distX, coords.y distY)) return tex2D(s0, coords) technique Technique1 pass Pass1 PixelShader compile ps 2 0 PixelShaderFunction() "textu" being the mask, "tex color" is the color value from the mask. It also multiplies the distortion by the alpha value in the mask. This seemed to work perfectly at first, but I started noticing some issues. I was using a completely white texture (as the mask) that was blurred around the edges. I set the color of this texture based on its rotation. Here is the method I used for that private Color GetDirectionColor(float rad) Vector2 v new Vector2( (float)Math.Cos(rad Math.PI), (float)Math.Sin(rad Math.PI) ) float r (v.X 0.5f) 0.5f float b (v.Y 0.5f) 0.5f return new Color(new Vector3(r, 0, b)) This allows the texture to "push" pixels in whatever direction it is facing. This method seems to work fine. The problem is, when the texture is rotated more than 135 degrees and less than 315 degrees (as in, the texture is pointing into the upper left half of a circle if you cut it in half at a 45 degree angle) it does something strange. Where the texture is blurred (the alpha values become less than 1) it starts to "push" the pixels in the opposite direction that it should be. I suspect this has to do with my shader and not something else in the program. Possibly the 0.5f part??? I'm terribly sorry if this is confusing... I could not find a better way to word it. Thanks a lot for your help!


XNA 3D coordinates seem off I'm going through a book, and the example it gave me seems like is should work, but when I try and implement it, it falls short. My Camera class takes three vectors in to generate View and Projection matrices. I'm giving it a position vector of (0,0,5), a target vector of Vector.Zero and a top vector (which way is up) of Vector.Up. My Three vertices are placed at (0,1,0), ( 1, 1,0), (1, 1,0). It seems like it should work because the vertices are centered around the origin, and thats where I'm telling the camera to look but when I run the game, the only way to get the camera to see the vertices is to set its position to (0,0, 5) and even then the triangle is skewed. Not sure what's wrong here. Any suggestions would be helpful. Just to make sure I've given you guys everything (I don't think these are important as the problem seems to be related to the coordinates, not the ability of the game to draw them) I'm using a VertexBuffer and a BasicEffect. My render code is as follows effect.World Matrix.Identity effect.View camera.view effect.Projection camera.projection effect.VertexColorEnabled true foreach (EffectPass pass in effect.CurrentTechnique.Passes) pass.Apply() GraphicsDevice.DrawUserPrimitives lt VertexPositionColor gt (PrimitiveType.TriangleStrip, verts, 0, 1)


What is wrong with my vertex declaration? What is wrong with my vertex declaration below? I am using it with instancing. After adding TextureInformation to it, it renders weird and has an epileptical seizure. public struct VertexInstance IVertexType public Matrix World public Color Color public Vector3 TextureInformation I use arithmetic here to show clearly where these numbers come from You can just type 28 if you want public static readonly int SizeInBytes sizeof(float) 23 Vertex Element array for our struct above public static readonly VertexElement VertexElements new VertexElement(0, VertexElementFormat.Vector4, VertexElementUsage.TextureCoordinate, 0), new VertexElement(sizeof(float) 4, VertexElementFormat.Vector4, VertexElementUsage.TextureCoordinate, 1), new VertexElement(sizeof(float) 8, VertexElementFormat.Vector4, VertexElementUsage.TextureCoordinate, 2), new VertexElement(sizeof(float) 12, VertexElementFormat.Vector4, VertexElementUsage.TextureCoordinate, 3), new VertexElement(sizeof(float) 16, VertexElementFormat.Color, VertexElementUsage.TextureCoordinate, 4), new VertexElement(sizeof(float) 20, VertexElementFormat.Vector3, VertexElementUsage.TextureCoordinate, 5) public static VertexDeclaration Declaration get return new VertexDeclaration(VertexElements) VertexDeclaration IVertexType.VertexDeclaration get return new VertexDeclaration(VertexElements)


XNA Static classes from game libraries executing after content pipeline extensions, how to avoid the problem? Alright, formulated this way I'm sure it sounds obscure, but I'll do my best to describe my problem. First, let me explain what's wrong with my real source code. I'm making a platformer, and here are the current components of my game a Level, which is holding its own grid of tiles and also the tile sheets and a Tile, which just keeps the name of its tile sheet and index within the tile sheet. All these are within a separate XNA game project, named GameLib. Here is how my levels are formatted in a text file x x . . . . . . . . b g r . . . . . . . . X X X X X X X Where . represents an empty tile, b represents a blue platform, X represents a block with a random color, etc. Instead of doing all the work of loading a level within the Level class, I decided to take advantage of the content pipeline extension and create a LevelContentPipelineExtension. As soon as I started, I quickly realized that I didn't want to hard code 20 lines of the kind if (symbol 'b') return new Tile( ... ) So, in the hope of at least centralizing all the content creation into one class, I made a static class, called LevelContentCreation, which holds the information about which symbol creates what and all this kind of stuff. It also holds a list of all the asset paths of the tile sheets, to load them later on. This class is within my GameLib game library project. The problem is, I'm using this LevelContentCreation static class in both my Level class (to load the actual tile sheets) and my content pipeline extension (to know which symbol represents what tile)... And here's how my LevelContentCreation class looks like public static class LevelContentCreation private static Dictionary lt char, TileCreationInfo gt AvailableTiles CreateAvailableTiles() private static List lt string gt AvailableTileSheets get set ... rest of the class Now, since the LevelContentCreation class is part of the game library, the content pipeline extension tries to use it but the call to CreateAvailableTiles() never happens and I'm unable to load a Level object from the content pipeline. I know this is because the content pipeline executes before the actual compilation or something like that, but how can I fix the problem? I can't really move the LevelContentCreation class to the pipeline extension, because then the Level class wouldn't be able to use it... I'm pretty lost and I don't know what to do... I know these are pretty bad design decisions, and I'd like it if somebody could point me in the right direction. Thank you for your precious time. If anything is not clear enough or if I should provide more information code, please leave a comment below. A little more information about my projects Game XNA Windows game project. Contains references to Engine, GameLib and GameContent GameLib XNA game library project. Contains references to Engine GameContent XNA content project. Contains references to LevelContentPipelineExtension Engine XNA game library project. No references. LevelContentPipelineExtension XNA content pipeline extension. Contains references to Engine and GameLib I know close to nothing about XNA 4.0 and I'm a little bit lost about how content works now. If you need more information, tell me.


Efficient way to avoid shadow "streaks" beyond bounds of shadow map BACKGROUND INFO Using MonoGame. To maximize shadow resolution, I've got a shadow map that covers only the area closest to the camera. (I am aware of Cascading shadow maps, but for now, I am willing to simply lose shadows far away, in exchange for higher resolution near the camera.) Specifically, I am rendering shadows of tree billboards, that are then cast on to a ground terrain. First version worked great except for one issue. If a shadow is drawn that touches an edge of the shadow map, then that final row (or column) of pixels is REPEATED by the "Clamp" setting of the sampler. Result is a shadow "streak" that continues from the edge of map into the distance on the ground. To eliminate those streaks, give full illumination when "outside" of shadow map, I added test to my lookup function to return full illumination (1.0) if UV outside of valid range if (texCoord.x lt 0 texCoord.x gt 1 texCoord.y lt 0 texCoord.y gt 1) return 1.0f ... followed by the code that looks up in shadow map, returns an illumination in range 0..1. This works. I have two questions about this Is there a more efficient way to test these 4 conditions, or to avoid the need to test? Is there an efficient way to solve this when the shadow map is created? The sampler is set to "clamp", so if the first and last row and column of map were all "untouched" (held the default depth value or illumination value, depending on the shadowing technique), then I would not need to do any special tests when using the map "clamp" would retrieve an edge pixel, so if those all were "untouched" by shadows, I would get the desired result. 2.b. It just occurred to me that one solution to (2) is to write the default value back into the four edge rows columns. after all shadows are rendered What is an efficient way to do that?


How can I determine if a cube is adjacent to another cube, and optimize its buffers if so? I'm trying to optimize the rendering of a collection of cubes, (based on an answer I was given to another question I asked). I understand the logic behind occlusion culling, but I'm having trouble with the code. When I create a cube, I want to determine if that cube is touching another existing cube, and if so I don't want to generate the redundant data in my vertex or index buffers. I'm planning on making a method that I call from my cube constructor so that everytime I create a cube, these checks are made, and neither occluded face is ever drawn. How would I go about this?


How can I make an object's hitbox rotate with its texture? 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.


MonoGame Draw thousands of quads without hardware instancing In my game, every bit of geometry is a textured quad billboard in 3D. I have many thousands of these things on screen at once, sometimes with overdraw. As I understand it, there are a few ways I can go about drawing these Have a single VBO per type of quad (ie, unique set of texture coords). Batch the VBO and texture, but make multiple draw calls. Looks something like this foreach (Quad quad in quadTypes) The VBO just contains 4 6 vertices. GraphicsDevice.SetVertexBuffer(quad. vertexBuffer) Shader.SetTexture(quad. texture) Draw each instance using multiple draw calls foreach(QuadInstance instance in quad. instances) Shader.SetWorldMatrix(instance. worldMatrix) foreach(ShaderPass pass in Shader. passes) pass.Apply() GraphicsDevice.DrawPrimitive(TRIANGLES) Make a single draw call by somehow combining all the triangles of all the instances of a quad type. Looks something like this foreach (Quad quad in quadTypes) Shader.SetTexture(quad. texture) Probably can cache a vertex buffer for when quads are created destroyed instead. VertexBuffer vertexBuffer new VertexBuffer() foreach(QuadInstance instance in quad. instances) Add all of the (world transformed) triangles of this instance to the vertex buffer vertexBuffer.AddAll(instance.CreateTriangles()) Draw all the quads with a single draw call and vertex buffer. GraphicsDevice.SetVertexBuffer(vertexBuffer) foreach(ShaderPass pass in Shader. passes) pass.Apply() GraphicsDevice.DrawPrimitive(TRIANGLES) True hardware instancing. This is currently how I do it in my (XNA HiDef profile) game, but I can't figure out a way to get it to work in Monogame. With true hardware instancing, each instance is represented as a vertex, and the GPU creates all the necessary duplicate vertices in a single draw call. In general, which one of these is most desirable? 1) makes many draw calls, but saves the most memory. 2) has a single draw call, but requires creating a vertex buffer for all of the instances, which seems really inefficient, and 3) has the best of both worlds but is not widely supported. Is there a fourth way that I'm missing?


Why use this equation to get a percentage? In an XNA book I read that this code does an action with a 0.2 of probability but I don't' understand why float chance 0.2f if((float)rand.Next(0,1000) 10 lt chance) ... I understand the statement, but not the reasoning for that equation. Can anyone explain me, please?


Why is my client laggy despite 60 update packets a second? I am developing a small multiplayer game with XNA. It's a usual client server architecture I have a server and many clients communicating with it through UDP (via .NET's Socket class). These clients send data to the server (for example, the player's position) and the server handles it and decides what to do (send it to every other client or drop it). What's the most efficient "correct" way to send position of moving object from a client to a server? Currently, I send the client's ID and player position 60 times a second (XNA's default update rate) while a player is moving. When I see my own player on the screen, it moves very smoothly, but other don't, despite every client having the same update rate. What am I doing wrong?


How to Create a New Instance of a Game Object Alright, please don't scald me here haha. I'm very new to XNA, C , and game development as a whole. I have done web design, but that is my main experience with programming. It is a Space Invaders type ish game. In the code below I have a Meteor class. In this class I want to create a meteor in a random location (on the X axis) and then have it fall. I don't care much about it doing damage yet. I can always get one meteor created, and falling, yet when I press 'M' to create another instance of the class it isn't creating another meteor. I could very possibly be going about this entirely wrong...please forgive me if I am. class Meteor private Random randomNumber new Random() private Rectangle position private int fallSpeed private double damage private int x, y 0 private int WIDTH, HEIGHT List to hold meteors created (holds instance of Meteor class) List lt Meteor gt meteors new List lt Meteor gt () Texture for the meteor private Texture2D meteor lt summary gt Create the meteor and each meteor's properties lt summary gt public Meteor() HEIGHT randomNumber.Next(0, 60) WIDTH HEIGHT fallSpeed randomNumber.Next(0, 10) damage fallSpeed 2 x randomNumber.Next(0, 600) Randomly generates where meteor will spawn on X axis public void createMeteor() meteors.Add(new Meteor()) lt summary gt Load content (graphics) relating to the meteor lt summary gt public void LoadContent(ContentManager Content) Load meteor texture meteor Content.Load lt Texture2D gt ("Sprites meteor") lt summary gt Update the meteors position lt summary gt public void Update() Update position of metoer (falling) y Testing purposes mostly...I want meteors to be created when I press 'M' if (Keyboard.GetState().IsKeyDown(Keys.M)) createMeteor() lt summary gt Draw the metoer (and it's new position). lt summary gt public void Draw(SpriteBatch spriteBatch) position new Rectangle(x, y, HEIGHT, WIDTH) spriteBatch.Draw(meteor, position, Color.White) So I can get the damage public double getDamage() return damage


Better quality texture when zooming Is there any way to have better quality textures ? I thought that creating huge textures will improve their quality in game, that's why I draw textures with 0.25f or 0.5f scale. I understand that computer can't display 4 pixels in 1 screen pixel, but how people do to have beautiful sprites while zooming ? even on smartphones... Hope you can help me.


Change opacity for texture or sprites in XNA Is there a way to change the opacity or transparency for a texture or sprite?


What kind of performance issues does multiple instances of the exact same object have on a game? I'm fairly new to programming, and I've pretty much learned all the things I know on the go, while working on projects. The problem is that there some things that I just don't know where to begin searching. My question is about performance, and how can multiple instances of the same object affect it Specifically, I'm talking about XNA's "GraphicsDevice" class. I have it instanced on four different parts of my game, and in three of those, the object has the exact same values for all the attributes. So, in that case, should I be using the same instance of GraphicsDevice, passing it as a parameter, even if I use it in different classes? I apologize if the question seems redundant, but like I said, I've taught myself most of what I know, so there are quite a few "holes" in my learning process.


How can I create a resizeable 2D camera with parallax scrolling? I want to create a Windows Phone jump and run game with parallax scrolling. The character should always be in centered in the viewport. I use the following camera so that the viewport looks on every resolution the same Vector2 vp, gameWorldSize new Vector2(800, 480) vp new Vector2(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height) ScaleX vp.X gameWorldSize.X ScaleY vp.Y gameWorldSize.Y Scale Math.Min(ScaleX, ScaleY) Vector2 PlayerPosition Vector2 Viewport float Scale public Matrix GetMatrix(float scrollingspeed) return Matrix.CreateTranslation(new Vector3( PlayerPosition.X, PlayerPosition.Y, 0) scrollingspeed) Matrix.CreateScale(Scale, Scale, 1) Matrix.CreateTranslation(Viewport.X 2, Viewport.Y 2, 0) I draw the sprites like this spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, camera.GetMatrix(0.8f)) BackgroundLayer1.Render(spriteBatch) spriteBatch.End() spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, camera.GetMatrix(1.0f)) Player.Render(spriteBatch) spriteBatch.End() in the Player class batch.Draw(Playertex, new Rectangle(400, 240, Playertex.Width, Playertex.Height), null, Color.White, 0, new Vector2(Playertex.Width 2, Playertex.Height 2), SpriteEffects.None, 0f) in the BackgroundLayer1 class batch.Draw(Background1tex, new Rectangle(400, 240, Background1tex.Width, Background1tex.Height), null, Color.White, 0, new Vector2(Background1tex.Width 2, Background1tex.Height 2), SpriteEffects.None, 1.0f) The camera is working fine and the player is always in the center of the viewport, but I don't know how to implement Parallax Scrolling. What is the best way to implement Parallax Scrolling? How can I create a resizeable 2D viewport that follows the player and supports parallax scrolling? UPDATE1 In addition, the background sprites shouldn't repeat in a loop, because I have ten 800x480 pixel sprites that are drawn one after another. For example, the first sprite is drawn at (0,0), the second at (800,0), the third at (1600,0), The last sprite(number 10) is the end of the level. The player can move back but not further. I will create more than one layer of sprites, but every layer with a different speed factor to create the Parallax Scrolling. How can I add the speed factor so that the background sprites move slower than the player sprite? UPDATE2 If I draw "BackgroundLayer1" with a scrolling speed of 1.0f, the sprite is drawn on the correct position, but if I change the scrolling speed to another value(for example 0.8f), then the sprites of "BackgroundLayer1" aren't drawn on the correct position. Why are the sprites of "BackgroundLayer1" not drawn on the same position if I change the scrolling speed? What is wrong? The sprites should be drawn on the same positions, even if I change the scrolling speed. In these two pictures, you see the differences if I change the scrolling speed of BackgroundLayer1 scrollingspeed 1.0f http s1.directupload.net images 140505 qdi6cqwz.jpg scrollingspeed 0.8f http s1.directupload.net images 140505 56ferzuv.jpg


Most efficient way to hide out of bounds object in tile based environment I am working on a desktop game in C , with Monogame framework. I am storing the tile instances in a 2D Array, for the sake of easy collision detection. But the levels are big (often 100x100 or bigger) and there are lots of tiles out of the screen bounds all the time which I should not draw. At the moment I'm running through the arrays and checking whether they are in the screen bounds or outside, but that may not be too efficient due to the big count of the tiles. Is there any better way to hide out of bounds tiles?


How would I go about using FXAA in XNA? This isn't so much a "give me teh codez" as it is a request for the "right" steps to go through. I want to implement FXAA in XNA, but I'm a relative newb to the graphics side of game dev, so I'm not sure what the most efficient way to do this would be. My first hunch is to render the scene into a texture, and then render that texture on a rectangle, with the FXAA code in a pixel shader. However, I would actually be surprised if there was no more efficient way to do it.


Consistency of DirectX models Is there a way to check the consistency of a DirectX model (.x) ? Whilst compiling .x files with XNA GameStudio 3.1 compilation is aborted with the following error message Error 2 Could not read the X file. The file is corrupt or invalid. Error code D3DXFERR PARSEERROR. C WFP Browser Content m.x KiviBrowser Some models compile correctly without any error warning and some abort as described. The files of each model have several thousand lines. I am creating the files in Googles SketchUp 8 where they all look fine and don't show any sign of corruption. Suppose I have such a model my XNA compiler won't compile because their is an inconsistency somewhere in the file how could I identify this in order to correct it ?


Loading and storing content efficiently So for example I have a class called TypingKeyboard. It allows you to display a string while it's being typed by the computer with sounds. I need one in the menu, for the title. And one for the credits, and some in game. So loading every sound and storing it to the RAM for every instance of TypingKeyboard is not very efficient. So, I want to make a class that already holds these sounds, then call it when I need it, so I don't have to load everything. How do I design this? I mean, how do you get these sounds loading and then make them accessible without initializing a class for it?


Rendering multiple RenderTargets to the screen Let's say I have a background and a set of entities. I have managed to draw the background into a Texture2D using a RenderTarget I have also managed to draw all my entities into another RenderTarget Now I want to take these two Textures and render them on the screen as so Top level rendering entitiesSystem.Process() background.Process() Texture2D entitiesTexture entitiesSystem.EntitiesTexture Texture2D backgroundTexture background.BackgroundTexture graphicsDevice.SetRenderTarget(null) graphicsDevice.Clear(Color.Black) spriteBatch.Begin() spriteBatch.Draw( backgroundTexture, LevelManager.LEVEL RECTANGLE, null, Color.White, 0.0f, Vector2.Zero, SpriteEffects.None, 1 ) spriteBatch.Draw( entitiesTexture, LevelManager.LEVEL RECTANGLE, null, Color.White, 0.0f, Vector2.Zero, SpriteEffects.None, 0 ) spriteBatch.End() Here is how the background system renders the background graphicsDevice.SetRenderTarget(BackgroundTexture) spriteBatch.Begin() for (int i 0 i lt 2 i ) spriteBatch.Draw(textures i , positions i , Color.White) spriteBatch.End() Almost the same thing happens for the entities I set the render target to the relevant one (not the same as the one for the background), start the spritebatch (again, not the same one), draw the entities and end the spritebatch. If I set BlendMode to additive, the result is correct (they blend together). However, if I set to to AlphaBlend, then I can only render one of them (depending on the SpriteSortMode). I have come as far as understanding that the problem lies in not preserving... something, but I am not sure how to preserve it P By the way, I read that multiple render targets are not supported for the XBOX... Soooooooo... what is the alternative of doing what I am doing now?


How can I export a model using the CAT bone system into XNA? Has anyone successfully used the CAT bone system in 3ds Max and exported the file into XNA? If so, what was your method of doing so? There are a number of methods of doing this, apparently, but the ones I've tried have not worked. I used the Panda Exporter which creates an .X file. This seems to be the latest way of going about this, but when it's loaded in XNA, there is an error saying something about the bone weights. This happens when I export with and without CAT bones.


Portable sound and music for XNA MonoGame? What is the best (recommended) way to integrate audio (both sound effect and music) in a game project (using C XNA) targeting multiple desktop platforms (W7, W8 Metro, Linux, OSX, ...) via MonoGame. XACT was the usual way in XNA but it is deprecated in W8 and also cannot be used with MonoGame, I am looking for an alternaive. Is there one?


How much memory does a texture take up on the GPU? A large png on disk may only take up a couple megabytes but I imagine that on the gpu the same png is stored in an uncompressed format which takes up much more space. Is this true? If it is true, how much space?


Mouse Interaction in 3D space (ray) I use this code public static Ray CalculateRay(Vector2 mouseLocation, Matrix view, Matrix projection, Viewport viewport) Vector3 nearPoint viewport.Unproject(new Vector3(mouseLocation.X, mouseLocation.Y, 0.0f), projection, view, Matrix.Identity) Vector3 farPoint viewport.Unproject(new Vector3(mouseLocation.X, mouseLocation.Y, 1.0f), projection, view, Matrix.Identity) Vector3 direction farPoint nearPoint direction.Normalize() return new Ray(nearPoint, direction) to calculate a ray for mouse position x y. But the result is everytime again NaN.. If I try it with .99f it works but the collision detection is not exact.. How can I determine whether the cursor hits and model in 3d space?


Getting a 3d mouse position I've looked at a few tutorials about picking and the method Unproject, so I have an idea of how getting the mouse in 3d space is done. The code I have does display a mouse position, but it is way off of the actual position the mouse is at. public Vector3 FindWhereClicked(MouseState ms) Vector3 nearScreen new Vector3(ms.X, ms.Y, 0) Vector3 farScreen new Vector3(ms.X, ms.Y, 1) Vector3 nearWorld device.Viewport.Unproject(nearScreen, cam.proj, cam.view, Matrix.Identity) Vector3 farWorld device.Viewport.Unproject(farScreen, cam.proj, cam.view, Matrix.Identity) Vector3 direction farWorld nearWorld float zFactor nearWorld.Y direction.Y Vector3 zeroWorldPoint nearWorld direction zFactor return zeroWorldPoint This code is from another thread I found on here. I'm guessing the problem is the near and far world variables. public ThirdPersonCam() proj Matrix.CreatePerspectiveFieldOfView(0.78f, 1.7777f, 1f, 10000f) public void CameraUpdate(Matrix objectToFollow) Vector3 camPosition objectToFollow.Translation (objectToFollow.Backward 10) (objectToFollow.Up 2) Vector3 camTarget objectToFollow.Translation view Matrix.CreateLookAt(camPosition, camTarget, Vector3.Up) The variables are grabbed from my camera class, but I don't know why it isn't working. A point that's supposed to be at 0, 0, 0 ends up being at something like 36, 1, 57


How (update,set, apply) dynamically color on a model of a XNA project? I encounter a problem for set a background color on my model instantiated. I can change the texture but not change color. Is there a parameter for change the color ? Or change the opacity ? I am looking for a way to highlight a model. thank you so much Here is my code used Everything works except the two last line. I searched but can not find name parameter for color and opacity Does not work effect.Parameters "Color" .SetValue(new Vector3(0,1,0)) effect.Parameters "Opacity" .SetValue(0.5f) void DrawModelHardwareInstancing(Model model, Matrix modelBones, Matrix instances, Matrix view, Matrix projection) ....... foreach (ModelMesh mesh in model.Meshes) foreach (ModelMeshPart meshPart in mesh.MeshParts) Tell the GPU to read from both the model vertex buffer plus our instanceVertexBuffer. Game.GraphicsDevice.SetVertexBuffers( new VertexBufferBinding(meshPart.VertexBuffer, meshPart.VertexOffset, 0), new VertexBufferBinding(instanceVertexBuffer, 0, 1) ) Game.GraphicsDevice.Indices meshPart.IndexBuffer Set up the instance rendering effect. Effect effect meshPart.Effect effect.CurrentTechnique effect.Techniques "HardwareInstancing" effect.Parameters "World" .SetValue(modelBones mesh.ParentBone.Index ) Work perfect effect.Parameters "View" .SetValue(view) effect.Parameters "Projection" .SetValue(projection) effect.Parameters "Texture" .SetValue(textureInstancedModel) Does not work effect.Parameters "Color" .SetValue(new Vector3(0,1,0)) effect.Parameters "Opacity" .SetValue(0.5f) Draw all the instance copies in a single call. foreach (EffectPass pass in effect.CurrentTechnique.Passes) pass.Apply() Game.GraphicsDevice.DrawInstancedPrimitives(PrimitiveType.TriangleList, 0, 0, meshPart.NumVertices, meshPart.StartIndex, meshPart.PrimitiveCount, instances.Length) ........


x axis detection issues platformer starter kit I've come across a problem with the collision detection code in the platformer starter kit for xna.It will send up the impassible flag on the x axis despite being nowhere near a wall in either direction on the x axis, could someone could tell me why this happens ? Here is the collision method. lt summary gt Detects and resolves all collisions between the player and his neighboring tiles. When a collision is detected, the player is pushed away along one axis to prevent overlapping. There is some special logic for the Y axis to handle platforms which behave differently depending on direction of movement. lt summary gt private void HandleCollisions() Get the player's bounding rectangle and find neighboring tiles. Rectangle bounds BoundingRectangle int leftTile (int)Math.Floor((float)bounds.Left Tile.Width) int rightTile (int)Math.Ceiling(((float)bounds.Right Tile.Width)) 1 int topTile (int)Math.Floor((float)bounds.Top Tile.Height) int bottomTile (int)Math.Ceiling(((float)bounds.Bottom Tile.Height)) 1 Reset flag to search for ground collision. isOnGround false For each potentially colliding tile, for (int y topTile y lt bottomTile y) for (int x leftTile x lt rightTile x) If this tile is collidable, TileCollision collision Level.GetCollision(x, y) if (collision ! TileCollision.Passable) Determine collision depth (with direction) and magnitude. Rectangle tileBounds Level.GetBounds(x, y) Vector2 depth RectangleExtensions.GetIntersectionDepth(bounds, tileBounds) if (depth ! Vector2.Zero) float absDepthX Math.Abs(depth.X) float absDepthY Math.Abs(depth.Y) Resolve the collision along the shallow axis. if (absDepthY lt absDepthX collision TileCollision.Platform) If we crossed the top of a tile, we are on the ground. if (previousBottom lt tileBounds.Top) isOnGround true Ignore platforms, unless we are on the ground. if (collision TileCollision.Impassable IsOnGround) Resolve the collision along the Y axis. Position new Vector2(Position.X, Position.Y depth.Y) Perform further collisions with the new bounds. bounds BoundingRectangle This is the section which deals with collision on the x axis else if (collision TileCollision.Impassable) Ignore platforms. Resolve the collision along the X axis. Position new Vector2(Position.X depth.X, Position.Y) Perform further collisions with the new bounds. bounds BoundingRectangle Save the new bounds bottom. previousBottom bounds.Bottom


HLSL Pixel Shader Color depending on condition I am new to shaders and HLSL so bare with me on this one. I have a 2D tile map in my game and want to create a mini map, at first I was just copying all the data from one sprite batch to another and rendering it in a smaller camera. This obviously has a performance issue. So I want to make a mini map that is composed of coloured pixels depending on what is in that particular cell. I have a basic shader going at the moment that converts tex coordinates to pixel position but now I need a way to determine what color to set it. My instant decision was to simply pass in a 2d array of colors and grab the color using the x and y coordinate of the pixel, this crashed lol. Here is what I have so far for the shader sampler s0 The width and height of the texture being sampled int width, height float4 PixelShaderFunction(float2 coords TEXCOORD0) COLOR0 float4 color tex2D(s0, coords) Covert the tex coordinates to pixel coordinates int2 tc int2(width coords.x, height coords.y) Here I need to do some sort of check or something? return color technique Technique1 pass Pass1 PixelShader compile ps 2 0 PixelShaderFunction() How can I pass the color data to the pixel shader so it knows what color to set each pixel? I already know how to pass data but not sure how I can represent that data to pass it. My map is every changing and units are moving around constantly, so the data will be passed in almost every frame.


XNA HLSL what happens if I grab a pixel outside a texture? I'm using the tex2D function of HLSL, and I am wondering what will happen if I try to grab a pixel from a pixel coordinate outside of my texture (as an example 1.1). Will it clamp? Will it repeat the texture and grab something else? Will it return transparent?


Is it possible to use Windows Forms in an XNA project? Is it possible to keep a Windows Form inside a XNA project? I tried it but without success. Below I'm showing how my main file is. using System namespace JogoSuecaOnline if WINDOWS XBOX static class Program lt summary gt The main entry point for the application. lt summary gt static void Main(string args) MainMenu menu new MainMenu() menu.Show() endif


How to pause and resume a game in XNA using the same key? I'm attempting to implement a really simple game state system, this is my first game trying to make a Tetris clone. I'd consider myself a novice programmer at best. I've been testing it out by drawing different textures to the screen depending on the current state. The 'Not Playing' state seems to work fine, I press Space and it changes to 'Playing', but when I press 'P' to pause or resume the game nothing happens. I tried checking current and previous keyboard states thinking it was happening to fast for me to see, but again nothing seemed to happen. If I change either the pause or resume, so they're both different, it works as intended. I'm clearly missing something obvious, or completely lacking some know how in regards to how update and or the keyboard states work. Here's what I have in my Update method at the moment protected override void Update(GameTime gameTime) KeyboardState CurrentKeyboardState Keyboard.GetState() Allows the game to exit if (CurrentKeyboardState.IsKeyDown(Keys.Escape)) this.Exit() TODO Add your update logic here if (CurrentGameState GameStates.NotPlaying) if (CurrentKeyboardState.IsKeyDown(Keys.Space)) CurrentGameState GameStates.Playing if (CurrentGameState GameStates.Playing) if (CurrentKeyboardState.IsKeyDown(Keys.P)) CurrentGameState GameStates.Paused if (CurrentGameState GameStates.Paused) if (CurrentKeyboardState.IsKeyDown(Keys.P)) CurrentGameState GameStates.Playing base.Update(gameTime)


XNA C Adding objects to List in another class Hi all i started creating this XNA C version of Space invaders to get better at xna since i've only been using it for about 4 days. I've managed fine till now.. So my problem is adding my Bullets to a List in another class. So i've tried working out the solution for about 3 hours now and i hope you guys can help me. In the Player.cs class i've got a method FireBullet() wich should create a new Bullet.cs class and add it to the list in Game1.cs (it does not do this when you debug) in theory this should work(i think). Linking all the corresponding classes will take too much room so i've uploaded it to github https github.com Breinss Space Invaders XNA C says C in title ran out of character ment to be C Thanks in advanced!


generating complex maps in xna I just wonder how does these maps like in this video are made. http www.youtube.com watch?v TM6kcOau5oQ I was looking for some tutorials on the web but no success. All I found was some 2D Vectors (Matrixes) with 0,1,2 values on it but I think these maps are generated and stored in a different ways. Can somebody help me or give me some advice about these maps. I saw some presentations about indie games and I was just amazed by these games. I want to make my own game. I am a beginner and already started an XNA book and some tutorials. I would like to learn how these games are made. Thanks!


Character jumping movement in isometric tile When I want to draw my character moving from one tile to another, I would find the displacement vector between two tile's drawing offset and let the character walk in a linear line toward that direction until it complete this displacement vector. Now, I want to make my character jump from higher lower tile to lower higher tile. I have a drawing location (x,y) for the texture, start and end. However, I want it to motion like a projectile, not a linear line. Therefore, given 2 point, start and end point, how would I motion my character in a jumping motion form (maybe it's a parabolic form)?


Biased, conservative random walk I have a sprite which has Velocity and Position, either stored as Vector2. At each Update cycle, velocity is added to the position. I would like to give the sprite a third vector, Target. New targets may be given at any iteration. I would like the sprite to essentially move in a random walk pattern, however two parameters must be exposed A typical random walk is equally likely to increase or decrease the distance to any given Target (plus the small chance of tangential movement). I must be able to bias my random walk such that, while still random, the direction on which the sprite "decides" should be more likely to bring it closer to Target. The random walk should be "smooth" the sprite should not rapidly change direction, as this will look like it's "flickering" or "trembling" to the player. It should gradually veer this way or that, moving randomly, while slowly getting closer when averaged. What is a good, simple way to do this? If possible, give the answer as a Vector2 RandomWalk(Vector2 target) method. I already have a NextGaussian(mean, stdev) method available, if that is helpful.


SpriteBatch memory leak I have a strange problem with XNA 4. I'm constructing a SpriteBatch using this.spriteBatch new SpriteBatch( GraphicsDevice ) . This leads to a memory leak up to 600 MB memory consumption. This problem didn't exist two days ago. I have a static class called Resources public static GraphicsDeviceManager gdm This gets set in the Game constructor public class Game Microsoft.Xna.Framework.Game public Game() Resources.gdm new GraphicsDeviceManager( this ) Content.RootDirectory "Content" In the Initialize Method I'm creating a SpriteBatch in the Resources protected override void Initialize() base.Initialize() Resources.Game this Resources.spriteBatch new SpriteBatch( GraphicsDevice ) At the point Resources.spriteBatch new SpriteBatch( GraphicsDevice ) it allocates up to 600 MB memory. Why is XNA allocating so much after I created a SpriteBatch? How can I fix it? (It worked two days ago and I didn't change anything that could cause this problem.)


What is the difference between Vector2.Transform and this method? I've been working on some steering behaviors and ran into trouble with my logic for converting points in world space into points in local space. I had this (it's not optimized for multiple points yet, but that is not the point of my question) public Vector2 WorldPointToLocal(Vector2 point) var tx Vector2.Dot(this.Location, this.Heading) var ty Vector2.Dot(this.Location, this.HeadingPerpendicular) var rotationMatrix new Matrix M11 this.Heading.X, M12 this.HeadingPerpendicular.X, M21 this.Heading.Y, M22 this.HeadingPerpendicular.Y, M31 tx, M32 ty return Vector2.Transform(point, rotationMatrix) This did not work. The returned point was always well outside the expected range. I had collated most of the mathematics from various sources and began to suspect that Vector2.Transform wasn't doing what I thought it was supposed to do. I found an alternative implementation in C and translated it into C private Vector2 VectorTransform(Vector2 vector, Matrix matrix) var tempX (matrix.M11 vector.X) (matrix.M21 vector.Y) matrix.M31 var tempY (matrix.M12 vector.X) (matrix.M22 vector.Y) matrix.M32 return new Vector2(tempX, tempY) When I used this implementation instead of Vector2.Transform, everything worked perfectly. However, I don't want to leave it at that. I'd like to understand why Vector2.Transform does not do the same thing, and whether there's anything I can do to leverage it instead of writing my own. The API documentation doesn't help at all and I'm a bit clueless when it comes to matrix mathematics.


Texture2D.SetData Method Overload Been reading up on various methods in the XNA framework, and found this one. I've done some Google searching, but I can't seem to find any information on how to use this particular method overload. Parameters 3 5 are easy enough to understand, since they are used in another overload, but I'm not so sure about the first two. I'm fairly sure that the first parameter is the mipmap level we are setting data to, but the second one has me completely lost. However, I'm not exactly sure what I should be passing in here. I know it can be a null object, or a valid Rectangle object, but I'm not sure whether it is being used to specify the size of the mipmap texture like this Or whether it is supposed to be its position and size inside the Texture2D object like this Can someone shed some light on this please, and maybe provide a parameter sample or two so I can better understand? (I'm one of those people that can spend 2 hours trying to understand a theory and make absolutely no progress, and get it in about 5 minutes after a few examples or half dozen for more complex stuff )


Rendering multiple RenderTargets to the screen Let's say I have a background and a set of entities. I have managed to draw the background into a Texture2D using a RenderTarget I have also managed to draw all my entities into another RenderTarget Now I want to take these two Textures and render them on the screen as so Top level rendering entitiesSystem.Process() background.Process() Texture2D entitiesTexture entitiesSystem.EntitiesTexture Texture2D backgroundTexture background.BackgroundTexture graphicsDevice.SetRenderTarget(null) graphicsDevice.Clear(Color.Black) spriteBatch.Begin() spriteBatch.Draw( backgroundTexture, LevelManager.LEVEL RECTANGLE, null, Color.White, 0.0f, Vector2.Zero, SpriteEffects.None, 1 ) spriteBatch.Draw( entitiesTexture, LevelManager.LEVEL RECTANGLE, null, Color.White, 0.0f, Vector2.Zero, SpriteEffects.None, 0 ) spriteBatch.End() Here is how the background system renders the background graphicsDevice.SetRenderTarget(BackgroundTexture) spriteBatch.Begin() for (int i 0 i lt 2 i ) spriteBatch.Draw(textures i , positions i , Color.White) spriteBatch.End() Almost the same thing happens for the entities I set the render target to the relevant one (not the same as the one for the background), start the spritebatch (again, not the same one), draw the entities and end the spritebatch. If I set BlendMode to additive, the result is correct (they blend together). However, if I set to to AlphaBlend, then I can only render one of them (depending on the SpriteSortMode). I have come as far as understanding that the problem lies in not preserving... something, but I am not sure how to preserve it P By the way, I read that multiple render targets are not supported for the XBOX... Soooooooo... what is the alternative of doing what I am doing now?


How should the actual game interface with the menu system I'm using the Game State Management (GSM) concept in my prototype and I like it very much. One of the screen has a "Game" embeded in it, where all the "good stuff" happens. The menu launching the game works fine, but I'm not sure how I should allow the game to request a screen from the ScreenManager. I'm not talking about a menu screen, but about something contextual to the game. For clarity's sake, let's say that when I click on a game element (a rendered model for example) I want a screen that asks me what color I want that model to be drawn next. Right now, my game knows that model is "targeted" with the mouse (I use a Ray picking approach). I looked at the Role Playing sample to see how they did this, but when their GameScreen handles the keys, to open the inventory for example, it's never contextual to what's actually happening in the GameScreen. Ideas welcomed! Edit The game must also be able to get a feedback or something from the "contextual screen" to get the new model color, for example.


XNA How do I match Spritebatch View Projection Matrices with BasicEffect Matrices? I'm rendering a bunch of 2D content using SpriteBatches to a default XNA viewport. A simple 2D camera is used to move around the scene, which generates a transformation matrix passed to each SpriteBatch.Begin() call. I want to draw custom polygons on top of my SpriteBatches, which I'm doing via DrawIndexedPrimitives (straightforward, as well). I'm using a BasicEffect to shade them. How can I best match up the SpriteBatch's implicit view and projection matrices with the BasicEffect's matrices? Currently, I create the matrices for the Effect from scratch, using the Viewport's properties. How can I get around this? Can I access the Viewport's matrices and pass them into the BasicEffect? So far, Google has come up empty on this.


Texture Mapping in Blender XNA I have a simple Blender Model (just a few faces). I want to add 2 Textures. (a special face should get Texture 1, the other faces Texture 2). This model I want to use in XNA. The first Texture should be replaceable at Runtime by Code (the new image is generated based on user input). So how do I best solve this Using UV Maps or Normal based Maps in Blender? How can I access the Blender UV Mapping in XNA? Or do I completely perform the Texturing in XNA (using Code or shaders)? And how (I m new to this)?


Is there documentation on XNA other than at MSDN? MSDN documentation of XNA seems to be incomplete and or bad. Is there another resource available? And by documentation I mean of the library framework itself, similar to what UNITY, SFML, or SDL all have available.


component Initialization in component based game architectures I'm develping a 2d game (in XNA) and i've gone slightly towards a component based approach, where i have a main game object (container) that holds different components. When implementing the needed functionality as components, i'm now faced with an issue who should initialize components? Are components usually passed in initialized into an entity, or some other entity initialized them? In my current design, i have an issue where the component, when created, requires knowledge regarding an attached entity, however these 2 events may not happen at the same time (component construction, attaching to a game entity). I am looking for a standard approach or examples of implementations that work, that overcome this issue or present a clear way to resolve it


Switch axes and handedness of a quaternion? I have a quaternion, coming from a system with the following (intertial sensor) Right handed. Forward direction Y axis Right direction X axis Up direction Z axis I need to convert this into a coordinate system that is (Unreal engine) left handed. Forward direction X axis Right direction Y axis Up direction Z axis I have tried negating the axis, and angle, I have tried switching values, i cannot get this to work. All help greatly appreciated! I am working in C , with Microsoft.Xna.Quaternion.


Programming and drawing to deal with different screen sizes and resolutions I started making an XNA game years ago and picked it up recently. I'm looking later to convert it to use Monogame so that it can be deployed on various mobile devices and OS, though I have a sinking feeling that a lot of the sprites and code will be broken by the changing screen sizes when I move outside of the emulator. The game is currently hard coded to to 800x480 and the level placements and sprite sizes were all done to fit that at the time. So question What do I need to ensure this works and displays properly on a variety of screens and devices?


XNA Multiple Key Input I'm using the KeyboardState state way (if there are any others) of handling key presses for a PC game. It has been working fine for single key presses but now I am trying to handle multiple key presses at once. I have it grab the newState at the top and then save it to the oldState at the bottom. I've tried it this way if (newState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.D2) amp amp newState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftAlt)) if (equipment accessory2 ! null) UseItem(equipment accessory2, "Accessory 2") And I've also tried Microsoft.Xna.Framework.Input.Keys currentPressedKeys newState.GetPressedKeys() bool altPressed false, twoPressed false for (int i 0 i lt currentPressedKeys.Length i ) if (currentPressedKeys i Microsoft.Xna.Framework.Input.Keys.LeftAlt) altPressed true else if (currentPressedKeys i Microsoft.Xna.Framework.Input.Keys.D2) twoPressed true ... if (altPressed) if (equipment accessory2 ! null amp amp twoPressed) UseItem(equipment accessory2, "Accessory 2") Both ways work to a certain degree. The end result is that you're able to press alt and then a key between 1 and 5 to quick use a consumable. Normally you have skills in those slots so holding down alt makes the skills you have bound disappear and instead shows your quick use items. The problem I'm having is that no matter what I have tried, the only way it works is that you have to hold 2 then hold alt. If you hold alt first and press hold 2 it does nothing and doesn't work. I have spent 4 or 5 hours trying to figure out why it only works when you hold down 2 and then press alt. The problem with having it only work this way is if they have a skill bound to 2 then they're going to use the skill so the system is supposed to be to hold down left alt to swap the skill bar to the quick use bar. I can't figure out why both ways I've tried doing multi key input aren't working when I press alt first. EDIT ok it must be something with my keyboard because alt 1 works but 2, 3, 4, and 5 don't work. EDIT2 restarted and 2 5 work now too, was something with my keyboard apparently.


Rotating a group of sprites How to calculate origin I am rotating a group of sprites in XNA, which I developed with the help of the following example http msdn.microsoft.com en us library bb194912 28v xnagamestudio.10 29.aspx It all works very well, however, the rotations rely on a point of origin, which it will rotate around. The problem is that I do not know how to calculate the point of origin, so that it is exactly in the center of the sprite group. I am able to set the point of origin to where I want it, but as soon as the sprite group changes, the origin is typically off, and it doesn't rotate from the center of the group. My main question, is there a way to calculate the center of a group of sprites? My original idea was to calc the boundaries (left, right, top, bottom), and place the origin the the center, but this doesn't work properly.


What are the differences between XNA 3.1 and 4.0? I have been away from XNA for a couple months and want to get back into it. I had a game I was currently working on, but it was done in XNA 3.1. What are the differences between the two, and is it worth updating?


Colour intersection of two alpha blended sprites In XNA, is it possible to merge two alpha blended sprites so they look like one contiguous shape, eliminating the merge of colour at the overlap? At the moment when I try, the intersection is quite visible I'd like it to look more like this mockup This is the drawing code for this example, but it's similar to what's being used in the actual game protected override void Draw(GameTime gameTime) GraphicsDevice.Clear(Color.Black) spriteBatch.Begin(SpriteSortMode.FrontToBack, null, SamplerState.PointClamp, null, null) for (int x 10 x lt 1000 x 10) for (int y 10 y lt 1000 y 10) spriteBatch.Draw(Content.Load lt Texture2D gt ("dot"), new Vector2(x, y), null, Color.Gray, 0, Vector2.Zero, 1, SpriteEffects.None, 0.1f) spriteBatch.Draw(Content.Load lt Texture2D gt ("circle"), new Vector2(200, 200), null, Color.FromNonPremultiplied(255, 255, 255, 50), 0, Vector2.Zero, 1, SpriteEffects.None, 0.5f) spriteBatch.Draw(Content.Load lt Texture2D gt ("circle"), new Vector2(300, 200), null, Color.FromNonPremultiplied(255, 255, 255, 50), 0, Vector2.Zero, 1, SpriteEffects.None, 0.5f) spriteBatch.End() base.Draw(gameTime) I suspect the answer is somehow combining the textures before passing them to the spritebatch to be drawn, but I'd prefer to avoid that if at all possible. Thanks for any help!


How can I optimize a parallax effect consisting of multiple transparent layers? I have a parallax effect in MonoGame consisting of multiple semi transparent layers of textures. The effect is simple, but rendering multiple transparent layers on top of each other is rather slow. This effect doesn't need to be "accurate". How can I optimize this effect or fake it with shaders to make it more efficient? The main premise is multiple full screen size semi transparent layers drawn on top of each other from back to front. There are currently 3 layers the actual game layer that also has some transparency. I used a stencil buffer to render the game layer, already eliminating some of the parallax layers' pixels from rendering, but it's still inefficient.


Xna Equivalent of Viewport.Unproject in a draw call as a matrix transformation 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 https 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 I would also like to be able to move the camera around without moving my sprite. Before I was doing something like if(directionofsprite positive amp amp sprite position is not less than 200) sprite 5 map 5 This would make it appear as though the camera is moving to the right. I just want to simplify all of this by making my sprites draw to worldspace.


How do I prevent getting an access denied loading a file in XNA, when I have the application running in the program files directory (in Windows 7)? I'm creating an app in XNA. I'm trying to load a custom save file. I named the file with my own custom extension. It's an XML file serialized with the DataContractSerializer. I've tried several things to load the file. And they all work when I'm running in my development environment, or when the game is running from most folders, but if the game has been placed in the program files folder (or any other protected by Windows 7), the game won't load my custom files, but it will load images and other items that the content importer handles naturally. Things I have tried Directly loading the file using the DirectoryInfo.CurrentDirectory() then scanning for files, and loading them. Using the StorageContainer.TitleLocation Creating a custom importer, and loading them into the content pipeline In all cases, it works fine running in my IDE (C Express 2008), but when the app is running from Program Files, I get the following error Access to the path 'C Program Files MyFolder MyAppName Content CustomFolder Blah.CustomExtension' is denied. I am running as administrator (though obviously, I eventually don't want the end user to need this right). Any suggestions?


3d vertex translated onto 2d viewport I have a spherical world defined by simple trigonometric functions to create triangles that are relatively similar in size and shape throughout. What I want to be able to do is use mouse input to target a range of vertices in the area around the mouse click in order to manipulate these vertices in real time. I read a post on this forum regarding translating 3d world coordinates into the 2d viewport.. it recommended that you should multiply the world vector coordinates by the viewport and then the projection, but they didn't include any code examples, and suffice to say i couldn't get any good results. Further information.. I am using a lookat method for the viewport. Does this cause a problem, and if so is there a solution? If this isn't the problem, does anyone have a simple code example illustrating translating one vertex in a 3d world into a 2d viewspace? I am using XNA.


How to correclty play the sounds in a 3D enviornment? I'm currently working on an XNA game with C . I've been looking into 3D Sounds recently as this is the next objective on my list. I've found several tutorials online and they don't work to the standards I'm after. What I've found is that even when the player moves, the sounds don't or when the play looks around the sound doesn't change where it's being projected from in my earphones. (When I look at the sound source, I expect to hear it and in front of me, or if I have my left turned to it, then I expect to hear it on my left etc...) My Code so far Decleration private Cue cue private AudioEmitter emitter new AudioEmitter() private AudioListener listener new AudioListener() private AudioEngine engine private WaveBank waveBank private SoundBank soundBank private float angle 0 load content engine new AudioEngine("Content music footsteps footsteps.xgs") waveBank new WaveBank(engine, "Content music footsteps Wave Bank.xwb") soundBank new SoundBank(engine, "Content music footsteps Sound Bank.xsb") update listener.Position Vector3.Zero emitter.Position new Vector3(10, 10, 10) cue.Apply3D(listener, emitter) cue soundBank.GetCue("pl step1") cue.Apply3D(listener, emitter) cue.Play() My code works fine in that the sounds are being played and I can hear them, they are just not realistic and so I'm asking if anyone could help me how I could make the sound move around so that it sounds like it does in real life. (If the source emitter is on my left, the main sounds should be coming through my left earphone.)