xna

Casting generic delegates to another type with interfaces

流过昼夜 提交于 2019-12-24 00:22:58
问题 (Using .NET 4.0) Ok, so I have private Dictionary<int, Action<IMyInterface, IMyInterface>> handler {get; set;} public void Foo<T, U>(Action<T, U> myAction) where T : IMyInterface where U : IMyInterface { // | This line Fails // V Action<IMyInterface, IMyInterface> anotherAction = myAction; handler.Add(someInt, anotherAction); } I'm trying to store the delegate in a generic collection, so I can pull it back out later to invoke it. How do I properly cast it? 回答1: The generic parameters to the

Embeding a XNA Game in a Windows Form User Control

≡放荡痞女 提交于 2019-12-23 18:21:07
问题 I have a simple XNA 4.0 Game written. I want to make a Windows Form User Control that will render this game, and provide the necessary interaction feedback (keyboard and mouse) back to XNA. I have tried the following: In XNA: Redirect XNA's Game.GraphicsDevice to a RenderTarget2D. Emit an event sending an object with KeyboardState and MouseState to be filled in by Windows Forms, at the beginning of Update() In WinForms: Capture the event, filling in KeyboardState and MouseState with data

How to get a list of the assets in the WP7 Content Project?

放肆的年华 提交于 2019-12-23 15:35:35
问题 I can load a textures with: Texture2D texture = ContentManager.Load<Texture2D>(assetName); But this throws an exception if the file doesn't exist. Is there a way to determine if a requested asset of a given name actually exists first? I'm storing a series of assets using suffixed number counters (art001.png, art002.png, ...) and would like to have a simple call preload the textures by just counting through them. 回答1: It is not possible to iterate through the contents of your XAP file. You'll

Sorting meshes in XNA

蓝咒 提交于 2019-12-23 15:33:57
问题 I have problem with trees in XNA. When I have tree, I need to use alpha blending to make non-leaf parts transparent, but some parts of model are not correctly displayed and thus alpha blending fails. I want to know if there is possibility to read mesh position to sort them or is there any other way to have transparent non-leaf parts. Sorting in model probably won't work because I want to look at this tree from all angles. 回答1: Alpha blending in a 3D environment can be a tricky issue. Shawn

Xna: Mocking Texture2D

落花浮王杯 提交于 2019-12-23 14:24:15
问题 I'm writing WinForms / Xna app and I need some way to abstract away interaction with the GraphicsDevice in my Controller / Model code. I've created an interface IGraphicsService. I'll use that to abstract away things like loading textures. What I can't figure out though is what to do when I need to return some kind of Texture information. Should I create a class that wraps Texture2D? I'm worried this will incur unnecessary overhead. I would like to be able to create some kind of MockTexture2D

XNA - Embed DirectX control in a form?

若如初见. 提交于 2019-12-23 12:35:30
问题 I want to render DirectX (well, XNA) stuff to a system.windows.forms control rather than the whole window (so I can pair it with buttons and stuff). Is this possible? Which control would I use? How would I do it? I've searched the documentation but I don't know which terms I'm meant to use! 回答1: Yes, it's possible. There's a sample that does just this. 来源: https://stackoverflow.com/questions/577145/xna-embed-directx-control-in-a-form

Cannot load a spriteFont in XNA4

一个人想着一个人 提交于 2019-12-23 09:42:37
问题 Im goofing around with XNA and I've come to the part where I need to load a font in. Easy enough right? Font1 = Content.Load<SpriteFont>("Arial"); Is the code that I'm using to load the font. <?xml version="1.0" encoding="utf-8"?> <!-- This file contains an xml description of a font, and will be read by the XNA Framework Content Pipeline. Follow the comments to customize the appearance of the font in your game, and to change the characters which are available to draw with. --> <XnaContent

Implementing Fur with Shells technique in Unity

南笙酒味 提交于 2019-12-23 07:26:38
问题 I am trying to implement fur in Unity with the Shells technique. The Fins technique is purposely left out because I want this to run on low end mobiles (mostly Android devices) and that requires OpenGL ES 3.0 and above while Shells technique only requires OpenGL ES 2.0 . There is an example on the Shell technique based on XNA and I made an attempt to port that into Unity but it failed to work. Here is the article with the XNA project. The XNA shader: float4x4 World; float4x4 View; float4x4

Create vector from distance and vector

旧街凉风 提交于 2019-12-23 06:06:27
问题 How can I create vector from another vector and a distance? For example, with a vector3d(1,1,2) and distance 12, create another vector that has the same direction but is longer by 12 units. 回答1: You want to find the unit vector in the direction you want; in XNA this is given by Vector3.Normalize . Then you can scalar multiply that unit vector (which has, by definition, length = 1) by the final distance. Ex.: var originalVector = new Vector3(1, 1, 2); var finalLength = originalVector.Length +

How to include framework dll's with my game so the user wont have to download them?

半腔热情 提交于 2019-12-23 05:49:53
问题 In one of my previous threads someone said this was possible, so I did research. I couldn't find anything relevant, can anyone say how to do this, if it is possible? 回答1: Set the property of every referenced dll Copy Local=true 回答2: I can see from your other post that the framework you are referring to is the XNA framework. You're really not supposed to be distribute Microsoft DLLs as loose files! You're supposed to distribute the XNA redistributable only! Using the DLLs without installing