Mike36

Hi all:

I'm still playing around with XNA and figuring out what I can do with the current state of the technology. What I want to do is have a 3D model of a spaceship that has RCS thrusters and a main engine. The RCS thrusters and main engine will all have a particle stream to simulate rocket exhaust.

Somehow, I need to define the size and type of rocket exhaust, and what direction it should take, and do so within the context of the XNA framework. I presume I'd need a custom processor for the model to identify where rocket exhaust nodes are (think named invisible cubes in the 3D model, like "MainEngine" and "YawRight"), but I'm stumped on how to define the direction of the particle stream in relation to the model itself. Perhaps something like "YawRightPort" means shoot the stream to the left, whereas "YawRightStarboard" means shoot the stream right.

Any ideas



Re: XNA Game Studio Express Any suggestions for defining direction of partical effects on a 3D model?

Hlubocky

I'm not sure if there is a way to insert some kind of metadata in the .X or .FBX files themselves, but if not then I would probably be creating some kind of wrapper file that describes which model to use as well as other information about the location of the exhaust nodes, or more generally particle emitter locations and types. I haven't played with 1.0 yet but from what I have heard it sounds like you would need to create some kind of processor that knows how to load the xml data (or whatever format it is in) into data structures.




Re: XNA Game Studio Express Any suggestions for defining direction of partical effects on a 3D model?

Shawn Hargreaves - MSFT

I'd do this by putting a couple of marker objects in the source mesh. I might either place a single object per emitter and rotate it to point the way I want the particles to go, or perhaps place two, one for the source and another that I want them to move towards.

I would then make a custom processor, deriving from ModelProcessor. I'd overload the Process method, and before I chain to the base class version, scan down the tree of NodeContent instances to find my special marker objects (using the Name property to identify them). Having found the markers, you can store their positions, then remove them from their parent node so they won't actually show up in the runtime model.

After the base Process method converts the NodeContent tree into a ModelContent, you can attach the particle emitter position data to its Tag property.





Re: XNA Game Studio Express Any suggestions for defining direction of partical effects on a 3D model?

Mike36

Hm.. Interesting idea, I'll have to try that, thanks. Since I can define any data for the ModelContent's Tag property, if I were to define a hashtable (er, Dictionary nowadays) with the name of the marker node and its position data, would that persist into the runtime object Say, (Dictionary<string, someStructure)myModel.Tag["RCSPortYaw"]..





Re: XNA Game Studio Express Any suggestions for defining direction of partical effects on a 3D model?

Shawn Hargreaves - MSFT

Mike36 wrote:

Hm.. Interesting idea, I'll have to try that, thanks. Since I can define any data for the ModelContent's Tag property, if I were to define a hashtable (er, Dictionary nowadays) with the name of the marker node and its position data, would that persist into the runtime object Say, (Dictionary<string, someStructure)myModel.Tag["RCSPortYaw"]..



Mostly, yes.

The issue here is that for a type to be serialized into XNB, there needs to be a ContentTypeWriter and ContentTypeReader for it.

We have built in support for dictionaries, strings, and all the XNA math types, so if your tag was something like a Dictionary<string, Matrix>, that could be serialized totally automatically.

If your someStructure is a custom type that the framework doesn't already know about, though, you will have to write your own ContentTypeWriter/Reader for it (not hard, just a bit of code to fill in).