xna

XNA - Creating a lot of particles at the same time

一曲冷凌霜 提交于 2019-12-19 03:12:29
问题 time for another XNA question. This time it is purely from a technical design standpoint though. My situation is this: I've created a particle-engine based on GPU-calculations, far from complete but it works. My GPU easily handles 10k particles without breaking a sweat and I wouldn't be surprised if I could add a bunch more. My problem: Whenever I have a lot of particles created at the same time, my frame rate hates me. Why? A lot of CPU-usage, even though I have minimized it to contain

What is this rotation behavior in XNA?

邮差的信 提交于 2019-12-18 16:55:24
问题 I am just starting out in XNA and have a question about rotation. When you multiply a vector by a rotation matrix in XNA, it goes counter-clockwise. This I understand. However, let me give you an example of what I don't get. Let's say I load a random art asset into the pipeline. I then create some variable to increment every frame by 2 radians when the update method runs(testRot += 0.034906585f). The main thing of my confusion is, the asset rotates clockwise in this screen space. This

How to scale on-screen pixels?

痴心易碎 提交于 2019-12-18 13:34:40
问题 I have written a 2D Jump&Run Engine resulting in a 320x224 (320x240) image. To maintain the old school "pixely"-feel to it, I would like to scale the resulting image by 2 or 3 or 4, according to the resolution of the user. I don't want to scale each and every sprite, but the resulting image! Thanks in advance :) 回答1: Bob's answer is correct about changing the filtering mode to TextureFilter.Point to keep things nice and pixelated. But possibly a better method than scaling each sprite (as you

XNA ViewPort projection and SpriteBatch

本小妞迷上赌 提交于 2019-12-18 11:43:17
问题 I'm working on an XNA game and I am using ViewPort.Project and ViewPort.Unproject to translate to and from world coordinates. Currently I use these for each object I draw with SpriteBatch. What I would like to do is calculate a Matrix that I can send to SpriteBatch.Begin to do the screen-space transformation for me. Here are the functions I currently use to translate to and from screenspace: Vector2 ToWorldCoordinates(Vector2 pixels) { Vector3 worldPosition = graphics.GraphicsDevice.Viewport

Per-Pixel collision code

淺唱寂寞╮ 提交于 2019-12-18 09:48:27
问题 I tried to understand the code that checks the collision between two objects in the game - per pixel collision. The code is: /// <summary> /// Determines if there is overlap of the non-transparent pixels /// between two sprites. /// </summary> /// <param name="rectangleA">Bounding rectangle of the first sprite</param> /// <param name="dataA">Pixel data of the first sprite</param> /// <param name="rectangleB">Bouding rectangle of the second sprite</param> /// <param name="dataB">Pixel data of

Wildcard for content in an XNA content project?

社会主义新天地 提交于 2019-12-18 07:26:28
问题 I have an XNA 3.1 content project (.contentproj) with the following: <ItemGroup> <Compile Include="tiles\B000N800.BMP"> <Name>B000N800</Name> <Importer>TextureImporter</Importer> <Processor>TextureProcessor</Processor> </Compile> <Compile Include="tiles\B000N801.BMP"> <Name>B000N801</Name> <Importer>TextureImporter</Importer> <Processor>TextureProcessor</Processor> </Compile> (... and so on ...) </ItemGroup> What I'd like to do is be able to specify a wildcard so that tiles\*.bmp gets

Serializing XNA Rectangle with Json.NET

允我心安 提交于 2019-12-18 06:26:10
问题 I'm using Json.NET First look at this: using System.Drawing; string json = JsonConvert.SerializeObject(new Rectangle(-3,6,32,32), Formatting.Indented); Console.WriteLine(json); Rectangle deserializedRectangle = JsonConvert.DeserializeObject<Rectangle>(json); Everything works as expected. The console output is: "3, 6, 32, 32" But when I want to do the same thing with the XNA Rectangle, I get an error. (just replaced the old using with this "using Microsoft.Xna.Framework;") The console output

Does XNA effectively replace Managed Directx? [duplicate]

ぐ巨炮叔叔 提交于 2019-12-18 04:46:06
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Comparison between XNA and DirectX (C#) The subject speaks for itself. Does XNA effectively replace Managed DirectX? We have a few projects using managed DirectX in VB.NET. I was considering porting one over to XNA, but wonder whether it's worth the effort. 回答1: Does XNA effectively replace Managed DirectX? According to the wikipedia entry for MDX it does. At least for game development purposes. XNA aims to be a

String.Insert not working [duplicate]

时光总嘲笑我的痴心妄想 提交于 2019-12-17 21:38:28
问题 This question already has answers here : string.Replace (or other string modification) not working (4 answers) Closed 11 months ago . I have (hopefully) a simple problem. String.Insert(0, "test"); is not working, yet: String.Text += "test"; does..? I need Insert so I can insert something in the middle of a string. 回答1: I'm such an idiot, instant Google search fixed this. String.Insert does not modify the string it is called on, but instead returns a new string with the inserted text in. So I

HLSL: Enforce Constant Register Limit at Compile Time

三世轮回 提交于 2019-12-17 21:17:42
问题 In HLSL, is there any way to limit the number of constant registers that the compiler uses? Specifically, if I have something like: float4 foobar[300]; In a vs_2_0 vertex shader, the compiler will merrily generate the effect with more than 256 constant registers. But a 2.0 vertex shader is only guaranteed to have access to 256 constant registers, so when I try to use the effect, it fails in an obscure and GPU-dependent way at runtime. I would much rather have it fail at compile time. This