xna

Position of a modelmesh in XNA

Deadly 提交于 2019-12-12 05:37:14
问题 How do you find the vector 3 position of a mesh inside of a model in XNA(in global coordinates)? I've made a model of a simple lamp post in blender. Where the light should be, I've put a single vertice as its own object and named it "Light", in the position a typical light would be in a lamp post. In my XNA program, I want to put a floating point light at the position from the model. I can find the mesh by name. But need the Vector3 position of the "Light" mesh to do it. 回答1: It depends how

Defining two SpriteSortModes?

不问归期 提交于 2019-12-12 04:57:26
问题 In DirectX it is possible to set the D3DXSPRITE parameters to be a combination of both: D3DXSPRITE_SORT_DEPTH_BACKTOFRONT and D3DXSPRITE_SORT_TEXTURE Meaning that sprites are sorted first by their layer depth and then secondly by the texture that they are on. I'm trying to do the same in XNA and i'm having some problems. I've tried: SpriteBtch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.BackToFront & SpriteSortMode.Texture, SaveStateMode.None); But it doesn't work and just seems to do

Is a non-zero threshold required to prevent flicking when reading the Xbox360 thumbstick for an XNA menu?

左心房为你撑大大i 提交于 2019-12-12 04:23:12
问题 The vertical menus in my game allow you to press up or down on the thumbstick to jump to the next (or previous) menu item. I implement this by storing the old thumbstick state. If the state was zero and is now non-zero, the next (or previous) menu item is selected. I have never noticed any "flicking" with this implementation either on Xbox controller attached to a PC or an Xbox. I have tested with several controllers. However when I answered the question question XNA - how to tell if a thumb

XNA.Texture2D to System.Drawing.Bitmap

僤鯓⒐⒋嵵緔 提交于 2019-12-12 03:48:35
问题 I need load XNA.Texture2D to PictureBox. i've tried this: http://www.gamedev.net/community/forums/viewreply.asp?ID=3224621 but it doesn't work. Any suggestions? 回答1: You should be able to use that method, but make sure that your XNA Texture2D is created with a format of 32bbpARGB. Any other format will prevent that method from working directly. 回答2: Easier way to do it is save the Texture2D using Texture2D.SaveAsPng or Texture2D.SaveAsJpeg to a memory stream and the open the virtual file

Does using MediaLibrary class pose portability problems?

别等时光非礼了梦想. 提交于 2019-12-12 03:42:19
问题 In my Windows Phone project for SDK 7.1 (maybe I need to update it to use WP8 later) I want to add a test image into Windows Phone Emulator using this code. The latter uses MediaLibrary class and so I have to add a reference to Microsoft.Xna.Framework . No other code in my project needs that assembly. I've found this MSDN document that says You can use certain XNA Framework assemblies in apps that target Windows Phone OS 8.0. and the list includes Microsoft.Xna.Framework.dll . So looks like I

'System.InvalidOperationException' using xnaFramework to play a sound effect in windows phone 7 app?

a 夏天 提交于 2019-12-12 03:20:55
问题 This is kindof strange, in the code i have one sound effect(i have 24 sound effects in total)if i comment out (23 effects) except loadsound("resources/drink.wav",out drink) and comment out the corresponding "if"'s in "private void button_Click" method, it works fine?? uncomment all sound effects and then 'System.InvalidOperationException'? i have 24 sound effects each no more than 6 sec long. any ideas anyone...is there a limit on the amount of sound files that can be used or maybe i have to

XNA Menu Not Working

二次信任 提交于 2019-12-12 03:17:24
问题 I have a problem with the logic of this code, XNA's Update Method is to fast so when i am trying to icreas the value by 1 every time the down button is pressed on the keyboard, it ends up updating a more than just by 1 Have a look at the code and see if you can think of a better way to do it, public void Update(GameTime gameTime) { var now = Keyboard.GetState(); KeyboardState old = Keyboard.GetState(); if (now.IsKeyDown(Keys.Down) && !old.IsKeyUp(Keys.Down)) { properties.Menuposition++; }

Return a String with LuaInterface

爷,独闯天下 提交于 2019-12-12 03:13:55
问题 So, I'm trying to implement Lua as a scripting language in C#. It's simple enough, really, if you use it as part of a console application. But I want to be able to create a game console within XNA. The problem is that Lua.DoString() seems to return a console line, rather than a string - which, as I said, is fine for console applications, but I want to add it to an output buffer as a string so I can display it in-game, rather than in a console window. I apologize if this is confusing -

Console.ReadLine() crash in XNA

懵懂的女人 提交于 2019-12-12 03:08:22
问题 Why does my game crash when I add Console.ReadLine() in program.cs right before the game using statement. using System; namespace MyGame { #if WINDOWS || XBOX static class Program { /// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { Console.ReadLine(); using (Game1 game = new Game1()) { game.Run(); } } } #endif } I get an IO Exception was unhandled. Not enough storage is available to process this command. 来源: https://stackoverflow.com

Invisible geometry in DX11

为君一笑 提交于 2019-12-12 02:56:32
问题 After struggling for many hours to understand and compensate for Microsoft's deprecation of D3DX in Windows 8, I've run into a problem that I can't shake off. The first time I started my program, it became immortal because of an access violation. After having restarted my computer and recompiling and running the same code, it doesn't crash, but the cube I should be seeing just isn't there. I'm also getting a warning that "object declared on the heap may not be aligned 16". AFAIK from my